Skip to content

Commit

Permalink
Merge pull request DroidKaigi#524 from ked4ma/feature/bottom-nav-area…
Browse files Browse the repository at this point in the history
…-471

Enable to show contents under the bottom nav bar
  • Loading branch information
takahirom authored Aug 16, 2024
2 parents 30b7d01 + f97946f commit aeb7bee
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -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(),
)
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -148,9 +150,11 @@ private fun Contributors(
contributors: PersistentList<Contributor>,
onContributorsItemClick: (url: String) -> Unit,
modifier: Modifier = Modifier,
contentPadding: PaddingValues = PaddingValues(),
) {
LazyColumn(
modifier = modifier,
contentPadding = contentPadding,
) {
items(contributors) {
ContributorsItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
)
}
Expand All @@ -130,11 +134,12 @@ private fun EventMap(
eventMapEvents: PersistentList<EventMapEvent>,
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fun SearchScreen(
containerColor = MaterialTheme.colorScheme.surface,
) { innerPadding ->
Column(
modifier = Modifier.padding(innerPadding),
modifier = Modifier.padding(top = innerPadding.calculateTopPadding()),
) {
HorizontalDivider()
SearchFilters(
Expand Down Expand Up @@ -176,6 +176,7 @@ fun SearchScreen(
highlightWord = uiState.searchWord,
onBookmarkClick = { timetableItem, _ -> onTimetableItemBookmark(timetableItem) },
onTimetableItemClick = onTimetableItemClick,
contentPadding = PaddingValues(bottom = innerPadding.calculateBottomPadding()),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,33 +29,33 @@ 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

@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)
} else {
it
}
},
contentPadding = PaddingValues(horizontal = 12.dp),
contentPadding = contentPadding + PaddingValues(horizontal = 12.dp),
) {
item(span = { GridItemSpan(maxLineSpan) }) {
SponsorHeader(
Expand Down Expand Up @@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -118,7 +119,7 @@ fun StaffScreen(
LazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(padding)
.padding(top = padding.calculateTopPadding())
.testTag(StaffScreenLazyColumnTestTag)
.let {
if (scrollBehavior != null) {
Expand All @@ -127,6 +128,7 @@ fun StaffScreen(
it
}
},
contentPadding = PaddingValues(bottom = padding.calculateBottomPadding()),
) {
items(uiState.staff) { staff ->
StaffItem(
Expand Down

0 comments on commit aeb7bee

Please sign in to comment.