- Notifications
You must be signed in to change notification settings - Fork13
📜 Cross platform custom ActionSheet
License
NotificationsYou must be signed in to change notification settings
valerybugakov/react-native-custom-actionsheet
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Cross platform ActionSheet. This component implements a custom ActionSheet and provides the same way of drawing it on the different platforms (iOS and Android). Actually, In order to keep the best effect, it still uses the ActionSheetIOS on iOS. For custom ActionSheet it uses different styles depending on the platform.
This project is based onreact-native-actionsheet bybeefe.
npm i -S react-native-custom-actionsheet
so you can customize ActionSheet buttons
importReact,{Component}from'react'import{View,Text,StyleSheet}from'react-native'import{ActionSheetCustomasActionSheet}from'react-native-custom-actionsheet'constCANCEL_INDEX=0constDESTRUCTIVE_INDEX=4constoptions=['Cancel','Apple',{component:<Textstyle={{color:'orange',fontSize:24}}>Banana</Text>,height:80,},'Watermelon',{component:<Textstyle={{color:'blueviolet'}}>Apple</Text>,height:40,},]consttitle=<Textstyle={{color:'crimson',fontSize:18}}>Which one do you like?</Text>classCustomExampleextendsComponent{state={selected:1,}showActionSheet=()=>this.actionSheet.show()getActionSheetRef=ref=>(this.actionSheet=ref)handlePress=index=>this.setState({selected:index})render(){const{ selected}=this.stateconstselectedText=options[selected].component||options[selected]return(<Viewstyle={styles.wrapper}><Textstyle={{marginBottom:20}}> I like{selectedText}</Text><Textstyle={styles.button}onPress={this.showActionSheet}> Custom ActionSheet</Text><ActionSheetref={this.getActionSheetRef}title={title}message="custom message custom message custom message custom message custom message custom message "options={options}cancelButtonIndex={CANCEL_INDEX}destructiveButtonIndex={DESTRUCTIVE_INDEX}onPress={this.handlePress}/></View>)}}
importReactfrom'react'import{View,Text,StyleSheet}from'react-native'importActionSheetfrom'react-native-custom-actionsheet'constCANCEL_INDEX=0constDESTRUCTIVE_INDEX=4constoptions=['Cancel','Apple','Banana','Watermelon','Durian']consttitle='Which one do you like?'classDefaultExampleextendsReact.Component{state={selected:'',}showActionSheet=()=>this.actionSheet.show()getActionSheetRef=ref=>(this.actionSheet=ref)handlePress=(index)=>this.setState({selected:index})render(){return(<Viewstyle={styles.wrapper}><Textstyle={{marginBottom:20}}> I like{options[this.state.selected]}</Text><Textstyle={styles.button}onPress={this.showActionSheet}> Default ActionSheet</Text><ActionSheetref={this.getActionSheetRef}title={title}message="custom message custom message custom message custom message custom message custom message "options={options}cancelButtonIndex={CANCEL_INDEX}destructiveButtonIndex={DESTRUCTIVE_INDEX}onPress={this.handlePress}/></View>)}}
Prop name | Desciption | Type | Default |
---|---|---|---|
title | PropTypes.string or PropTypes.element | ||
message | PropTypes.string or PropTypes.element | ||
options | PropTypes.arrayOf([ PropTypes.string, PropTypes.shape({ component: PropTypes.element, height: PropTypes.number }), ]) | ||
tintColor | PropTypes.string | ||
cancelButtonIndex | PropTypes.number | ||
destructiveButtonIndex | PropTypes.number | ||
onPress | PropTypes.func | (index) => {} | |
styles | StyleSheet object with some keys from ./lib/styles |
About
📜 Cross platform custom ActionSheet
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.