brabo-hi
01/21/2022, 5:33 PMNavHost(navController = navController, startDestination = "") {
composable("viewA"){}
composable("viewB") {}
Scaffold(){
NavHost(myOwnNavController, startDestination = "Child1") { // How to avoid this
composable("Child1") {}
}
}
}
In this example i have to use two NavController
Ian Lake
01/21/2022, 10:07 PMcurrentBackStackEntryAsState()
to hide and show your bottom bar based on what destination you are onIan Lake
01/21/2022, 10:21 PMval navController = rememberNavController()
Scaffold(
bottomBar = {
// Use the NavController as the source of truth
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
// Use whatever logic you want to decide when to show the bottom bar
val showBottomBar = currentDestination?.route == "bottomBarScreen"
// Instead of instantly popping the bottom bar in and out of existence, animate it
AnimatedVisibility(visible = showBottomBar) {
BottomNavigation {
//
}
}
}
) {
NavHost(...)
}
brabo-hi
01/22/2022, 4:10 AM