Open skymansandy opened 3 months ago
Also, @adrielcafe would it be better if All Screen
s by default has the lifecycle callbacks like onCreate/onStart/onResume/...../onDestroy
like fragments/activities have?
Update:
I think the crash had something to do with using Composable marked functions in subclasses of a base class. (https://issuetracker.google.com/issues/316196500)
I had to override ProvideBeforeScreenContent
as well in the subclass.
But I'm still not getting onDispose
callback.
class HomeScreen : Screen, ScreenLifecycleProvider {
override fun getLifecycleOwner() = object : ScreenLifecycleOwner {
override fun onDispose(screen: Screen) {
println("HomeScreen is being disposed")
}
@Composable
override fun ProvideBeforeScreenContent(
provideSaveableState: @Composable (suffixKey: String, content: @Composable () -> Unit) -> Unit,
content: @Composable () -> Unit
) {
super.ProvideBeforeScreenContent(provideSaveableState, content)
}
}
@Composable
override fun Content() {
val navigator = LocalNavigator.currentOrThrow
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center,
) {
Button(onClick = { navigator.push(ProfileScreen()) }) {
Text("Home Screen")
}
}
}
}
I'm trying to use this API to listen to screen being disposed. https://voyager.adriel.cafe/lifecycle/#screenlifecycleowner
Getting this crash whenever trying to navigate to the screen. Any idea what is missed?
Library version:
1.1.0-beta-02
Crashlog: