mirror of
https://github.com/bbara04/Purefin.git
synced 2026-03-31 17:10:08 +02:00
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:
@@ -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)),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user