์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- ์๋๋ก์ด๋์คํ๋์ค
- c++
- ํ์ดํ๋
- ๋ฐ์ดํฐ๋ถ์
- nlp
- ๋ถ์
- ์ธํ๋ฐ
- ๋ค์ดํฐ๋ธ
- ์ํ์ฝ๋ฉ
- ์๋ฒ ๋ฉ
- native
- ๋ฐ์ดํฐ์๊ฐํ
- ๋จธ์ ๋ฌ๋
- AI
- ๋์
- ๋ฐ์ดํฐ
- Kaggle
- ๋ฐฑ์ค
- Titanic
- react
- ํ๊ตญ์ด์๋ฒ ๋ฉ
- ๋ฆฌ์กํธ
- cs231n
- ์ ํ๋์ํ
- ๊ฒฐ์ ํธ๋ฆฌ
- ์๊ณ ๋ฆฌ์ฆ
- linearalgebra
- ๋ฅ๋ฌ๋
- Git
- ๊นํ
- Today
- Total
yeon's ๐ฉ๐ป๐ป
[React-Native ๊ธฐ์ด ๊ฐ์] Modal ๋ณธ๋ฌธ
Modal
- ํ๋ฉด ๊ฐ์ฅ ์์ ํ์๋ Layer
ex) ์ ์ ๊ฐ ๊ด๊ณ ๋ฅผ ๊ผญ ๋ณด๊ฒ๋ ๊ด๊ณ ๊ฐ ๋๋ ๋๊น์ง ๋ค๋ก ๋์๊ฐ ์ ์๋ ํ๋ฉด ์์ฑ,
์ค๋ฅ๊ฐ ๋ฐ์ํ์ ๋ ๋ค๋ฅธ ์์ ํ์ง ๋ชปํ๊ฒ ๊ฒฝ๊ณ ์ฐฝ ๋์ฐ๊ธฐ
- ์ผ๋จ ์ด์ ๊ณผ ๋๊ฐ์ด ... App.js์์ ํด๋น js ํ์ผ ๋ถ๋ฌ์ค๊ณ , ์๋์ <Modal> ํ๊ทธ๋ฅผ ์ง์ด ๋ฃ๊ณ ์์
- handleModal : Modal์ ์ํ๊ฐ true์ธ์ง false์ธ์ง, ์ฆ ํ๋ฉด ๊ฐ์ฅ ์์ ์๋ layer์ ๋ง๋ค์ง ์ ๋ง๋ค์ง ๊ฒฐ์
class ModalComponent extends Component {
state = {
modal: false
}
handleModal = () => {
this.setState({
modal: this.state.modal ? false : true
})
}
- ์ด๊ธฐ modal ๊ฐ์ false๋ก ๋๊ณ ,
- handleModal ํจ์์์ modal ๊ฐ์ด true์ด๋ฉด false๋ก, false์ด๋ฉด true๋ก ๋ฐ๊พธ๋ ์์ ์ ํ๋ค.
render() {
return (
<View stlye={{width: '100%'}}>
<Button
title="Open Modal"
onPress={this.handleModal}
/>
<Modal>
<View style={{
marginTop: 60,
backgroundColor: 'red'
}}>
<Text>This is modal content</Text>
</View>
</Modal>
</View>
)
}
- <View> ํ๊ทธ ์์ <Button>์ ์์ฑํ์์ง๋ง ๋ฒํผ์ ๋ณด์ด์ง ์๊ณ , <Modal> ์์ ๋ง๋ View๋ง ๋ณด์ธ๋ค.
-> ์๋ฌด ๊ฒ๋ ํ์ง ์์๋๋ฐ Modal ํ๋ฉด์ ๋ณด์ด๋ค ..? -> ์ฐ๋ฆฌ๊ฐ state ํจ์๋ฅผ ์ ์ผ๊ธฐ ๋๋ฌธ!!!
<Modal
visible={this.state.modal}
>
- visible์ด ture์ฌ์ผ์ง๋ง Modal์ด ๋ณด์ธ๋ค.
- state.modal ์ด๊ธฐ๊ฐ์ด false์ด๋ฏ๋ก, ๋ฒํผ์ ํ ๋ฒ ๋๋ฌ์ผ true๋ก ๋ฐ๋์ด Modal ํ๋ฉด์ด ๋ณด์ผ ๊ฒ์ด๋ค.
- but, ์์ง ๋ค๋ก ๋์๊ฐ ๋ฐฉ๋ฒ์ด ์๋ค.
<Button
title="Go Back"
onPress={this.handleModal}
/>
</Modal>
- ์๋์ <Button> ํ๋ ๋ ๋ง๋ค๊ธฐ
- handleModal ํจ์๋ฅผ ํตํด false -> true -> false -> ture ... ๊ฐ ๋ฐ๋ณต๋๋ค.
- animationType
- slider : ๋ชจ๋ฌ ์ฐฝ์ด ์๋์์ ์๋ก ๋์ด
- fade : fade ํจ๊ณผ๋ก ๋ชจ๋ฌ ์ฐฝ์ด ๋ธ
- none : default ๊ฐ
<Modal
visible={this.state.modal}
animationType={'slider'} // slider, fade
>
- onShow : ๋ชจ๋ฌ ์ฐฝ์ด ๋ด์ ๋ trigger๋๋ property
<Modal
visible={this.state.modal}
animationType={'slider'} // slider, fade
onShow={()=>alert('Warning!!!')}
>
- ๊ฐ๋จํ alert ์ฐฝ์ผ๋ก ํ์ธํด๋ณด๊ธฐ
'Computer ๐ป > React' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[React-Native] React Navigation | ํ๋ฉด Linking 01 (0) | 2021.07.24 |
---|---|
[React-Native] React Navigation ์ค์น (0) | 2021.07.24 |
[React-Native ๊ธฐ์ด ๊ฐ์] Image (0) | 2021.07.22 |
[React-Native ๊ธฐ์ด ๊ฐ์] ActivityIndicator (0) | 2021.07.22 |
[React-Native ๊ธฐ์ด ๊ฐ์] Slider (0) | 2021.07.22 |