简体   繁体   English

从堆栈导航器反应本机隐藏顶部导航

[英]React Native hide top navigation from stack navigator

I'm new to RN and I have the following setup. 我是RN的新手,并且具有以下设置。

                const stackNavBudget = createStackNavigator({
                Budget: {screen: Budget,
                    navigationOptions: {
                        header: null,
                    },
                },
                Details: {screen: Details},
            });

            //hide bottom nav
            stackNavBudget.navigationOptions = ({ navigation }) => {
                let tabBarVisible = true;
                if (navigation.state.index > 0) {
                    tabBarVisible = false;
                }
                return {
                    tabBarVisible,
                };
            };
            const TabNavigatorSub = createBottomTabNavigator({
                Budget: {screen:stackNavBudget,
                    navigationOptions: {
                        header: null,
                        tabBarVisible: true,
                    },
                },
                Transactions:Transactions,
            });

            const TabNavigatorComp = createAppContainer(TabNavigatorSub);

            ///////////////////////////////////////////////////

            const TabNavigator = createMaterialTopTabNavigator({
                Home: OverView,
                Spending: TabNavigatorComp,
                Facilities: Facilities,    
                },
                {
                    tabBarOptions: {
                        scrollEnabled: true
                    },
                });

So I am able to hide the bottom navigator when i am in the "Details" screen but i can't hide the main top one. 因此,当我在“详细信息”屏幕中时,我可以隐藏底部导航器,但是我不能隐藏主要的顶部导航器。 It's like the "tabBarVisible" only has a view of the most immeidiate tab navigator which is the bottom one. 就像“ tabBarVisible”仅具有最直接的标签导航器视图一样,它是最下面的一个。

The hierarchy is as follows 层次结构如下

Details page  --> Budget --> Bottom Navigator --> Top Navigator  

When i click on an item in the details page. 当我单击详细信息页面中的项目时。 All I would like to see the stack navigator back button. 我只想看到堆栈导航器的后退按钮。

Not the top navigator options. 不是顶部导航器选项。

There are two ways to hide the headers. 隐藏标题有两种方法。 You can use headermode in Navigator Settings. 您可以在“导航器设置”中使用headermode

 const stackNavBudget = createStackNavigator({
                Budget: {screen: Budget,
                    navigationOptions: {
                        headerMode: 'none',
                    },
                },
                Details: {screen: Details},
            });

Or you can give a price directly to the screen. 或者,您可以直接在屏幕上给出价格。

class Budget extends React.Component {
  static navigationOptions = {
    header: null,
  };

  /* render function, etc */
}

try like this 这样尝试

 navigater_page: {
            screen: navigater_page,
            navigationOptions: ({navigation}) => ({
                header: null,
            }),
        }

navigater_page = obj of your stacknavigater page which initialise in App.js navigationr_page =在App.js中初始化的stacknavigater页面的obj

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM