Skip to content

Commit

Permalink
Merge pull request #156 from chikoski/main
Browse files Browse the repository at this point in the history
Replacement of spacers in LazyLists and LazyGrids
  • Loading branch information
chikoski authored Mar 22, 2024
2 parents b6abbe2 + 319ef9e commit 2b4fc33
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 41 deletions.
25 changes: 12 additions & 13 deletions JetStreamCompose/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
[versions]
activity-compose = "1.8.2"
android-gradle-plugin = "8.2.1"
android-test-plugin = "8.2.1"
benchmark-macro-junit4 = "1.2.2"
android-gradle-plugin = "8.2.2"
android-test-plugin = "8.2.2"
benchmark-macro-junit4 = "1.2.3"
coil-compose = "2.5.0"
compose-bom = "2023.10.01"
compose-bom = "2024.03.00"
compose-for-tv = "1.0.0-alpha10"
compose-ui = "1.6.0-rc01"
core-ktx = "1.12.0"
core-splashscreen = "1.0.1"
hilt-navigation-compose = "1.1.0"
hilt-android = "2.48.1"
hilt-navigation-compose = "1.2.0"
hilt-android = "2.51"
junit = "1.1.5"
kotlin-android = "1.9.0"
kotlinx-serialization = "1.6.0"
ksp = "1.9.0-1.0.13"
lifecycle-runtime-ktx = "2.7.0"
media3-ui = "1.2.1"
media3-exoplayer = "1.2.1"
navigation-compose = "2.7.6"
media3-ui = "1.3.0"
media3-exoplayer = "1.3.0"
navigation-compose = "2.7.7"
profileinstaller = "1.3.1"
uiautomator = "2.2.0"
uiautomator = "2.3.0"

[libraries]
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activity-compose" }
androidx-benchmark-macro-junit4 = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "benchmark-macro-junit4" }
androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "compose-bom" }
androidx-compose-ui-base = { module = "androidx.compose.ui:ui", version.ref = "compose-ui" }
androidx-compose-ui-base = { module = "androidx.compose.ui:ui" }
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose-ui" }
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "core-ktx" }
androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "core-splashscreen" }
androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "hilt-navigation-compose" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
Expand Down Expand Up @@ -188,10 +187,10 @@ fun ImmersiveListScope.ImmersiveListMoviesRow(
) { movieState ->
TvLazyRow(
modifier = Modifier.focusRestorer(),
pivotOffsets = PivotOffsets(parentFraction = 0.07f)
pivotOffsets = PivotOffsets(parentFraction = 0.07f),
contentPadding = PaddingValues(start = startPadding, end = endPadding),
horizontalArrangement = Arrangement.spacedBy(20.dp)
) {
item { Spacer(modifier = Modifier.padding(start = startPadding)) }

movieState.forEachIndexed { index, movie ->
item {
key(movie.id) {
Expand All @@ -209,10 +208,7 @@ fun ImmersiveListScope.ImmersiveListMoviesRow(
)
}
}
item { Spacer(modifier = Modifier.padding(end = 20.dp)) }
}

item { Spacer(modifier = Modifier.padding(start = endPadding)) }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.google.jetstream.presentation.screens.categories
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
Expand All @@ -37,7 +37,6 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.tv.foundation.lazy.grid.TvGridCells
import androidx.tv.foundation.lazy.grid.TvGridItemSpan
import androidx.tv.foundation.lazy.grid.TvLazyVerticalGrid
import androidx.tv.material3.Border
import androidx.tv.material3.CardDefaults
Expand Down Expand Up @@ -73,9 +72,11 @@ fun CategoryMovieListScreen(
is CategoryMovieListScreenUiState.Loading -> {
Loading()
}

is CategoryMovieListScreenUiState.Error -> {
Error()
}

is CategoryMovieListScreenUiState.Done -> {
val categoryDetails = s.movieCategoryDetails
CategoryDetails(
Expand Down Expand Up @@ -115,7 +116,8 @@ private fun CategoryDetails(
)
)
TvLazyVerticalGrid(
columns = TvGridCells.Fixed(6)
columns = TvGridCells.Fixed(6),
contentPadding = PaddingValues(bottom = JetStreamBottomListPadding)
) {
categoryDetails.movies.forEachIndexed { index, movie ->
item {
Expand Down Expand Up @@ -171,9 +173,6 @@ private fun CategoryDetails(
}
}
}
item(span = { TvGridItemSpan(currentLineSpan = 6) }) {
Spacer(modifier = Modifier.padding(bottom = JetStreamBottomListPadding))
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
Expand Down Expand Up @@ -57,7 +57,7 @@ fun CastAndCrewList(castAndCrew: List<MovieCast>) {
val childPadding = rememberChildPadding()

Column(
modifier = Modifier.padding(top = childPadding.top)
modifier = Modifier.padding(top = childPadding.top),
) {
Text(
text = stringResource(R.string.cast_and_crew),
Expand All @@ -72,10 +72,9 @@ fun CastAndCrewList(castAndCrew: List<MovieCast>) {
.focusRestorer(),
pivotOffsets = PivotOffsets(
parentFraction = 0.07f
)
),
contentPadding = PaddingValues(start = childPadding.start)
) {
item { Spacer(modifier = Modifier.padding(start = childPadding.start)) }

items(castAndCrew, key = { it.id }) {
CastAndCrewItem(it, modifier = Modifier.width(144.dp))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.google.jetstream.presentation.screens.movies

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -90,11 +89,8 @@ private fun Catalog(
TvLazyColumn(
modifier = modifier,
state = tvLazyListState,
contentPadding = PaddingValues(bottom = 104.dp)
contentPadding = PaddingValues(top = childPadding.top, bottom = 104.dp)
) {
item {
Spacer(modifier = Modifier.padding(top = childPadding.top))
}
item {
MoviesScreenMovieList(
movieList = movieList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.google.jetstream.presentation.screens.shows

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -94,11 +93,8 @@ private fun Catalog(
TvLazyColumn(
modifier = modifier,
state = tvLazyListState,
contentPadding = PaddingValues(bottom = 104.dp)
contentPadding = PaddingValues(top = childPadding.top, bottom = 104.dp)
) {
item {
Spacer(modifier = Modifier.padding(top = childPadding.top))
}
item {
MoviesScreenMovieList(
movieList = tvShowList,
Expand Down

0 comments on commit 2b4fc33

Please sign in to comment.