如何隐藏本机选项卡导航选项卡的反应?

时间:2018-06-28 10:19:33

标签: react-native react-navigation tabnavigator react-native-tabnavigator

我想有条件地隐藏选项卡导航中的一个或多个项目。从重定向的页面,我发送一个布尔参数(..navigate('SomePage',{some_value:true});),然后根据此值更改选项卡页面项的可见性。但是从我的研究来看,动态构建选项卡导航似乎根本没有能力。

问题

如何将项目分配给TabNavigator?

以下是相关代码:

        import X from './X'
        import Y from './Y'
        export const TabNavigatorTest = TabNavigator({
          X: {
            screen: X, navigationOptions: (props) => ({
              title: "X"
            })
          },
          Y: {
            screen: Y, navigationOptions: (props) => ({
              title: "Y",
            })
          }
        },
          {
            navigationOptions: ({ navigation }) => ({
              tabBarIcon: ({ focused, tintColor }) => {
                const { routeName } = navigation.state;
                let iconName;
                if (routeName === 'X') {
                  iconName = `ios-information-circle${focused ? '' : '-outline'}`;
                } else if (routeName === 'Y') {
                  iconName = `ios-flask${focused ? '' : '-outline'}`;
                }
                return <Ionicons name={iconName} size={25} color={tintColor} />;
              }
            }),
            tabBarOptions: {
              activeTintColor: 'tomato',
              inactiveTintColor: 'gray',
            },
            tabBarComponent: TabBarBottom,
            tabBarPosition: 'bottom',
            removeClippedSubviews: true,
            animationEnabled: true,
            swipeEnabled: true,
          });
    ....
    export default class Urun extends React.Component {
    ...
      static router = TabNavigatorTest.router;
    ...
      render() {
    ...
          return (
            <TabNavigatorTest
              navigation={this.props.navigation} />
          );
      }
    }

0 个答案:

没有答案