๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ“ฑ Cross Platform/React Native

[React Native] Modal component์˜ ๊ฑฐ์˜ ๋ชจ๋“  ๊ฒƒ (Almost Everything in Modal)

by Fomagran ๐Ÿ’ป 2022. 6. 21.
728x90
๋ฐ˜์‘ํ˜•

 

์•ˆ๋…•ํ•˜์„ธ์š” Foma ์ž…๋‹ˆ๋‹ค!

 

์š”์ฆ˜ React Native์˜ modal์„ ๋””ํ…Œ์ผํ•˜๊ฒŒ ์ •๋ฆฌํ•ด ๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

 

๋ฐ”๋กœ ์‹œ์ž‘ํ• ๊ฒŒ์š”~!


Modal์ด๋ž€?

 

Modal์˜ ์‚ฌ์ „์  ์˜๋ฏธ๊ฐ€ ๊ถ๊ธˆํ•ด์„œ ์ฐพ์•„ ๋ดค๋”๋‹ˆ ์˜๋ฏธ๋ฅผ ์•Œ ์ˆ˜ ์—†๋Š”.. ๋œป์ด ๋‚˜์˜ค๋”๋ผ๊ตฌ์š”.

 

 

๊ทธ๋ž˜์„œ ๊ตฌ๊ธ€๋ง์„ ํ†ตํ•ด์„œ ๋” ์ž์„ธํžˆ ์ฐพ์•„๋ดค๋”๋‹ˆ ์ด ๋ถ„์ด ์ž˜ ์ •๋ฆฌ๋ฅผ ํ•ด๋†“์œผ์…จ๋”๋ผ๊ตฌ์š”.

 

 

GNUJAVA

์ œ๋ชฉ์—†์Œ jQuery UI 1.6 - The User Interface Library for jQuery (Feb 2009),  Dan Wellman Chapter 4. Dialog modal, modality? ์ด๊ฒŒ ๋ฌด์Šจ ๋œป์ผ๊นŒ? ‘modal’ , ‘modality’ ์ด ๋‹จ์–ด, ์ฐธ ๋œป์ด ๋ฌ˜์—ฐํ•˜๋‹ค. ๋„์ €ํžˆ ์‚ฌ์ „์  ์˜๋ฏธ๋ฅผ ๊ฐ€์ง€

www.gnujava.com

 

๊ฐ„๋‹จํžˆ ๋งํ•ด ๋“œ๋ฆฌ๋ฉด modal์€ mode + al ์ด๊ณ  ๋ฐ˜๋Œ€๋ง์€ modeless ์ž…๋‹ˆ๋‹ค.

 

์ฆ‰, modal์€ ์–ด๋– ํ•œ ํ˜•์‹(mode)์œผ๋กœ ๋œ ํ™”๋ฉด์„ ์˜๋ฏธํ•˜๋ฉฐ ์‰ฝ๊ฒŒ ์ดํ•ดํ•˜๋ ค๋ฉด Dialog๋‚˜ ํŒ์—… ์ฐฝ์„ ๋„์šฐ๋Š” ํ™”๋ฉด์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.


Modal Component

 

Modal์€ React Native ์ž์ฒด์—์„œ ์ปดํฌ๋„ŒํŠธ๋กœ ์ œ๊ณตํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

Modal · React Native

The Modal component is a basic way to present content above an enclosing view.

reactnative.dev

 

์‚ฌ์šฉ ๋ฐฉ๋ฒ•์€ ์•„๋ž˜์™€ ๊ฐ™์ด Modal๊ณผ ์—ฌ๋Ÿฌ Props๋กœ ์ปค์Šคํ…€ ํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ์š”.

 

<Modal visible={true} transparent={true} ... />

 

์ง€๊ธˆ๋ถ€ํ„ฐ ํ•˜๋‚˜ ํ•˜๋‚˜ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.


animationType

 

์•„๋ž˜์™€ ๊ฐ™์ด ์›ํ•˜๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜ ํƒ€์ž…์„ ์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

<Modal animationType={"fade"} />

 

๋ชจ๋‹ฌ ํ™”๋ฉด์„ ๋„์šธ ๋•Œ ์–ด๋–ค ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ฐฉ์‹์œผ๋กœ ๋„์šธ๊ฑด์ง€๋ฅผ ๊ฒฐ์ •ํ•˜๋Š” ์†์„ฑ์ธ๋ฐ์š”.

 

none, fade, slide ์ด๋ ‡๊ฒŒ ์ด 3๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

 

์™ผ์ชฝ๋ถ€ํ„ฐ ์ฐจ๋ก€๋Œ€๋กœ none, fade, slide ์ž…๋‹ˆ๋‹ค.

 


onDismiss

 

