Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/valerybugakov/react-native-custom-actionsheet
📜 Cross platform custom ActionSheet
https://github.com/valerybugakov/react-native-custom-actionsheet
action-sheet custom-actionsheet react react-native react-native-actionsheet
Last synced: about 2 months ago
JSON representation
📜 Cross platform custom ActionSheet
- Host: GitHub
- URL: https://github.com/valerybugakov/react-native-custom-actionsheet
- Owner: valerybugakov
- License: mit
- Created: 2017-10-17T17:36:00.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T03:01:28.000Z (almost 2 years ago)
- Last Synced: 2024-10-13T01:38:26.143Z (2 months ago)
- Topics: action-sheet, custom-actionsheet, react, react-native, react-native-actionsheet
- Language: JavaScript
- Homepage:
- Size: 4.73 MB
- Stars: 48
- Watchers: 3
- Forks: 13
- Open Issues: 40
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-react-native - react-native-custom-actionsheet ★21 - Fully customizable ActionSheet for React Native. (Components / UI)
- awesome-reactnative-ui - react-native-custom-actionsheet - native-custom-actionsheet/master/./examples/ios.gif)| (Others)
- awesome-react-native - react-native-custom-actionsheet ★21 - Fully customizable ActionSheet for React Native. (Components / UI)
- awesome-react-native - react-native-custom-actionsheet ★21 - Fully customizable ActionSheet for React Native. (Components / UI)
- awesome-reactnative-ui - react-native-custom-actionsheet - native-custom-actionsheet/master/./examples/ios.gif)| (Others)
- awesome-react-native - react-native-custom-actionsheet ★21 - Fully customizable ActionSheet for React Native. (Components / UI)
README
# react-native-custom-actionsheet
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 on [react-native-actionsheet](https://github.com/beefe/react-native-actionsheet) by [beefe](https://github.com/beefe).
# Installation
```
npm i -S react-native-custom-actionsheet
```## Usage of ActionSheetCustom
so you can customize ActionSheet buttons
```javascript
import React, { Component } from 'react'
import { View, Text, StyleSheet } from 'react-native'
import { ActionSheetCustom as ActionSheet } from 'react-native-custom-actionsheet'const CANCEL_INDEX = 0
const DESTRUCTIVE_INDEX = 4
const options = [
'Cancel',
'Apple',
{
component: Banana,
height: 80,
},
'Watermelon',
{
component: Apple,
height: 40,
},
]
const title = Which one do you like?class CustomExample extends Component {
state = {
selected: 1,
}showActionSheet = () => this.actionSheet.show()
getActionSheetRef = ref => (this.actionSheet = ref)
handlePress = index => this.setState({ selected: index })
render() {
const { selected } = this.state
const selectedText = options[selected].component || options[selected]return (
I like {selectedText}
Custom ActionSheet
)
}
}
```## Usage
```javascript
import React from 'react'
import { View, Text, StyleSheet } from 'react-native'
import ActionSheet from 'react-native-custom-actionsheet'const CANCEL_INDEX = 0
const DESTRUCTIVE_INDEX = 4
const options = [ 'Cancel', 'Apple', 'Banana', 'Watermelon', 'Durian' ]
const title = 'Which one do you like?'class DefaultExample extends React.Component {
state = {
selected: '',
}showActionSheet = () => this.actionSheet.show()
getActionSheetRef = ref => (this.actionSheet = ref)
handlePress = (index) => this.setState({ selected: index })
render() {
return (
I like {options[this.state.selected]}
Default ActionSheet
)
}
}
```## Props
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