mirror of
https://github.com/bbara04/Purefin.git
synced 2026-07-23 19:26:50 +00:00
feat: add UnwatchedEpisodeBadge and remove 'started' parameter from WatchStateBadge
This commit is contained in:
@@ -29,12 +29,13 @@ import androidx.compose.ui.text.style.TextOverflow
|
|||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import hu.bbara.purefin.ui.common.badge.WatchStateBadge
|
|
||||||
import hu.bbara.purefin.ui.common.image.PurefinAsyncImage
|
|
||||||
import hu.bbara.purefin.core.model.EpisodeUiModel
|
import hu.bbara.purefin.core.model.EpisodeUiModel
|
||||||
import hu.bbara.purefin.core.model.MediaUiModel
|
import hu.bbara.purefin.core.model.MediaUiModel
|
||||||
import hu.bbara.purefin.core.model.MovieUiModel
|
import hu.bbara.purefin.core.model.MovieUiModel
|
||||||
import hu.bbara.purefin.core.model.SeriesUiModel
|
import hu.bbara.purefin.core.model.SeriesUiModel
|
||||||
|
import hu.bbara.purefin.ui.common.badge.UnwatchedEpisodeBadge
|
||||||
|
import hu.bbara.purefin.ui.common.badge.WatchStateBadge
|
||||||
|
import hu.bbara.purefin.ui.common.image.PurefinAsyncImage
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -134,10 +135,17 @@ fun PosterCardContent(
|
|||||||
.align(Alignment.TopEnd)
|
.align(Alignment.TopEnd)
|
||||||
.padding(indicatorPadding),
|
.padding(indicatorPadding),
|
||||||
watched = model.watched,
|
watched = model.watched,
|
||||||
started = (model.progress ?: 0f) > 0f
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else -> Unit
|
is SeriesUiModel -> {
|
||||||
|
UnwatchedEpisodeBadge(
|
||||||
|
unwatchedCount = model.unwatchedEpisodeCount,
|
||||||
|
size = 26,
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.TopEnd)
|
||||||
|
.padding(indicatorPadding),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Column(
|
Column(
|
||||||
|
|||||||
@@ -304,7 +304,6 @@ private fun TvEpisodeCard(
|
|||||||
} else {
|
} else {
|
||||||
WatchStateBadge(
|
WatchStateBadge(
|
||||||
watched = episode.watched,
|
watched = episode.watched,
|
||||||
started = (episode.progress ?: 0.0) > 0.0,
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.TopEnd)
|
.align(Alignment.TopEnd)
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ fun PosterCardContent(
|
|||||||
.align(Alignment.TopEnd)
|
.align(Alignment.TopEnd)
|
||||||
.padding(indicatorPadding),
|
.padding(indicatorPadding),
|
||||||
watched = model.watched,
|
watched = model.watched,
|
||||||
started = (model.progress ?: 0f) > 0f
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else -> Unit
|
else -> Unit
|
||||||
|
|||||||
@@ -6,13 +6,15 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import hu.bbara.purefin.core.model.EpisodeUiModel
|
||||||
|
import hu.bbara.purefin.core.model.MediaUiModel
|
||||||
|
import hu.bbara.purefin.core.model.MovieUiModel
|
||||||
|
import hu.bbara.purefin.core.model.SeriesUiModel
|
||||||
|
import hu.bbara.purefin.ui.common.badge.UnwatchedEpisodeBadge
|
||||||
import hu.bbara.purefin.ui.common.badge.WatchStateBadge
|
import hu.bbara.purefin.ui.common.badge.WatchStateBadge
|
||||||
import hu.bbara.purefin.ui.common.card.MediaImageCard
|
import hu.bbara.purefin.ui.common.card.MediaImageCard
|
||||||
import hu.bbara.purefin.ui.common.media.homeMediaSharedBoundsSource
|
import hu.bbara.purefin.ui.common.media.homeMediaSharedBoundsSource
|
||||||
import hu.bbara.purefin.ui.common.media.rememberHomeMediaSharedBoundsClick
|
import hu.bbara.purefin.ui.common.media.rememberHomeMediaSharedBoundsClick
|
||||||
import hu.bbara.purefin.core.model.EpisodeUiModel
|
|
||||||
import hu.bbara.purefin.core.model.MediaUiModel
|
|
||||||
import hu.bbara.purefin.core.model.MovieUiModel
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun HomeBrowseCard(
|
internal fun HomeBrowseCard(
|
||||||
@@ -42,10 +44,16 @@ internal fun HomeBrowseCard(
|
|||||||
.align(Alignment.TopEnd)
|
.align(Alignment.TopEnd)
|
||||||
.padding(8.dp),
|
.padding(8.dp),
|
||||||
watched = uiModel.watched,
|
watched = uiModel.watched,
|
||||||
started = (uiModel.progress ?: 0f) > 0f
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else -> Unit
|
is SeriesUiModel -> {
|
||||||
|
UnwatchedEpisodeBadge(
|
||||||
|
unwatchedCount = uiModel.unwatchedEpisodeCount,
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.TopEnd)
|
||||||
|
.padding(8.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import hu.bbara.purefin.core.feature.browse.library.LibraryViewModel
|
import hu.bbara.purefin.core.feature.browse.library.LibraryViewModel
|
||||||
import hu.bbara.purefin.core.navigation.LibraryDto
|
|
||||||
import hu.bbara.purefin.ui.common.badge.WatchStateBadge
|
|
||||||
import hu.bbara.purefin.ui.common.card.MediaImageCard
|
|
||||||
import hu.bbara.purefin.core.model.EpisodeUiModel
|
import hu.bbara.purefin.core.model.EpisodeUiModel
|
||||||
import hu.bbara.purefin.core.model.MediaUiModel
|
import hu.bbara.purefin.core.model.MediaUiModel
|
||||||
import hu.bbara.purefin.core.model.MovieUiModel
|
import hu.bbara.purefin.core.model.MovieUiModel
|
||||||
import hu.bbara.purefin.core.model.SeriesUiModel
|
import hu.bbara.purefin.core.model.SeriesUiModel
|
||||||
|
import hu.bbara.purefin.core.navigation.LibraryDto
|
||||||
|
import hu.bbara.purefin.ui.common.badge.WatchStateBadge
|
||||||
|
import hu.bbara.purefin.ui.common.card.MediaImageCard
|
||||||
import hu.bbara.purefin.ui.screen.library.components.LibraryTopBar
|
import hu.bbara.purefin.ui.screen.library.components.LibraryTopBar
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -98,7 +98,6 @@ internal fun LibraryPosterGrid(
|
|||||||
.align(Alignment.TopEnd)
|
.align(Alignment.TopEnd)
|
||||||
.padding(8.dp),
|
.padding(8.dp),
|
||||||
watched = item.watched,
|
watched = item.watched,
|
||||||
started = (item.progress ?: 0f) > 0f
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else -> Unit
|
else -> Unit
|
||||||
|
|||||||
@@ -59,13 +59,13 @@ import hu.bbara.purefin.core.download.DownloadState
|
|||||||
import hu.bbara.purefin.core.feature.content.series.SeriesViewModel
|
import hu.bbara.purefin.core.feature.content.series.SeriesViewModel
|
||||||
import hu.bbara.purefin.core.image.ArtworkKind
|
import hu.bbara.purefin.core.image.ArtworkKind
|
||||||
import hu.bbara.purefin.core.image.ImageUrlBuilder
|
import hu.bbara.purefin.core.image.ImageUrlBuilder
|
||||||
|
import hu.bbara.purefin.core.navigation.EpisodeDto
|
||||||
|
import hu.bbara.purefin.core.navigation.Route
|
||||||
import hu.bbara.purefin.model.CastMember
|
import hu.bbara.purefin.model.CastMember
|
||||||
import hu.bbara.purefin.model.Episode
|
import hu.bbara.purefin.model.Episode
|
||||||
import hu.bbara.purefin.model.Season
|
import hu.bbara.purefin.model.Season
|
||||||
import hu.bbara.purefin.model.Series
|
import hu.bbara.purefin.model.Series
|
||||||
import hu.bbara.purefin.core.navigation.EpisodeDto
|
|
||||||
import hu.bbara.purefin.navigation.LocalNavigationManager
|
import hu.bbara.purefin.navigation.LocalNavigationManager
|
||||||
import hu.bbara.purefin.core.navigation.Route
|
|
||||||
import hu.bbara.purefin.player.PlayerActivity
|
import hu.bbara.purefin.player.PlayerActivity
|
||||||
import hu.bbara.purefin.ui.common.badge.WatchStateBadge
|
import hu.bbara.purefin.ui.common.badge.WatchStateBadge
|
||||||
import hu.bbara.purefin.ui.common.bar.MediaProgressBar
|
import hu.bbara.purefin.ui.common.bar.MediaProgressBar
|
||||||
@@ -376,7 +376,6 @@ private fun EpisodeCard(
|
|||||||
} else {
|
} else {
|
||||||
WatchStateBadge(
|
WatchStateBadge(
|
||||||
watched = episode.watched,
|
watched = episode.watched,
|
||||||
started = (episode.progress ?: 0.0) > 0.0,
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.TopEnd)
|
.align(Alignment.TopEnd)
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ fun UnwatchedEpisodeBadge(
|
|||||||
unwatchedCount: Int,
|
unwatchedCount: Int,
|
||||||
foregroundColor: Color = MaterialTheme.colorScheme.onPrimary,
|
foregroundColor: Color = MaterialTheme.colorScheme.onPrimary,
|
||||||
backgroundColor: Color = MaterialTheme.colorScheme.primary,
|
backgroundColor: Color = MaterialTheme.colorScheme.primary,
|
||||||
size: Int = 24,
|
size: Int = 28,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
if (unwatchedCount == 0) {
|
if (unwatchedCount == 0) {
|
||||||
@@ -31,16 +31,16 @@ fun UnwatchedEpisodeBadge(
|
|||||||
Box(
|
Box(
|
||||||
contentAlignment = Alignment.Center,
|
contentAlignment = Alignment.Center,
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.border(1.dp, backgroundColor.copy(alpha = 0.8f), CircleShape)
|
.border(1.dp, backgroundColor, CircleShape)
|
||||||
.background(backgroundColor.copy(alpha = 0.8f), CircleShape)
|
.background(backgroundColor, CircleShape)
|
||||||
.size(size.dp)
|
.size(size.dp)
|
||||||
.clip(CircleShape)
|
.clip(CircleShape)
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = if (unwatchedCount > 9) "9+" else unwatchedCount.toString(),
|
text = if (unwatchedCount > 99) "99+" else unwatchedCount.toString(),
|
||||||
color = foregroundColor.copy(alpha = 0.8f),
|
color = foregroundColor,
|
||||||
fontWeight = FontWeight.W900,
|
fontWeight = FontWeight.Bold,
|
||||||
fontSize = 15.sp
|
fontSize = 13.sp
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,42 +22,33 @@ import androidx.compose.ui.unit.dp
|
|||||||
@Composable
|
@Composable
|
||||||
fun WatchStateBadge(
|
fun WatchStateBadge(
|
||||||
watched: Boolean,
|
watched: Boolean,
|
||||||
started: Boolean,
|
|
||||||
watchedColor: Color = MaterialTheme.colorScheme.onPrimary,
|
watchedColor: Color = MaterialTheme.colorScheme.onPrimary,
|
||||||
watchedBackgroundColor: Color = MaterialTheme.colorScheme.primary,
|
watchedBackgroundColor: Color = MaterialTheme.colorScheme.primary,
|
||||||
startedColor: Color = MaterialTheme.colorScheme.onSecondary,
|
|
||||||
startedBackgroundColor: Color = MaterialTheme.colorScheme.secondary,
|
|
||||||
size: Int = 24,
|
size: Int = 24,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
if (!watched && !started) {
|
if (!watched) {
|
||||||
return
|
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(
|
Box(
|
||||||
contentAlignment = Alignment.Center,
|
contentAlignment = Alignment.Center,
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.border(1.dp, borderColor, CircleShape)
|
.border(1.dp, watchedBackgroundColor, CircleShape)
|
||||||
.background(backgroundColor, CircleShape)
|
.background(watchedBackgroundColor, CircleShape)
|
||||||
.size(size.dp)
|
.size(size.dp)
|
||||||
.clip(CircleShape)
|
.clip(CircleShape)
|
||||||
) {
|
) {
|
||||||
if (watched) {
|
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.Check,
|
imageVector = Icons.Outlined.Check,
|
||||||
contentDescription = "Check",
|
contentDescription = "Check",
|
||||||
tint = foregroundColor,
|
tint = watchedColor,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(1.dp)
|
.padding(1.dp)
|
||||||
.matchParentSize()
|
.matchParentSize()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
@@ -65,15 +56,12 @@ private fun WatchStateBadgePreview() {
|
|||||||
Column {
|
Column {
|
||||||
WatchStateBadge(
|
WatchStateBadge(
|
||||||
watched = false,
|
watched = false,
|
||||||
started = false
|
|
||||||
)
|
)
|
||||||
WatchStateBadge(
|
WatchStateBadge(
|
||||||
watched = true,
|
watched = true,
|
||||||
started = false
|
|
||||||
)
|
)
|
||||||
WatchStateBadge(
|
WatchStateBadge(
|
||||||
watched = false,
|
watched = false,
|
||||||
started = true
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user