From 83aa63d83864776d6fba89bfbce59e978e0b4957 Mon Sep 17 00:00:00 2001 From: Yuki Anzai Date: Wed, 15 Jun 2022 22:13:37 +0900 Subject: [PATCH 1/2] use contentPadding of LazyColumn for TabContent --- .../apps/nowinandroid/feature/interests/InterestsScreen.kt | 6 ++---- .../apps/nowinandroid/feature/interests/TabContent.kt | 7 +++++-- 2 files changed, 7 insertions(+), 6 deletions(-) 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 fa47eb26e..24df3788b 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 @@ -21,7 +21,6 @@ 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.material.icons.Icons @@ -35,7 +34,6 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import com.google.samples.apps.nowinandroid.core.model.data.FollowableAuthor import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic @@ -152,7 +150,7 @@ private fun InterestsContent( topics = uiState.topics, onTopicClick = navigateToTopic, onFollowButtonClick = followTopic, - modifier = Modifier.padding(top = 8.dp) + modifier = Modifier ) } 1 -> { @@ -160,7 +158,7 @@ private fun InterestsContent( authors = uiState.authors, onAuthorClick = navigateToAuthor, onFollowButtonClick = followAuthor, - modifier = Modifier.padding(top = 8.dp) + modifier = Modifier ) } } 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 55efafc33..bfe4096fa 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 @@ -16,6 +16,7 @@ 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 @@ -40,7 +41,8 @@ fun TopicsTabContent( modifier: Modifier = Modifier ) { LazyColumn( - modifier = modifier.padding(horizontal = 16.dp) + modifier = modifier.padding(horizontal = 16.dp), + contentPadding = PaddingValues(vertical = 8.dp) ) { topics.forEach { followableTopic -> item { @@ -75,7 +77,8 @@ fun AuthorsTabContent( modifier: Modifier = Modifier ) { LazyColumn( - modifier = modifier.padding(horizontal = 16.dp) + modifier = modifier.padding(horizontal = 16.dp), + contentPadding = PaddingValues(vertical = 8.dp) ) { authors.forEach { followableAuthor -> item { From a3f8999c121605f5236e5103a425928c2e480472 Mon Sep 17 00:00:00 2001 From: Yuki Anzai Date: Thu, 16 Jun 2022 12:55:13 +0900 Subject: [PATCH 2/2] remove passing default Modifier and change contentPadding from vertical to top --- .../apps/nowinandroid/feature/interests/InterestsScreen.kt | 2 -- .../samples/apps/nowinandroid/feature/interests/TabContent.kt | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) 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 24df3788b..e536b632f 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 @@ -150,7 +150,6 @@ private fun InterestsContent( topics = uiState.topics, onTopicClick = navigateToTopic, onFollowButtonClick = followTopic, - modifier = Modifier ) } 1 -> { @@ -158,7 +157,6 @@ private fun InterestsContent( authors = uiState.authors, onAuthorClick = navigateToAuthor, onFollowButtonClick = followAuthor, - modifier = Modifier ) } } 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 bfe4096fa..fc75bf49b 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 @@ -42,7 +42,7 @@ fun TopicsTabContent( ) { LazyColumn( modifier = modifier.padding(horizontal = 16.dp), - contentPadding = PaddingValues(vertical = 8.dp) + contentPadding = PaddingValues(top = 8.dp) ) { topics.forEach { followableTopic -> item { @@ -78,7 +78,7 @@ fun AuthorsTabContent( ) { LazyColumn( modifier = modifier.padding(horizontal = 16.dp), - contentPadding = PaddingValues(vertical = 8.dp) + contentPadding = PaddingValues(top = 8.dp) ) { authors.forEach { followableAuthor -> item {