-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
102 lines (96 loc) · 1.67 KB
/
App.js
File metadata and controls
102 lines (96 loc) · 1.67 KB
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
99
100
101
102
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React, { createRef, useState } from 'react';
import {View, Text} from 'react-native'
import ActionSheet from '@alessiocancian/react-native-actionsheet'
const data = [
{
id: 0,
name: 'İstanbul'
},
{
id: 1,
name: 'Ankara'
},
{
id: 2,
name: 'İzmir'
},
{
id: 3,
name: 'İstanbul'
},
{
id: 4,
name: 'Ankara'
},
{
id: 5,
name: 'İzmir'
},
{
id: 6,
name: 'İstanbul'
},
{
id: 7,
name: 'Ankara'
},
{
id: 8,
name: 'İzmir'
},
{
id: 9,
name: 'Samsun'
},
{
id: 10,
name: 'İzmir'
},
{
id: 11,
name: 'İstanbul'
},
{
id: 12,
name: 'Ankara'
},
{
id: 13,
name: 'İzmir'
},
{
id: 14,
name: 'Cancel'
},
]
const App = () => {
const ref = createRef();
const [showActionText, setShowActionText] = useState('Open ActionSheet')
const showActionSheet = () => {
ref.current.show()
}
return (
<View view style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<Text onPress={showActionSheet}>{showActionText}</Text>
<ActionSheet
ref={ref}
title={'Which one do you like ?'}
options={data.map(d => d.name)}
cancelButtonIndex={14}
// destructiveButtonIndex={2}
onPress={(index) => { /* do something */
console.log('id', index)
setShowActionText(data[index].name)
}}
/>
</View>
)
};
export default App;