Skip to content

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.kt
index 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.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
-import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.layout.windowInsetsPadding
+import androidx.compose.foundation.layout.windowInsetsBottomHeight
+import androidx.compose.foundation.layout.windowInsetsTopHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import 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.kt
index 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.padding
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.layout.wrapContentSize
import 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.kt
index 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.interests
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
-import androidx.compose.foundation.layout.WindowInsetsSides
-import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.safeDrawing
-import androidx.compose.foundation.layout.windowInsetsPadding
+import androidx.compose.foundation.layout.windowInsetsTopHeight
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import 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.kt
index 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.interests
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
-import androidx.compose.foundation.layout.WindowInsetsSides
-import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawing
-import androidx.compose.foundation.layout.windowInsetsPadding
+import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.CircleShape
import 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.kt
index 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.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
-import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.layout.windowInsetsPadding
+import androidx.compose.foundation.layout.windowInsetsBottomHeight
+import androidx.compose.foundation.layout.windowInsetsTopHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import 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))
}
}
}