forked from talut/rn-actionsheet-module
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (29 loc) · 1.25 KB
/
index.js
File metadata and controls
31 lines (29 loc) · 1.25 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
import {NativeModules, Platform, ActionSheetIOS} from 'react-native';
import PropTypes from 'prop-types';
const {RNActionsheet} = NativeModules;
const ActionSheet = (props, callback) => {
const {optionsIOS, optionsAndroid, title, tintColor, message, destructiveButtonIndex, cancelButtonIndex, onCancelAndroidIndex} = props;
if(Platform.OS === "ios") {
ActionSheetIOS.showActionSheetWithOptions({
title : title,
message : message,
tintColor : tintColor,
options : optionsIOS,
destructiveButtonIndex: destructiveButtonIndex === null ? undefined : destructiveButtonIndex,
cancelButtonIndex : cancelButtonIndex,
}, callback)
} else {
RNActionsheet.show(title, optionsAndroid, onCancelAndroidIndex, callback)
}
};
ActionSheet.propTypes = {
optionsIOS : PropTypes.array.isRequired,
optionsAndroid : PropTypes.array.isRequired,
title : PropTypes.string.isRequired,
message : PropTypes.string,
tintColor : PropTypes.string,
destructiveButtonIndex: PropTypes.number,
cancelButtonIndex : PropTypes.number,
onCancelAndroidIndex : PropTypes.number.isRequired,
};
export default ActionSheet;