Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

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