From b031d36fa29d6e27e22b8187c8b4c2e20e3417a6 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Thu, 29 Oct 2020 17:09:27 +0530 Subject: [PATCH] Only navigate when not on the current screen Signed-off-by: Harsh Shandilya --- app/src/main/java/dev/msfjarvis/lobsters/MainActivity.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/dev/msfjarvis/lobsters/MainActivity.kt b/app/src/main/java/dev/msfjarvis/lobsters/MainActivity.kt index b3d08c98..10d9a611 100644 --- a/app/src/main/java/dev/msfjarvis/lobsters/MainActivity.kt +++ b/app/src/main/java/dev/msfjarvis/lobsters/MainActivity.kt @@ -71,12 +71,11 @@ fun LobstersApp( label = { Text(stringResource(id = screen.labelRes)) }, selected = currentRoute == screen.route, onClick = { - // This is the equivalent to popUpTo the start destination - navController.popBackStack(navController.graph.startDestination, false) - // This if check gives us a "singleTop" behavior where we do not create a // second instance of the composable if we are already on that destination if (currentRoute != screen.route) { + // This is the equivalent to popUpTo the start destination + navController.popBackStack(navController.graph.startDestination, false) navController.navigate(screen.route) } }