Handle back button properly when the drawer is open

This commit is contained in:
Brent Vatne
2018-10-16 15:10:18 -07:00
committed by satyajit.happy
parent ef56c1a980
commit c8d49948b1

View File

@@ -60,6 +60,24 @@ export default class DrawerView extends React.PureComponent {
drawerGestureRef = React.createRef();
_handleDrawerStateChange = newState => {
if (newState === 'Idle') {
if (!this.props.navigation.state.isDrawerIdle) {
this.props.navigation.dispatch({
type: DrawerActions.MARK_DRAWER_IDLE,
key: this.props.navigation.state.key,
});
}
} else {
if (this.props.navigation.state.isDrawerIdle) {
this.props.navigation.dispatch({
type: DrawerActions.MARK_DRAWER_ACTIVE,
key: this.props.navigation.state.key,
});
}
}
};
_handleDrawerOpen = () => {
this.props.navigation.dispatch({
type: DrawerActions.DRAWER_OPENED,
@@ -126,6 +144,7 @@ export default class DrawerView extends React.PureComponent {
drawerWidth={this.state.drawerWidth}
onDrawerOpen={this._handleDrawerOpen}
onDrawerClose={this._handleDrawerClose}
onDrawerStateChanged={this._handleDrawerStateChange}
useNativeAnimations={this.props.navigationConfig.useNativeAnimations}
renderNavigationView={this._renderNavigationView}
drawerPosition={