|
|
|
@ -143,10 +143,10 @@ class NiaAppState(
|
|
|
|
|
trace("Navigation: ${topLevelDestination.name}") {
|
|
|
|
|
val topLevelNavOptions = navOptions {
|
|
|
|
|
val startDestination = navController.graph.findStartDestination()
|
|
|
|
|
|
|
|
|
|
// Avoid popUpTo and navigate to same screen.
|
|
|
|
|
val shouldNotSavedAndRestored = isStartDestinationSameWithNextDestination(
|
|
|
|
|
startDestination, topLevelDestination
|
|
|
|
|
) ?: false
|
|
|
|
|
val shouldNotSavedAndRestored = startDestination.hasRoute(topLevelDestination.route)
|
|
|
|
|
|
|
|
|
|
// Pop up to the start destination of the graph to
|
|
|
|
|
// avoid building up a large stack of destinations
|
|
|
|
|
// on the back stack as users select items
|
|
|
|
@ -168,14 +168,6 @@ class NiaAppState(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if next destination is same with start destination of current graph.
|
|
|
|
|
*/
|
|
|
|
|
private fun isStartDestinationSameWithNextDestination(
|
|
|
|
|
startDestination: NavDestination,
|
|
|
|
|
nextDestination: TopLevelDestination,
|
|
|
|
|
): Boolean? = startDestination.hasRoute(nextDestination.route)
|
|
|
|
|
|
|
|
|
|
fun navigateToSearch() = navController.navigateToSearch()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|