feat: add WatchStateIndicator component to display episode watch status in SeriesScreen

This commit is contained in:
2026-02-04 10:02:02 +01:00
parent 88b34c4780
commit d5027047ce
2 changed files with 76 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ import hu.bbara.purefin.common.ui.MediaMetaChip
import hu.bbara.purefin.common.ui.components.GhostIconButton import hu.bbara.purefin.common.ui.components.GhostIconButton
import hu.bbara.purefin.common.ui.components.MediaActionButton import hu.bbara.purefin.common.ui.components.MediaActionButton
import hu.bbara.purefin.common.ui.components.PurefinAsyncImage import hu.bbara.purefin.common.ui.components.PurefinAsyncImage
import hu.bbara.purefin.common.ui.components.WatchStateIndicator
import hu.bbara.purefin.data.model.CastMember import hu.bbara.purefin.data.model.CastMember
import hu.bbara.purefin.data.model.Episode import hu.bbara.purefin.data.model.Episode
import hu.bbara.purefin.data.model.Season import hu.bbara.purefin.data.model.Season
@@ -254,6 +255,12 @@ private fun EpisodeCard(
fontWeight = FontWeight.Bold fontWeight = FontWeight.Bold
) )
} }
WatchStateIndicator(
episode.watched,
modifier = Modifier
.align(Alignment.TopEnd)
.padding(8.dp)
)
} }
Column( Column(
//verticalArrangement = Arrangement.spacedBy(2.dp) //verticalArrangement = Arrangement.spacedBy(2.dp)

View File

@@ -0,0 +1,69 @@
package hu.bbara.purefin.common.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Check
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
@Composable
fun WatchStateIndicator(
watched: Boolean,
watchedColor: Color = MaterialTheme.colorScheme.onPrimary,
watchedBackgroundColor: Color = MaterialTheme.colorScheme.primary,
unwatchedColor: Color = MaterialTheme.colorScheme.onSecondary,
unwatchedBackgroundColor: 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)
Box(
contentAlignment = Alignment.Center,
modifier = modifier
.border(1.dp, borderColor, CircleShape)
.background(backgroundColor, CircleShape)
.size(size.dp)
.clip(CircleShape)
) {
if (watched) {
Icon(
imageVector = Icons.Outlined.Check,
contentDescription = "Check",
tint = foregroundColor,
modifier = Modifier
.padding(1.dp)
.matchParentSize()
)
}
}
}
@Preview
@Composable
private fun WatchStateIndicatorPreview() {
Column() {
WatchStateIndicator(
watched = false,
)
WatchStateIndicator(
watched = true,
)
}
}