Hello, Is it possible with navigation to achieve t...
# compose
j
Hello, Is it possible with navigation to achieve this? I’m using the accompanist bottom sheet to create a nested graph. The first route I open in the bottom sheet, and I want all subsequent routes to open as normal screens inside the bottom sheet.
Basically want that from screen A navigate to screen B while sheet is still open
@Ian Lake maybe if can help?
i
"normal screens inside the bottom sheet" sounds like you need a second NavHost within the bottom sheet destination that would only replace the contents of the bottom sheet
n
@Ian Lake Sorry to necro this, but according to the `BottomSheetNavigator`’s docs this should automatically happen when navigating from one
BottomSheetNavigator.Destination
to another
BottomSheetNavigator.Destination
. And it’s indeed happening, but it will collapse and expand the bottom sheet again. Is there any way to prevent that behaviour? Also, I thought that having several `NavHost`s was not recommended, am I wrong? I was thinking about implementing a custom
Navigator
to avoid having more than one
NavHost
.
i
Each bottom sheet navigator destination is a new bottom sheet, so what you see is expected there
There's nothing wrong with having multiple NavHosts, it is just rarely the right choice. Remember a NavHost is just a Box that it's contents fill - if you want a Box of contents with a back stack inside a bottom sheet, there's no reason to write anything other than exactly that
n
Ok! 👍 Thanks for that. I was afraid that it would make the navigation harder to manage (deep linking, for example). I’ll try that solution, thanks, mate.