mirror of
https://github.com/bbara04/Purefin.git
synced 2026-03-31 17:10:08 +02:00
implement season selection logic and update SeriesScreen UI
- Update `SeasonTabs` to handle selection state and provide an `onSelect` callback. - Implement `selectedSeason` state in `SeriesScreen` using `remember` and `mutableStateOf`. - Refactor `SeriesScreen` to display episodes based on the currently selected season. - Adjust spacing and remove redundant styling from `EpisodeCarousel` items. - Clean up unused imports and commented-out code in `SeriesComponents.kt`.
This commit is contained in:
@@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
@@ -116,7 +115,12 @@ internal fun SeriesActionButtons(modifier: Modifier = Modifier) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun SeasonTabs(seasons: List<SeriesSeasonUiModel>, modifier: Modifier = Modifier) {
|
||||
internal fun SeasonTabs(
|
||||
seasons: List<SeriesSeasonUiModel>,
|
||||
selectedSeason: SeriesSeasonUiModel?,
|
||||
modifier: Modifier = Modifier,
|
||||
onSelect: (SeriesSeasonUiModel) -> Unit
|
||||
) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
@@ -124,21 +128,28 @@ internal fun SeasonTabs(seasons: List<SeriesSeasonUiModel>, modifier: Modifier =
|
||||
horizontalArrangement = Arrangement.spacedBy(20.dp)
|
||||
) {
|
||||
seasons.forEach { season ->
|
||||
SeasonTab(name = season.name, isSelected = season.isSelected)
|
||||
SeasonTab(
|
||||
name = season.name,
|
||||
isSelected = season == selectedSeason,
|
||||
modifier = Modifier.clickable { onSelect(season) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SeasonTab(name: String, isSelected: Boolean) {
|
||||
private fun SeasonTab(
|
||||
name: String,
|
||||
isSelected: Boolean,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val scheme = MaterialTheme.colorScheme
|
||||
val mutedStrong = scheme.onSurfaceVariant.copy(alpha = 0.7f)
|
||||
val color = if (isSelected) scheme.primary else mutedStrong
|
||||
val borderColor = if (isSelected) scheme.primary else Color.Transparent
|
||||
Column(
|
||||
modifier = Modifier
|
||||
modifier = modifier
|
||||
.padding(bottom = 8.dp)
|
||||
.clickable { }
|
||||
) {
|
||||
Text(
|
||||
text = name,
|
||||
@@ -160,7 +171,7 @@ private fun SeasonTab(name: String, isSelected: Boolean) {
|
||||
internal fun EpisodeCarousel(episodes: List<SeriesEpisodeUiModel>, modifier: Modifier = Modifier) {
|
||||
LazyRow(
|
||||
modifier = modifier,
|
||||
contentPadding = PaddingValues(horizontal = 20.dp),
|
||||
// contentPadding = PaddingValues(horizontal = 20.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
items(episodes) { episode ->
|
||||
@@ -179,10 +190,6 @@ private fun EpisodeCard(
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.width(260.dp)
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
.background(scheme.surfaceVariant.copy(alpha = 0.6f))
|
||||
.border(1.dp, scheme.outlineVariant, RoundedCornerShape(16.dp))
|
||||
.padding(12.dp)
|
||||
.clickable { viewModel.onSelectEpisode(episode.id) },
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
|
||||
@@ -14,6 +14,8 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
@@ -21,8 +23,8 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import hu.bbara.purefin.app.content.ContentMockData
|
||||
import hu.bbara.purefin.common.ui.PurefinWaitingScreen
|
||||
import hu.bbara.purefin.common.ui.MediaSynopsis
|
||||
import hu.bbara.purefin.common.ui.PurefinWaitingScreen
|
||||
import hu.bbara.purefin.common.ui.components.MediaHero
|
||||
import hu.bbara.purefin.navigation.ItemDto
|
||||
|
||||
@@ -58,6 +60,12 @@ private fun SeriesScreenInternal(
|
||||
val scheme = MaterialTheme.colorScheme
|
||||
val textMutedStrong = scheme.onSurfaceVariant.copy(alpha = 0.7f)
|
||||
|
||||
fun getDefaultSeason() : SeriesSeasonUiModel {
|
||||
// TODO get next next episodes season selected or add logic to it.
|
||||
return series.seasonTabs.first()
|
||||
}
|
||||
val selectedSeason = remember { mutableStateOf<SeriesSeasonUiModel>(getDefaultSeason()) }
|
||||
|
||||
Scaffold(
|
||||
modifier = modifier,
|
||||
containerColor = MaterialTheme.colorScheme.background,
|
||||
@@ -104,22 +112,17 @@ private fun SeriesScreenInternal(
|
||||
bodyLineHeight = null,
|
||||
titleSpacing = 8.dp
|
||||
)
|
||||
Spacer(modifier = Modifier.height(28.dp))
|
||||
Text(
|
||||
text = "Episodes",
|
||||
color = scheme.onBackground,
|
||||
fontSize = 18.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
SeasonTabs(
|
||||
seasons = series.seasonTabs,
|
||||
selectedSeason = selectedSeason.value,
|
||||
onSelect = { selectedSeason.value = it }
|
||||
)
|
||||
Spacer(modifier = Modifier.height(28.dp))
|
||||
SeasonTabs(seasons = series.seasonTabs)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
// Spacer(modifier = Modifier.height(16.dp))
|
||||
EpisodeCarousel(
|
||||
episodes = series.seasonTabs.firstOrNull { it.isSelected }?.episodes
|
||||
?: series.seasonTabs.firstOrNull()?.episodes
|
||||
?: emptyList()
|
||||
episodes = selectedSeason.value.episodes
|
||||
)
|
||||
Spacer(modifier = Modifier.height(32.dp))
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Text(
|
||||
text = "Cast",
|
||||
color = scheme.onBackground,
|
||||
|
||||
Reference in New Issue
Block a user