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

View File

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