https://kotlinlang.org logo
#compose
Title
# compose
b

brabo-hi

01/19/2022, 7:47 PM
Hi all, what is the best way to host a composable child that has a navbar? should we have two
NavHost
?
Copy code
NavHost(navController = navController, startDestination = "") {
   composable("viewA"){}
   composable("viewB")
}

viewB has a bottomNavBar, which means it looks like

Scaffold(){
 NavHost(navController, startDestination = Screen.Profile.route, Modifier.padding(innerPadding)) {
    composable(Screen.Profile.route) { Profile(navController) }
    composable(Screen.FriendsList.route) { FriendsList(navController) }
  }

}
ViewB will have it own
NavHost
different from the parent’s
NavHost
here is the final result
Copy code
NavHost(navController = navController, startDestination = "") {
        composable("viewA"){}
        composable("viewB") {}
        Scaffold(){
            NavHost(myOwnNavController, startDestination = "Child1") {
                composable("Child1") {}
            }
        }
    }
the issue is there are 2
NavHost
and two
NavController