Ryan
01/28/2025, 6:45 PMBottomBarItem.entries.forEach { destination ->
val isCurrentDestOnBackStack by
navController.isRouteOnBackStackAsState(destination.direction)
NavigationBarItem(
selected = isCurrentDestOnBackStack,
onClick = {
if (isCurrentDestOnBackStack) {
// When we click again on a bottom bar item and it was already selected
// we want to pop the back stack until the initial destination of this bottom bar
// item
navigator.popBackStack(destination.direction, false)
return@NavigationBarItem
}
navigator.navigate(destination.direction) {
// Pop up to the root of the graph to
// avoid building up a large stack of destinations
// on the back stack as users select items
popUpTo(NavGraphs.root) { saveState = true }
// Avoid multiple copies of the same destination when
// reselecting the same item
launchSingleTop = true
// Restore state when reselecting a previously selected item
restoreState = true
}
},
// ...
)
}
}
Is there a way within a subclassed DestinationStyle.Animated()
to see whether navigation is occurring from this bottom bar or is there a way through nested navigation graphs to achieve this (seems heavy handed for animation)?David
01/28/2025, 7:59 PMwhen (initialState.destination()) {
LoginDestination -> fadeIn()
else -> EnterTransition.None
}
Ryan
01/29/2025, 6:42 AMRafael Costa
01/29/2025, 8:04 AMRyan
01/29/2025, 5:32 PMRyan
01/29/2025, 5:48 PMshouldAnimate
is false, but that nav stack has additional destinations on it from its saved state, even if from my bottom bar I'm navigating to the Home destination, the target destination is its deepest destination on the stack. Is there a way to read the destinations root item on its stack?