Lock drawer when stack is not on root screen (#825)

This commit is contained in:
Diego Mello 2019-04-18 10:43:44 -03:00 committed by GitHub
parent fb88d08f88
commit 03adaa3f81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 0 deletions

View File

@ -129,18 +129,48 @@ const ChatsStack = createStackNavigator({
defaultNavigationOptions: defaultHeader defaultNavigationOptions: defaultHeader
}); });
ChatsStack.navigationOptions = ({ navigation }) => {
let drawerLockMode = 'unlocked';
if (navigation.state.index > 0) {
drawerLockMode = 'locked-closed';
}
return {
drawerLockMode
};
};
const ProfileStack = createStackNavigator({ const ProfileStack = createStackNavigator({
ProfileView ProfileView
}, { }, {
defaultNavigationOptions: defaultHeader defaultNavigationOptions: defaultHeader
}); });
ProfileView.navigationOptions = ({ navigation }) => {
let drawerLockMode = 'unlocked';
if (navigation.state.index > 0) {
drawerLockMode = 'locked-closed';
}
return {
drawerLockMode
};
};
const SettingsStack = createStackNavigator({ const SettingsStack = createStackNavigator({
SettingsView SettingsView
}, { }, {
defaultNavigationOptions: defaultHeader defaultNavigationOptions: defaultHeader
}); });
SettingsStack.navigationOptions = ({ navigation }) => {
let drawerLockMode = 'unlocked';
if (navigation.state.index > 0) {
drawerLockMode = 'locked-closed';
}
return {
drawerLockMode
};
};
const ChatsDrawer = createDrawerNavigator({ const ChatsDrawer = createDrawerNavigator({
ChatsStack, ChatsStack,
ProfileStack, ProfileStack,