Sterling Albury
08/20/2023, 7:10 PMNavHost(...) {
...
composable(route = "inner") {
InnerFirst(viewModel, callback = object: Callback {
fun goToNext() { outerNavController.navigate("innerTwo") }
})
}
composable(route = "innerTwo") {
Second()
}
}
@Composable
fun InnerFirst(viewModel, callback) {
val innerNavController = rememberNavController()
viewModel.navigation.observe(LocalLifecycleOwner.current) {
event?.consume { navigation ->
when (navigation) {
is InnerInnerOne -> innerNavController.navigate("innerInnerComposable")
is InnerInnerTwo -> innerNavController.navigate("")
is Outer -> callback.goToNext()
}
}
}
NavHost(innerNavController) {
...
composable(route = "innerInner") { InnerInnerComposable() }
}
}
So I nav from the outer graph to the inner composable destination, which lands me in the inner graph, and then I navigate from the inner graph to another destination in the outer graph via the callback. All works well except when i go back from Second composable to the InnerFirst. If I go forward through the flow, and go back, when I try to navigate to another destination in the inner graph, the nav controller seems to be processing the navigation event (I see the destination on the back stack) but I don't see the navigation. It's like the inner nav host doesn't react to the innerNavController.
Anyone have any insight what might be happening?Stylianos Gakis
08/20/2023, 7:46 PMSterling Albury
08/20/2023, 8:48 PM