Is it ok to have a nested `NavGraph` architecture?...
# compose
a
Is it ok to have a nested
NavGraph
architecture? For example, we have a outer
Navgraph
for an onboarding process which then leads down into a main screen which houses bottom navigation with it's own
Navhost
. Or would it be recommended to have one
Navgraph
and to simply show the bottom navigation bar when the screens using it are displayed to the user?
c
You may be interested in reading about nested navigation https://developer.android.com/jetpack/compose/navigation#nested-nav I have implemented something like this in my app, because we allow plugins to define arbitrary navigation destinations. There is a single NavHost at the top level. Each plugin just calls the
navigation()
function to define its own navigation.
a
I currently am using nested navigation in my app, however I am more curious as to the best way to structure the bottom nav bar into the one navhost structure
The documentation there shows it as a high level destination, with the navhost inserted directly into the content of the scaffold, but where should my other composable outside this flow go?
i
n
@Ian Lake When using the recommended approach the slide/expand transitions doesn't look good with bottom navigation. In fragments case I've always uses ViewPager2 along with bottom navigation inside a host fragment (to get proper animation). Is there any workarounds in compose?
i
The Material guidelines have been very, very, very specific since the first inclusion of bottom nav that you should never, ever use a slide animation between separate bottom nav items. That's the defining UX difference between independent bottom nav items and tabs+swipe between related screens
n
Sorry, the slide animations is not between bottom nav items. the slide animation is to another destination where bottom navigation not needed. Like for example, In Gmail android app when we selecting a mail item it goes to detail view. the bottom nav is having a slight delay in hiding (We can see the list item under the bottom nav when navigation). On the other hand in Play Store or Twitter android apps the transition between master and detail destinations doesn't have any delay at all.