Luis Mierez
06/02/2021, 5:05 PMLuis Mierez
06/02/2021, 5:07 PMval navController = rememberNavController()
NavHost(navController = navController, startDestination = "mainpicker") {
composable("mainpicker") {
ContactPickerScreen(
viewModel = viewModel,
onClientClicked = { viewModel.onAction(Action.ClientPressed) }
)
}
composable("myclients") { MyClientsScreen() }
}
the MainPicker screen is a simple composable that shows multiple rows to select different types of contacts (Clients, Phone Contacts, Friends, etc)Luis Mierez
06/02/2021, 5:08 PMnavController.navigate("myclients")
in the onClientClicked
callbackLuis Mierez
06/02/2021, 5:08 PMStateFlow
Luis Mierez
06/02/2021, 5:09 PMLuis Mierez
06/02/2021, 5:11 PMval model by viewModel.state.collectAsState()
but then I’m not sure where to add the navController.navigate(model.route)
. I tried adding it at the bottom of the composable like:Luis Mierez
06/02/2021, 5:12 PMval model by viewModel.state.collectAsState()
val navController = rememberNavController()
NavHost(navController = navController, startDestination = "mainpicker") {
composable("mainpicker") {
ContactPickerScreen(
viewModel = viewModel,
onClientClicked = { viewModel.onAction(Action.ClientPressed) }
)
}
composable("myclients") { MyClientsScreen() }
}
navController.navigate(model.route)
Luis Mierez
06/02/2021, 5:13 PMIan Lake
06/02/2021, 5:15 PMnavigate()
) as part of composition, that's never correctIan Lake
06/02/2021, 5:16 PMLuis Mierez
06/02/2021, 5:18 PMnavigate()
in the composition was wrong. I’ll take a look at that thread