当显示2级深度的路线时如何隐藏底部标签

问题描述 投票:0回答:1

所以当显示某个屏幕时,我希望底部的标签栏消失。我正在使用反应导航。

当洞察力细节调整屏幕处于活动状态时,我希望底部标签消失。当前注意的是有效,只有当我在bottomtab导航器中键入bottomtabs {visible:false}时,它才能工作,但我需要将它嵌套更深一层。

const incidentStack = createStackNavigator({
  'incident Overview': {
    screen: incidentOverview,
    navigationOptions: ({navigation}) => ({
      title: 'Pointbreak',
      headerLeft: ( 
      <TouchableOpacity onPress ={() => navigation.openDrawer()}>
        <Image style={{marginLeft: 10}} source={require('../img/menu.png')}></Image>
      </TouchableOpacity>
      )
    })
  },
  'insight detail adjustment': {
      screen: InsightDetailAdjustment,
      navigationOptions: ({navigation}) => ({
          header: (
            <HeaderTitleInsightDetailAdjustment navigation={navigation}/>
          ),
          bottomTabs: {
            visible: false
          }
      })
  }
})





const AppNavigator = createBottomTabNavigator(
    {
      Insights: {
        screen: InsightsStack,
        navigationOptions: {
          tabBarIcon: ({tintColor}) => (
            <Icon name='chart-line-variant' size={30} color={tintColor}/>
          ),

        }
      },
      Incidents: {
        screen: incidentStack,
        navigationOptions: ({navigation}) => ({
          tabBarVisible: () => (
            if(navigation.navigate('incident detail adjustment'){
              return false
            }else{
              return true
            })
          ),
          tabBarIcon: ({tintColor}) => (
            <Icon name='bullhorn-outline' size={30} color={tintColor}/>
          ),
        })
      },
reactjs react-native react-navigation
1个回答
0
投票

您可以尝试以下方法:


InsightsStack.navigationOptions = ({ navigation }) => {
  // hides tabNavigation starting from 2 screen deep in InsightsStack Stack
  let tabBarVisible = true;
  if (navigation.state.index > 0) {
    tabBarVisible = false;
  }

  return {
    tabBarVisible
  };
};
© www.soinside.com 2019 - 2024. All rights reserved.