-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path38_modal_from_scratch.js
48 lines (39 loc) · 964 Bytes
/
38_modal_from_scratch.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React,{useEffect,useState} from 'react';
import {Platform,Button, Text,StatusBar, View,ActivityIndicator,StyleSheet,Modal,Pressable } from 'react-native';
const App = () => {
const [modalVisible,setModalVisible] = useState(false);
return (
<View style={styles.container}>
{
modalVisible && ( <View style={styles.modal}>
<View style={styles.body}>
<Text>Modal</Text>
<Button title="Close"/>
</View>
</View> )
}
<Button title="Click me" onPress={()=>setModalVisible(!modalVisible)} />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'flex-end',
},
modal:{
flex:1,
backgroundColor:'rgba(50,50,50,0.5)',
justifyContent:'center',
alignItems:'center',
},
body:{
backgroundColor:'white',
height:200,
width:200,
padding:20,
borderRadius:10,
justifyContent:'flex-end'
}
})
export default App;