Skip to content

Commit

Permalink
Init ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
valerybugakov committed Oct 17, 2017
0 parents commit bea578a
Show file tree
Hide file tree
Showing 12 changed files with 7,046 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
@@ -0,0 +1,3 @@
{
"presets": ["env", "react-native"]
}
14 changes: 14 additions & 0 deletions .editorconfig
@@ -0,0 +1,14 @@
# editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
13 changes: 13 additions & 0 deletions .eslintrc.yml
@@ -0,0 +1,13 @@
---
extends: standard
parser: babel-eslint

plugins:
- babel
- react

rules:
comma-dangle: [2, 'always-multiline']
space-before-function-paren: [2, 'never']
no-return-assign: 0
react/jsx-uses-vars: 2
34 changes: 34 additions & 0 deletions .gitignore
@@ -0,0 +1,34 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IJ
#
.idea
.gradle
local.properties

# node.js
#
node_modules/
npm-debug.log
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 beefe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
170 changes: 170 additions & 0 deletions README.md
@@ -0,0 +1,170 @@
# react-native-custom-actionsheet
Cross platform ActionSheet. This component implements a custom ActionSheet and provides the same way to drawing it on the defferent platforms(iOS and Android). Actually, In order to keep the best effect, it still uses the ActionSheetIOS on iOS.

<img height="500" src="./doc/ios.png"> <img height="500" src="./doc/android.png">

# Installation

```
npm i -S react-native-custom-actionsheet
```

## Usage

```javascript
import React, { Component } from 'react'
import { View, Text, StyleSheet, Modal, ListView } 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 ExampleA extends Component {
state = {
selected: ''
}

showActionSheet = () => this.ActionSheet.show()

getActionSheetRef = ref => (this.actionSheet = ref)

handlePress = (index) => {
this.setState({ selected: index })
}

render() {
return (
<View style={styles.wrapper}>
<Text style={{marginBottom: 20}}>
I like {options[this.state.selected]}
</Text>
<Text style={styles.button} onPress={this.showActionSheet}>
Example A
</Text>
<ActionSheet
ref={this.getActionSheetRef}
title={title}
options={options}
cancelButtonIndex={CANCEL_INDEX}
destructiveButtonIndex={DESTRUCTIVE_INDEX}
onPress={this.handlePress}
/>
</View>
)
}
}
```


## Use ActionSheetCustom directly

so you can customize option and title

```javascript
import React from 'react'
import { View, Text, StyleSheet, Modal, ListView } from 'react-native'
import { ActionSheetCustom as ActionSheet } from 'react-native-actionsheet'

const CANCEL_INDEX = 0
const DESTRUCTIVE_INDEX = 4

const options = [
'Cancel',
'Apple',
<Text style={{color: 'yellow'}}>Banana</Text>,
'Watermelon',
<Text style={{color: 'red'}}>Durian</Text>
]

const title = <Text style={{color: '#000', fontSize: 18}}>Which one do you like?</Text>

class ExampleB extends React.Component {
state = {
selected: ''
}

showActionSheet = () => this.ActionSheet.show()

getActionSheetRef = ref => (this.actionSheet = ref)

handlePress = (index) => {
this.setState({ selected: index })
}

render() {
return (
<View style={styles.wrapper}>
<Text style={{ marginBottom: 20 }}>
I like {options[this.state.selected]}
</Text>
<Text style={styles.button} onPress={this.showActionSheet}>
Example B
</Text>
<ActionSheet
ref={this.getActionSheetRef}
title={title}
options={options}
cancelButtonIndex={CANCEL_INDEX}
destructiveButtonIndex={DESTRUCTIVE_INDEX}
onPress={this.handlePress}
/>
</View>
)
}
}
```
## Props
<table>
<tr>
<th>Prop name</th>
<th>Desciption</th>
<th>Type</th>
<th>Default</th>
</tr>
<tr>
<td>title</td>
<td></td>
<td>PropTypes.string or PropTypes.element</td>
<td></td>
</tr>
<tr>
<td>message</td>
<td></td>
<td>PropTypes.string or PropTypes.element</td>
<td></td>
</tr>
<tr>
<td>options</td>
<td></td>
<td>PropTypes.arrayOf([PropTypes.string, PropTypes.element])</td>
<td></td>
</tr>
<tr>
<td>tintColor</td>
<td></td>
<td>PropTypes.string</td>
<td></td>
</tr>
<tr>
<td>cancelButtonIndex</td>
<td></td>
<td>PropTypes.number</td>
<td></td>
</tr>
<tr>
<td>destructiveButtonIndex</td>
<td></td>
<td>PropTypes.number</td>
<td></td>
</tr>
<tr>
<td>onPress</td>
<td></td>
<td>PropTypes.func</td>
<td>(index) => {}</td>
</tr>
</table>

0 comments on commit bea578a

Please sign in to comment.