package tv.tivilux.nativeplayer.ui.screens import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.remember import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import coil.compose.AsyncImage import tv.tivilux.nativeplayer.model.MovieDetail import tv.tivilux.nativeplayer.ui.components.LuxButton import tv.tivilux.nativeplayer.ui.theme.LuxGold import tv.tivilux.nativeplayer.ui.theme.LuxLine import tv.tivilux.nativeplayer.ui.theme.LuxMuted import tv.tivilux.nativeplayer.ui.theme.LuxPanel2 import tv.tivilux.nativeplayer.ui.theme.LuxText @Composable fun MovieDetailScreen( detail: MovieDetail?, isFavorite: Boolean, resumePositionMs: Long = 0L, onBack: () -> Unit, onPlay: () -> Unit, onFavorite: () -> Unit, ) { if (detail == null) return val movie = detail.movie val playFocus = remember(movie.id) { FocusRequester() } LaunchedEffect(movie.id) { playFocus.requestFocus() } Box(Modifier.fillMaxSize().background(Color(0xFF090B10))) { val background = detail.backdrop.ifBlank { movie.image } if (background.isNotBlank()) { AsyncImage( model = background, contentDescription = movie.name, modifier = Modifier.fillMaxSize(), contentScale = ContentScale.Crop, alpha = .44f, ) } Box( Modifier.fillMaxSize().background( Brush.horizontalGradient( listOf(Color(0xFF090B10), Color(0xE8090B10), Color(0x5C090B10), Color(0xEF090B10)) ) ) ) Box( Modifier.fillMaxSize().background( Brush.verticalGradient(listOf(Color.Transparent, Color(0xFF090B10)), startY = 220f) ) ) Row( Modifier.fillMaxSize().padding(horizontal = 34.dp, vertical = 28.dp), horizontalArrangement = Arrangement.spacedBy(28.dp), verticalAlignment = Alignment.CenterVertically, ) { Box( Modifier.width(255.dp).height(378.dp) .background(LuxPanel2, RoundedCornerShape(18.dp)) .border(1.dp, LuxLine, RoundedCornerShape(18.dp)) ) { AsyncImage( model = movie.image, contentDescription = movie.name, modifier = Modifier.fillMaxSize(), contentScale = ContentScale.Crop, ) } Column(Modifier.weight(1f).fillMaxHeight(), verticalArrangement = Arrangement.Center) { Text("MOVIE", color = LuxGold, fontSize = 10.sp, fontWeight = FontWeight.Bold, letterSpacing = 1.8.sp) Text(movie.name, color = LuxText, fontSize = 40.sp, lineHeight = 44.sp, fontWeight = FontWeight.SemiBold, maxLines = 2, overflow = TextOverflow.Ellipsis) Spacer(Modifier.height(8.dp)) val meta = listOf( detail.releaseDate.ifBlank { movie.year }.take(4), detail.duration, detail.genre, detail.rating.takeIf { it.isNotBlank() }?.let { "★ $it" }.orEmpty(), ).filter { it.isNotBlank() }.joinToString(" • ") if (meta.isNotBlank()) Text(meta, color = LuxGold, fontSize = 13.sp, fontWeight = FontWeight.SemiBold) if (detail.plot.isNotBlank()) { Spacer(Modifier.height(14.dp)) Text( detail.plot, color = LuxText.copy(alpha = .88f), fontSize = 14.sp, lineHeight = 21.sp, modifier = Modifier.fillMaxWidth(.85f), maxLines = 5, overflow = TextOverflow.Ellipsis, ) } if (detail.cast.isNotBlank()) { Spacer(Modifier.height(12.dp)) Text("Cast ${detail.cast}", color = LuxMuted, fontSize = 11.sp, maxLines = 2, overflow = TextOverflow.Ellipsis) } if (detail.director.isNotBlank()) { Text("Director ${detail.director}", color = LuxMuted, fontSize = 11.sp, maxLines = 1, overflow = TextOverflow.Ellipsis) } Spacer(Modifier.height(24.dp)) Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) { LuxButton(if (resumePositionMs >= 60_000L) "RESUME" else "PLAY", onPlay, primary = true, focusRequester = playFocus, illuminateOnFocus = true) LuxButton(if (isFavorite) "MY LIST" else "ADD TO MY LIST", onFavorite) LuxButton("BACK", onBack) } } } } }