I want to disable swipe to open the drawer navigation but not for closing?
I found solutions for android but not for react-native. Currently I'm using this:
drawerLockMode: 'locked-open'
which works,but I can't close it with swipe.
I'm opening the drawer with hamburger menu icon like this:
onPress={() => props.navigation.toggleDrawer()}
Is here someone who already did this?
Is there a way to set drawerLockMode
globally?
Does onDrawerOpened
and onDrawerClosed
props exist?
Thanks!
This is the solution that worked for me, and I think its simple and easy:
import { DrawerNavigator } from "../router/router";
import React, { Component } from "react";
export default class Drawer extends Component {
state = {
lockMode: "locked-closed"
};
render() {
return (
<DrawerNavigator
screenProps={{
drawerLockMode: this.state.lockMode
}}
onNavigationStateChange={(prevState, newState, action) => {
if (
action.type === "Navigation/MARK_DRAWER_SETTLING" &&
!action.willShow
)
this.setState({ lockMode: "locked-closed" });
if (
action.type === "Navigation/MARK_DRAWER_SETTLING" &&
action.willShow
) {
this.setState({ lockMode: "unlocked" });
}
}}
/>
);
}
}