"createStackNavigator" 和 "createMaterialTopTabNavigator" 如何一起使用?

How to use "createStackNavigator" and "createMaterialTopTabNavigator" together?

在我的 React 本机应用程序中,我使用的是 "createStackNavigator",但是当我组合使用 "createMaterialTopTabNavigator" 时,它给出了错误。我怎样才能同时使用导航?我尝试了 aolot 但未能解决此问题。在我的代码中,我使用 createStackNavigator 两次,一次用于家庭,另一次用于 tabScreen,当我单独使用时它工作正常但无法组合。

Main.js

const Home = createStackNavigator(
    { 
        Profile: Profile,
        Feed: Feed,
        Chemein: Chemein,
        Graph: Graph,
    },
      {
          initialRouteName: 'Profile',

            defaultNavigationOptions: { 
            headerStyle: {
                backgroundColor: '#744DD2',
            },
            headerTintColor: '#fff',
            headerTitleStyle: {
                fontWeight: 'bold',
            },
        },
    },

);

const TabScreen = createMaterialTopTabNavigator(
    {
        Clubs: { screen: Clubs },
        Members: { screen: Members },
    },
    {
        tabBarPosition: 'top',
        swipeEnabled: true,
        tabBarOptions: {
            activeTintColor: '#ffff',
            inactiveTintColor: '#ccc',
            style: {
                backgroundColor: '#744DD2',
            },
        },
    }
);

const TopTab = createStackNavigator({
    TabScreen: {
        screen: TabScreen,
        navigationOptions: {
            headerStyle: {
                backgroundColor: '#744DD2',
            },
            headerTintColor: '#FFFFFF',
            title: 'Clubs',
        },
    },
});

 const container = createAppContainer(Home);
// const container = createAppContainer(TabScreen );

 export default container;

我做过这样的事情:

const TabNavigator = createBottomTabNavigator(
  {
    Home: AppStack,
    Notification: Notifications,
    Account: SettingsScreen,
  },
  {
    defaultNavigationOptions: ({navigation}) => ({
      tabBarIcon: ({focused, tintColor}) =>
        getTabBarIcon(navigation, focused, tintColor),
    }),
    tabBarOptions: {
      activeTintColor: colors.tealC,
      inactiveTintColor: 'gray',
    },
  },
);

我的 appstack 是我的堆栈导航器,代码如下:

const AppStack = createStackNavigator(
  {
    HomeScreen: {
      screen: Home,
    },
    AirportMeeting: {
      screen: AirportMeeting,
    },
    MeetingPoint: {
      screen: MeetingPoint,
    },
    DriverDetails: {
      screen: DriverDetails,
    },
    SightSeeing: {
      screen: SightSeeing,
    },
    HotelDetails: {
      screen: HotelDetails,
    },
    FlightDetails: {
      screen: FlightDetails,
    },
    AddSight: {
      screen: AddSight,
    },
    SightSeeingPurchase: {
      screen: SightSeeingPurchase,
    },
    AddMeals: {
      screen: AddMeals,
    },
    HomeCard: {
      screen: HomeCard,
    },
    Trips: {
      screen: Trips,
    },
    FAQ: {
      screen: FAQ,
    },
    Support: {
      screen: Support,
    },
    BeforeTravel: {
      screen: BeforeTravel,
    },
    Weather: {
      screen: Weather,
    },
  },
  {
    defaultNavigationOptions: {
      headerShown: false,
    },
    initialRouteName: 'HomeCard',
    transitionConfig: () => fromRight(),
  },
);

所以基本上在我的 tabnavigator 主路径中我使用了 Appstack,它是一个堆栈导航器。

以防万一你好奇,我也制作了一个 switchnavigator,我在其中添加了选项卡导航器和其他堆栈导航器,所以一切皆有可能:

const navigation = createAppContainer(
  createSwitchNavigator(
    {
      App: TabNavigator,
      Auth: AuthStack,
      SplashScreen: SplashScreen,
    },
    {
      initialRouteName: 'SplashScreen',
    },
  ),
);