Hello, I am facing some trouble tackling this scenario with Navigation Compose
Arsildo Murati
08/05/2024, 3:46 PM
image.png
Arsildo Murati
08/05/2024, 3:47 PM
So basically, in terms of nested navigation, I have a scaffold wrapping my app and a bottom bar, I have a destination that is part of one of the nested graphs that is inside the navhost, along with other routes in the bottom bar
Arsildo Murati
08/05/2024, 3:48 PM
As you can see in the picture in terms on context i am having trouble finding a good way to share the onClick of the button inside the destination screen and the onClick that is part of my bottom bar, they need to pass some arguments to the someDestination route
Arsildo Murati
08/05/2024, 3:50 PM
i want to keep the destination viewmodel separate of my root nav host, so i dont want to push it up in the hierarchy, One thing i tried is having a launched effect callback of when the data is loaded and then i can click and pass the same data on both onClick events, but this seems counter intuitive
Arsildo Murati
08/05/2024, 3:54 PM
Copy code
@Composable
fun RootGraph(
navController: NavHostController = rememberNavController()
) {
Scaffold(
bottomBar = {
NavigationBar {
// click event
}
}
) {
NavHost(
navController = navController
startDestination = "destinationGraph"
) {
home(
oncClick = {
// same click event as navigation bar
}
)
somethingElse()
someDestination() // bottom bar hidden here
}
}
}