-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (39 loc) · 951 Bytes
/
index.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
import React from "react";
import {
View,
Platform,
ActionSheetIOS
} from 'react-native';
import BottomSheetAndroid from './BottomSheetAndroid/BottomSheetAndroid';
class ActionSheet extends React.Component {
render() {
return (
<View>
<BottomSheetAndroid
ref={(ref) => this._bottomSheetAndroidRef = ref}
options={this.props.options}
onPressAction={(index) => {
this._bottomSheetAndroidRef.dismiss()
setTimeout(() => {
this.props.onPressAction(index)
}, 200)
}}
/>
</View>
)
}
show() {
if (Platform.OS === 'android') {
this._bottomSheetAndroidRef.show()
} else {
ActionSheetIOS.showActionSheetWithOptions(
{
...this.props.options,
cancelButtonIndex: 0
},
(index) => this.props.onPressAction(index)
)
}
}
}
module.exports = ActionSheet;