mirror of
https://github.com/bbara04/Purefin.git
synced 2026-03-31 17:10:08 +02:00
implement playback navigation in MovieScreen
- Add `id` field to `MovieUiModel` and populate it from the Jellyfin item. - Update `PlayButton` in `MovieComponents` to launch `PlayerActivity` with the selected media ID. - Integrate `MovieScreenViewModel` into `PlayButton` to access current movie data via `collectAsState`.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package hu.bbara.purefin.app.content.movie
|
package hu.bbara.purefin.app.content.movie
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
@@ -38,6 +39,7 @@ import androidx.compose.material.icons.outlined.VolumeUp
|
|||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
@@ -46,12 +48,15 @@ import androidx.compose.ui.graphics.Brush
|
|||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
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 androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import coil3.compose.AsyncImage
|
import coil3.compose.AsyncImage
|
||||||
|
import hu.bbara.purefin.player.PlayerActivity
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun MovieTopBar(modifier: Modifier = Modifier) {
|
internal fun MovieTopBar(modifier: Modifier = Modifier) {
|
||||||
@@ -414,14 +419,23 @@ private fun CastRow(cast: List<CastMember>) {
|
|||||||
@Composable
|
@Composable
|
||||||
private fun PlayButton(
|
private fun PlayButton(
|
||||||
size: Dp,
|
size: Dp,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier,
|
||||||
|
viewModel: MovieScreenViewModel = hiltViewModel()
|
||||||
) {
|
) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val movieId = viewModel.movie.collectAsState()
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.size(size)
|
.size(size)
|
||||||
.shadow(24.dp, CircleShape)
|
.shadow(24.dp, CircleShape)
|
||||||
.clip(CircleShape)
|
.clip(CircleShape)
|
||||||
.background(MoviePrimary),
|
.background(MoviePrimary)
|
||||||
|
.clickable{
|
||||||
|
val intent = Intent(context, PlayerActivity::class.java)
|
||||||
|
intent.putExtra("MEDIA_ID", movieId.value!!.id.toString())
|
||||||
|
context.startActivity(intent)
|
||||||
|
},
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package hu.bbara.purefin.app.content.movie
|
package hu.bbara.purefin.app.content.movie
|
||||||
|
|
||||||
|
import org.jellyfin.sdk.model.UUID
|
||||||
|
|
||||||
data class CastMember(
|
data class CastMember(
|
||||||
val name: String,
|
val name: String,
|
||||||
val role: String,
|
val role: String,
|
||||||
@@ -7,6 +9,7 @@ data class CastMember(
|
|||||||
)
|
)
|
||||||
|
|
||||||
data class MovieUiModel(
|
data class MovieUiModel(
|
||||||
|
val id: UUID,
|
||||||
val title: String,
|
val title: String,
|
||||||
val year: String,
|
val year: String,
|
||||||
val rating: String,
|
val rating: String,
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class MovieScreenViewModel @Inject constructor(
|
|||||||
} ?: ""
|
} ?: ""
|
||||||
val cast = people.orEmpty().map { it.toCastMember() }
|
val cast = people.orEmpty().map { it.toCastMember() }
|
||||||
return MovieUiModel(
|
return MovieUiModel(
|
||||||
|
id = id,
|
||||||
title = name ?: "Unknown title",
|
title = name ?: "Unknown title",
|
||||||
year = year,
|
year = year,
|
||||||
rating = rating,
|
rating = rating,
|
||||||
|
|||||||
Reference in New Issue
Block a user