Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

📜 Cross platform custom ActionSheet

License

NotificationsYou must be signed in to change notification settings

valerybugakov/react-native-custom-actionsheet

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.

Installation

npm i -S react-native-custom-actionsheet

Usage of ActionSheetCustom

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>)}}

Usage

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>)}}

Props

Prop nameDesciptionTypeDefault
titlePropTypes.string or PropTypes.element
messagePropTypes.string or PropTypes.element
options PropTypes.arrayOf([ PropTypes.string, PropTypes.shape({ component: PropTypes.element, height: PropTypes.number }), ])
tintColorPropTypes.string
cancelButtonIndexPropTypes.number
destructiveButtonIndexPropTypes.number
onPressPropTypes.func(index) => {}
stylesStyleSheet object with some keys from ./lib/styles

About

📜 Cross platform custom ActionSheet

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp