From a63bab7aef583ec3f8c7a2cb9732f401045daea3 Mon Sep 17 00:00:00 2001 From: Broda Noel Date: Mon, 27 Apr 2020 01:22:38 +0100 Subject: [PATCH 1/7] Wrap ActionSheet with a Modal --- src/ActionSheet/index.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ActionSheet/index.tsx b/src/ActionSheet/index.tsx index d830133..ab5bd63 100644 --- a/src/ActionSheet/index.tsx +++ b/src/ActionSheet/index.tsx @@ -3,6 +3,7 @@ import { Animated, BackHandler, Easing, + Modal, StyleSheet, TouchableWithoutFeedback, View, @@ -71,8 +72,13 @@ export default class ActionSheet extends React.Component { flex: 1, }}> {React.Children.only(this.props.children)} - {overlay} - {isVisible ? this._renderSheet() : null} + + {isVisible && ( + + {overlay} + {isVisible ? this._renderSheet() : null} + + )} ); } @@ -143,7 +149,7 @@ export default class ActionSheet extends React.Component { } 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); From 57ac1d1074be7b96d8e105971973cd165eea54a5 Mon Sep 17 00:00:00 2001 From: Broda Noel Date: Mon, 27 Apr 2020 01:23:12 +0100 Subject: [PATCH 2/7] Add Modal example --- example/App.tsx | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/example/App.tsx b/example/App.tsx index e588519..4bf0437 100644 --- a/example/App.tsx +++ b/example/App.tsx @@ -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 { state: State = { selectedIndex: null, + isModalOpen: false, }; _updateSelectionText = (selectedIndex: number) => { @@ -36,6 +45,10 @@ class App extends React.Component { return {text}; }; + _toggleModal = () => { + this.setState({ isModalOpen: !this.state.isModalOpen }); + }; + _renderButtons() { const { showActionSheetWithOptions } = this.props; return ( @@ -117,6 +130,37 @@ class App extends React.Component { onSelection={this._updateSelectionText} showActionSheetWithOptions={showActionSheetWithOptions} /> + {this._renderSectionHeader('Special Cases')} + + + Open Modal + + + {this.state.isModalOpen && ( + + + + + + + Close Modal + + + + + )} ); } From 15460e4354765f338fd491a44e716e6ebfdca146 Mon Sep 17 00:00:00 2001 From: Broda Noel Date: Mon, 27 Apr 2020 01:28:44 +0100 Subject: [PATCH 3/7] Simplify code --- example/App.tsx | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/example/App.tsx b/example/App.tsx index 4bf0437..95bcfba 100644 --- a/example/App.tsx +++ b/example/App.tsx @@ -132,13 +132,7 @@ class App extends React.Component { /> {this._renderSectionHeader('Special Cases')} - - Open Modal - + Open Modal {this.state.isModalOpen && ( @@ -150,13 +144,7 @@ class App extends React.Component { /> - - Close Modal - + Close Modal @@ -228,4 +216,8 @@ const styles = StyleSheet.create({ fontSize: 16, marginTop: 20, }, + link: { + fontSize: 15, + textDecorationLine: 'underline', + }, }); From 3deddde49a5b9a24cb33cfaf06ce3371fa499c50 Mon Sep 17 00:00:00 2001 From: Broda Noel Date: Mon, 27 Apr 2020 18:23:38 +0100 Subject: [PATCH 4/7] Add useModal on Example --- example/App.tsx | 1 + example/ShowActionSheetButton.tsx | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/example/App.tsx b/example/App.tsx index 95bcfba..768353b 100644 --- a/example/App.tsx +++ b/example/App.tsx @@ -138,6 +138,7 @@ class App extends React.Component { void ) => void; onSelection: (index: number) => void; @@ -18,6 +18,7 @@ interface Props { withSeparators?: boolean; withCustomStyles?: boolean; withAnchor?: boolean; + useModal?: boolean; } // A custom button that shows examples of different share sheet configurations @@ -30,6 +31,7 @@ export default class ShowActionSheetButton extends React.PureComponent { withCustomStyles: false, withAnchor: false, onSelection: null, + useModal: false, }; _anchorRef = React.createRef