mirror of
https://github.com/expo/react-native-action-sheet.git
synced 2026-11-14 19:11:42 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0cf2b8c8d | ||
|
|
5549e36a92 | ||
|
|
b605fb8a3b | ||
|
|
b95117a8cd | ||
|
|
9ed955dbba | ||
|
|
d85c167b55 | ||
|
|
128a48f2ff | ||
|
|
fe8c66dd0b | ||
|
|
bc3c27d767 | ||
|
|
33c7d9301c | ||
|
|
b20bf029ee | ||
|
|
37156dacf1 | ||
|
|
0d98570861 | ||
|
|
6fe293d4e2 | ||
|
|
ead0ed7dc1 | ||
|
|
27cef1a658 | ||
|
|
bfae6b4ebc | ||
|
|
eecc79ffb0 | ||
|
|
370e6e855f | ||
|
|
6fa494f9de | ||
|
|
fc86afb87e | ||
|
|
40aee02227 | ||
|
|
ac6f9f6ccd |
No files matched your search
@@ -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
|
||||
+11
-8
@@ -6,16 +6,19 @@
|
||||
"@semantic-release/changelog",
|
||||
{
|
||||
"changelogFile": "CHANGELOG.md",
|
||||
"changelogTitle": "Changelog"
|
||||
}
|
||||
],
|
||||
[
|
||||
"@semantic-release/git",
|
||||
{
|
||||
"assets": ["CHANGELOG.md"]
|
||||
"changelogTitle": "# Changelog"
|
||||
}
|
||||
],
|
||||
"@semantic-release/npm",
|
||||
[
|
||||
"@semantic-release/git",
|
||||
{
|
||||
"assets": [
|
||||
"CHANGELOG.md",
|
||||
"package.json"
|
||||
]
|
||||
}
|
||||
],
|
||||
"@semantic-release/github"
|
||||
]
|
||||
}
|
||||
}
|
||||
+35
-3
@@ -1,4 +1,38 @@
|
||||
Changelog
|
||||
# Changelog
|
||||
|
||||
# [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)
|
||||
|
||||
@@ -7,8 +41,6 @@ Changelog
|
||||
|
||||
* **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))
|
||||
|
||||
# Changelog
|
||||
|
||||
# [3.4.0](https://github.com/expo/react-native-action-sheet/compare/v3.3.2...v3.4.0) (2019-11-19)
|
||||
|
||||
|
||||
|
||||
@@ -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,25 @@ 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 | |
|
||||
|
||||
#### `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.
|
||||
|
||||
### 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,9 +117,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)
|
||||
|
||||
@@ -128,6 +140,10 @@ 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.
|
||||
|
||||
@@ -137,6 +153,12 @@ Apply any view style props to the container rather than use the default look (e.
|
||||
#### `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.
|
||||
|
||||
## Try it out
|
||||
|
||||
Try it in Expo: https://expo.io/@community/react-native-action-sheet-example
|
||||
|
||||
+46
-2
@@ -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',
|
||||
},
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import { Text, View, TextStyle, ViewStyle } 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
|
||||
@@ -79,6 +87,9 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
|
||||
backgroundColor: 'lightgrey',
|
||||
}
|
||||
: undefined;
|
||||
const anchor: number | null = this._anchorRef.current
|
||||
? findNodeHandle(this._anchorRef.current)
|
||||
: null;
|
||||
|
||||
showActionSheetWithOptions(
|
||||
{
|
||||
@@ -88,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
|
||||
@@ -100,8 +113,10 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
|
||||
messageTextStyle,
|
||||
// Android only,
|
||||
containerStyle,
|
||||
// Android only,
|
||||
useModal,
|
||||
},
|
||||
buttonIndex => {
|
||||
(buttonIndex: number) => {
|
||||
// Do something here depending on the button index selected
|
||||
onSelection(buttonIndex);
|
||||
}
|
||||
@@ -115,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
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@expo/react-native-action-sheet",
|
||||
"version": "3.3.0",
|
||||
"version": "3.8.0",
|
||||
"description": "A cross-platform ActionSheet for React Native",
|
||||
"react-native": "lib/module/index.js",
|
||||
"types": "lib/typescript/index.d.ts",
|
||||
|
||||
@@ -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,
|
||||
@@ -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>
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -31,6 +31,7 @@ export default class ActionSheet extends React.Component<Props> {
|
||||
// A null title or message on iOS causes a crash
|
||||
title: dataOptions.title || undefined,
|
||||
message: dataOptions.message || undefined,
|
||||
anchor: dataOptions.anchor || undefined,
|
||||
};
|
||||
ActionSheetIOS.showActionSheetWithOptions(iosOptions, onSelect);
|
||||
}
|
||||
|
||||
+35
-10
@@ -3,6 +3,7 @@ import {
|
||||
Animated,
|
||||
BackHandler,
|
||||
Easing,
|
||||
Modal,
|
||||
StyleSheet,
|
||||
TouchableWithoutFeedback,
|
||||
View,
|
||||
@@ -53,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={[
|
||||
@@ -64,15 +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
|
||||
pointerEvents={this.props.pointerEvents}
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -89,18 +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={[
|
||||
@@ -123,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}
|
||||
@@ -132,6 +153,7 @@ export default class ActionSheet extends React.Component<Props, State> {
|
||||
titleTextStyle={titleTextStyle}
|
||||
message={message || undefined}
|
||||
messageTextStyle={messageTextStyle}
|
||||
autoFocus={autoFocus}
|
||||
showSeparators={showSeparators}
|
||||
containerStyle={containerStyle}
|
||||
separatorStyle={separatorStyle}
|
||||
@@ -143,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);
|
||||
@@ -252,6 +274,9 @@ export default class ActionSheet extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
flexContainer: {
|
||||
flex: 1,
|
||||
},
|
||||
overlay: {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface ActionSheetIOSOptions {
|
||||
tintColor?: string;
|
||||
cancelButtonIndex?: number;
|
||||
destructiveButtonIndex?: number;
|
||||
anchor?: number;
|
||||
}
|
||||
|
||||
// for Android or Web
|
||||
@@ -22,7 +23,10 @@ export interface ActionSheetOptions extends ActionSheetIOSOptions {
|
||||
textStyle?: TextStyle;
|
||||
titleTextStyle?: TextStyle;
|
||||
messageTextStyle?: TextStyle;
|
||||
autoFocus?: boolean;
|
||||
showSeparators?: boolean;
|
||||
containerStyle?: ViewStyle;
|
||||
separatorStyle?: ViewStyle;
|
||||
useModal?: boolean;
|
||||
destructiveColor?: string;
|
||||
}
|
||||
@@ -1067,9 +1067,9 @@ acorn-jsx@^5.0.0:
|
||||
integrity sha512-HJ7CfNHrfJLlNTzIEUTj43LNWGkqpRLxm3YjAlcD0ACydk9XynzYsCBHxut+iqt+1aBXkx9UP/w/ZqMr13XIzg==
|
||||
|
||||
acorn@^6.0.7:
|
||||
version "6.2.0"
|
||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.2.0.tgz#67f0da2fc339d6cfb5d6fb244fd449f33cd8bbe3"
|
||||
integrity sha512-8oe72N3WPMjA+2zVG71Ia0nXZ8DpQH+QyyHO+p06jT8eg8FGG3FbcUIi8KziHlAfheJQZeoqbvq1mQSQHXKYLw==
|
||||
version "6.4.1"
|
||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.1.tgz#531e58ba3f51b9dacb9a6646ca4debf5b14ca474"
|
||||
integrity sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==
|
||||
|
||||
agent-base@4, agent-base@^4.3.0:
|
||||
version "4.3.0"
|
||||
|
||||
Reference in new issue
Block a user