如何禁用抽屉对特定屏幕的反应导航

时间:2019-02-19 04:38:11

标签: react-native react-native-android

我看过很多有关如何执行此操作的堆栈溢出文章,但是我都尝试了所有这些文章,但似乎没有一个适合我的情况。

我的目标:  以便能够从除JobFeedScreen之外的所有屏幕上禁用抽屉。

我已经做了什么: 抽屉锁模式:“锁定关闭”,抽屉锁模式:“锁定打开” 我还尝试使用

将其放在屏幕上
static navigationOptions = ({ navigation }) => {
    const { state } = navigation;
        const {} = state;
        return {  
          header: null,
          drawerLockMode: 'locked-closed' ( or drawerLockMode: 'locked-open')
        };

}

这是我的验证码

我的抽屉 AppNavigation.js

//DRAWER NAVIGATOR
const DrawerNav = createDrawerNavigator({
JobFeed: {
screen: JobFeedScreenStack,
navigationOptions: ({navigation})=>({
  drawerLabel: 'Job Feed',
  drawerIcon: ({ tintColor }) => (
    <SimpleLineIcons name="briefcase" size={ Metrics.icons.tiny } color={Colors.heavyGray} />
  )
})
},
NotificationScreen: {
screen: NotificationScreenStack,
navigationOptions: {
  drawerLabel: 'Notifications',
  drawerIcon: ({ tintColor }) => (
    <Entypo name = "notification" size = {15} color = {Colors.heavyGray} tintColor={Colors.white}/>  )  
}
},
ApplicationsFeed: {
screen: ApplicationScreenStack,
navigationOptions: {
  drawerLabel: 'Applications',
  drawerIcon: ({ tintColor }) => (
    <Foundation name = "clipboard-notes" size = {15} color = {Colors.heavyGray} tintColor={Colors.white}/>  ) 
}
},



},
{
  initialRouteName: 'JobFeed',
  drawerPosition: 'left',
  contentComponent: CustomDrawerComponent,
  drawerType: 'slide',
  drawerLockMode: 'locked-closed',
});
AppNavigation.js中的

其他代码:

    // Manifest of possible screens
const AuthStackNavigation = createStackNavigator({
  LaunchScreen: { 
     screen: LaunchScreen, 
  },
  JobFeedScreen: {
    screen: JobFeedScreen,
  },
  FilterScreen: {
    screen: FilterScreen,
  },
  NotificationScreen: {
    screen: NotificationScreen,
  },
  ApplicationScreen: {
    screen: ApplicationScreen,
  }
}, 
{
  // Default config for all screens
  initialRouteName: 'JobFeedScreen',
})

     //JOB FEED SCREEN
 const JobFeedScreenStack = createStackNavigator({
   JobFeedScreen: {
     screen: JobFeedScreen,
  },
 })

//LAUNCH SCREEN
const LaunchScreenStack = createStackNavigator({
  LaunchScreen: LaunchScreen,
})

//NOTIFICATION SCREEN
const NotificationScreenStack = createStackNavigator({
  NotificationScreen: NotificationScreen,
})

//APPLICATION SCREEN
const ApplicationScreenStack = createStackNavigator({
  ApplicationScreen: ApplicationScreen,
})

//FILTER SCREEN
const FilterScreenStack = createStackNavigator({
  FilterScreen: FilterScreen
})

// MAIN NAVIGATION
const MainNavigation = createSwitchNavigator({
DrawerNav: DrawerNav,
AuthStackNavigation: AuthStackNavigation, 
})

export default createAppContainer(MainNavigation)

0 个答案:

没有答案