I have a question about navigation cases. Imagine ...
# compose
s
I have a question about navigation cases. Imagine we have Scaffold with BottomNav BottomNav has 3 items - HomeScreen, SettingsScreen, CreateOrderScreen When you click on Home or Settings NavHost just changes screens in Scaffold But when you click CreateOrder user should be navigated to completely standalone screen (like different feature) CreateOrder screen doesn’t have bottom navigation and can be written without Scaffold, but since NavHost is located inside Scaffold composable we need no configure BottomNav to be hidden. But when application is getting bigger this logic might grow. Is there a good example how to share NavHost outside of Scaffold and BottomNav and still use it as root Composable or how this case should be done in Compose? @Ian Lake
z
I’m not an expert on Jetpack navigation, but I would think maybe this would be a use case for two nested nav hosts? One outside your scaffold and one inside
i
The exact same guidance for years also applies to Navigation Compose - if you want to hide your bottom nav based on what destination you're on, then do exactly that: have the visibility of your bottom nav tied to your source of truth: the NavController itself and its
currentBackStackEntryAsState()
👍 4