implement click handling for "Continue Watching" items

- Add `BaseItemKind` type to `ContinueWatchingItem` model.
- Update `HomePageViewModel` to populate the item type.
- Implement click logic in `HomeSections` to navigate to movie or series details based on the item type.
This commit is contained in:
2026-01-18 14:38:05 +01:00
parent ae02536ac6
commit aa00748923
3 changed files with 18 additions and 2 deletions

View File

@@ -69,6 +69,7 @@ class HomePageViewModel @Inject constructor(
if (it.type == BaseItemKind.EPISODE) {
ContinueWatchingItem(
id = it.id,
type = BaseItemKind.EPISODE,
primaryText = it.seriesName!!,
secondaryText = it.name!!,
progress = it.userData!!.playedPercentage!!,
@@ -77,6 +78,7 @@ class HomePageViewModel @Inject constructor(
} else {
ContinueWatchingItem(
id = it.id,
type = BaseItemKind.MOVIE,
primaryText = it.name!!,
secondaryText = it.premiereDate!!.format(DateTimeFormatter.ofLocalizedDate(
FormatStyle.MEDIUM)),

View File

@@ -7,6 +7,7 @@ import org.jellyfin.sdk.model.api.BaseItemKind
data class ContinueWatchingItem(
val id: UUID,
val type: BaseItemKind,
val primaryText: String,
val secondaryText: String,
val progress: Double,

View File

@@ -78,9 +78,18 @@ fun ContinueWatchingCard(
item: ContinueWatchingItem,
colors: HomeColors,
modifier: Modifier = Modifier,
viewModel: HomePageViewModel = hiltViewModel()
) {
val context = LocalContext.current
fun openItem(item: ContinueWatchingItem) {
when (item.type) {
BaseItemKind.MOVIE -> viewModel.onMovieSelected(item.id.toString())
BaseItemKind.EPISODE -> viewModel.onSeriesSelected(item.id.toString())
else -> {}
}
}
Column(
modifier = modifier
.width(280.dp)
@@ -100,8 +109,12 @@ fun ContinueWatchingCard(
type = ImageType.PRIMARY
),
contentDescription = null,
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop
modifier = Modifier.fillMaxSize()
.clickable {
openItem(item)
},
contentScale = ContentScale.Crop,
)
Box(
modifier = Modifier