๋ชจ๋‹ฌ ํ™”๋ฉด์ด ๊บผ์กŒ์„ ๋•Œ ์–ด๋–ค ๋™์ž‘์„ ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ฃผ๋Š” ์†์„ฑ์ž…๋‹ˆ๋‹ค.

 

์•„๋ž˜์™€ ๊ฐ™์ด ๋™์ž‘ํ•  function์„ ์ž‘์„ฑํ•ด ์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

 

<Modal transparent={false}/>

 

๋ชจ๋‹ฌ ํ™”๋ฉด์„ ๋‹ซ์€ ํ›„์— alert๊ฐ€ ๋œจ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

 


onShow

 

๋ชจ๋‹ฌ ํ™”๋ฉด์ด ์ผœ์กŒ์„ ๋•Œ ์–ด๋–ค ๋™์ž‘์„ ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ฃผ๋Š” ์†์„ฑ์ž…๋‹ˆ๋‹ค.

 

์•„๋ž˜์™€ ๊ฐ™์ด ๋™์ž‘ํ•  function์„ ์ž‘์„ฑํ•ด ์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

 

<Modal onShow={() => alert("Show")}/>

 

๋ชจ๋‹ฌ ํ™”๋ฉด์ด ๋œจ๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด alert๊ฐ€ ๋œจ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 


visible

 

๋ง ๊ทธ๋Œ€๋กœ ๋ชจ๋‹ฌ ํ™”๋ฉด์„ ๋ณด์ด๊ฒŒ ํ•  ๊ฒƒ์ธ์ง€ ์ˆจ๊ธธ ๊ฒƒ์ธ์ง€๋ฅผ ๊ฒฐ์ •ํ•˜๋Š” ์†์„ฑ์ž…๋‹ˆ๋‹ค.

 

visible์„ false๋กœ ํ•˜๋ฉด ๋ชจ๋‹ฌ ํ™”๋ฉด์ด ๋ณด์ด์ง€ ์•Š๊ณ , true๋กœ ํ•˜๋ฉด ๋ชจ๋‹ฌ ํ™”๋ฉด์ด ๋œจ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

Open์„ ๋ˆŒ๋ €์„ ๋•Œ ๋ชจ๋‹ฌ ํ™”๋ฉด์ด ๋œจ๋„๋ก ์„ค์ •ํ•ด ๋†“์•„๋„ visible์ด false๋ฉด ๋ชจ๋‹ฌ ํ™”๋ฉด์ด ๋„์›Œ์ง€์ง€ ์•Š๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋ณด์ž…๋‹ˆ๋‹ค.

 


transparent

 

<Modal transparent={false}/>

 

๋ชจ๋‹ฌ ํ™”๋ฉด์„ ํˆฌ๋ช…ํ•˜๊ฒŒ ํ•  ๊ฒƒ์ธ์ง€๋ฅผ ๊ฒฐ์ •ํ•˜๋Š” ์†์„ฑ์ž…๋‹ˆ๋‹ค.

 

์•„๋ž˜ ํ™”๋ฉด์—์„œ ์™ผ์ชฝ์ด false๋กœ ํ•˜์˜€์„ ๋•Œ, true๋กœ ํ•˜์˜€์„ ๋•Œ ๋ชจ์Šต์ž…๋‹ˆ๋‹ค.

 


presentationStyle

 

๋ชจ๋‹ฌ ํ™”๋ฉด์„ ๋‚˜ํƒ€๋‚ผ ์Šคํƒ€์ผ์„ ์ •ํ•˜๋Š” ์†์„ฑ์ž…๋‹ˆ๋‹ค.

 

<Modal presentationStyle={"fullScreen"}/>


fullScreen, overFullScreen, pageSheet, formSheet ์ด๋ ‡๊ฒŒ ์ด 4๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

 

์™ผ์ชฝ์ด fullScreen, overFullScreen ์˜ค๋ฅธ์ชฝ์ด pageSheet, formSheet ํ™”๋ฉด์ž…๋‹ˆ๋‹ค.

 

 

 

fullScreen์€ transparent๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š๊ณ  ๋งŒ์•ฝ ํˆฌ๋ช…ํ•œ ์ „์ฒด ํ™”๋ฉด์„ ์›ํ•œ๋‹ค๋ฉด overFullScreen์„ ์‚ฌ์šฉํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

 

pageSheet๊ณผ formSheet์˜ ์ฐจ์ด์ ์€ ํฐ ํ™”๋ฉด์—์„œ ๋‚˜ํƒ€๋‚˜๋Š”๋ฐ, ์™ผ์ชฝ์ด pageSheet, ์˜ค๋ฅธ์ชฝ์ด formSheet ์ž…๋‹ˆ๋‹ค.

 

728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€