Justin Yue
05/07/2021, 12:07 AMJustin Yue
05/07/2021, 12:08 AMJustin Yue
05/07/2021, 12:09 AMjava.lang.IllegalStateException: ViewModelStore should be set before setGraph call
Colton Idle
05/07/2021, 12:09 AMIan Lake
05/07/2021, 12:16 AMJustin Yue
05/07/2021, 12:22 AMIan Lake
05/07/2021, 12:24 AMnavigation
element within your graph's DSLIan Lake
05/07/2021, 12:24 AMNavHost
which is almost never the right approachJustin Yue
05/07/2021, 12:26 AMnavigation
element, but it uses 2 nav controller, which I believe is unnecessary. Doing it conditionally would definitely solve my issue, so I guess what my question now is, when should I use a nav graph?Justin Yue
05/07/2021, 12:27 AMIan Lake
05/07/2021, 12:36 AMJustin Yue
05/07/2021, 12:47 AMNestedNavInGraph()
composable but would instead be inside a different composable like Profile
or Dashboard
composables in the sample codeIan Lake
05/07/2021, 1:19 AMJustin Yue
05/07/2021, 1:30 AMNeal Sanche
05/07/2021, 2:35 AMval navBackStackEntry by nav.currentBackStackEntryAsState()
LaunchedEffect(navBackStackEntry) {
navBackStackEntry?.destination!!.arguments[KEY_ROUTE]?.defaultValue.toString()
.let { currentRoute ->
viewModel.onNavigationRouteChanged(currentRoute)
}
}
You, obviously can ignore the viewModel stuff if it doesn't suit your architecture.Neal Sanche
05/07/2021, 2:38 AMAnimatedVisibility(
visible = showBottomNavigation,
enter = slideInVertically(initialOffsetY = { it }),
exit = slideOutVertically(targetOffsetY = { it })
) {
MainBottomNavigation(nav)
}
Justin Yue
05/07/2021, 2:41 AMIan Lake
05/07/2021, 2:42 AMLaunchedEffect
will run a frame behind, which might not be the best for animation purposes. Directly using the state as the source of truth (and using tools like derivedStateOf
for computed state) is generally a much better reactive patternNeal Sanche
05/07/2021, 3:19 PMnavBackStackEntry
to have some form of getRouteOrNull
but otherwise, this isn't too bad. I still need to test whether this solves all cases for us, but so far, it seems to be working for most.Ian Lake
05/07/2021, 3:47 PMnavBackStackEntry?.destination?.route