Nested navigation¶
There should be no issues if you need to set up some sort of nested navigation.
Any navigator N
with screen B
created within screen A
is bound
to the lifecycle of screen A
.
If screen A
happens to get disposed, navigator N
and its screen B
will also get disposed.
@Composable
fun App(){
Navigator(ScreenA)
}
data object ScreenA : Screen {
@Composable
override fun Content() {
Navigator(ScreenB)
}
}
data object ScreenB : Screen {
@Composable
override fun Content() {
// ...
}
}
You can call LocalNavigator.currentOrThrow.parent to access the navigator of the screen owning the current navigator.
You can find source code for a working example here.