From aa007489232df9ebc77f7471de8a72836182312f Mon Sep 17 00:00:00 2001 From: Barnabas Balogh Date: Sun, 18 Jan 2026 14:38:05 +0100 Subject: [PATCH] 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. --- .../bbara/purefin/app/home/HomePageViewModel.kt | 2 ++ .../hu/bbara/purefin/app/home/ui/HomeModels.kt | 1 + .../bbara/purefin/app/home/ui/HomeSections.kt | 17 +++++++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/hu/bbara/purefin/app/home/HomePageViewModel.kt b/app/src/main/java/hu/bbara/purefin/app/home/HomePageViewModel.kt index e0b601e..a42f3a3 100644 --- a/app/src/main/java/hu/bbara/purefin/app/home/HomePageViewModel.kt +++ b/app/src/main/java/hu/bbara/purefin/app/home/HomePageViewModel.kt @@ -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)), diff --git a/app/src/main/java/hu/bbara/purefin/app/home/ui/HomeModels.kt b/app/src/main/java/hu/bbara/purefin/app/home/ui/HomeModels.kt index c6e8d18..bd06d86 100644 --- a/app/src/main/java/hu/bbara/purefin/app/home/ui/HomeModels.kt +++ b/app/src/main/java/hu/bbara/purefin/app/home/ui/HomeModels.kt @@ -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, diff --git a/app/src/main/java/hu/bbara/purefin/app/home/ui/HomeSections.kt b/app/src/main/java/hu/bbara/purefin/app/home/ui/HomeSections.kt index 486128b..98d8344 100644 --- a/app/src/main/java/hu/bbara/purefin/app/home/ui/HomeSections.kt +++ b/app/src/main/java/hu/bbara/purefin/app/home/ui/HomeSections.kt @@ -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