A fully functional Android app built entirely with Kotlin and Jetpack Compose
Use window sizes for insets
Alex Vanyof3b845527945
diff --git a/feature-author/src/main/java/com/google/samples/apps/nowinandroid/feature/author/AuthorScreen.kt b/feature-author/src/main/java/com/google/samples/apps/nowinandroid/feature/author/AuthorScreen.ktindex 254b92ce9..22c8e8c09 100644--- a/feature-author/src/main/java/com/google/samples/apps/nowinandroid/feature/author/AuthorScreen.kt+++ b/feature-author/src/main/java/com/google/samples/apps/nowinandroid/feature/author/AuthorScreen.kt@@ -22,13 +22,12 @@ import androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.Spacerimport androidx.compose.foundation.layout.WindowInsets-import androidx.compose.foundation.layout.WindowInsetsSidesimport androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.onlyimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.safeDrawingimport androidx.compose.foundation.layout.size-import androidx.compose.foundation.layout.windowInsetsPadding+import androidx.compose.foundation.layout.windowInsetsBottomHeight+import androidx.compose.foundation.layout.windowInsetsTopHeightimport androidx.compose.foundation.lazy.LazyColumnimport androidx.compose.foundation.lazy.LazyListScopeimport androidx.compose.foundation.shape.CircleShape@@ -91,13 +90,7 @@ internal fun AuthorScreen(horizontalAlignment = Alignment.CenterHorizontally) {item {- Spacer(- // TODO: Replace with windowInsetsTopHeight after- // https://issuetracker.google.com/issues/230383055- Modifier.windowInsetsPadding(- WindowInsets.safeDrawing.only(WindowInsetsSides.Top)- )- )+ Spacer(Modifier.windowInsetsTopHeight(WindowInsets.safeDrawing))}when (authorState) {AuthorUiState.Loading -> {@@ -126,13 +119,7 @@ internal fun AuthorScreen(}}item {- Spacer(- // TODO: Replace with windowInsetsBottomHeight after- // https://issuetracker.google.com/issues/230383055- Modifier.windowInsetsPadding(- WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom)- )- )+ Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))}}}diff --git a/feature-foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt b/feature-foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.ktindex 5acf0daa0..c2fea6834 100644--- a/feature-foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt+++ b/feature-foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt@@ -37,6 +37,7 @@ import androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.safeDrawingimport androidx.compose.foundation.layout.sizeimport androidx.compose.foundation.layout.width+import androidx.compose.foundation.layout.windowInsetsBottomHeightimport androidx.compose.foundation.layout.windowInsetsPaddingimport androidx.compose.foundation.layout.wrapContentSizeimport androidx.compose.foundation.lazy.LazyColumn@@ -182,13 +183,7 @@ fun ForYouScreen()item {- Spacer(- // TODO: Replace with windowInsetsBottomHeight after- // https://issuetracker.google.com/issues/230383055- Modifier.windowInsetsPadding(- WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom)- )- )+ Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))}}}diff --git a/feature-interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/InterestsScreen.kt b/feature-interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/InterestsScreen.ktindex aa6c358ad..f8a462a5a 100644--- a/feature-interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/InterestsScreen.kt+++ b/feature-interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/InterestsScreen.kt@@ -19,10 +19,8 @@ package com.google.samples.apps.nowinandroid.feature.interestsimport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Spacerimport androidx.compose.foundation.layout.WindowInsets-import androidx.compose.foundation.layout.WindowInsetsSides-import androidx.compose.foundation.layout.onlyimport androidx.compose.foundation.layout.safeDrawing-import androidx.compose.foundation.layout.windowInsetsPadding+import androidx.compose.foundation.layout.windowInsetsTopHeightimport androidx.compose.material3.Textimport androidx.compose.material3.TopAppBarDefaultsimport androidx.compose.runtime.Composable@@ -83,13 +81,7 @@ fun InterestsScreen(modifier = modifier,horizontalAlignment = Alignment.CenterHorizontally) {- Spacer(- // TODO: Replace with windowInsetsTopHeight after- // https://issuetracker.google.com/issues/230383055- Modifier.windowInsetsPadding(- WindowInsets.safeDrawing.only(WindowInsetsSides.Top)- )- )+ Spacer(Modifier.windowInsetsTopHeight(WindowInsets.safeDrawing))NiaTopAppBar(titleRes = R.string.interests,diff --git a/feature-interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/TabContent.kt b/feature-interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/TabContent.ktindex fc75bf49b..fb36fe1bc 100644--- a/feature-interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/TabContent.kt+++ b/feature-interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/TabContent.kt@@ -19,11 +19,9 @@ package com.google.samples.apps.nowinandroid.feature.interestsimport androidx.compose.foundation.layout.PaddingValuesimport androidx.compose.foundation.layout.Spacerimport androidx.compose.foundation.layout.WindowInsets-import androidx.compose.foundation.layout.WindowInsetsSides-import androidx.compose.foundation.layout.onlyimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.safeDrawing-import androidx.compose.foundation.layout.windowInsetsPadding+import androidx.compose.foundation.layout.windowInsetsBottomHeightimport androidx.compose.foundation.lazy.LazyColumnimport androidx.compose.foundation.shape.CircleShapeimport androidx.compose.runtime.Composable@@ -58,13 +56,7 @@ fun TopicsTabContent(}item {- Spacer(- // TODO: Replace with windowInsetsBottomHeight after- // https://issuetracker.google.com/issues/230383055- Modifier.windowInsetsPadding(- WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom)- )- )+ Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))}}}@@ -94,13 +86,7 @@ fun AuthorsTabContent(}item {- Spacer(- // TODO: Replace with windowInsetsBottomHeight after- // https://issuetracker.google.com/issues/230383055- Modifier.windowInsetsPadding(- WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom)- )- )+ Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))}}}diff --git a/feature-topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt b/feature-topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.ktindex 4e7f5b657..c3fe5e332 100644--- a/feature-topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt+++ b/feature-topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt@@ -23,13 +23,12 @@ import androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.Spacerimport androidx.compose.foundation.layout.WindowInsets-import androidx.compose.foundation.layout.WindowInsetsSidesimport androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.onlyimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.safeDrawingimport androidx.compose.foundation.layout.size-import androidx.compose.foundation.layout.windowInsetsPadding+import androidx.compose.foundation.layout.windowInsetsBottomHeight+import androidx.compose.foundation.layout.windowInsetsTopHeightimport androidx.compose.foundation.lazy.LazyColumnimport androidx.compose.foundation.lazy.LazyListScopeimport androidx.compose.material.icons.Icons.Filled@@ -91,13 +90,7 @@ internal fun TopicScreen(horizontalAlignment = Alignment.CenterHorizontally) {item {- Spacer(- // TODO: Replace with windowInsetsTopHeight after- // https://issuetracker.google.com/issues/230383055- Modifier.windowInsetsPadding(- WindowInsets.safeDrawing.only(WindowInsetsSides.Top)- )- )+ Spacer(Modifier.windowInsetsTopHeight(WindowInsets.safeDrawing))}when (topicState) {Loading -> item {@@ -124,13 +117,7 @@ internal fun TopicScreen(}}item {- Spacer(- // TODO: Replace with windowInsetsBottomHeight after- // https://issuetracker.google.com/issues/230383055- Modifier.windowInsetsPadding(- WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom)- )- )+ Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))}}}