I'm trying out Compose Navigation (so far I've bee...
# compose
m
I'm trying out Compose Navigation (so far I've been using Fragments with Compose content), and I'm trying to understand how NavHost is supposed to be used when nesting navigation. Let's say I have screens A and B. On Screen A I have a bottom app bar switching between screens C, D, E (that are themselves part of screen A, which contains the navbar itself). So I have a root NavHost with screens A and B, and on screen A I have another NavHost with screens C, D, E. This works fine, but is this the intended solution? Or can I somehow use a single NavHost?
i
This is not a case where you should be using nested NavHosts, no. Here's the last conversation, with the link to the previous conversation and the one before that too: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1628603770177000?thread_ts=1628589309.155500&cid=CJLTWPH7S
It was not the right answer for Navigation with Fragments for this case either, FWIW
m
Thank you, so following the links to here: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1627490432392100?thread_ts=1627477759.324500&cid=CJLTWPH7S If I understand this correctly, I should not have a screen A for the navbar, instead just one NavHost with screens B, C, D, E, and the navbar in a root-level composable with visibility only showing when screens C, D or E are the current screen. Is that the idea?
i
that's the idea at the moment, yep. Even in a future world where shared elements exist, you still would only want a single NavHost: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1657131291210089?thread_ts=1657125808.017769&cid=CJLTWPH7S
m
That's some useful conversations you linked, thanks.