diff --git a/core/ui/src/commonMain/kotlin/io/github/droidkaigi/confsched/ui/PaddingValuesExt.kt b/core/ui/src/commonMain/kotlin/io/github/droidkaigi/confsched/ui/PaddingValuesExt.kt new file mode 100644 index 000000000..225c264ef --- /dev/null +++ b/core/ui/src/commonMain/kotlin/io/github/droidkaigi/confsched/ui/PaddingValuesExt.kt @@ -0,0 +1,18 @@ +package io.github.droidkaigi.confsched.ui + +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.calculateEndPadding +import androidx.compose.foundation.layout.calculateStartPadding +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalLayoutDirection + +@Composable +operator fun PaddingValues.plus(other: PaddingValues): PaddingValues { + val layoutDirection = LocalLayoutDirection.current + return PaddingValues( + top = this.calculateTopPadding() + other.calculateTopPadding(), + start = this.calculateStartPadding(layoutDirection) + other.calculateStartPadding(layoutDirection), + end = this.calculateEndPadding(layoutDirection) + other.calculateEndPadding(layoutDirection), + bottom = this.calculateBottomPadding() + other.calculateBottomPadding(), + ) +} diff --git a/feature/contributors/src/commonMain/kotlin/io/github/droidkaigi/confsched/contributors/ContributorsScreen.kt b/feature/contributors/src/commonMain/kotlin/io/github/droidkaigi/confsched/contributors/ContributorsScreen.kt index 545874374..aa39b732b 100644 --- a/feature/contributors/src/commonMain/kotlin/io/github/droidkaigi/confsched/contributors/ContributorsScreen.kt +++ b/feature/contributors/src/commonMain/kotlin/io/github/droidkaigi/confsched/contributors/ContributorsScreen.kt @@ -1,5 +1,6 @@ package io.github.droidkaigi.confsched.contributors +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding @@ -129,9 +130,10 @@ fun ContributorsScreen( Contributors( contributors = uiState.contributors, onContributorsItemClick = onContributorsItemClick, + contentPadding = PaddingValues(bottom = padding.calculateBottomPadding()), modifier = Modifier .fillMaxSize() - .padding(padding) + .padding(top = padding.calculateTopPadding()) .let { if (scrollBehavior != null) { it.nestedScroll(scrollBehavior.nestedScrollConnection) @@ -148,9 +150,11 @@ private fun Contributors( contributors: PersistentList, onContributorsItemClick: (url: String) -> Unit, modifier: Modifier = Modifier, + contentPadding: PaddingValues = PaddingValues(), ) { LazyColumn( modifier = modifier, + contentPadding = contentPadding, ) { items(contributors) { ContributorsItem( diff --git a/feature/eventmap/src/commonMain/kotlin/io/github/droidkaigi/confsched/eventmap/EventMapScreen.kt b/feature/eventmap/src/commonMain/kotlin/io/github/droidkaigi/confsched/eventmap/EventMapScreen.kt index e9e93585e..4058c01c8 100644 --- a/feature/eventmap/src/commonMain/kotlin/io/github/droidkaigi/confsched/eventmap/EventMapScreen.kt +++ b/feature/eventmap/src/commonMain/kotlin/io/github/droidkaigi/confsched/eventmap/EventMapScreen.kt @@ -35,6 +35,7 @@ import io.github.droidkaigi.confsched.model.EventMapEvent import io.github.droidkaigi.confsched.ui.SnackbarMessageEffect import io.github.droidkaigi.confsched.ui.UserMessageStateHolder import io.github.droidkaigi.confsched.ui.component.AnimatedTextTopAppBar +import io.github.droidkaigi.confsched.ui.plus import io.github.droidkaigi.confsched.ui.rememberUserMessageStateHolder import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf @@ -119,7 +120,10 @@ fun EventMapScreen( EventMap( eventMapEvents = uiState.eventMap, onEventMapItemClick = onEventMapItemClick, - modifier = Modifier.fillMaxSize().padding(padding) + contentPadding = PaddingValues(bottom = padding.calculateBottomPadding()), + modifier = Modifier + .fillMaxSize() + .padding(top = padding.calculateTopPadding()) .nestedScroll(scrollBehavior.nestedScrollConnection), ) } @@ -130,11 +134,12 @@ private fun EventMap( eventMapEvents: PersistentList, onEventMapItemClick: (url: String) -> Unit, modifier: Modifier = Modifier, + contentPadding: PaddingValues = PaddingValues(), ) { LazyColumn( modifier = modifier .testTag(EventMapLazyColumnTestTag), - contentPadding = PaddingValues(horizontal = 16.dp), + contentPadding = contentPadding + PaddingValues(horizontal = 16.dp), ) { item { EventMapTab() diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/SearchScreen.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/SearchScreen.kt index 332e5ae10..cf8475efa 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/SearchScreen.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/SearchScreen.kt @@ -148,7 +148,7 @@ fun SearchScreen( containerColor = MaterialTheme.colorScheme.surface, ) { innerPadding -> Column( - modifier = Modifier.padding(innerPadding), + modifier = Modifier.padding(top = innerPadding.calculateTopPadding()), ) { HorizontalDivider() SearchFilters( @@ -176,6 +176,7 @@ fun SearchScreen( highlightWord = uiState.searchWord, onBookmarkClick = { timetableItem, _ -> onTimetableItemBookmark(timetableItem) }, onTimetableItemClick = onTimetableItemClick, + contentPadding = PaddingValues(bottom = innerPadding.calculateBottomPadding()), ) } } diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/section/SearchList.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/section/SearchList.kt index 26a25a101..ba9aec329 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/section/SearchList.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/section/SearchList.kt @@ -13,13 +13,14 @@ fun SearchList( onTimetableItemClick: (TimetableItem) -> Unit, onBookmarkClick: (TimetableItem, Boolean) -> Unit, modifier: Modifier = Modifier, + contentPadding: PaddingValues = PaddingValues(), ) { TimetableList( uiState = uiState, scrollState = rememberLazyListState(), onBookmarkClick = onBookmarkClick, onTimetableItemClick = onTimetableItemClick, - contentPadding = PaddingValues(), + contentPadding = contentPadding, highlightWord = highlightWord, modifier = modifier, ) diff --git a/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt b/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt index f9989e569..508206caf 100644 --- a/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt +++ b/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt @@ -1,6 +1,8 @@ package io.github.droidkaigi.confsched.sponsors +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons.AutoMirrored.Filled import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.ExperimentalMaterial3Api @@ -139,11 +141,13 @@ fun SponsorsScreen( }, ) { padding -> SponsorsList( - modifier = Modifier.fillMaxSize(), - padding = padding, + modifier = Modifier + .padding(top = padding.calculateTopPadding()) + .fillMaxSize(), uiState = uiState.sponsorsListUiState, scrollBehavior = scrollBehavior, onSponsorsItemClick = onSponsorsItemClick, + contentPadding = PaddingValues(bottom = padding.calculateBottomPadding()), ) } } diff --git a/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/section/SponsorsList.kt b/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/section/SponsorsList.kt index 832fee5d4..06d45418b 100644 --- a/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/section/SponsorsList.kt +++ b/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/section/SponsorsList.kt @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.grid.GridCells import androidx.compose.foundation.lazy.grid.GridItemSpan import androidx.compose.foundation.lazy.grid.LazyVerticalGrid @@ -30,6 +29,7 @@ import io.github.droidkaigi.confsched.sponsors.SponsorsListUiState import io.github.droidkaigi.confsched.sponsors.SponsorsRes import io.github.droidkaigi.confsched.sponsors.component.SponsorHeader import io.github.droidkaigi.confsched.sponsors.component.SponsorItem +import io.github.droidkaigi.confsched.ui.plus import kotlinx.collections.immutable.toPersistentList import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.ui.tooling.preview.Preview @@ -37,18 +37,17 @@ import org.jetbrains.compose.ui.tooling.preview.Preview @OptIn(ExperimentalMaterial3Api::class) @Composable fun SponsorsList( - padding: PaddingValues, uiState: SponsorsListUiState, onSponsorsItemClick: (url: String) -> Unit, scrollBehavior: TopAppBarScrollBehavior?, modifier: Modifier = Modifier, + contentPadding: PaddingValues = PaddingValues(), ) { LazyVerticalGrid( columns = GridCells.Fixed(6), verticalArrangement = Arrangement.spacedBy(12.dp), horizontalArrangement = Arrangement.spacedBy(12.dp), modifier = modifier - .padding(padding) .let { if (scrollBehavior != null) { it.nestedScroll(scrollBehavior.nestedScrollConnection) @@ -56,7 +55,7 @@ fun SponsorsList( it } }, - contentPadding = PaddingValues(horizontal = 12.dp), + contentPadding = contentPadding + PaddingValues(horizontal = 12.dp), ) { item(span = { GridItemSpan(maxLineSpan) }) { SponsorHeader( @@ -137,7 +136,6 @@ fun SponsorsListPreview() { goldSponsors = Sponsor.fakes().filter { it.plan == GOLD }.toPersistentList(), supporters = Sponsor.fakes().filter { it.plan == SUPPORTER }.toPersistentList(), ), - padding = PaddingValues(), onSponsorsItemClick = {}, scrollBehavior = null, ) diff --git a/feature/staff/src/commonMain/kotlin/io/github/droidkaigi/confsched/staff/StaffScreen.kt b/feature/staff/src/commonMain/kotlin/io/github/droidkaigi/confsched/staff/StaffScreen.kt index af8649ade..2d2704c34 100644 --- a/feature/staff/src/commonMain/kotlin/io/github/droidkaigi/confsched/staff/StaffScreen.kt +++ b/feature/staff/src/commonMain/kotlin/io/github/droidkaigi/confsched/staff/StaffScreen.kt @@ -1,5 +1,6 @@ package io.github.droidkaigi.confsched.staff +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding @@ -118,7 +119,7 @@ fun StaffScreen( LazyColumn( modifier = Modifier .fillMaxSize() - .padding(padding) + .padding(top = padding.calculateTopPadding()) .testTag(StaffScreenLazyColumnTestTag) .let { if (scrollBehavior != null) { @@ -127,6 +128,7 @@ fun StaffScreen( it } }, + contentPadding = PaddingValues(bottom = padding.calculateBottomPadding()), ) { items(uiState.staff) { staff -> StaffItem(