React Native Conditional TabNavigator

时间:2018-03-30 16:10:32

标签: react-native navigation react-navigation

我有以下导航结构。在我的第三个选项卡上,应用程序必须基于用户登录状态加载,即,如果用户在加载UserProfileScreen之前登录或加载CreateAnAccountScreen。现在,用户尚未登录,并且应用程序已使用CreateAnAccountScreen加载了第三个选项卡,当用户尝试登录时,成功后,应用程序必须导航到同一选项卡下的UserProfileScreen。 作为新的反应原生,我不确定这个导航系统是如何工作的。

const Stylelist = StackNavigator({
LoginScreen: {
  screen: LoginScreen,
  navigationOptions: ({ navigation }) => ({
    header: null,
  }),
},
SplashScreen: {
  screen: SplashScreen,
  navigationOptions: ({ navigation }) => ({
    header: null,
  }),
},
LaunchScreen: {
  screen: LaunchScreen,
  navigationOptions: ({ navigation }) => ({
    header: null,
  }),
},
Home: {
  screen: TabNavigator({
    RemoteControlScreen: {screen: RemoteControlScreen, navigationOptions: ({ navigation }) => ({header: null, tabBarIcon: ({focused }) => <Image source={Images.iconDrop} style={{tintColor: focused ? Colors.lightGreen : null}}/>}),},
    GetInspiredScreen: {screen: GetInspiredScreen, navigationOptions: ({ navigation }) => ({header: null, tabBarIcon: ({focused }) => <Image source={Images.iconGetInspired} style={{tintColor: focused ? Colors.lightGreen : null}}/>}),},
   ...AppConfig.isUserRegistered ?
    { UserProfileScreen: {screen: UserProfileScreen, navigationOptions: ({ navigation }) => ({header: null, tabBarIcon: ({focused }) => <Image source={Images.iconProfile} style={{tintColor: focused ? Colors.lightGreen : null}}/>}),}, } : 
     {
       CreateAnAccountScreen: {screen: CreateAnAccountScreen, navigationOptions: ({ navigation }) => ({header: null, tabBarIcon: ({focused }) => <Image source={Images.iconProfile} style={{tintColor: focused ? Colors.lightGreen : null}}/>}),},
    }
  },
   {
     tabBarPosition: 'bottom',
     animationEnabled: false,
     swipeEnabled: false,
     showLabel: false,
     tabBarOptions: {
       activeTintColor: 'yellow',
       inactiveTintColor: 'black',
       showLabel: false,
       showIcon: true,
       style: {
         height: (deviceHeight * 5) / 67,
         justifyContent: 'center',
         backgroundColor: Colors.background,
       },
     }
  }),
  navigationOptions: ({ navigation }) => ({
    // title: 'Home',
  }),
},

},  {     headerMode:'none',     initialRouteName:'SplashScreen',     navigationOptions:{       headerStyle:styles.header     }   });

导出默认样式列表;

0 个答案:

没有答案