Skip to content

Instantly share code, notes, and snippets.

@raamcosta
Created September 28, 2021 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raamcosta/8c362610439df6412a209b1bd57cc6b9 to your computer and use it in GitHub Desktop.
Save raamcosta/8c362610439df6412a209b1bd57cc6b9 to your computer and use it in GitHub Desktop.
Current Compose Navigation Graph code example - NavHost
NavHost(
navController = navController,
startDestination = Screens.Login.route
) {
composable(Screens.Login.route) { LoginScreen(/*...*/) }
composable(Screens.MainFeed.route) {
MainFeedScreen(
navigateToProfile = { id, isEditable ->
navController.navigate("profile/$id?isEditable=$isEditable")
}
)
}
composable(
route = Screens.Profile.route,
arguments = listOf(
navArgument("id") {
type = NavType.StringType
},
navArgument("isEditable") {
type = NavType.BoolType
defaultValue = false
}
)
) {
ProfileScreen(
profileId = it.arguments?.getString("id")!!,
isEditable = it.arguments?.getBoolean("isEditable")!!
)
}
composable(Screens.Search.route) { SearchScreen(/*...*/) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment