Clament John
11/11/2021, 11:54 AMNestedNavigation
(jetpack navigation) with arguments?
How would I pass id
to the login
nav graph?
fun NavGraphBuilder.loginGraph(navController: NavController) {
navigation(
startDestination = "username",
route = "login/{id}",
arguments = listOf(navArgument("id") { type = NavType.StringType }),
) {
composable("username") { ... }
composable("password") { ... }
composable("registration") { ... }
}
}
Johan Reitan
11/11/2021, 12:17 PMnavController.navigate("login/123")
. You can get the argument either from the `startDestination`’s arguments
, or from the graph’s arguments:
navController.getBackStackEntry("login/{id}").arguments.getString("id")
Clament John
11/11/2021, 12:20 PMarguments
is not a valid parameter for navigation
. This is why I was confused how to do itClament John
11/11/2021, 12:21 PMdeeplink
to nested navigation graph
https://stackoverflow.com/questions/69906721/jetpack-compose-deep-link-into-nested-navigationJohan Reitan
11/11/2021, 12:23 PMnavigation
function from Accompanist? It’s missing these arguments, but the function from androidx.navigation.compose
has themClament John
11/11/2021, 12:24 PMarguments
param?Johan Reitan
11/11/2021, 12:24 PMcomposable
functions from com.google.accompanist.navigation.animation
Johan Reitan
11/11/2021, 12:24 PMpublic fun NavGraphBuilder.navigation(
startDestination: String,
route: String,
arguments: List<NamedNavArgument> = emptyList(),
deepLinks: List<NavDeepLink> = emptyList(),
builder: NavGraphBuilder.() -> Unit
)
Clament John
11/11/2021, 12:25 PMIan Lake
11/11/2021, 2:27 PMfun NavGraphBuilder.loginGraph(navController: NavController) {
navigation(
startDestination = "username",
route = "login/{id}"
) {
// Inside the lambda, any of the
// NavGraphBuilder extensions can
// be called directly
navArgument("id") { type = NavType.StringType })
composable("username") { ... }
composable("password") { ... }
composable("registration") { ... }
}
}