fix padding of trending tabs on home screen

This commit is contained in:
Owen LeJeune
2023-06-29 13:08:24 -04:00
parent c2b65ffd2f
commit 859ab14d95
2 changed files with 32 additions and 25 deletions

View File

@@ -7,6 +7,7 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.focusable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyGridItemScope
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
@@ -57,6 +58,7 @@ private val POSTER_HEIGHT = 180.dp
fun PagingPosterGrid(
modifier: Modifier = Modifier,
lazyPagingItems: LazyPagingItems<TmdbItem>?,
header: @Composable (LazyGridItemScope.() -> Unit)? = null,
onClick: (id: Int) -> Unit = {}
) {
lazyPagingItems?.let {
@@ -66,6 +68,9 @@ fun PagingPosterGrid(
contentPadding = PaddingValues(8.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
header?.let {
header(header)
}
lazyPagingItems(
lazyPagingItems = lazyPagingItems,
key = { i -> it[i]!!.id }

View File

@@ -99,33 +99,35 @@ fun MediaTabTrendingContent(
val mediaListItems = flow.value.collectAsLazyPagingItems()
Column {
Row(
horizontalArrangement = Arrangement.spacedBy(12.dp),
modifier = Modifier.padding(all = 12.dp)
) {
SelectableTextChip(
selected = timeWindow.value == TimeWindow.DAY,
onSelected = { timeWindow.value = TimeWindow.DAY },
text = stringResource(id = R.string.time_window_day),
modifier = Modifier.weight(1f)
)
SelectableTextChip(
selected = timeWindow.value == TimeWindow.WEEK,
onSelected = { timeWindow.value = TimeWindow.WEEK },
text = stringResource(id = R.string.time_window_week),
modifier = Modifier.weight(1f)
)
}
PagingPosterGrid(
lazyPagingItems = mediaListItems,
onClick = { id ->
appNavController.navigate(
AppNavItem.DetailView.withArgs(mediaType, id)
PagingPosterGrid(
lazyPagingItems = mediaListItems,
header = {
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier
.padding(horizontal = 4.dp)
.padding(bottom = 4.dp)
) {
SelectableTextChip(
selected = timeWindow.value == TimeWindow.DAY,
onSelected = { timeWindow.value = TimeWindow.DAY },
text = stringResource(id = R.string.time_window_day),
modifier = Modifier.weight(1f)
)
SelectableTextChip(
selected = timeWindow.value == TimeWindow.WEEK,
onSelected = { timeWindow.value = TimeWindow.WEEK },
text = stringResource(id = R.string.time_window_week),
modifier = Modifier.weight(1f)
)
}
)
}
},
onClick = { id ->
appNavController.navigate(
AppNavItem.DetailView.withArgs(mediaType, id)
)
}
)
}
@OptIn(ExperimentalPagerApi::class)