I have been thinking about how I could handle full...
# compose
a
I have been thinking about how I could handle full screen navigations (screens that show on top of the bottom navigation screens. I’m thinking of using nested NavHost, but I read somewhere here that it’s not a good idea. I’m also not sure if sharing
navController
(bottom navigation triggers a fullscreen navigatino) in multiple NavHost is a supported thing 😅. How is everyone handling fullscreen navigations?
My idea is something like:
assume all nested nav graphs above are defined in their feature modules
d
FWIW we are using nested NavHosts without issue. Now I'm curious, where did you get the steer that this isn't a good idea? And was it from a UX or technical Compose perspective?
👍 1
a
I think it’s this one but I didn’t understand the alternative.
https://kotlinlang.slack.com/archives/CJLTWPH7S/p1607399581443600?thread_ts=1607392764.442700&cid=CJLTWPH7S
Are you doing it similarly to my snippet above for the same reasons?
So I guess @Ian Lake's antipathy to using nested NavHosts is from an Compose purism/efficiency standpoint. NavHosts change their content imperatively, not declaratively, after all.
i
They just aren't needed in just about every case and complicate deep linking, state restoration, etc.
Particularly when it is even easier in Compose to use your NavController as the single source of truth and smoothly animate in/out your bottom nav, there's no reason to complicate your life so much
1
a
Yeah, agree. I’m trying it out and I’m questioning how the deep linking will work, how the backstack will look like, etc.
NavController as the single source of truth
And this is what I’m aiming for. However I can’t wrap around my head on how to handle fullscreen navigations with a single NavHost. Well, actually, I have worked around single NavHost in our current approach (Fragment Jetpack Navigation) by manually hiding the bottom nav for full screen navigations, but it doesn’t look so good (it doesn’t look like the screen pops over the screen with bottom nav)
i
The view system doesn't nice resizing container transitions easy, no. That's not the case for Compose though, so once Navigation Compose supports transitions (tracked in https://issuetracker.google.com/issues/172112072), I think you'll be able to animate your bottom nav down and out and have the new destination expand in and get the effect you're looking for quite seamlessly
😍 1
a
Omg, I was betting for the shared transitions to enable functionality like this, I just wasn’t sure. Thanks! Our current approach then is not so much of a workaround.