Jasmin Fajkic
08/24/2022, 7:04 PM@Composable
fun NavigationHost(navController: NavHostController) {
NavHost(
navController = navController,
startDestination = NavRoutes.Feed.route,
) {
fun navigate(route: String) {
navController.navigate(route)
}
composable(NavRoutes.Feed.route) {
CommunityFeed(
navigate = { route: String -> navigate(route) },
)
}
composable(NavRoutes.Discover.route) {
Discover(
navigate = { route: String -> navigate(route) },
)
}
composable(NavRoutes.Inbox.route) {
Inbox(
navigate = { route: String -> navigate(route) },
)
}
composable(NavRoutes.TimeLine.route) {
Timeline(
navigate = { route: String -> navigate(route) },
)
}
composable(NavRoutes.CreatePost.route) {
CreatePost(
navigate = { route: String -> navigate(route) },
)
}
}
}
or in navhost create as many as needed functions for each composable and define how they behave. Second solution is possible a bit strange as if my screen is very complex I could easily have in navhost 10 functions that I would pass to my composable.Ian Lake
08/24/2022, 7:25 PM