Daniele B
11/03/2020, 1:53 AMnavigation
. Congratulations, it’s great! It’s much neater than the one in SwiftUI. I also like the fact that it uses URIs, which makes it very adaptable to the Web too.
But maybe there is still some room for improvement. For example, I find rather verbose the way to collect string arguments. Having to repeat the parameter name twice doesn’t feel optimum.
NavHost(navController, startDestination = "master") {
.....
composable("detail/{item}") { backStackEntry ->
val detailName = backStackEntry.arguments?.getString("item")!!
DetailView(appState = appState, detailName = detailName)
}
}
Ian Lake
11/03/2020, 3:56 AMDaniele B
11/03/2020, 3:57 AMIan Lake
11/03/2020, 3:59 AMDaniele B
11/03/2020, 4:02 AMcomposable("detail/{item}") { backStackEntry ->
val detailName = backStackEntry.lastArg
DetailView(appState = appState, detailName = detailName)
}
Ian Lake
11/03/2020, 4:11 AMlastArg
would not be the same from composable to composable. I'm not sure if trading actual names for positional requirements actually works well when you allow multiple arguments and optional argumentsDaniele B
11/03/2020, 4:19 AMroute
parameter is defined as a String.Ian Lake
11/03/2020, 4:29 AMarguments
BundleDaniele B
11/03/2020, 4:39 AMlastArg
could be casted to a type with as
(e.g. as String
).
Considering that most use cases would take into consideration just the last argument, it would be useful not having to repeat the parameter name twice, it would also prevent mistyping bugs.Ian Lake
11/03/2020, 4:48 AMDaniele B
11/03/2020, 4:54 AMlastArg
as a simplified API, which would be used in common use cases, where you typically have a master/detail architecture, and the detail has an argument associated with it. For more complex situations, there would still be the freedom to use named arguments.Ian Lake
11/03/2020, 5:19 AMStefano Rodriguez
11/03/2020, 9:31 AMPage
-based approach is way better and more coherent with a component-based framework like Flutter or Jetpack Compose and they made a huge effort to make both approaches interoperable.