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 | |
|---|---|---|---|
|
|
0131ebbb44 | ||
|
|
0627e77fba | ||
|
|
d114cfb321 | ||
|
|
8016008781 | ||
|
|
39fc431c97 | ||
|
|
76397fa7c4 | ||
|
|
8448370658 | ||
|
|
223d35fb85 | ||
|
|
979da65d59 | ||
|
|
b4f1ae39f9 | ||
|
|
817582e054 | ||
|
|
1a34e86f43 |
No files matched your search
@@ -15,7 +15,7 @@ jobs:
|
||||
with:
|
||||
node-version: 12
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
run: yarn
|
||||
- name: Type check
|
||||
run: npm run type-check
|
||||
- name: Lint
|
||||
|
||||
+13
-1
@@ -2,7 +2,19 @@
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
"@semantic-release/changelog",
|
||||
[
|
||||
"@semantic-release/changelog",
|
||||
{
|
||||
"changelogFile": "CHANGELOG.md",
|
||||
"changelogTitle": "Changelog"
|
||||
}
|
||||
],
|
||||
[
|
||||
"@semantic-release/git",
|
||||
{
|
||||
"assets": ["CHANGELOG.md"]
|
||||
}
|
||||
],
|
||||
"@semantic-release/npm",
|
||||
"@semantic-release/github"
|
||||
]
|
||||
|
||||
@@ -1 +1,18 @@
|
||||
Changelog
|
||||
|
||||
## [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))
|
||||
|
||||
# Changelog
|
||||
|
||||
# [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))
|
||||
@@ -109,6 +109,7 @@ The below props allow modification of the Android ActionSheet. They have no effe
|
||||
| titleTextStyle | TextStyle | No | |
|
||||
| messageTextStyle | TextStyle | No | |
|
||||
| showSeparators | boolean | No | false |
|
||||
| containerStyle | ViewStyle | No | |
|
||||
| separatorStyle | ViewStyle | No | |
|
||||
|
||||
#### `icons` (optional)
|
||||
@@ -130,6 +131,9 @@ Apply any text style props to the message if present.
|
||||
#### `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.
|
||||
|
||||
|
||||
@@ -62,6 +62,22 @@ class App extends React.Component<Props, State> {
|
||||
onSelection={this._updateSelectionText}
|
||||
showActionSheetWithOptions={showActionSheetWithOptions}
|
||||
/>
|
||||
<ShowActionSheetButton
|
||||
title="Nested Action Sheets"
|
||||
onSelection={index => {
|
||||
if (index < 3) {
|
||||
showActionSheetWithOptions(
|
||||
{
|
||||
title: 'Sub Action Sheet',
|
||||
options: ['One', 'Two', 'Three', 'Done'],
|
||||
cancelButtonIndex: 3,
|
||||
},
|
||||
this._updateSelectionText
|
||||
);
|
||||
}
|
||||
}}
|
||||
showActionSheetWithOptions={showActionSheetWithOptions}
|
||||
/>
|
||||
{this._renderSectionHeader('Android-Only Options')}
|
||||
<ShowActionSheetButton
|
||||
title="Icons"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import { Text, View, TextStyle } from 'react-native';
|
||||
import { Text, View, TextStyle, ViewStyle } from 'react-native';
|
||||
import { MaterialIcons, Entypo } from '@expo/vector-icons';
|
||||
import { ActionSheetOptions } from '@expo/react-native-action-sheet';
|
||||
|
||||
@@ -74,6 +74,12 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
|
||||
textAlign: 'right',
|
||||
}
|
||||
: undefined;
|
||||
const containerStyle: ViewStyle | undefined = withCustomStyles
|
||||
? {
|
||||
backgroundColor: 'lightgrey',
|
||||
}
|
||||
: undefined;
|
||||
|
||||
showActionSheetWithOptions(
|
||||
{
|
||||
options,
|
||||
@@ -91,7 +97,9 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
|
||||
// Android only
|
||||
titleTextStyle,
|
||||
// Android only
|
||||
messageTextStyle, // Android only
|
||||
messageTextStyle,
|
||||
// Android only,
|
||||
containerStyle,
|
||||
},
|
||||
buttonIndex => {
|
||||
// Do something here depending on the button index selected
|
||||
|
||||
Generated
-15052
File diff suppressed because it is too large.
Load diff
@@ -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",
|
||||
|
||||
@@ -25,7 +25,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>
|
||||
|
||||
@@ -1,24 +1,36 @@
|
||||
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,
|
||||
};
|
||||
ActionSheetIOS.showActionSheetWithOptions(iosOptions, onSelect);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
StyleSheet,
|
||||
TouchableWithoutFeedback,
|
||||
View,
|
||||
ViewProps,
|
||||
} from 'react-native';
|
||||
import ActionGroup from './ActionGroup';
|
||||
import { ActionSheetOptions } from '../types';
|
||||
@@ -21,6 +22,7 @@ interface State {
|
||||
|
||||
interface Props {
|
||||
readonly useNativeDriver: boolean | undefined;
|
||||
readonly pointerEvents?: ViewProps['pointerEvents'];
|
||||
}
|
||||
|
||||
const OPACITY_ANIMATION_IN_TIME = 225;
|
||||
@@ -64,6 +66,7 @@ export default class ActionSheet extends React.Component<Props, State> {
|
||||
) : null;
|
||||
return (
|
||||
<View
|
||||
pointerEvents={this.props.pointerEvents}
|
||||
style={{
|
||||
flex: 1,
|
||||
}}>
|
||||
@@ -93,6 +96,7 @@ export default class ActionSheet extends React.Component<Props, State> {
|
||||
message,
|
||||
messageTextStyle,
|
||||
showSeparators,
|
||||
containerStyle,
|
||||
separatorStyle,
|
||||
} = options;
|
||||
return (
|
||||
@@ -129,6 +133,7 @@ export default class ActionSheet extends React.Component<Props, State> {
|
||||
message={message || undefined}
|
||||
messageTextStyle={messageTextStyle}
|
||||
showSeparators={showSeparators}
|
||||
containerStyle={containerStyle}
|
||||
separatorStyle={separatorStyle}
|
||||
/>
|
||||
</View>
|
||||
@@ -140,12 +145,8 @@ export default class ActionSheet extends React.Component<Props, State> {
|
||||
showActionSheetWithOptions = (options: ActionSheetOptions, onSelect: (i: number) => void) => {
|
||||
const { isVisible, isAnimating, overlayOpacity, sheetOpacity } = this.state;
|
||||
|
||||
if (isVisible && isAnimating) {
|
||||
this._deferNextShow = this.showActionSheetWithOptions.bind(this, options, onSelect);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isVisible) {
|
||||
this._deferNextShow = this.showActionSheetWithOptions.bind(this, options, onSelect);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,5 +23,6 @@ export interface ActionSheetOptions extends ActionSheetIOSOptions {
|
||||
titleTextStyle?: TextStyle;
|
||||
messageTextStyle?: TextStyle;
|
||||
showSeparators?: boolean;
|
||||
containerStyle?: ViewStyle;
|
||||
separatorStyle?: ViewStyle;
|
||||
}
|
||||
Reference in new issue
Block a user