Closed emrosenf closed 8 years ago
Maybe we should split it into two issues: Hide tab bar and hide nav bar. For hide tab bar we have #52
Looks like such features require full refactoring of existing code - separate Router/Route/Schema from UI and navigator implementation, create full hierarchy of router tree, so child route could find all his parent routers and pass information to them. I will think about it.
I think it's easy enough to implement a custom navigation bar, so it's perfectly reasonable not to fix this.
In my opinion, hiding the tab bar is a more important issue, because without it you cannot have a true modal experience.
I agree with @emrosenf here, selectively hiding the tab bar would be fantastic for modals.
Just an idea, what if you would 'push' modal not from tab navigator, but from root navigator? This way you will not see any tab bar.
I went with this modal component because my visual specs required the modal to only fill up ~50% of the screen height: https://github.com/maxs15/react-native-modalbox
Not sure if I'm able to configure the tab navigator to "hide" when using that one. Not a huge issue for me really, but others might find it useful.
@aksonov that is a very clever solution, and it works.
It wasn't obvious to me how to selectively push from the root navigator, so let me document here. My goal would be to submit a pull request documenting this for you later.
Route
that you want to present modally should be a child of the root Router
wrapRouter={true}
on the Route
.Example:
<Router>
<Schema name="modal" sceneConfig={Navigator.SceneConfigs.FloatFromBottom}/>
<Route name="myModal" component={myModal} title="Modal" schema="modal" wrapRouter={true} />
<Route name="tabbar">
<Router footer={TabBar}>
<Route name="tab1" schema="tab" title="Tab 1" component={Tab1}/>
</Router>
</Route>
</Router>
If you are in the Tab1
controller and do an Actions.myModal()
, myModal
will be presented modally from the root navigator.
Yes, I've specially written such behavior, but didn't document it, sorry, you PR will be very welcome.
@aksonov or @emrosenf Could you give an example of rolling your own navbar and putting it in the header?
@joshuarotenberg sure, it's not as glamorous as you might think. Here's one of my screens
<View style={styles.container}>
<AHNavBar title={this.props.title} leftTitle={""} rightImage={require('../img/filter.png')}/>
<ScrollView style={[this.props.style, styles.scrollStyle]}>
...
</ScrollView>
</View>
@emrosenf Why don't you put the AHNavBar
component into your route's header={}
object instead?
@andreasbhansen That is a cool option. The reason I don't use it is parameter passing. For example, I would have to write Actions.myPage({rightImage: require('rightImage.png')})
and define the properties of the navigation bar when I am calling the screen transition. That feels like an anti-pattern,
@emrosenf Thank you.
Now hideNavBar is supported for Route element.
I have a multi-nested router:
As you can see, there are two things I would like to be able to do that I cannot:
DiscoverPage
should be presented without the navigation bar, butEventPage
should have it.ArtistPage
modal, I don't want to see the tab bar, but the view pops from underneath it.