From a324fcc8d3f4ffe21a7e56c1c37a61d71c4ee3af Mon Sep 17 00:00:00 2001 From: Alex Vanyo Date: Mon, 6 May 2024 11:41:56 -0700 Subject: [PATCH 1/2] Fix state loss with workaround Change-Id: I96025bd8b2f4f59019df95d1391b832249e7dc91 --- .../google/samples/apps/nowinandroid/ui/NiaApp.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 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 4c8232a26..a381298c0 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 @@ -201,13 +201,13 @@ internal fun NiaApp( } Box( - modifier = if (shouldShowTopAppBar) { - Modifier.consumeWindowInsets( - WindowInsets.safeDrawing.only(WindowInsetsSides.Top), - ) - } else { - Modifier - }, + modifier = Modifier.consumeWindowInsets( + if (shouldShowTopAppBar) { + WindowInsets.safeDrawing.only(WindowInsetsSides.Top) + } else { + WindowInsets(0, 0, 0, 0) + }, + ), ) { NiaNavHost( appState = appState, From 488b97a0716574a33e9e30b30984f644cefdafe2 Mon Sep 17 00:00:00 2001 From: Don Turner Date: Wed, 29 May 2024 16:31:04 +0100 Subject: [PATCH 2/2] Update app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaApp.kt --- .../kotlin/com/google/samples/apps/nowinandroid/ui/NiaApp.kt | 1 + 1 file changed, 1 insertion(+) 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 a381298c0..e64fd158a 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 @@ -201,6 +201,7 @@ internal fun NiaApp( } Box( + // Workaround for https://issuetracker.google.com/338478720 modifier = Modifier.consumeWindowInsets( if (shouldShowTopAppBar) { WindowInsets.safeDrawing.only(WindowInsetsSides.Top)