Compare commits

...
5 Commits
Author SHA1 Message Date
Peter Piekarczyk 3b4439dd09 2.1.0 2019-01-30 19:01:32 -06:00
Evan Bacon 5ee7d9af74 Update ActionSheet.js 2019-01-30 16:04:02 -08:00
Brent Vatne 68ff6a1df9 Merge pull request #99 from expo/@evanbacon/expo-web/action-sheet
[Web] Added support for running with expo for web
2019-01-30 15:41:29 -08:00
Evan Bacon 3be83131c6 Updated docs 2019-01-30 15:19:52 -08:00
Evan Bacon 8e943863db Added Web 2019-01-30 15:16:21 -08:00
3 changed files with 36 additions and 25 deletions

No files matched your search

+4 -3
View File
@@ -421,9 +421,10 @@ ActionSheet.defaultProps = {
useNativeDriver: true,
};
let TouchableComponent;
TouchableComponent = Platform.Version <= 20 ? TouchableOpacity : TouchableNativeFeedback;
let TouchableComponent = Platform.select({
web: TouchableOpacity,
default: Platform.Version <= 20 ? TouchableOpacity : TouchableNativeFeedback,
});
if (TouchableComponent !== TouchableNativeFeedback) {
TouchableComponent.SelectableBackground = () => ({});
+30 -20
View File
@@ -3,6 +3,7 @@
ActionSheet is a cross-platform React Native component that uses the native UIActionSheet on iOS and a JS implementation on Android. Almost a drop in replacement for [ActionSheetIOS](https://facebook.github.io/react-native/docs/actionsheetios.html) except it cannot be called statically.
## Installation
```
npm install @expo/react-native-action-sheet
```
@@ -12,7 +13,10 @@ npm install @expo/react-native-action-sheet
import ActionSheetProvider & connectActionSheet
```es6
import { ActionSheetProvider, connectActionSheet } from '@expo/react-native-action-sheet';
import {
ActionSheetProvider,
connectActionSheet,
} from '@expo/react-native-action-sheet';
```
wrap your top-level component with `<ActionSheetProvider />`
@@ -33,7 +37,9 @@ decorate the component you want to use the action sheet with `@connectActionShee
```es6
@connectActionSheet
class App extends React.Component { /* ... */ }
class App extends React.Component {
/* ... */
}
```
access actionSheet method as `this.props.showActionSheetWithOptions`
@@ -44,37 +50,41 @@ _onOpenActionSheet = () => {
const options = ['Delete', 'Save', 'Cancel'];
const destructiveButtonIndex = 0;
const cancelButtonIndex = 2;
this.props.showActionSheetWithOptions({
options,
cancelButtonIndex,
destructiveButtonIndex,
},
(buttonIndex) => {
// Do something here depending on the button index selected
});
}
this.props.showActionSheetWithOptions(
{
options,
cancelButtonIndex,
destructiveButtonIndex,
},
buttonIndex => {
// Do something here depending on the button index selected
},
);
};
```
## Options
The goal of this library is to mimic the native iOS and Android ActionSheets as closely as possible.
This library can also be used with on web with Expo.
### Universal Props
The same options available on React Native's [ActionSheetIOS](https://facebook.github.io/react-native/docs/actionsheetios.html#showactionsheetwithoptions) component exist for both iOS and Android in this library.
### Android-Only Props
The below props allow modification of the Android ActionSheet. They have no effect on the look on iOS as the native iOS Action Sheet does not have options for modifying these options.
The below props allow modification of the Android ActionSheet. They have no effect on the look on iOS as the native iOS Action Sheet does not have options for modifying these options.
* `icons` (array of required images or icons; optional): Show icons to go along with each option. If image source paths are provided via `require`, images will be rendered for you. Alternatively, you can provide an array of elements such as vector icons, pre-rendered Images, etc.
* `tintIcons` (boolean; optional; default: `true`): Icons by default will be tinted to match the text color. When set to false, the icons will be the color of the source image. This is useful if you want to use multicolor icons. If you provide your own nodes/pre-rendered icons rather than required images in the `icons` array, you will need to tint them appropriately before providing them in the array of `icons`; `tintColor` will not be applied to icons unless they are images from a required source.
* `textStyle` (Text.propTypes.style; optional): Apply any text style props to the options. If the `tintColor` option is provided, it takes precedence over a color text style prop.
* `titleTextStyle` (Text.propTypes.style; optional): Apply any text style props to the title if present.
* `messageTextStyle` (Text.propTypes.style; optional): Apply any text style props to the message if present.
* `showSeparators`: (boolean; optional; default: false): Show separators between items. On iOS, separators always show so this prop has no effect.
* `separatorStyle`: (View.propTypes.style; optional): Modify the look of the separators rather than use the default look.
- `icons` (array of required images or icons; optional): Show icons to go along with each option. If image source paths are provided via `require`, images will be rendered for you. Alternatively, you can provide an array of elements such as vector icons, pre-rendered Images, etc.
- `tintIcons` (boolean; optional; default: `true`): Icons by default will be tinted to match the text color. When set to false, the icons will be the color of the source image. This is useful if you want to use multicolor icons. If you provide your own nodes/pre-rendered icons rather than required images in the `icons` array, you will need to tint them appropriately before providing them in the array of `icons`; `tintColor` will not be applied to icons unless they are images from a required source.
- `textStyle` (Text.propTypes.style; optional): Apply any text style props to the options. If the `tintColor` option is provided, it takes precedence over a color text style prop.
- `titleTextStyle` (Text.propTypes.style; optional): Apply any text style props to the title if present.
- `messageTextStyle` (Text.propTypes.style; optional): Apply any text style props to the message if present.
- `showSeparators`: (boolean; optional; default: false): Show separators between items. On iOS, separators always show so this prop has no effect.
- `separatorStyle`: (View.propTypes.style; optional): Modify the look of the separators rather than use the default look.
## Try it out
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@expo/react-native-action-sheet",
"version": "2.0.1",
"version": "2.1.0",
"description": "A cross-platform ActionSheet for React Native",
"main": "index.js",
"scripts": {
@@ -15,7 +15,7 @@
"action-sheet"
],
"files": [
"ActionSheet.android.js",
"ActionSheet.js",
"ActionSheet.ios.js",
"ActionSheetProvider.js",
"connectActionSheet.js",