forked from beefe/react-native-actionsheet
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathExampleB.js
72 lines (65 loc) · 1.73 KB
/
ExampleB.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
import React from 'react'
import { View, Text, StyleSheet } from 'react-native'
import { ActionSheetCustom as 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 ExampleB extends React.Component {
constructor (props) {
super(props)
this.state = {
selected: ''
}
this.handlePress = this.handlePress.bind(this)
this.showActionSheet = this.showActionSheet.bind(this)
}
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 B</Text>
<ActionSheet
ref={o => { this.ActionSheet = o }}
title={title}
message={message}
options={options}
cancelButtonIndex={CANCEL_INDEX}
destructiveButtonIndex={DESTRUCTIVE_INDEX}
onPress={this.handlePress}
styles={{messageBox: { height: 60 }}}
/>
</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 ExampleB