|
| 1 | +# react-native-actionsheet-cstm |
| 2 | + |
| 3 | +## Getting started |
| 4 | + |
| 5 | +`$ npm install react-native-actionsheet-cstm --save` |
| 6 | + |
| 7 | +## Demo |
| 8 | + |
| 9 | +<p align="center"> |
| 10 | + <img src="https://github.com/gurbela/react-native-actionsheet-cstm/blob/master/image/Simulator Screen Shot - iPhone1.png" |
| 11 | + height="380" width="200" |
| 12 | + /> |
| 13 | + <img src="https://github.com/gurbela/react-native-actionsheet-cstm/blob/master/image/Screenshot_1.png" |
| 14 | + height="380" width="200" |
| 15 | + /> |
| 16 | + <img src="https://github.com/gurbela/react-native-actionsheet-cstm/blob/master/image/Simulator Screen Shot - iPhone2.png" |
| 17 | + height="380" width="200" |
| 18 | + /> |
| 19 | + <img src="https://github.com/gurbela/react-native-actionsheet-cstm/blob/master/image/Screenshot_2.png" |
| 20 | + height="380" width="200" |
| 21 | + /> |
| 22 | +</p> |
| 23 | + |
| 24 | +## A basic Setup |
| 25 | + |
| 26 | +```javascript |
| 27 | +import React, {useState} from 'react'; |
| 28 | +import {SafeAreaView, Text, ScrollView, TouchableOpacity} from 'react-native'; |
| 29 | + |
| 30 | +import {ActionSheet} from 'react-native-actionsheet-cstm'; |
| 31 | + |
| 32 | +const App = () => { |
| 33 | + const [showActionSheed, setShowActionSheet] = useState < boolean > false; |
| 34 | + |
| 35 | + const onShowActionSheet = () => { |
| 36 | + setShowActionSheet(true); |
| 37 | + }; |
| 38 | + const onCloseActionSheet = () => { |
| 39 | + setShowActionSheet(false); |
| 40 | + }; |
| 41 | + |
| 42 | + return ( |
| 43 | + <SafeAreaView style={{flex: 1}}> |
| 44 | + <Text style={{textAlign: 'center'}}>Components</Text> |
| 45 | + <ScrollView style={{flex: 1, marginTop: 50}}> |
| 46 | + <TouchableOpacity |
| 47 | + style={{ |
| 48 | + flex: 1, |
| 49 | + height: 40, |
| 50 | + justifyContent: 'center', |
| 51 | + alignItems: 'center', |
| 52 | + backgroundColor: '#3880ff', |
| 53 | + }} |
| 54 | + onPress={onShowActionSheet}> |
| 55 | + <Text style={{color: '#fff'}}>Show Action Sheet</Text> |
| 56 | + </TouchableOpacity> |
| 57 | + |
| 58 | + <ActionSheet |
| 59 | + visible={showActionSheed} |
| 60 | + onClose={onCloseActionSheet} |
| 61 | + actionItems={[ |
| 62 | + { |
| 63 | + text: 'Save', |
| 64 | + onPress: () => { |
| 65 | + console.log('Save'); |
| 66 | + }, |
| 67 | + }, |
| 68 | + { |
| 69 | + text: 'Update', |
| 70 | + onPress: () => { |
| 71 | + console.log('Update'); |
| 72 | + }, |
| 73 | + }, |
| 74 | + { |
| 75 | + text: 'Delete', |
| 76 | + textStyle: [{color: 'red'}], |
| 77 | + onPress: () => { |
| 78 | + console.log('Delete'); |
| 79 | + }, |
| 80 | + }, |
| 81 | + ]} |
| 82 | + /> |
| 83 | + </ScrollView> |
| 84 | + </SafeAreaView> |
| 85 | + ); |
| 86 | +}; |
| 87 | + |
| 88 | +export default App; |
| 89 | +``` |
| 90 | + |
| 91 | +## Options |
| 92 | + |
| 93 | +## ActionSheetProps |
| 94 | + |
| 95 | +| Name | Type | Default | Description | |
| 96 | +| -------------------- | -------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------- | |
| 97 | +| visible | boolean | false | Show the Action sheet | |
| 98 | +| onClose | function | null | Trigger a function asking to close the Action sheet. | |
| 99 | +| actionItems | Array<ActionItem> | null | (array of ActionItem) - a list of button | |
| 100 | +| onShow? | function | null | The onShow prop allows passing a function that will be called once the Action sheet has been shown. | |
| 101 | +| onDismiss? | function | null | The onDismiss prop allows passing a function that will be called once the Action sheet has been dismissed. | |
| 102 | +| backdropStyle? | StyleProp<ViewStyle> | null | Back drop style | |
| 103 | +| containerStyle? | StyleProp<ViewStyle> | null | Container style | |
| 104 | +| titleContainerStyle? | StyleProp<ViewStyle> | null | Container title style | |
| 105 | +| title? | string | 'Action Sheet Title' | Action sheet title | |
| 106 | +| titleTextStyle? | StyleProp<ViewStyle> | null | Action sheet title style | |
| 107 | +| cancelButtonStyle? | StyleProp<ViewStyle> | null | Action sheet cancel button style | |
| 108 | +| cancelText? | string | 'Cancel' | Action sheet cancel button title | |
| 109 | +| cancelTextStyle? | StyleProp<ViewStyle> | null | Action sheet cancel button text style | |
| 110 | +| hiddeCancel | boolean | false | Hidde the Action sheet Cancel button | |
| 111 | + |
| 112 | +## ActionItem |
| 113 | + |
| 114 | +| Name | Type | Default | Description | |
| 115 | +| ---------- | -------------------- | ------- | ------------- | |
| 116 | +| text | string | null | button title | |
| 117 | +| onPress | function | null | button action | |
| 118 | +| textStyle? | StyleProp<ViewStyle> | null | button style | |
0 commit comments