@Composable
fun AppPage() {
val navController = rememberNavController()
//first way
Page1(navController)
//second way
Page3 {
navController.navigate("AnyRoute")
}
}
@Composable
fun Page1(navController: NavHostController) {
//do anything
Page2(navController = navController)
}
@Composable
fun Page2(navController: NavHostController) {
navController.navigate("AnyRoute")
}
@Composable
fun Page3(toLogin: () -> Unit) {
//do anything
Page4 {
toLogin.invoke()
}
}
@Composable
fun Page4(toLogin: () -> Unit) {
Text(text = "test", modifier = Modifier.clickable {
toLogin.invoke()
})
}
I don't think these two methods are very good. Both of them can easily lead to too many parameters in the method, especially the second one, and I feel it's very troublesome. Is there a good way to use navigation for navigation
This is how I do my navigation. I did my best to apply it to your example.