I resolved but.. i don/t understand recomposition....
# compose
a
I resolved but.. i don/t understand recomposition. I use classic navigation
Copy code
@Composable
fun NavigationComponent(navController: NavHostController) {
    NavHost(
        navController = navController,
        startDestination = Destination.Splash.path
    ) {
        composable(Destination.Splash.path) {
            SplashScreen(navController)
        }
        composable(Destination.Login.path) {
            LoginScreen(navController)
        }
    }
}
In SplashScreen viewModel after 3 second changes a variable to go LoginScreen
Copy code
val uiState = MutableStateFlow(SplashState())
init {
    Handler(Looper.myLooper()!!).postDelayed({
       gotoLogin()
    }, 3000)
}
private fun gotoLogin() {
    uiState.value = uiState.value.copy(
        gotoLogin = true
    )
}
ok it works but i have a loop, if i navigate to LoginScreen i see some mistake.. and see log every 3 seconds
Copy code
@Composable
fun SplashScreen(navController: NavHostController?) {
 val viewModel: SplashViewModel= viewModel()

    var screenState= viewModel.uiState.collectAsState().value
    if(screenState.gotoLogin){
         Log.i("app", "SplashScreen gotoLogin" )
        navController?.navigate(Destination.Login.path)
        //screenState.gotoLogin= false
    }