-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Always restoreState in bottom navigation
- Loading branch information
Showing
1 changed file
with
10 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,11 +113,17 @@ private fun NavHostController.navigateToSelectedItem(destination: MainNavigation | |
} | ||
// Avoid multiple copies of the same destination when re-selecting the same item | ||
launchSingleTop = true | ||
|
||
// Restore state when re-selecting a previously selected item | ||
val currentBackStackEntry = this@navigateToSelectedItem.currentBackStackEntry | ||
val hasDeepLink = currentBackStackEntry?.arguments?.parcelableExtra<Intent>(NavController.KEY_DEEP_LINK_INTENT) != null | ||
val isNavigatingToStartDestination = startDestination.route == destination::class.qualifiedName | ||
restoreState = !hasDeepLink || !isNavigatingToStartDestination | ||
restoreState = true | ||
|
||
// The commented code below was supposed to be an improvement on the line above, | ||
// but it doesn't behave the way we'd like. TODO: Find a better solution that works | ||
|
||
// val currentBackStackEntry = [email protected] | ||
// val hasDeepLink = currentBackStackEntry?.arguments?.parcelableExtra<Intent>(NavController.KEY_DEEP_LINK_INTENT) != null | ||
// val isNavigatingToStartDestination = startDestination.route == destination::class.qualifiedName | ||
// restoreState = !hasDeepLink || !isNavigatingToStartDestination | ||
} | ||
} | ||
|
||
|