forked from alessiocancian/react-native-actionsheet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleA.js
More file actions
60 lines (53 loc) · 1.5 KB
/
Copy pathExampleA.js
File metadata and controls
60 lines (53 loc) · 1.5 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
import React from 'react'
import { View, Text, StyleSheet } from 'react-native'
import ActionSheet from './lib'
const CANCEL_INDEX = 0
const DESTRUCTIVE_INDEX = 4
const options = [ 'Cancel', 'Apple', 'Banana', 'Watermelon', 'Durian' ]
const title = 'Which one do you like ?'
const message = 'In botany, a fruit is the seed-bearing structure in flowering plants (also known as angiosperms) formed from the ovary after flowering.'
class ExampleA extends React.Component {
state = {
selected: ''
}
showActionSheet = () => {
this.ActionSheet.show()
}
handlePress = (buttonIndex) => {
this.setState({ selected: buttonIndex })
}
render () {
return (
<View style={styles.wrapper}>
<Text style={{marginBottom: 20}} >I like {options[this.state.selected] || '...'}</Text>
<Text style={styles.button} onPress={this.showActionSheet}>Example A</Text>
<ActionSheet
ref={o => { this.ActionSheet = o }}
title={title}
message={message}
options={options}
cancelButtonIndex={CANCEL_INDEX}
destructiveButtonIndex={DESTRUCTIVE_INDEX}
onPress={this.handlePress}
/>
</View>
)
}
}
const styles = StyleSheet.create({
wrapper: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
},
button: {
width: 200,
marginBottom: 10,
paddingTop: 15,
paddingBottom: 15,
textAlign: 'center',
color: '#fff',
backgroundColor: '#38f'
}
})
export default ExampleA