mirror of
https://github.com/bbara04/Purefin.git
synced 2026-03-31 17:10:08 +02:00
feat: enhance WatchStateIndicator to include started state and update usage in SeriesComponents
This commit is contained in:
@@ -256,14 +256,14 @@ private fun EpisodeCard(
|
||||
)
|
||||
}
|
||||
WatchStateIndicator(
|
||||
episode.watched,
|
||||
watched = episode.watched,
|
||||
started = (episode.progress ?: 0.0) > 0.0,
|
||||
modifier = Modifier
|
||||
.align(Alignment.TopEnd)
|
||||
.padding(8.dp)
|
||||
)
|
||||
}
|
||||
Column(
|
||||
//verticalArrangement = Arrangement.spacedBy(2.dp)
|
||||
) {
|
||||
Text(
|
||||
text = episode.title,
|
||||
|
||||
@@ -66,7 +66,11 @@ data class PosterItem(
|
||||
BaseItemKind.SERIES -> series!!.heroImageUrl
|
||||
else -> throw IllegalArgumentException("Invalid type: $type")
|
||||
}
|
||||
|
||||
fun watched() = when (type) {
|
||||
BaseItemKind.MOVIE -> movie!!.watched
|
||||
BaseItemKind.EPISODE -> episode!!.watched
|
||||
else -> throw IllegalArgumentException("Invalid type: $type")
|
||||
}
|
||||
}
|
||||
|
||||
data class HomeNavItem(
|
||||
|
||||
@@ -22,16 +22,22 @@ import androidx.compose.ui.unit.dp
|
||||
@Composable
|
||||
fun WatchStateIndicator(
|
||||
watched: Boolean,
|
||||
started: Boolean,
|
||||
watchedColor: Color = MaterialTheme.colorScheme.onPrimary,
|
||||
watchedBackgroundColor: Color = MaterialTheme.colorScheme.primary,
|
||||
unwatchedColor: Color = MaterialTheme.colorScheme.onSecondary,
|
||||
unwatchedBackgroundColor: Color = MaterialTheme.colorScheme.secondary,
|
||||
startedColor: Color = MaterialTheme.colorScheme.onSecondary,
|
||||
startedBackgroundColor: Color = MaterialTheme.colorScheme.secondary,
|
||||
size: Int = 24,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val foregroundColor = if (watched) watchedColor.copy(alpha = 0.8f) else unwatchedColor.copy(alpha = 0.3f)
|
||||
val backgroundColor = if (watched) watchedBackgroundColor.copy(alpha = 0.8f) else unwatchedBackgroundColor.copy(alpha = 0.3f)
|
||||
val borderColor = if (watched) watchedBackgroundColor.copy(alpha = 0.8f) else unwatchedBackgroundColor.copy(alpha = 0.8f)
|
||||
|
||||
if (watched.not() && started.not()) {
|
||||
return
|
||||
}
|
||||
|
||||
val foregroundColor = if (watched) watchedColor.copy(alpha = 0.8f) else startedColor.copy(alpha = 0.3f)
|
||||
val backgroundColor = if (watched) watchedBackgroundColor.copy(alpha = 0.8f) else startedBackgroundColor.copy(alpha = 0.3f)
|
||||
val borderColor = if (watched) watchedBackgroundColor.copy(alpha = 0.8f) else startedBackgroundColor.copy(alpha = 0.8f)
|
||||
|
||||
|
||||
Box(
|
||||
@@ -61,9 +67,15 @@ private fun WatchStateIndicatorPreview() {
|
||||
Column() {
|
||||
WatchStateIndicator(
|
||||
watched = false,
|
||||
started = false
|
||||
)
|
||||
WatchStateIndicator(
|
||||
watched = true,
|
||||
started = false
|
||||
)
|
||||
WatchStateIndicator(
|
||||
watched = false,
|
||||
started = true
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user