React-Native抽屉/侧面菜单问题

时间:2018-11-28 11:57:34

标签: react-native navigation-drawer react-navigation react-native-drawer

我的项目中有此代码结构-

    const HomeScreenRouter = DrawerNavigator(
      {

        AppTabNavigator: { screen: AppTabNavigator },
        LogOutScreen: { screen: LogOutScreen }
      },
      {
        contentComponent: props => <SideBar {...props} />,
        drawerWidth: Dimensions.get('window').width-30,
        drawerPosition: "right",
      }
    );

const MenuImage = ({navigation}) => {
  if(!navigation.state.isDrawerOpen){
      return <Image source={require('../images/menu-button.png')}/>
  }else{
      return <Image source={require('../images/left-arrow.png')}/>
  }
}


const AppStackNavigator = createStackNavigator({


  DrawerNavigator:{
      screen: HomeScreenRouter
  },


},{
  navigationOptions: ({ navigation }) => ({

      headerRight: 
      <TouchableOpacity  onPress={() => {navigation.dispatch(DrawerActions.toggleDrawer())} }>
            <MenuImage style="styles.bar" navigation={navigation}/>
        </TouchableOpacity>,
      headerStyle: {
          backgroundColor: '#333',
      },


      headerTintColor: '#fff',
      headerTitleStyle: {
        fontWeight: 'bold',
      },

  })
});

export default AppStackNavigator;

在每个选项卡屏幕中,我都希望使用公共侧菜单。我已经做到了以上的事情。但是我的问题是,当我导航到选项卡详细信息屏幕时(通过单击选项卡屏幕内部的按钮),有返回的按钮可见的嵌套堆栈。但是,我要在父级中返回按钮(通用标题/菜单)。请让我知道我如何实现这一目标。

0 个答案:

没有答案