Skip to content

Commit

Permalink
handle back android
Browse files Browse the repository at this point in the history
  • Loading branch information
nysamnang committed Oct 5, 2019
1 parent f2df95e commit 07c2078
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ declare module "react-native-raw-bottom-sheet" {
duration?: number;
closeOnDragDown?: boolean;
closeOnPressMask?: boolean;
closeOnPressBack?: boolean;
onClose?: () => void;
customStyles?: {
wrapper?: StyleProp<ViewStyle>;
Expand Down
13 changes: 11 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ class RBSheet extends Component {
}

render() {
const { animationType, closeOnDragDown, closeOnPressMask, children, customStyles } = this.props;
const {
animationType,
closeOnDragDown,
closeOnPressMask,
closeOnPressBack,
children,
customStyles
} = this.props;
const { animatedHeight, pan, modalVisible } = this.state;
const panStyle = {
transform: pan.getTranslateTransform()
Expand All @@ -98,7 +105,7 @@ class RBSheet extends Component {
visible={modalVisible}
supportedOrientations={SUPPORTED_ORIENTATIONS}
onRequestClose={() => {
this.setModalVisible(false);
if (closeOnPressBack) this.setModalVisible(false);
}}
>
<KeyboardAvoidingView
Expand Down Expand Up @@ -135,6 +142,7 @@ RBSheet.propTypes = {
duration: PropTypes.number,
closeOnDragDown: PropTypes.bool,
closeOnPressMask: PropTypes.bool,
closeOnPressBack: PropTypes.bool,
customStyles: PropTypes.objectOf(PropTypes.object),
onClose: PropTypes.func,
children: PropTypes.node
Expand All @@ -147,6 +155,7 @@ RBSheet.defaultProps = {
duration: 300,
closeOnDragDown: false,
closeOnPressMask: true,
closeOnPressBack: true,
customStyles: {},
onClose: null,
children: <View />
Expand Down

0 comments on commit 07c2078

Please sign in to comment.