react-native-actionsheet
Cross platform ActionSheet. This component implements a custom ActionSheet and provides the same way to drawing it on the defferent platforms(iOS and Android). Actually, In order to keep the best effect, it still uses the ActionSheetIOS on iOS.
Installation
npm i react-native-actionsheet --save
Usage
const CANCEL_INDEX = 0const DESTRUCTIVE_INDEX = 4const options = label:'Cancel'label:'Canel'label:'213'label:'12313' const title = 'Which one do you like?' Component { superprops thisstate = selected: '' thishandlePress = thishandlePress thisshowActionSheet = thisshowActionSheet } { thisActionSheet } { this } { return <View style=styleswrapper> <Text style=marginBottom: 20 >I like optionsthisstateselected</Text> <Text style=stylesbutton onPress=thisshowActionSheet>Example A</Text> <ActionSheet ref= thisActionSheet = o title=title labelName=labelName options=options cancelButtonIndex=CANCEL_INDEX destructiveButtonIndex=DESTRUCTIVE_INDEX onPress=thishandlePress /> </View> }
Use ActionSheetCustom directly
so you can customize option and title
const CANCEL_INDEX = 0const DESTRUCTIVE_INDEX = 4 const options = 'Cancel' 'Apple' <Text style=color: 'yellow'>Banana</Text> 'Watermelon' <Text style=color: 'red'>Durian</Text> const title = <Text style=color: '#000' fontSize: 18>Which one do you like?</Text> Component { superprops thisstate = selected: '' thishandlePress = thishandlePress thisshowActionSheet = thisshowActionSheet } { thisActionSheet } { this } { return <View style=styleswrapper> <Text style=marginBottom: 20 >I like optionsthisstateselected</Text> <Text style=stylesbutton onPress=thisshowActionSheet>Example B</Text> <ActionSheet ref= thisActionSheet = o title=title options=options cancelButtonIndex=CANCEL_INDEX destructiveButtonIndex=DESTRUCTIVE_INDEX onPress=thishandlePress /> </View> }
Props
Prop name | Desciption | Type | Default |
---|---|---|---|
title | PropTypes.string or PropTypes.element | ||
options | PropTypes.arrayOf([PropTypes.string, PropTypes.element]) | ||
labelName | label名字 || 'label' | ||
tintColor | PropTypes.string | ||
cancelButtonIndex | PropTypes.number | ||
destructiveButtonIndex | PropTypes.number | ||
onPress | PropTypes.func | (index) => {} |