Closed
Description
I have a TabNavigator with three TabView children. Each TabView has a stacknavigator as a child so that the user can visit detail views, etc. I want to hide the tabs on one of the detail views. I have tried registering each navigator in a high level context and then accessing the tab navigator from the screen and doing setParams on it, but it doesn't seem that setParams is doing anything.
What is the best way to selectively hide the tabs?
Activity
KabirKang-zz commentedon Feb 23, 2017
The tabs:
this.TabNav = TabNavigator( HOME_TABS_ROUTER, { initialRouteName: this.initialTab, tabBarPosition: 'bottom', tabBarComponent: TabView.TabBarBottom, order: [HOME_TABS.FIND_TEACHER_TAB, HOME_TABS.CHAT_TAB, HOME_TABS.DASHBOARD_TAB], lazyLoad: true, swipeEnabled: false, animationEnabled: false, tabBarOptions: { showIcon: true, style: { backgroundColor: Colors.headerBackground, height: normalizeValue(65), padding: normalizeValue(10) }, labelStyle: textStyles.footerLabel, activeTintColor: Colors.brandDefault, inactiveTintColor: Colors.defaultText } } );
A child stack nav:
grabbou commentedon Feb 23, 2017
In order to hide a tabBar on one of the tabs, you can set this option to true. It's been recently documented. Is that something you were looking for?
KabirKang-zz commentedon Feb 23, 2017
@grabbou but how would you put the tabBar navigation option on a screen that is a part of the stacknavigator.
the stack nav is a child of the tabnavigators. that's why i was trying to find a round-about way to reach the "grandparent" navigator.
KabirKang-zz commentedon Feb 23, 2017
and i cant make the profile screen part of the tabnavigator because that would make it a tab. not really what i want. let me know if my question is too confusing, and i'll try to add more code.
grabbou commentedon Feb 23, 2017
I think I know what's the issue. I have one idea I'll try to send you tomorrow morning, maybe it works.
KabirKang-zz commentedon Feb 23, 2017
ok thanks
KabirKang-zz commentedon Feb 23, 2017
@grabbou does it involve redux?
dbhowell commentedon Feb 23, 2017
@KabirKang, to do this you have to have the Parent navigation as the StackNavigation, and then have your TabNavigation as one of the Stack screens. Then by turning on/off the
visible
of each of the top Stack screens you get your desired outcome.KabirKang-zz commentedon Feb 23, 2017
@dbhowell In your example you wrote header: {visible: true}. Did you mean tabBar? and would that work for tabbar?
dbhowell commentedon Feb 23, 2017
Note that
{ visible: true}
in this case hides the Stack toolbar, not the Tabbar.Edit: I meant that
{visible true}
shows the Stack toolbarKabirKang-zz commentedon Feb 23, 2017
@dbhowell So would the structure you suggest allow you to visit more screens within each tab or would each tab still need to have a nested stack navigator in each?
Also what does this do to the back button? If you were to switch tabs, and then click the Android back button, would it go back to the previous tab?
dbhowell commentedon Feb 23, 2017
It does get confusing, so the best thing is to try it out and see what the result is.
bjrn commentedon Feb 28, 2017
@dbhowell that works fine with headers (if
headerMode: "screen"
), but that's probably because the header option is part of the stackNavigator.tabBar: { visible: false }
won't work since it's part of the parent TabNavigator.I'm also interested in how to do this, as a typical use case for us would be to hide the tab bar on the second level navigation throughout the app.
Would be willing to help out implementing it, but need a few pointers on how to go about it. @grabbou, any ideas you have would be highly appreciated!
ahmedlhanafy commentedon Mar 1, 2017
@grabbou any update on this one?
54 remaining items