From e6c0176bfd722b4529f6cc7e0dd5b0dde2c91efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Moczkowski?= Date: Tue, 27 Jun 2023 11:54:10 +0200 Subject: [PATCH] Fix bottom bar scaffold navigation Change-Id: I5ca88c5d99f20daf4299ab13b3454990c4d9fc1d --- .../apps/nowinandroid/core/ui/AdaptiveScaffold.kt | 2 ++ .../core/ui/AdaptiveScaffoldNavigator.kt | 13 +++++++------ .../feature/topic/navigation/TopicNavigation.kt | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/AdaptiveScaffold.kt b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/AdaptiveScaffold.kt index d65cc680d..8bac0ba79 100644 --- a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/AdaptiveScaffold.kt +++ b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/AdaptiveScaffold.kt @@ -294,6 +294,7 @@ private fun RailScaffold( snackbarHost = snackbarHost, containerColor = colors.contentContainerColor, contentColor = colors.contentColor, + contentWindowInsets = contentWindowInsets, ) { padding -> content(padding) } @@ -399,6 +400,7 @@ fun AdaptiveScaffold( content: @Composable (padding: PaddingValues) -> Unit, ) { val isDetailsPaneVisible by navigator.isVisible.collectAsState(initial = false) + AdaptiveScaffold( modifier = modifier, navigationItems = navigationItems, diff --git a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/AdaptiveScaffoldNavigator.kt b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/AdaptiveScaffoldNavigator.kt index 83616e3a8..4aa4580d8 100644 --- a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/AdaptiveScaffoldNavigator.kt +++ b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/AdaptiveScaffoldNavigator.kt @@ -64,10 +64,11 @@ class AdaptiveScaffoldNavigator : Navigator() { value = backStackEntry } } - val backStackEntry = currentBackStackEntry - backStackEntry?.LocalOwnersProvider(saveableStateHolder) { - val destination = (backStackEntry.destination as? Destination) - destination?.content?.invoke(backStackEntry) + currentBackStackEntry?.let { backStackEntry -> + backStackEntry.LocalOwnersProvider(saveableStateHolder) { + val destination = backStackEntry.destination as Destination + destination.content(backStackEntry) + } } } @@ -82,12 +83,12 @@ class AdaptiveScaffoldNavigator : Navigator() { navigatorExtras: Extras?, ) { entries.forEach { entry -> - state.pushWithTransition(entry) + state.push(entry) } } override fun popBackStack(popUpTo: NavBackStackEntry, savedState: Boolean) { - state.popWithTransition(popUpTo, savedState) + state.pop(popUpTo, savedState) } @NavDestination.ClassType(Composable::class) diff --git a/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/navigation/TopicNavigation.kt b/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/navigation/TopicNavigation.kt index fb0f1c651..edcacb08f 100644 --- a/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/navigation/TopicNavigation.kt +++ b/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/navigation/TopicNavigation.kt @@ -38,7 +38,7 @@ internal class TopicArgs(val topicId: String) { fun NavController.navigateToTopic(topicId: String) { val encodedId = Uri.encode(topicId) this.navigate("topic_route/$encodedId") { - launchSingleTop = true + popBackStack("topic_route/{$topicIdArg}", inclusive = true) } }