1.1.2 • Published 8 years ago
react-naive-highly-customizable-action-sheet v1.1.2
react-naive-highly-customizable-action-sheet
A highly customizable ActionSheet component which can be used in iOS and Android platform.

Introduction Blog in Chinese:简书:结合一个开源的底部弹出菜单组件来讲一下如何封装一个React Native组件
default style:

customized iOS style:

customized other style:

Installation
npm install react-naive-highly-customizable-action-sheet
Usage
1. Import component
import ActionSheet from 'react-naive-highly-customizable-action-sheet'2. Custom and show
Example 1:
<ActionSheet
mainTitle="There are three ways to contact. Please choose one to contact."
itemTitles = {["By phone","By message","By email"]}
selectionCallbacks = {[this.clickedByPhone,this.clickedByMessage,this.clickedByEmail]}
mainTitleTextAlign = 'center'
ref={(actionsheet)=>{this.actionsheet = actionsheet}}
/>
//show ActionSheet
showActionSheet(){
this.actionsheet.show();
}
//callback 1
clickedByPhone(){
alert('By Phone');
}
//callback 2
clickedByMessage(){
alert('By Message');
}
//callback 3
clickedByEmail(){
alert('By Email');
}
Example2:
<ActionSheet
mainTitle="There are three ways to contact. Please choose one to contact."
itemTitles = {["By phone","By message","By email"]}
selectionCallbacks = {[this.clickedByPhone,this.clickedByMessage,this.clickedByEmail]}
mainTitleTextAlign = 'center'
contentBackgroundColor = '#EFF0F1'
bottomSpace = {10}
cancelVerticalSpace = {10}
borderRadius = {5}
sideSpace = {6}
itemTitleColor = '#006FFF'
cancelTitleColor = '#006FFF'
ref={(actionsheet)=>{this.actionsheet = actionsheet}}
/>
Props:
itemTitles(Array):titles of all selection itemsselectionCallbacks(Array):callbacks of all selection itemsmainTitle(String):main title textmainTitleFont(Number):main title text fontmainTitleColor(String):main title text colormainTitleHeight(Number):main title cell heightmainTitleTextAlign(String):main title text alignmainTitlePadding(Number):main title paddingitemTitleFont(Number):item text fontitemTitleColor(String):item text coloritemHeight(Number):item cell height
cancelTitle(String):cancel text,default is 'Cancel'cancelTitleFont(Number):cancel text fontcancelTitleColor(String):cancel text colorcancelHeight(Number):cancel cell heighthideCancel(Bool):if hide cancel cell (default is no)
fontWeight(String):all text fontWeight (default: title and item text fontWeight is 'normal', cancel text fontWeight is 'bold' )titleFontWeight(String):title text fontWeightitemFontWeight(String):item text fontWeightcancelFontWeight(String):cancel text fontWeight
contentBackgroundColor(String):all cell background color (default is white)titleBackgroundColor(String):title cell background color (default is white)itemBackgroundColor(String):item cell background color (default is white)cancelBackgroundColor(String):cancel cell background color (default is white)itemSpaceColor(String):seperate line color between item cellscancelSpaceColor(String):seperate line color between last item cell and cancel cell
itemVerticalSpace(Number):distance between item cells
cancelVerticalSpace(Number):distance between last item item cell and cancel cellbottomSpace(Number):distance between screen bottom and cancel cell (default is 0)sideSpace(Number):distance between content edge and screen edge (default is 0)
borderRadius(Number):border radius of content (default is 0)
maskOpacity(Number):opacity of mask (default is 0.3)
Highly customizable





License
All source code is licensed under the MIT License.