Compare commits

..
42 Commits
Author SHA1 Message Date
semantic-release-bot bbb48dadea chore(release): 3.9.0 [skip ci]
# [3.9.0](https://github.com/expo/react-native-action-sheet/compare/v3.8.0...v3.9.0) (2021-03-12)

### Bug Fixes

* allow callback to be async ([#183](https://github.com/expo/react-native-action-sheet/issues/183)) ([d0d5182](https://github.com/expo/react-native-action-sheet/commit/d0d518278028556a80deec3d9b57c332b82ba28d))
* center icons with titles ([#188](https://github.com/expo/react-native-action-sheet/issues/188)) ([d48c323](https://github.com/expo/react-native-action-sheet/commit/d48c323e4563363c8683c427d1803e1ff4cddcb5))

### Features

* add `userInterfaceStyle` option for iOS ([#206](https://github.com/expo/react-native-action-sheet/issues/206)) ([735cfa5](https://github.com/expo/react-native-action-sheet/commit/735cfa54ba1bfd90139671489aca525fdbd59626))
2021-03-12 11:40:32 -06:00
Manu 735cfa54ba feat: add userInterfaceStyle option for iOS (#206) 2021-03-11 14:13:29 -06:00
Emmanuel Johnandemmanuel.john 1af3809e07 chore: allow setting useNativeDriver on the provider (#202)
Fixes #184 

Co-authored-by: emmanuel.john <[email protected]>
2021-02-12 11:00:32 -06:00
dependabot[bot] d76a61f593 chore(deps): bump ini from 1.3.5 to 1.3.7 (#196)
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.7.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.7)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-12 07:21:44 -06:00
Brad Bumbalough 3ef49be264 chore: upgrade example app to SDK 39 (#193) 2020-12-02 17:14:07 -06:00
Brad Bumbalough 18e63e275d chore: resolve dependency audit issues (#192)
* chore: update semantic-release to latest

* chore: update yarn.lock to resolve audit issues
2020-12-02 17:02:16 -06:00
Svarto d48c323e45 fix: center icons with titles (#188) 2020-12-02 16:37:09 -06:00
Vincent PizzoandVincent Pizzo d0d5182780 fix: allow callback to be async (#183)
Co-authored-by: Vincent Pizzo <[email protected]>
2020-12-02 16:27:15 -06:00
dependabot[bot] eb30b1ed14 chore(deps-dev): bump semantic-release from 15.13.31 to 17.2.3 (#190)
Bumps [semantic-release](https://github.com/semantic-release/semantic-release) from 15.13.31 to 17.2.3.
- [Release notes](https://github.com/semantic-release/semantic-release/releases)
- [Commits](https://github.com/semantic-release/semantic-release/compare/v15.13.31...v17.2.3)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-02 16:26:09 -06:00
dependabot[bot] f509356bdd chore(deps): bump npm-user-validate from 1.0.0 to 1.0.1 (#186)
Bumps [npm-user-validate](https://github.com/npm/npm-user-validate) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/npm/npm-user-validate/releases)
- [Commits](https://github.com/npm/npm-user-validate/compare/v1.0.0...v1.0.1)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-02 16:25:55 -06:00
dependabot[bot] 86007a32a0 chore(deps): bump npm from 6.13.4 to 6.14.6 (#175)
Bumps [npm](https://github.com/npm/cli) from 6.13.4 to 6.14.6.
- [Release notes](https://github.com/npm/cli/releases)
- [Changelog](https://github.com/npm/cli/blob/latest/CHANGELOG.md)
- [Commits](https://github.com/npm/cli/compare/v6.13.4...v6.14.6)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-08-03 13:20:43 -05:00
dependabot[bot] 76da5f5fe5 chore(deps): bump lodash from 4.17.14 to 4.17.19 (#178)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.14 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.14...4.17.19)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-20 15:11:36 -05:00
dependabot[bot] e1bd0b0415 chore(deps): bump lodash from 4.17.14 to 4.17.19 in /example
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.14 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.14...4.17.19)

Signed-off-by: dependabot[bot] <[email protected]>
2020-07-17 11:39:23 -07:00
semantic-release-bot d0cf2b8c8d chore(release): 3.8.0 [skip ci]
# [3.8.0](https://github.com/expo/react-native-action-sheet/compare/v3.7.0...v3.8.0) (2020-05-19)

### Features

* Add destructiveColor option ([#171](https://github.com/expo/react-native-action-sheet/issues/171)) ([5549e36](https://github.com/expo/react-native-action-sheet/commit/5549e36a92d8afcc0ce2bf6a601e83209b5ce080))
* Improvements to Android accessibility ([#168](https://github.com/expo/react-native-action-sheet/issues/168)) ([b605fb8](https://github.com/expo/react-native-action-sheet/commit/b605fb8a3b6421c244f7f18d934bb5ea0753d461))
2020-05-19 07:58:03 -05:00
V. Danilichev 5549e36a92 feat: Add destructiveColor option (#171) 2020-05-19 07:55:17 -05:00
Steven Fuqua b605fb8a3b feat: Improvements to Android accessibility (#168) 2020-05-19 07:48:58 -05:00
semantic-release-bot b95117a8cd chore(release): 3.7.0 [skip ci]
# [3.7.0](https://github.com/expo/react-native-action-sheet/compare/v3.6.0...v3.7.0) (2020-05-06)

### Features

* adds `useModal` prop wrap action sheet in a modal ([9ed955d](https://github.com/expo/react-native-action-sheet/commit/9ed955dbba7259cbcf5e31ef3d4ed091ae4a3145)), closes [#169](https://github.com/expo/react-native-action-sheet/issues/169)
2020-05-06 08:27:32 -05:00
Broda Noel 9ed955dbba feat: adds useModal prop wrap action sheet in a modal
Fixes #169
2020-05-06 08:07:46 -05:00
Brad Bumbalough d85c167b55 chore: run git release after npm 2020-03-30 08:34:04 -05:00
Brad Bumbalough 128a48f2ff chore: commit package.json 2020-03-30 08:32:46 -05:00
semantic-release-bot fe8c66dd0b chore(release): 3.6.0 [skip ci]
# [3.6.0](https://github.com/expo/react-native-action-sheet/compare/v3.5.0...v3.6.0) (2020-03-30)

### Bug Fixes

* Android 'Super expression must either be null or a function' ([37156da](https://github.com/expo/react-native-action-sheet/commit/37156dacf114aa5146da153db9ee00c1aea8eaca))

### Features

* Add accessibility label to Action options ([#158](https://github.com/expo/react-native-action-sheet/issues/158)) ([bc3c27d](https://github.com/expo/react-native-action-sheet/commit/bc3c27d767a5657032b73f70aa1aacfea0481f66))
2020-03-30 08:29:47 -05:00
David Smith bc3c27d767 feat: Add accessibility label to Action options (#158)
* Add accessibility Label to Action options

* Commit Build

* Revert "Commit Build"

This reverts commit 9d891a6d3a.
2020-03-30 08:11:06 -05:00
Brad Bumbalough 33c7d9301c Merge pull request #160 from jdmunro/clarify-docs
Clarify setup documentation
2020-03-30 08:10:30 -05:00
Brad Bumbalough b20bf029ee Merge pull request #162 from Mitch528/fix-android
Fix Android 'Super expression must either be null or a function'
2020-03-30 08:09:36 -05:00
Mitchell Kutchuk 37156dacf1 fix: Android 'Super expression must either be null or a function' 2020-03-26 16:26:39 -07:00
James Munro 0d98570861 Update README.md 2020-03-14 16:06:11 +00:00
dependabot[bot] 6fe293d4e2 Bump acorn from 6.2.0 to 6.4.1
Bumps [acorn](https://github.com/acornjs/acorn) from 6.2.0 to 6.4.1.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/6.2.0...6.4.1)

Signed-off-by: dependabot[bot] <[email protected]>
2020-03-13 16:27:46 -07:00
semantic-release-bot ead0ed7dc1 chore(release): 3.5.0 [skip ci]
# [3.5.0](https://github.com/expo/react-native-action-sheet/compare/v3.4.1...v3.5.0) (2020-02-04)

### Features

* add anchor option for iPads ([#155](https://github.com/expo/react-native-action-sheet/issues/155)) ([370e6e8](https://github.com/expo/react-native-action-sheet/commit/370e6e855fbacbfc683cc6ab16304f26c159e6b5))
2020-02-04 06:13:09 -06:00
Brad Bumbalough 27cef1a658 Merge pull request #157 from expo/chore/ipad-example
chore: ipad anchor in example app
2020-02-04 06:07:22 -06:00
Brad Bumbalough bfae6b4ebc chore: update readme with anchor option 2020-02-04 06:03:58 -06:00
Brad Bumbalough eecc79ffb0 chore: update example app with iPad anchor 2020-02-04 06:03:49 -06:00
Kashish Grover 370e6e855f feat: add anchor option for iPads (#155) 2020-02-04 05:54:18 -06:00
Brad Bumbalough 6fa494f9de Merge pull request #156 from expo/chore/remove-gh-action
chore: remove github actions
2020-02-04 05:53:25 -06:00
Brad Bumbalough fc86afb87e chore: remove github actions 2020-02-04 05:52:30 -06:00
Evan Bacon 40aee02227 Update README.md 2019-12-31 23:08:24 -08:00
Brad Bumbalough ac6f9f6ccd chore: cleanup changelog file 2019-12-13 07:50:40 -06:00
semantic-release-bot 0131ebbb44 chore(release): 3.4.1 [skip ci]
## [3.4.1](https://github.com/expo/react-native-action-sheet/compare/v3.4.0...v3.4.1) (2019-12-13)

### Bug Fixes

* **iOS:** crash when using Android only options ([#144](https://github.com/expo/react-native-action-sheet/issues/144)) ([8016008](https://github.com/expo/react-native-action-sheet/commit/8016008781cbe418dc03f04a324d5e5ef5bcdaa7))
2019-12-13 07:46:57 -06:00
Brad Bumbalough 0627e77fba Merge pull request #148 from expo/chore/changelog
chore: commit changelog when releasing
2019-12-13 07:46:06 -06:00
Brad Bumbalough d114cfb321 chore: commit changelog when releasing 2019-12-13 07:43:56 -06:00
Hashir Ch 8016008781 fix(iOS): crash when using Android only options (#144) 2019-12-13 07:15:56 -06:00
Colin Darie 39fc431c97 feat(android): allow customizing container styles (#142)
* Android: container style configurable (background)
* Add containerStyle prop description to readme
* Add containerStyle prop to example app
2019-11-18 22:12:18 -06:00
Hammad Jutt 76397fa7c4 feat: Allow pointerEvents prop to pass through to containing view (#124) 2019-11-18 21:41:57 -06:00
17 changed files with 7478 additions and 2933 deletions

No files matched your search

-27
View File
@@ -1,27 +0,0 @@
name: Release
on:
push:
branches:
- master
jobs:
release:
name: Release
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
- name: Install dependencies
run: yarn
- name: Type check
run: npm run type-check
- name: Lint
run: npm run lint
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
+17 -2
View File
@@ -2,8 +2,23 @@
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md",
"changelogTitle": "# Changelog"
}
],
"@semantic-release/npm",
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md",
"package.json"
]
}
],
"@semantic-release/github"
]
}
}
+62
View File
@@ -1 +1,63 @@
# Changelog
# [3.9.0](https://github.com/expo/react-native-action-sheet/compare/v3.8.0...v3.9.0) (2021-03-12)
### Bug Fixes
* allow callback to be async ([#183](https://github.com/expo/react-native-action-sheet/issues/183)) ([d0d5182](https://github.com/expo/react-native-action-sheet/commit/d0d518278028556a80deec3d9b57c332b82ba28d))
* center icons with titles ([#188](https://github.com/expo/react-native-action-sheet/issues/188)) ([d48c323](https://github.com/expo/react-native-action-sheet/commit/d48c323e4563363c8683c427d1803e1ff4cddcb5))
### Features
* add `userInterfaceStyle` option for iOS ([#206](https://github.com/expo/react-native-action-sheet/issues/206)) ([735cfa5](https://github.com/expo/react-native-action-sheet/commit/735cfa54ba1bfd90139671489aca525fdbd59626))
# [3.8.0](https://github.com/expo/react-native-action-sheet/compare/v3.7.0...v3.8.0) (2020-05-19)
### Features
* Add destructiveColor option ([#171](https://github.com/expo/react-native-action-sheet/issues/171)) ([5549e36](https://github.com/expo/react-native-action-sheet/commit/5549e36a92d8afcc0ce2bf6a601e83209b5ce080))
* Improvements to Android accessibility ([#168](https://github.com/expo/react-native-action-sheet/issues/168)) ([b605fb8](https://github.com/expo/react-native-action-sheet/commit/b605fb8a3b6421c244f7f18d934bb5ea0753d461))
# [3.7.0](https://github.com/expo/react-native-action-sheet/compare/v3.6.0...v3.7.0) (2020-05-06)
### Features
* adds `useModal` prop wrap action sheet in a modal ([9ed955d](https://github.com/expo/react-native-action-sheet/commit/9ed955dbba7259cbcf5e31ef3d4ed091ae4a3145)), closes [#169](https://github.com/expo/react-native-action-sheet/issues/169)
# [3.6.0](https://github.com/expo/react-native-action-sheet/compare/v3.5.0...v3.6.0) (2020-03-30)
### Bug Fixes
* Android 'Super expression must either be null or a function' ([37156da](https://github.com/expo/react-native-action-sheet/commit/37156dacf114aa5146da153db9ee00c1aea8eaca))
### Features
* Add accessibility label to Action options ([#158](https://github.com/expo/react-native-action-sheet/issues/158)) ([bc3c27d](https://github.com/expo/react-native-action-sheet/commit/bc3c27d767a5657032b73f70aa1aacfea0481f66))
# [3.5.0](https://github.com/expo/react-native-action-sheet/compare/v3.4.1...v3.5.0) (2020-02-04)
### Features
* add anchor option for iPads ([#155](https://github.com/expo/react-native-action-sheet/issues/155)) ([370e6e8](https://github.com/expo/react-native-action-sheet/commit/370e6e855fbacbfc683cc6ab16304f26c159e6b5))
## [3.4.1](https://github.com/expo/react-native-action-sheet/compare/v3.4.0...v3.4.1) (2019-12-13)
### Bug Fixes
* **iOS:** crash when using Android only options ([#144](https://github.com/expo/react-native-action-sheet/issues/144)) ([8016008](https://github.com/expo/react-native-action-sheet/commit/8016008781cbe418dc03f04a324d5e5ef5bcdaa7))
# [3.4.0](https://github.com/expo/react-native-action-sheet/compare/v3.3.2...v3.4.0) (2019-11-19)
### Features
* **android:** allow customizing container styles ([#142](https://github.com/expo/react-native-action-sheet/issues/142)) ([39fc431](https://github.com/expo/react-native-action-sheet/commit/39fc431c97cb0ec03ab2a8386bd1b836d9f1cd2f))
* Allow pointerEvents prop to pass through to containing view ([#124](https://github.com/expo/react-native-action-sheet/issues/124)) ([76397fa](https://github.com/expo/react-native-action-sheet/commit/76397fa7c4bff7318780ac72600156d753fad3f0))
+57 -19
View File
@@ -23,7 +23,24 @@ $ yarn add @expo/react-native-action-sheet
## A basic ActionSheet Setup
### 1. Connect your component which uses showActionSheetWithOptions.
### 1. Wrap your top-level component with `<ActionSheetProvider />`
```es6
import { ActionSheetProvider } from '@expo/react-native-action-sheet'
class AppContainer extends React.Component {
render() {
return (
<ActionSheetProvider>
<ConnectedApp />
</ActionSheetProvider>
);
}
}
```
### 2. Connect your component which uses showActionSheetWithOptions.
```es6
import { connectActionSheet } from '@expo/react-native-action-sheet'
@@ -69,33 +86,29 @@ export default function App () {
}
```
### 2. Wrap your top-level component with `<ActionSheetProvider />`
```es6
import { ActionSheetProvider } from '@expo/react-native-action-sheet'
class AppContainer extends React.Component {
render() {
return (
<ActionSheetProvider>
<ConnectedApp />
</ActionSheetProvider>
);
}
}
```
## 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.
This library can also be used in the browser with Expo for web.
### 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.
### iOS Only Props
| Name | Type | Required | Default |
| -------------------| -------| -------- | ------- |
| anchor | number | No | |
| userInterfaceStyle | string | No | |
#### `anchor` (optional)
iPad only option that allows for docking the action sheet to a node. See [ShowActionSheetButton.tsx](/example/ShowActionSheetButton.tsx) for an example on how to implement this.
#### `userInterfaceStyle` (optional)
The interface style used for the action sheet, can be set to `light` or `dark`, otherwise the default system style will be used.
### Android/Web-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.
@@ -108,8 +121,12 @@ The below props allow modification of the Android ActionSheet. They have no effe
| textStyle | TextStyle | No | |
| titleTextStyle | TextStyle | No | |
| messageTextStyle | TextStyle | No | |
| autoFocus | boolean | No | false |
| showSeparators | boolean | No | false |
| containerStyle | ViewStyle | No | |
| separatorStyle | ViewStyle | No | |
| useModal | boolean | No | false |
| destructiveColor | string | No | #d32f2f |
#### `icons` (optional)
@@ -127,12 +144,33 @@ Apply any text style props to the title if present.
#### `messageTextStyle` (optional)
Apply any text style props to the message if present.
#### `autoFocus`: (optional)
If true, will give the first option screen reader focus automatically when the action sheet becomes visible.
On iOS, this is the default behavior of the native action sheet.
#### `showSeparators`: (optional)
Show separators between items. On iOS, separators always show so this prop has no effect.
#### `containerStyle`: (optional)
Apply any view style props to the container rather than use the default look (e.g. dark mode).
#### `separatorStyle`: (optional)
Modify the look of the separators rather than use the default look.
#### `useModal`: (optional)
Wrap the ActionSheet with a Modal, in order to show in front of other Modals that were already opened ([issue reference](https://github.com/expo/react-native-action-sheet/issues/164)).
#### `destructiveColor`: (optional)
Modify color for text of destructive option.
## ActionSheetProvider Props
The following props can be set directly on the `ActionSheetProvider`
#### `useNativeDriver` (optional)
Windows only option that provides the option to disable the [native animation](https://reactnative.dev/docs/animated#using-the-native-driver) driver for React Native Windows projects targeting _Windows 10 Version-1809 ; Build-10.0.17763.0_ and earlier. `useNativeDriver` is [supported in Version-1903 and later](https://microsoft.github.io/react-native-windows/docs/win10-compat) so if your project is targeting that, you don't need to set this prop.
## Try it out
Try it in Expo: https://expo.io/@community/react-native-action-sheet-example
+46 -2
View File
@@ -1,9 +1,16 @@
import * as React from 'react';
import { StyleSheet, Text, View, ScrollView, SafeAreaView } from 'react-native';
import {
Modal,
StyleSheet,
Text,
View,
ScrollView,
SafeAreaView,
TouchableOpacity,
} from 'react-native';
import {
ActionSheetProvider,
connectActionSheet,
ActionSheetOptions,
ActionSheetProps,
} from '@expo/react-native-action-sheet';
import ShowActionSheetButton from './ShowActionSheetButton';
@@ -12,11 +19,13 @@ type Props = ActionSheetProps;
interface State {
selectedIndex: number | null;
isModalOpen: boolean;
}
class App extends React.Component<Props, State> {
state: State = {
selectedIndex: null,
isModalOpen: false,
};
_updateSelectionText = (selectedIndex: number) => {
@@ -36,6 +45,10 @@ class App extends React.Component<Props, State> {
return <Text style={styles.sectionHeaderText}>{text}</Text>;
};
_toggleModal = () => {
this.setState({ isModalOpen: !this.state.isModalOpen });
};
_renderButtons() {
const { showActionSheetWithOptions } = this.props;
return (
@@ -62,6 +75,13 @@ class App extends React.Component<Props, State> {
onSelection={this._updateSelectionText}
showActionSheetWithOptions={showActionSheetWithOptions}
/>
<ShowActionSheetButton
title="iPad Anchor"
withAnchor
withTitle
onSelection={this._updateSelectionText}
showActionSheetWithOptions={showActionSheetWithOptions}
/>
<ShowActionSheetButton
title="Nested Action Sheets"
onSelection={index => {
@@ -110,6 +130,26 @@ class App extends React.Component<Props, State> {
onSelection={this._updateSelectionText}
showActionSheetWithOptions={showActionSheetWithOptions}
/>
{this._renderSectionHeader('Special Cases')}
<TouchableOpacity onPress={this._toggleModal}>
<Text style={styles.link}>Open Modal</Text>
</TouchableOpacity>
{this.state.isModalOpen && (
<Modal>
<View style={{ flex: 1, padding: 30 }}>
<ShowActionSheetButton
useModal
title="Options Only"
onSelection={this._updateSelectionText}
showActionSheetWithOptions={showActionSheetWithOptions}
/>
<TouchableOpacity onPress={this._toggleModal}>
<Text style={styles.link}>Close Modal</Text>
</TouchableOpacity>
</View>
</Modal>
)}
</View>
);
}
@@ -177,4 +217,8 @@ const styles = StyleSheet.create({
fontSize: 16,
marginTop: 20,
},
link: {
fontSize: 15,
textDecorationLine: 'underline',
},
});
+32 -5
View File
@@ -1,5 +1,5 @@
import * as React from 'react';
import { Text, View, TextStyle } from 'react-native';
import { Text, View, TextStyle, ViewStyle, findNodeHandle, Button } from 'react-native';
import { MaterialIcons, Entypo } from '@expo/vector-icons';
import { ActionSheetOptions } from '@expo/react-native-action-sheet';
@@ -8,7 +8,7 @@ const icon = (name: string) => <MaterialIcons key={name} name={name} size={24} /
interface Props {
title: string;
showActionSheetWithOptions: (
optons: ActionSheetOptions,
options: ActionSheetOptions,
callback: (buttonIndex: number) => void
) => void;
onSelection: (index: number) => void;
@@ -17,6 +17,8 @@ interface Props {
withIcons?: boolean;
withSeparators?: boolean;
withCustomStyles?: boolean;
withAnchor?: boolean;
useModal?: boolean;
}
// A custom button that shows examples of different share sheet configurations
@@ -27,11 +29,16 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
withIcons: false,
withSeparators: false,
withCustomStyles: false,
withAnchor: false,
onSelection: null,
useModal: false,
};
_anchorRef = React.createRef<Button>();
_showActionSheet = () => {
const {
withAnchor,
withTitle,
withMessage,
withIcons,
@@ -39,6 +46,7 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
withCustomStyles,
onSelection,
showActionSheetWithOptions,
useModal,
} = this.props;
// Same interface as https://facebook.github.io/react-native/docs/actionsheetios.html
@@ -74,6 +82,15 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
textAlign: 'right',
}
: undefined;
const containerStyle: ViewStyle | undefined = withCustomStyles
? {
backgroundColor: 'lightgrey',
}
: undefined;
const anchor: number | null = this._anchorRef.current
? findNodeHandle(this._anchorRef.current)
: null;
showActionSheetWithOptions(
{
options,
@@ -82,6 +99,8 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
title,
message,
icons,
//iPad only
anchor: withAnchor && anchor ? anchor : undefined,
// Android only
tintIcons: true,
// Android only; default is true
@@ -91,9 +110,13 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
// Android only
titleTextStyle,
// Android only
messageTextStyle, // Android only
messageTextStyle,
// Android only,
containerStyle,
// Android only,
useModal,
},
buttonIndex => {
(buttonIndex: number) => {
// Do something here depending on the button index selected
onSelection(buttonIndex);
}
@@ -107,7 +130,11 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
style={{
margin: 6,
}}>
<Entypo.Button name="code" backgroundColor="#3e3e3e" onPress={this._showActionSheet}>
<Entypo.Button
name="code"
backgroundColor="#3e3e3e"
onPress={this._showActionSheet}
ref={this._anchorRef}>
<Text
style={{
fontSize: 15,
+1 -2
View File
@@ -4,7 +4,6 @@
"description": "A cross-platform ActionSheet component. https://github.com/expo/react-native-action-sheet",
"slug": "react-native-action-sheet-example",
"privacy": "public",
"sdkVersion": "35.0.0",
"version": "3.0.0",
"orientation": "portrait",
"primaryColor": "#cccccc",
@@ -15,4 +14,4 @@
"web"
]
}
}
}
+9 -9
View File
@@ -14,17 +14,17 @@
"dependencies": {
"@expo/react-native-action-sheet": "../src",
"@expo/vector-icons": "^10.0.0",
"expo": "^35.0.0",
"expo": "^39.0.0",
"hoist-non-react-statics": "^3.3.0",
"react": "16.8.3",
"react-dom": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
"react-native-web": "^0.11.5"
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-39.0.3.tar.gz",
"react-native-web": "~0.13.7"
},
"devDependencies": {
"@types/react": "^16.8.23",
"@types/react-native": "^0.57.65",
"babel-preset-expo": "^7.0.0",
"typescript": "^3.5.3"
"@types/react": "~16.9.35",
"@types/react-native": "~0.63.2",
"babel-preset-expo": "^8.3.0",
"typescript": "~3.9.2"
}
}
+2753 -1705
View File
File diff suppressed because it is too large. Load diff
+3 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@expo/react-native-action-sheet",
"version": "3.3.0",
"version": "3.9.0",
"description": "A cross-platform ActionSheet for React Native",
"react-native": "lib/module/index.js",
"types": "lib/typescript/index.d.ts",
@@ -36,6 +36,7 @@
"@react-native-community/bob": "^0.6.1",
"@react-native-community/eslint-config": "^0.0.5",
"@semantic-release/changelog": "^3.0.5",
"@semantic-release/git": "^7.0.18",
"@types/react": "^16.8.23",
"@types/react-native": "^0.57.65",
"@typescript-eslint/eslint-plugin": "^1.12.0",
@@ -48,7 +49,7 @@
"prettier": "^1.18.2",
"react": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
"semantic-release": "^15.13.28",
"semantic-release": "^17.3.0",
"typescript": "^3.5.3"
},
"peerDependencies": {
+42 -4
View File
@@ -1,5 +1,15 @@
import * as React from 'react';
import { StyleSheet, Text, Image, View, ScrollView } from 'react-native';
import {
StyleSheet,
Text,
Image,
View,
ScrollView,
findNodeHandle,
AccessibilityInfo,
Platform,
UIManager,
} from 'react-native';
import TouchableNativeFeedbackSafe from './TouchableNativeFeedbackSafe';
import { ActionSheetOptions } from '../types';
@@ -14,6 +24,28 @@ const BLACK_54PC_TRANSPARENT = '#0000008a';
const BLACK_87PC_TRANSPARENT = '#000000de';
const DESTRUCTIVE_COLOR = '#d32f2f';
/**
* Can be used as a React ref for a component to auto-focus for accessibility on render.
* @param ref The component to auto-focus
*/
const focusViewOnRender = (ref: React.Component | null) => {
if (ref) {
const reactTag = findNodeHandle(ref);
if (reactTag) {
if (Platform.OS === 'android') {
// @ts-ignore: sendAccessibilityEvent is missing from @types/react-native
UIManager.sendAccessibilityEvent(
reactTag,
// @ts-ignore: AccessibilityEventTypes is missing from @types/react-native
UIManager.AccessibilityEventTypes.typeViewFocused
);
} else {
AccessibilityInfo.setAccessibilityFocus(reactTag);
}
}
}
};
export default class ActionGroup extends React.Component<Props> {
static defaultProps = {
title: null,
@@ -25,7 +57,7 @@ export default class ActionGroup extends React.Component<Props> {
render() {
return (
<View style={styles.groupContainer}>
<View style={[styles.groupContainer, this.props.containerStyle]}>
{this._renderTitleContent()}
<ScrollView>{this._renderOptionViews()}</ScrollView>
</View>
@@ -75,11 +107,13 @@ export default class ActionGroup extends React.Component<Props> {
options,
icons,
destructiveButtonIndex,
destructiveColor = DESTRUCTIVE_COLOR,
onSelect,
startIndex,
length,
textStyle,
tintColor,
autoFocus,
showSeparators,
} = this.props;
const optionViews: React.ReactNode[] = [];
@@ -92,16 +126,19 @@ export default class ActionGroup extends React.Component<Props> {
const defaultColor = tintColor
? tintColor
: (textStyle || {}).color || BLACK_87PC_TRANSPARENT;
const color = i === destructiveButtonIndex ? DESTRUCTIVE_COLOR : defaultColor;
const color = i === destructiveButtonIndex ? destructiveColor : defaultColor;
const iconSource = icons != null ? icons[i] : null;
optionViews.push(
<TouchableNativeFeedbackSafe
ref={autoFocus && i === 0 ? focusViewOnRender : undefined}
key={i}
pressInDelay={0}
background={nativeFeedbackBackground}
onPress={() => onSelect(i)}
style={styles.button}>
style={styles.button}
accessibilityRole="button"
accessibilityLabel={options[i]}>
{this._renderIconElement(iconSource, color)}
<Text style={[styles.text, textStyle, { color }]}>{options[i]}</Text>
</TouchableNativeFeedbackSafe>
@@ -132,6 +169,7 @@ const styles = StyleSheet.create({
width: 24,
height: 24,
marginRight: 32,
justifyContent: "center",
},
message: {
marginTop: 12,
@@ -8,10 +8,14 @@ import {
} from 'react-native';
// This TouchableOpacity has the same staic method of TouchableNativeFeedback
class CustomTouchableOpacity extends TouchableOpacity {
class CustomTouchableOpacity extends React.Component {
static SelectableBackground = () => ({});
static SelectableBackgroundBorderless = () => ({});
static Ripple = (color: string, borderless?: boolean) => ({});
render() {
return <TouchableOpacity {...this.props}>{this.props.children}</TouchableOpacity>;
}
}
const TouchableComponent = Platform.select({
+20 -6
View File
@@ -1,24 +1,38 @@
import * as React from 'react';
import { ActionSheetIOS, View } from 'react-native';
import { ActionSheetIOS, View, ViewProps } from 'react-native';
import { ActionSheetIOSOptions } from '../types';
interface Props {
readonly children: React.ReactNode;
readonly pointerEvents?: ViewProps['pointerEvents'];
}
type onSelect = (buttonIndex: number) => void;
export default class ActionSheet extends React.Component<Props> {
render() {
return <View style={{ flex: 1 }}>{React.Children.only(this.props.children)}</View>;
return (
<View pointerEvents={this.props.pointerEvents} style={{ flex: 1 }}>
{React.Children.only(this.props.children)}
</View>
);
}
showActionSheetWithOptions(options: ActionSheetIOSOptions, onSelect: onSelect) {
showActionSheetWithOptions(dataOptions: ActionSheetIOSOptions, onSelect: onSelect) {
// ...dataOptions include other keys which use in android and web, thats why `Android-Only options` Crash on IOS
const { cancelButtonIndex, destructiveButtonIndex, options, tintColor } = dataOptions;
const iosOptions: ActionSheetIOSOptions = {
...options,
cancelButtonIndex,
destructiveButtonIndex,
options,
tintColor,
// A null title or message on iOS causes a crash
title: options.title || undefined,
message: options.message || undefined,
title: dataOptions.title || undefined,
message: dataOptions.message || undefined,
anchor: dataOptions.anchor || undefined,
userInterfaceStyle: dataOptions.userInterfaceStyle || undefined,
};
ActionSheetIOS.showActionSheetWithOptions(iosOptions, onSelect);
}
+39 -9
View File
@@ -3,9 +3,11 @@ import {
Animated,
BackHandler,
Easing,
Modal,
StyleSheet,
TouchableWithoutFeedback,
View,
ViewProps,
} from 'react-native';
import ActionGroup from './ActionGroup';
import { ActionSheetOptions } from '../types';
@@ -21,6 +23,7 @@ interface State {
interface Props {
readonly useNativeDriver: boolean | undefined;
readonly pointerEvents?: ViewProps['pointerEvents'];
}
const OPACITY_ANIMATION_IN_TIME = 225;
@@ -51,7 +54,8 @@ export default class ActionSheet extends React.Component<Props, State> {
(this._actionSheetHeight = nativeEvent.layout.height);
render() {
const { isVisible, overlayOpacity } = this.state;
const { isVisible, overlayOpacity, options } = this.state;
const useModal = options ? options.useModal === true : false;
const overlay = isVisible ? (
<Animated.View
style={[
@@ -62,14 +66,31 @@ export default class ActionSheet extends React.Component<Props, State> {
]}
/>
) : null;
return (
// While the sheet is visible, hide the rest of the app's content from screen readers.
const appContent = (
<View
style={{
flex: 1,
}}>
style={styles.flexContainer}
importantForAccessibility={isVisible ? 'no-hide-descendants' : 'auto'}>
{React.Children.only(this.props.children)}
{overlay}
{isVisible ? this._renderSheet() : null}
</View>
);
return (
<View pointerEvents={this.props.pointerEvents} style={styles.flexContainer}>
{appContent}
{isVisible && !useModal && (
<React.Fragment>
{overlay}
{this._renderSheet()}
</React.Fragment>
)}
{isVisible && useModal && (
<Modal animationType="none" transparent={true} onRequestClose={this._selectCancelButton}>
{overlay}
{this._renderSheet()}
</Modal>
)}
</View>
);
}
@@ -86,17 +107,20 @@ export default class ActionSheet extends React.Component<Props, State> {
icons,
tintIcons,
destructiveButtonIndex,
destructiveColor,
textStyle,
tintColor,
title,
titleTextStyle,
message,
messageTextStyle,
autoFocus,
showSeparators,
containerStyle,
separatorStyle,
} = options;
return (
<TouchableWithoutFeedback onPress={this._selectCancelButton}>
<TouchableWithoutFeedback importantForAccessibility="yes" onPress={this._selectCancelButton}>
<Animated.View
needsOffscreenAlphaCompositing={isAnimating}
style={[
@@ -119,6 +143,7 @@ export default class ActionSheet extends React.Component<Props, State> {
icons={icons}
tintIcons={tintIcons === undefined ? true : tintIcons}
destructiveButtonIndex={destructiveButtonIndex}
destructiveColor={destructiveColor}
onSelect={this._onSelect}
startIndex={0}
length={optionsArray.length}
@@ -128,7 +153,9 @@ export default class ActionSheet extends React.Component<Props, State> {
titleTextStyle={titleTextStyle}
message={message || undefined}
messageTextStyle={messageTextStyle}
autoFocus={autoFocus}
showSeparators={showSeparators}
containerStyle={containerStyle}
separatorStyle={separatorStyle}
/>
</View>
@@ -138,7 +165,7 @@ export default class ActionSheet extends React.Component<Props, State> {
}
showActionSheetWithOptions = (options: ActionSheetOptions, onSelect: (i: number) => void) => {
const { isVisible, isAnimating, overlayOpacity, sheetOpacity } = this.state;
const { isVisible, overlayOpacity, sheetOpacity } = this.state;
if (isVisible) {
this._deferNextShow = this.showActionSheetWithOptions.bind(this, options, onSelect);
@@ -247,6 +274,9 @@ export default class ActionSheet extends React.Component<Props, State> {
}
const styles = StyleSheet.create({
flexContainer: {
flex: 1,
},
overlay: {
position: 'absolute',
top: 0,
+2 -1
View File
@@ -5,6 +5,7 @@ import { ActionSheetOptions } from './types';
interface Props {
children: React.ReactNode;
useNativeDriver?: boolean;
}
export default class ActionSheetProvider extends React.Component<Props> {
@@ -27,7 +28,7 @@ export default class ActionSheetProvider extends React.Component<Props> {
render() {
return (
<Provider value={this.getContext()}>
<ActionSheet ref={this._actionSheetRef}>
<ActionSheet ref={this._actionSheetRef} useNativeDriver={this.props.useNativeDriver}>
{React.Children.only(this.props.children)}
</ActionSheet>
</Provider>
+7 -1
View File
@@ -2,7 +2,7 @@ import * as React from 'react';
import { TextStyle, ViewStyle } from 'react-native';
export interface ActionSheetProps {
showActionSheetWithOptions: (options: ActionSheetOptions, callback: (i: number) => void) => void;
showActionSheetWithOptions: (options: ActionSheetOptions, callback: (i: number) => void | Promise<void>) => void;
}
// for iOS
@@ -13,6 +13,8 @@ export interface ActionSheetIOSOptions {
tintColor?: string;
cancelButtonIndex?: number;
destructiveButtonIndex?: number;
anchor?: number;
userInterfaceStyle?: 'light' | 'dark';
}
// for Android or Web
@@ -22,6 +24,10 @@ export interface ActionSheetOptions extends ActionSheetIOSOptions {
textStyle?: TextStyle;
titleTextStyle?: TextStyle;
messageTextStyle?: TextStyle;
autoFocus?: boolean;
showSeparators?: boolean;
containerStyle?: ViewStyle;
separatorStyle?: ViewStyle;
useModal?: boolean;
destructiveColor?: string;
}
+4383 -1138
View File
File diff suppressed because it is too large. Load diff