forked from Karthik-B-06/RN-Custom-ActionSheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
98 lines (93 loc) · 2.1 KB
/
App.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React, { useState } from 'react';
import {
Dimensions, SafeAreaView,
StatusBar, StyleSheet,
Text,
TouchableOpacity, View
} from 'react-native';
import Modal from 'react-native-modal';
import ActionSheet from './src/actionSheet';
const App = () => {
const actionItems = [
{
id: 1,
label: 'Action Item 1',
onPress: () => {
}
},
{
id: 2,
label: 'Action Item 2',
onPress: () => {
}
},
{
id: 3,
label: 'Action Item 3',
onPress: () => {
}
},
{
id: 4,
label: 'Action Item 4',
onPress: () => {
}
},
];
const [actionSheet, setActionSheet] = useState(false);
const closeActionSheet = () => setActionSheet(false);
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView style={styles.container}>
<Text style={{ fontSize: 24 }}>Hello,World!</Text>
<Text style={{ fontSize: 24, margin: 10 }}>React Native Custom Action Sheet</Text>
<TouchableOpacity activeOpacity={0.7} onPress={() => setActionSheet(true)}>
<View style={styles.buttonStyle}><Text style={styles.buttonText}>Action Sheet</Text></View>
</TouchableOpacity>
<Modal
isVisible={actionSheet}
style={{
margin: 0,
justifyContent: 'flex-end'
}}
>
<ActionSheet
actionItems={actionItems}
onCancel={closeActionSheet}
/>
</Modal>
</SafeAreaView>
</>
);
};
const styles = StyleSheet.create({
container: {
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
flex: 1
},
buttonStyle: {
height: 50,
backgroundColor: 'rgb(0,98,255)',
width: Dimensions.get('window').width - 50,
alignItems: 'center',
justifyContent: 'center',
borderRadius: 10,
margin: 10
},
buttonText: {
fontSize: 17,
color: 'rgb(255,255,255)',
}
});
export default App;