From 91215c5c89461c20925fc6d30753105e0ec4a4ad Mon Sep 17 00:00:00 2001 From: Alex Vanyo Date: Tue, 16 Apr 2024 17:45:16 -0700 Subject: [PATCH 1/2] Update to navigation 2.7.7 Change-Id: Iaceea1fc216c899f7fac58e7f5eeaea4e1c10dbb --- app/dependencies/prodReleaseRuntimeClasspath.txt | 10 +++++----- gradle/libs.versions.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/dependencies/prodReleaseRuntimeClasspath.txt b/app/dependencies/prodReleaseRuntimeClasspath.txt index 7cd6df2d22..71e0ab2894 100644 --- a/app/dependencies/prodReleaseRuntimeClasspath.txt +++ b/app/dependencies/prodReleaseRuntimeClasspath.txt @@ -103,11 +103,11 @@ androidx.lifecycle:lifecycle-viewmodel:2.8.0-alpha04 androidx.loader:loader:1.0.0 androidx.localbroadcastmanager:localbroadcastmanager:1.0.0 androidx.metrics:metrics-performance:1.0.0-alpha04 -androidx.navigation:navigation-common-ktx:2.7.4 -androidx.navigation:navigation-common:2.7.4 -androidx.navigation:navigation-compose:2.7.4 -androidx.navigation:navigation-runtime-ktx:2.7.4 -androidx.navigation:navigation-runtime:2.7.4 +androidx.navigation:navigation-common-ktx:2.7.7 +androidx.navigation:navigation-common:2.7.7 +androidx.navigation:navigation-compose:2.7.7 +androidx.navigation:navigation-runtime-ktx:2.7.7 +androidx.navigation:navigation-runtime:2.7.7 androidx.print:print:1.0.0 androidx.privacysandbox.ads:ads-adservices-java:1.0.0-beta05 androidx.privacysandbox.ads:ads-adservices:1.0.0-beta05 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7c354432c4..ef84555fab 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,7 +20,7 @@ androidxHiltNavigationCompose = "1.2.0" androidxLifecycle = "2.7.0" androidxMacroBenchmark = "1.2.2" androidxMetrics = "1.0.0-alpha04" -androidxNavigation = "2.7.4" +androidxNavigation = "2.7.7" androidxProfileinstaller = "1.3.1" androidxTestCore = "1.5.0" androidxTestExt = "1.1.5" From 068cee0278cf73192d1c9c2a2d843a2a6021732c Mon Sep 17 00:00:00 2001 From: Alex Vanyo Date: Thu, 2 May 2024 17:28:39 -0700 Subject: [PATCH 2/2] Add workaround for state loss bug Change-Id: I7ac4495c8e3ada419358688c61214c33c0d4040e --- .../samples/apps/nowinandroid/ui/NiaApp.kt | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaApp.kt b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaApp.kt index 8cbabc247b..4c8232a26a 100644 --- a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaApp.kt +++ b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaApp.kt @@ -16,6 +16,7 @@ package com.google.samples.apps.nowinandroid.ui +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.WindowInsets @@ -199,15 +200,7 @@ internal fun NiaApp( ) } - NiaNavHost( - appState = appState, - onShowSnackbar = { message, action -> - snackbarHostState.showSnackbar( - message = message, - actionLabel = action, - duration = Short, - ) == ActionPerformed - }, + Box( modifier = if (shouldShowTopAppBar) { Modifier.consumeWindowInsets( WindowInsets.safeDrawing.only(WindowInsetsSides.Top), @@ -215,7 +208,18 @@ internal fun NiaApp( } else { Modifier }, - ) + ) { + NiaNavHost( + appState = appState, + onShowSnackbar = { message, action -> + snackbarHostState.showSnackbar( + message = message, + actionLabel = action, + duration = Short, + ) == ActionPerformed + }, + ) + } } // TODO: We may want to add padding or spacer when the snackbar is shown so that