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) {
|
if (it.type == BaseItemKind.EPISODE) {
|
||||||
ContinueWatchingItem(
|
ContinueWatchingItem(
|
||||||
id = it.id,
|
id = it.id,
|
||||||
|
type = BaseItemKind.EPISODE,
|
||||||
primaryText = it.seriesName!!,
|
primaryText = it.seriesName!!,
|
||||||
secondaryText = it.name!!,
|
secondaryText = it.name!!,
|
||||||
progress = it.userData!!.playedPercentage!!,
|
progress = it.userData!!.playedPercentage!!,
|
||||||
@@ -77,6 +78,7 @@ class HomePageViewModel @Inject constructor(
|
|||||||
} else {
|
} else {
|
||||||
ContinueWatchingItem(
|
ContinueWatchingItem(
|
||||||
id = it.id,
|
id = it.id,
|
||||||
|
type = BaseItemKind.MOVIE,
|
||||||
primaryText = it.name!!,
|
primaryText = it.name!!,
|
||||||
secondaryText = it.premiereDate!!.format(DateTimeFormatter.ofLocalizedDate(
|
secondaryText = it.premiereDate!!.format(DateTimeFormatter.ofLocalizedDate(
|
||||||
FormatStyle.MEDIUM)),
|
FormatStyle.MEDIUM)),
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.jellyfin.sdk.model.api.BaseItemKind
|
|||||||
|
|
||||||
data class ContinueWatchingItem(
|
data class ContinueWatchingItem(
|
||||||
val id: UUID,
|
val id: UUID,
|
||||||
|
val type: BaseItemKind,
|
||||||
val primaryText: String,
|
val primaryText: String,
|
||||||
val secondaryText: String,
|
val secondaryText: String,
|
||||||
val progress: Double,
|
val progress: Double,
|
||||||
|
|||||||
@@ -78,9 +78,18 @@ fun ContinueWatchingCard(
|
|||||||
item: ContinueWatchingItem,
|
item: ContinueWatchingItem,
|
||||||
colors: HomeColors,
|
colors: HomeColors,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
viewModel: HomePageViewModel = hiltViewModel()
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
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(
|
Column(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.width(280.dp)
|
.width(280.dp)
|
||||||
@@ -100,8 +109,12 @@ fun ContinueWatchingCard(
|
|||||||
type = ImageType.PRIMARY
|
type = ImageType.PRIMARY
|
||||||
),
|
),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize()
|
||||||
contentScale = ContentScale.Crop
|
.clickable {
|
||||||
|
openItem(item)
|
||||||
|
},
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
|
||||||
)
|
)
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
Reference in New Issue
Block a user