Compare commits

...
26 Commits
Author SHA1 Message Date
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
Brad Bumbalough 8448370658 Merge pull request #141 from expo/chore/yarn-release
chore: use yarn instead of npm for action
2019-11-05 07:31:39 -06:00
Brad Bumbalough 223d35fb85 chore: use yarn instead of npm for action 2019-11-05 07:30:58 -06:00
Brad Bumbalough 979da65d59 Merge pull request #140 from expo/fix/android-nested-action-sheet
[Android] Fix nested action sheets... again
2019-11-05 07:23:19 -06:00
Brad Bumbalough b4f1ae39f9 fix: android calling nested action sheets
- Shouldn't wait until isAnimating since onSelect gets called before _animateOut().
2019-11-04 22:48:40 -06:00
Brad Bumbalough 817582e054 chore: add nested action sheet example 2019-11-04 22:47:30 -06:00
Brad Bumbalough 1a34e86f43 chore: remove package-lock.json
- Accidentally commited this in #136.
2019-11-04 22:40:19 -06:00
Brad Bumbalough e571b97653 chore: sync package-lock and fix audit issues (#139) 2019-10-30 07:44:44 -05:00
Brad Bumbalough a4e11daeec chore(release): configure semantic-release (#136)
- Updates changelog
- Deploys to npm, github tag
- Create github workflow to run release on merges to master
2019-10-30 07:36:54 -05:00
Brad Bumbalough 08a929d477 chore(release): configure semantic-release
- Updates changelog
- Deploys to npm, github tag
- Create github workflow to run release on merges to master
2019-10-30 07:35:28 -05:00
soh335 cd966b48ad style(types): export ActionSheetProps (#135)
When using connectActionSheet, component props should have Context.
So need to type `showActionSheetWithOptions: (options:
ActionSheetOptions, callback: (i: number) => void) => void;` many times.

Context is exported, but it is too common name and cant import from
`'@expo/react-native-action-sheet'`.
2019-10-30 07:31:49 -05:00
dependabot[bot] 3fc5e9f478 fix: update eslint-utils to resolve security issue (#137)
Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.3.1 to 1.4.3.
- [Release notes](https://github.com/mysticatea/eslint-utils/releases)
- [Commits](https://github.com/mysticatea/eslint-utils/compare/v1.3.1...v1.4.3)

Signed-off-by: dependabot[bot] <[email protected]>
2019-10-28 17:25:01 -05:00
13 changed files with 3480 additions and 94 deletions

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md",
"changelogTitle": "# Changelog"
}
],
[
"@semantic-release/git",
{
"assets": ["CHANGELOG.md", "package.json"]
}
],
"@semantic-release/npm",
"@semantic-release/github"
]
}
+23
View File
@@ -0,0 +1,23 @@
# Changelog
# [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))
+14 -1
View File
@@ -90,12 +90,21 @@ class AppContainer extends React.Component {
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.
@@ -109,6 +118,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 +140,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.
+25 -3
View File
@@ -4,12 +4,11 @@ import {
ActionSheetProvider,
connectActionSheet,
ActionSheetOptions,
ActionSheetProps,
} from '@expo/react-native-action-sheet';
import ShowActionSheetButton from './ShowActionSheetButton';
interface Props {
showActionSheetWithOptions: (options: ActionSheetOptions, callback: (i: number) => void) => void;
}
type Props = ActionSheetProps;
interface State {
selectedIndex: number | null;
@@ -63,6 +62,29 @@ 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 => {
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"
+26 -4
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';
@@ -17,6 +17,7 @@ interface Props {
withIcons?: boolean;
withSeparators?: boolean;
withCustomStyles?: boolean;
withAnchor?: boolean;
}
// A custom button that shows examples of different share sheet configurations
@@ -27,11 +28,15 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
withIcons: false,
withSeparators: false,
withCustomStyles: false,
withAnchor: false,
onSelection: null,
};
_anchorRef = React.createRef<Button>();
_showActionSheet = () => {
const {
withAnchor,
withTitle,
withMessage,
withIcons,
@@ -74,6 +79,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 +96,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 +107,11 @@ export default class ShowActionSheetButton extends React.PureComponent<Props> {
// Android only
titleTextStyle,
// Android only
messageTextStyle, // Android only
messageTextStyle,
// Android only,
containerStyle,
},
buttonIndex => {
(buttonIndex: number) => {
// Do something here depending on the button index selected
onSelection(buttonIndex);
}
@@ -107,7 +125,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,
+5 -1
View File
@@ -14,7 +14,8 @@
"build": "bob build",
"type-check": "tsc --noEmit",
"lint": "eslint . --ext .ts,.tsx --fix",
"fmt": "prettier --write \"{src,example}/**/*.{ts,tsx}\""
"fmt": "prettier --write \"{src,example}/**/*.{ts,tsx}\"",
"semantic-release": "semantic-release"
},
"repository": {
"type": "git",
@@ -34,6 +35,8 @@
"devDependencies": {
"@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",
@@ -46,6 +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",
"typescript": "^3.5.3"
},
"peerDependencies": {
+1 -1
View File
@@ -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>
+19 -6
View File
@@ -1,24 +1,37 @@
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,
};
ActionSheetIOS.showActionSheetWithOptions(iosOptions, onSelect);
}
+6 -5
View File
@@ -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;
}
+3 -2
View File
@@ -1,9 +1,10 @@
import * as React from 'react';
import { Consumer, Context } from './context';
import { Consumer } from './context';
import hoistNonReactStatic from 'hoist-non-react-statics';
import { ActionSheetProps } from './types';
export default function connectActionSheet<OwnProps = any>(
WrappedComponent: React.ComponentType<OwnProps & Context>
WrappedComponent: React.ComponentType<OwnProps & ActionSheetProps>
) {
const ConnectedActionSheet = (props: OwnProps) => {
return (
+2 -6
View File
@@ -1,11 +1,7 @@
import * as React from 'react';
import { ActionSheetOptions } from './types';
import { ActionSheetOptions, ActionSheetProps } from './types';
export interface Context {
showActionSheetWithOptions: (options: ActionSheetOptions, callback: (i: number) => void) => void;
}
const context = React.createContext<Context>({
const context = React.createContext<ActionSheetProps>({
showActionSheetWithOptions: (options: ActionSheetOptions, callback: (i: number) => void) => {},
});
+6
View File
@@ -1,6 +1,10 @@
import * as React from 'react';
import { TextStyle, ViewStyle } from 'react-native';
export interface ActionSheetProps {
showActionSheetWithOptions: (options: ActionSheetOptions, callback: (i: number) => void) => void;
}
// for iOS
export interface ActionSheetIOSOptions {
options: string[];
@@ -9,6 +13,7 @@ export interface ActionSheetIOSOptions {
tintColor?: string;
cancelButtonIndex?: number;
destructiveButtonIndex?: number;
anchor?: number;
}
// for Android or Web
@@ -19,5 +24,6 @@ export interface ActionSheetOptions extends ActionSheetIOSOptions {
titleTextStyle?: TextStyle;
messageTextStyle?: TextStyle;
showSeparators?: boolean;
containerStyle?: ViewStyle;
separatorStyle?: ViewStyle;
}
+3329 -65
View File
File diff suppressed because it is too large. Load diff