需要帮助管理导航器以响应本机

时间:2018-10-21 15:02:14

标签: react-native

我目前正在实现一个小型React Native应用,这是我目前拥有的导航器:

    const RootNav=  createStackNavigator(
     {
      Login: LogInScreen,
     },
    );
    const TabNav = createBottomTabNavigator(
     {
      Home: { screen: HomeScreen },
      Calendar: { screen: CalendarScreen },
      Discussion: { screen: DiscussionScreen },
      Profile: { screen: ProfileScreen },
     },
    );
    export const SwitchNav = createSwitchNavigator(
     {
      AuthLoading: AuthLoadingScreen,
      Auth: RootNav,
      MainApp: TabNav,
     },
     {
      initialRouteName: 'AuthLoading',
     },
    );

现在,在HomeScreen和CalendarScreen中,有几个Card组件应导航到名为EventScreen的另一个屏幕,并具有返回到上一个屏幕的选项,该选项应该是另一个createStackNavigator想,但我仍然需要帮助,以正确的方式设置导航器。预先感谢。

1 个答案:

答案 0 :(得分:0)

您可以有一个StackNavigatorEventScreen作为其子项的父项TabNav

const RootNav = createStackNavigator(
  {
    Login: LogInScreen,
  }
);

const HomeNav = createStackNavigator(
  {
    tabNav: TabNav,
    Events: { screen: EventScreen },
  }
);

const TabNav = createBottomTabNavigator(
  {
    Home: { screen: HomeScreen },
    Calendar: { screen: CalendarScreen },
    Discussion: { screen: DiscussionScreen },
    Profile: { screen: ProfileScreen },
  }
);

export const SwitchNav = createSwitchNavigator(
  {
    AuthLoading: AuthLoadingScreen,
    Auth: RootNav,
    MainApp: HomeNav,
  },
  {
    initialRouteName: 'AuthLoading',
  }
);

如果您觉得将来也需要DrawerNavigation,那么现在就好好处理它是个好主意。 This article可能会有帮助。