mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-18 00:57:02 +05:30
Only navigate when not on the current screen
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
97dc62afe1
commit
b031d36fa2
1 changed files with 2 additions and 3 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue