mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-18 07:57:03 +05:30
src: use launchSingleTop to prevent adding duplicate composables
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com> (cherry picked from commit 45e3bd56855570db0f449ae5dde89dd46e4f2129)
This commit is contained in:
parent
2547d36254
commit
7e7eff6c8e
1 changed files with 5 additions and 4 deletions
|
@ -99,10 +99,11 @@ fun LobstersBottomNav(
|
|||
selected = currentRoute == screen.route,
|
||||
alwaysShowLabels = false,
|
||||
onClick = {
|
||||
if (currentRoute == screen.route) return@BottomNavigationItem
|
||||
navController.popBackStack(navController.graph.startDestination, false)
|
||||
if (screen.route != Destination.startDestination.route) {
|
||||
navController.navigate(screen.route)
|
||||
if (screen.route != currentRoute) {
|
||||
navController.navigate(screen.route) {
|
||||
launchSingleTop = true
|
||||
popUpTo(navController.graph.startDestination) { inclusive = false }
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue