Florian
08/09/2021, 8:38 PMroute
property of the `navBackStackEntry`'s destination
contains the argument syntax. But in order to add arguments later, my own route string needs to be the "base" route without arguments.
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
val hideBottomNav = fullScreenDestinations.any { destination ->
destination.route == currentDestination?.route
}
So here destination.route
= "AddEditTask"
while currentDestination.route
= "AddEditTask?taskId=taskID"
.
How else could I check what destination we are currently on?
using contains
to compare a sub-string seems error-prone.Ian Lake
08/09/2021, 8:58 PMFlorian
08/09/2021, 9:01 PMFlorian
08/09/2021, 9:01 PMFlorian
08/09/2021, 9:09 PMFlorian
08/09/2021, 9:10 PMFlorian
08/10/2021, 9:42 AMcomposable(
route = BottomNavDestination.Timer.route,
arguments = listOf(
navArgument(ARG_SHOW_BOTTOM_NAV) {
type = NavType.BoolType
defaultValue = true
}
)
) {
TimerScreen()
}
Scaffold(
bottomBar = {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
val showBottomNav = navBackStackEntry?.arguments?.get(ARG_SHOW_BOTTOM_NAV) == true
[...]
Ian Lake
08/10/2021, 1:47 PMBoolType
- it should be automatically determined from the default valueFlorian
08/10/2021, 2:45 PM