Skip to content

Commit 5388d7f

Browse files
committed
refactor(ui): optimize bottom navigation behavior
This commit improves the navigation logic within `BottomNavigation` by implementing standard state preservation and restoration. This ensures that the back stack is properly managed and the state of individual tabs is maintained when switching between them. - **refactor(ui)**: Updated `navController.navigate` in `BottomNavigation` to use `popUpTo` the home screen with `saveState = true`. - **refactor(ui)**: Enabled `launchSingleTop` and `restoreState` to prevent multiple instances of the same destination and restore previous tab states.
1 parent 3351188 commit 5388d7f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/AppNavigation.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,14 @@ fun AppNavigation(
248248
BottomNavigation(
249249
currentScreen = currentScreen,
250250
onNavigate = {
251-
navController.navigate(it)
251+
navController.navigate(it) {
252+
popUpTo(GithubStoreGraph.HomeScreen) {
253+
saveState = true
254+
}
255+
256+
launchSingleTop = true
257+
restoreState = true
258+
}
252259
},
253260
modifier = Modifier
254261
.align(Alignment.BottomCenter)

0 commit comments

Comments
 (0)