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:
Aditya Wasan 2021-01-25 01:20:50 +05:30 committed by Harsh Shandilya
parent 2547d36254
commit 7e7eff6c8e
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80

View file

@ -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 }
}
}
}
)