package tv.tivilux.nativeplayer.ui.screens import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.focusable import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.scale import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.focus.onFocusChanged import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.input.key.Key import androidx.compose.ui.input.key.KeyEventType import androidx.compose.ui.input.key.key import androidx.compose.ui.input.key.onPreviewKeyEvent import androidx.compose.ui.input.key.type import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.painterResource 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 androidx.compose.ui.window.Dialog import coil.compose.AsyncImage import kotlinx.coroutines.Job import kotlinx.coroutines.delay import kotlinx.coroutines.launch import tv.tivilux.nativeplayer.AppScreen import tv.tivilux.nativeplayer.R import tv.tivilux.nativeplayer.model.HouseholdProfile import tv.tivilux.nativeplayer.model.MediaEntry import tv.tivilux.nativeplayer.model.PlaybackProgress import tv.tivilux.nativeplayer.model.SessionInfo import tv.tivilux.nativeplayer.ui.components.LuxButton import tv.tivilux.nativeplayer.ui.theme.LuxGold import tv.tivilux.nativeplayer.ui.theme.LuxGreen import tv.tivilux.nativeplayer.ui.theme.LuxLine import tv.tivilux.nativeplayer.ui.theme.LuxMuted import tv.tivilux.nativeplayer.ui.theme.LuxPanel import tv.tivilux.nativeplayer.ui.theme.LuxPanel2 import tv.tivilux.nativeplayer.ui.theme.LuxText import java.text.SimpleDateFormat import java.util.Date import java.util.Locale // One-line emergency rollback. The GOLDEN HomeScreen remains compiled in the same APK source. internal const val TIVILUX_HOME_NEXT_ENABLED = true /** * TiviLux NEXT home shell. * * IMPORTANT: this screen is presentation-only. It intentionally receives the exact same data and * callbacks as the proven HomeScreen and never creates a player, fetches provider data, or mutates * Xtream/EPG state. HomeScreen.kt remains in the project as an instant fallback. */ @Composable fun HomeScreenV2( session: SessionInfo?, activeProfile: HouseholdProfile, profilesCount: Int, lastPlayed: MediaEntry?, continueWatching: List, sportsLiveCount: Int, sportsChannelCount: Int, sportsScanning: Boolean, sportsBackgroundLoading: Boolean, sportsBackgroundCategory: String, sportsBackgroundReady: Boolean, onNavigate: (AppScreen) -> Unit, onResume: (MediaEntry) -> Unit, onContinue: (PlaybackProgress) -> Unit, onRemoveContinue: (PlaybackProgress) -> Unit, onProfiles: () -> Unit, onLastChannel: () -> Unit, onRefreshGuide: ((Boolean) -> Unit) -> Unit, ) { if (!TIVILUX_HOME_NEXT_ENABLED) { HomeScreen( session = session, activeProfile = activeProfile, profilesCount = profilesCount, lastPlayed = lastPlayed, continueWatching = continueWatching, sportsLiveCount = sportsLiveCount, sportsChannelCount = sportsChannelCount, sportsScanning = sportsScanning, sportsBackgroundLoading = sportsBackgroundLoading, sportsBackgroundCategory = sportsBackgroundCategory, sportsBackgroundReady = sportsBackgroundReady, onNavigate = onNavigate, onResume = onResume, onContinue = onContinue, onRemoveContinue = onRemoveContinue, onProfiles = onProfiles, ) return } var clockMs by remember { mutableStateOf(System.currentTimeMillis()) } var removeCandidate by remember { mutableStateOf(null) } var showEmptyContinueDialog by remember { mutableStateOf(false) } var guideRefreshState by remember { mutableStateOf(null) } LaunchedEffect(Unit) { while (true) { delay(60_000) clockMs = System.currentTimeMillis() } } val firstContinue = continueWatching.firstOrNull() // Never put an unrelated movie/channel image behind a live-sports hero. When sports is live, // the hero uses the premium TiviLux gradient treatment; otherwise it can use current VOD art. val heroImage = if (sportsLiveCount > 0) "" else ( firstContinue?.item?.image?.takeIf { it.isNotBlank() } ?: lastPlayed?.image?.takeIf { it.isNotBlank() } ?: "" ) val heroTitle: String val heroKicker: String val heroDescription: String val heroAction: String val heroClick: () -> Unit when { sportsLiveCount > 0 -> { heroKicker = "TIVILUX SPORTS ZONE" heroTitle = "$sportsLiveCount LIVE ${if (sportsLiveCount == 1) "GAME" else "GAMES"} RIGHT NOW" heroDescription = "$sportsChannelCount matched provider feeds are ready. Open Game Center for live scores, matchups and alternate feeds." heroAction = "WATCH LIVE SPORTS" heroClick = { onNavigate(AppScreen.SPORTS) } } firstContinue != null -> { heroKicker = "CONTINUE WATCHING" heroTitle = firstContinue.item.seriesName.ifBlank { firstContinue.item.name } heroDescription = if (firstContinue.item.season > 0 && firstContinue.item.episodeNumber > 0) { "S${firstContinue.item.season} E${firstContinue.item.episodeNumber} • ${firstContinue.item.name}" } else { "Pick up exactly where you left off on ${activeProfile.name}'s profile." } heroAction = "CONTINUE" heroClick = { onContinue(firstContinue) } } lastPlayed != null -> { heroKicker = "WELCOME BACK" heroTitle = lastPlayed.name heroDescription = "Resume your most recent channel or jump into the rest of TiviLux." heroAction = "RESUME" heroClick = { onResume(lastPlayed) } } else -> { heroKicker = "TIVILUX PREMIUM TELEVISION" heroTitle = "YOUR NIGHT STARTS HERE" heroDescription = "Live TV, sports, movies, series, favorites and MultiView — built for the big screen." heroAction = "WATCH LIVE TV" heroClick = { onNavigate(AppScreen.LIVE) } } } // Build 85: full-width TV dashboard. Home navigation lives in the tiles, so the permanent // sidebar is intentionally hidden on Home only. No player/EPG/provider behavior is changed. BoxWithConstraints(Modifier.fillMaxSize()) { val compact = maxHeight < 700.dp val gap = if (compact) 9.dp else 13.dp val outerH = if (compact) 22.dp else 34.dp val outerV = if (compact) 14.dp else 22.dp val headerHeight = if (compact) 48.dp else 62.dp val featureHeight = if (compact) 245.dp else 330.dp val tileHeight = if (compact) 92.dp else 122.dp Column( Modifier.fillMaxSize().padding(horizontal = outerH, vertical = outerV), verticalArrangement = Arrangement.spacedBy(gap), ) { Row( Modifier.fillMaxWidth().height(headerHeight), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically, ) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(18.dp)) { Image( painter = painterResource(R.drawable.tivilux_wordmark), contentDescription = "TiviLux", modifier = Modifier.width(if (compact) 150.dp else 190.dp).fillMaxHeight(), ) Text("PREMIUM TV", color = LuxMuted, fontSize = 8.sp, letterSpacing = 2.4.sp) } Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(18.dp)) { Column(horizontalAlignment = Alignment.End) { Text(formatClockV2(clockMs), color = LuxText, fontSize = if (compact) 16.sp else 20.sp, fontWeight = FontWeight.SemiBold) Text(formatDateV2(clockMs), color = LuxGold, fontSize = 9.sp) } HomeProfileChipV2(activeProfile.name, profilesCount, onProfiles) } } Row( Modifier.fillMaxWidth().height(featureHeight), horizontalArrangement = Arrangement.spacedBy(gap), ) { HomeSportsFeatureV2( sportsLiveCount = sportsLiveCount, sportsChannelCount = sportsChannelCount, loading = sportsBackgroundLoading, loadingCategory = sportsBackgroundCategory, ready = sportsBackgroundReady, scanning = sportsScanning, modifier = Modifier.weight(1.62f).fillMaxHeight(), requestFocus = true, ) { onNavigate(AppScreen.SPORTS) } Column( Modifier.weight(1f).fillMaxHeight(), verticalArrangement = Arrangement.spacedBy(gap), ) { HomeDashboardUtilityV2( title = "LAST CHANNEL", subtitle = "Return to the channel + its TV Guide", symbol = "↩", modifier = Modifier.weight(1f).fillMaxWidth(), ) { onLastChannel() } HomeDashboardUtilityV2( title = "REFRESH TV GUIDE", subtitle = guideRefreshState ?: "Update EPG in the background", symbol = "↻", modifier = Modifier.weight(1f).fillMaxWidth(), ) { if (guideRefreshState != "Updating TV Guide…") { guideRefreshState = "Updating TV Guide…" onRefreshGuide { ok -> guideRefreshState = if (ok) "TV Guide Updated" else "Refresh failed — cached guide kept" } } } } } Row( Modifier.fillMaxWidth().height(tileHeight), horizontalArrangement = Arrangement.spacedBy(gap), ) { HomeDashboardTileV2("LIVE TV", "TV Guide & Live Channels", "◉", Modifier.weight(1f)) { onNavigate(AppScreen.LIVE) } HomeDashboardTileV2("MOVIES", "On Demand Library", "●", Modifier.weight(1f)) { onNavigate(AppScreen.MOVIES) } HomeDashboardTileV2("SERIES", "Seasons & Episodes", "▣", Modifier.weight(1f)) { onNavigate(AppScreen.SERIES) } HomeDashboardTileV2("FAVORITES", "Your Saved Channels", "♥", Modifier.weight(1f)) { onNavigate(AppScreen.FAVORITES) } } Row( Modifier.fillMaxWidth().height(tileHeight), horizontalArrangement = Arrangement.spacedBy(gap), ) { HomeDashboardTileV2("CONTINUE WATCHING", "Pick up where you left off", "▶", Modifier.weight(1f)) { if (firstContinue != null) onContinue(firstContinue) else showEmptyContinueDialog = true } HomeDashboardTileV2("MULTIVIEW", "Watch Multiple Channels", "▦", Modifier.weight(1f)) { onNavigate(AppScreen.MULTIVIEW) } HomeDashboardTileV2("SEARCH", "Find Channels, Movies & Shows", "⌕", Modifier.weight(1f)) { onNavigate(AppScreen.SEARCH) } HomeDashboardTileV2("SETTINGS", "App Preferences", "⚙", Modifier.weight(1f)) { onNavigate(AppScreen.SETTINGS) } } } } removeCandidate?.let { progress -> RemoveContinueDialogV2( progress = progress, onDismiss = { removeCandidate = null }, onRemove = { removeCandidate = null onRemoveContinue(progress) }, ) } if (showEmptyContinueDialog) { Dialog(onDismissRequest = { showEmptyContinueDialog = false }) { Column( Modifier.width(430.dp) .clip(RoundedCornerShape(20.dp)) .background(Color(0xFF111820)) .border(1.dp, LuxGold.copy(alpha = .55f), RoundedCornerShape(20.dp)) .padding(22.dp), verticalArrangement = Arrangement.spacedBy(12.dp), ) { Text("CONTINUE WATCHING", color = LuxGold, fontSize = 10.sp, fontWeight = FontWeight.Black, letterSpacing = 1.3.sp) Text("Nothing to continue yet", color = LuxText, fontSize = 20.sp, fontWeight = FontWeight.SemiBold) Text( "Start a movie or episode and TiviLux will save your progress here automatically.", color = LuxMuted, fontSize = 11.sp, lineHeight = 16.sp, ) Row(horizontalArrangement = Arrangement.spacedBy(9.dp)) { LuxButton("MOVIES", { showEmptyContinueDialog = false onNavigate(AppScreen.MOVIES) }, primary = true) LuxButton("SERIES", { showEmptyContinueDialog = false onNavigate(AppScreen.SERIES) }) LuxButton("CLOSE", { showEmptyContinueDialog = false }) } } } } } @Composable private fun HomeProfileChipV2(name: String, profilesCount: Int, onClick: () -> Unit) { var focused by remember { mutableStateOf(false) } Column( Modifier.clip(RoundedCornerShape(14.dp)) .background(if (focused) Color(0xFF24201A) else Color(0xFF11171F)) .border(1.dp, if (focused) LuxGold else LuxLine, RoundedCornerShape(14.dp)) .onFocusChanged { focused = it.isFocused }.focusable().clickable(onClick = onClick) .padding(horizontal = 14.dp, vertical = 8.dp), horizontalAlignment = Alignment.CenterHorizontally, ) { Text(name, color = LuxText, fontSize = 10.sp, fontWeight = FontWeight.Bold, maxLines = 1) Text(if (profilesCount > 1) "SWITCH PROFILE" else "PROFILE", color = LuxGold, fontSize = 7.sp, fontWeight = FontWeight.Bold) } } @Composable private fun HomeSportsFeatureV2( sportsLiveCount: Int, sportsChannelCount: Int, loading: Boolean, loadingCategory: String, ready: Boolean, scanning: Boolean, modifier: Modifier, requestFocus: Boolean = false, onClick: () -> Unit, ) { var focused by remember { mutableStateOf(false) } val focusRequester = remember { FocusRequester() } LaunchedEffect(requestFocus) { if (requestFocus) { delay(120) runCatching { focusRequester.requestFocus() } } } Box( modifier.focusRequester(focusRequester).scale(if (focused) 1.008f else 1f) .clip(RoundedCornerShape(22.dp)) .background( Brush.linearGradient( listOf(Color(0xFF090D13), Color(0xFF17202A), Color(0xFF2B2114), Color(0xFF0A0D12)) ) ) .border(1.5.dp, if (focused) LuxGold else LuxGold.copy(alpha = .55f), RoundedCornerShape(22.dp)) .onFocusChanged { focused = it.isFocused }.focusable().clickable(onClick = onClick) ) { Box(Modifier.fillMaxSize().background(Brush.verticalGradient(listOf(Color.Transparent, Color(0xB8000000))))) Column( Modifier.fillMaxSize().padding(if (focused) 25.dp else 24.dp), verticalArrangement = Arrangement.SpaceBetween, ) { Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically) { Text("SPORTS ZONE", color = LuxGold, fontSize = 10.sp, fontWeight = FontWeight.Black, letterSpacing = 1.5.sp) if (sportsLiveCount > 0) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) { Box(Modifier.size(7.dp).background(LuxGreen, RoundedCornerShape(50))) Text("LIVE", color = LuxGreen, fontSize = 8.sp, fontWeight = FontWeight.Black) } } } Column(verticalArrangement = Arrangement.spacedBy(7.dp)) { Text("SPORTS ZONE", color = LuxText, fontSize = 34.sp, lineHeight = 36.sp, fontWeight = FontWeight.Black) Text("LIVE GAMES • SCORES • SCHEDULES", color = Color(0xFFD4D7DC), fontSize = 10.sp, fontWeight = FontWeight.Bold, letterSpacing = 1.1.sp) Text( when { sportsLiveCount > 0 -> "$sportsLiveCount live games • $sportsChannelCount matched feeds" scanning -> "Scanning today's games…" sportsChannelCount > 0 -> "$sportsChannelCount matched sports feeds ready" else -> "NFL • MLB • NBA • NHL • NCAA • UFC • WWE" }, color = LuxMuted, fontSize = 10.sp, maxLines = 1, overflow = TextOverflow.Ellipsis, ) if (loading) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(7.dp)) { CircularProgressIndicator(Modifier.size(11.dp), strokeWidth = 1.5.dp, color = LuxGold) Text(if (loadingCategory.isNotBlank()) "Loading $loadingCategory…" else "Updating Game Center…", color = LuxMuted, fontSize = 8.sp) } } else if (ready) { Text("GAME CENTER READY", color = LuxGreen, fontSize = 8.sp, fontWeight = FontWeight.Bold) } } Text("ENTER SPORTS ZONE ›", color = if (focused) LuxGold else LuxText, fontSize = 11.sp, fontWeight = FontWeight.Black) } } } @Composable private fun HomeDashboardUtilityV2(title: String, subtitle: String, symbol: String, modifier: Modifier, onClick: () -> Unit) { var focused by remember { mutableStateOf(false) } Row( modifier.scale(if (focused) 1.01f else 1f).clip(RoundedCornerShape(20.dp)) .background(if (focused) Color(0xFF241F17) else Color(0xFF11171F)) .border(1.25.dp, if (focused) LuxGold else LuxLine, RoundedCornerShape(20.dp)) .onFocusChanged { focused = it.isFocused }.focusable().clickable(onClick = onClick) .padding(horizontal = 20.dp, vertical = 14.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(18.dp), ) { Text(symbol, color = LuxGold, fontSize = 34.sp, fontWeight = FontWeight.Black) Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(4.dp)) { Text(title, color = if (focused) LuxGold else LuxText, fontSize = 15.sp, fontWeight = FontWeight.Black) Text(subtitle, color = LuxMuted, fontSize = 9.sp, lineHeight = 12.sp, maxLines = 2, overflow = TextOverflow.Ellipsis) } Text("›", color = LuxMuted, fontSize = 24.sp) } } @Composable private fun HomeDashboardTileV2(title: String, subtitle: String, symbol: String, modifier: Modifier, onClick: () -> Unit) { var focused by remember { mutableStateOf(false) } Row( modifier.scale(if (focused) 1.012f else 1f).clip(RoundedCornerShape(18.dp)) .background( Brush.horizontalGradient( if (focused) listOf(Color(0xFF282116), Color(0xFF171C24)) else listOf(Color(0xFF151C24), Color(0xFF10151B)) ) ) .border(1.15.dp, if (focused) LuxGold else LuxLine, RoundedCornerShape(18.dp)) .onFocusChanged { focused = it.isFocused }.focusable().clickable(onClick = onClick) .padding(horizontal = 16.dp, vertical = 12.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(13.dp), ) { Text(symbol, color = if (focused) LuxGold else Color(0xFFDCE4EE), fontSize = 26.sp, fontWeight = FontWeight.Bold) Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(3.dp)) { Text(title, color = if (focused) LuxGold else LuxText, fontSize = 13.sp, fontWeight = FontWeight.Black, maxLines = 1, overflow = TextOverflow.Ellipsis) Text(subtitle, color = LuxMuted, fontSize = 8.sp, maxLines = 1, overflow = TextOverflow.Ellipsis) } Text("›", color = LuxMuted, fontSize = 20.sp) } } @Composable private fun HomeSidebarV2( modifier: Modifier, compact: Boolean, activeProfile: HouseholdProfile, profilesCount: Int, session: SessionInfo?, onNavigate: (AppScreen) -> Unit, onContinue: () -> Unit, onProfiles: () -> Unit, ) { val outerVertical = if (compact) 9.dp else 16.dp val itemPad = if (compact) 5.dp else 9.dp val itemSpacing = if (compact) 1.dp else 3.dp Column( modifier.background(Color(0xB20A0D12)).border(width = 1.dp, color = LuxLine).padding(horizontal = 13.dp, vertical = outerVertical), verticalArrangement = Arrangement.spacedBy(itemSpacing), ) { Image( painter = painterResource(R.drawable.tivilux_wordmark), contentDescription = "TiviLux", modifier = Modifier.fillMaxWidth().height(if (compact) 36.dp else 50.dp), ) Text( "PREMIUM TV", color = LuxMuted, fontSize = 7.sp, letterSpacing = 2.2.sp, modifier = Modifier.padding(start = 9.dp, bottom = if (compact) 3.dp else 10.dp), ) HomeNavItemV2("HOME", active = true, requestFocus = true, verticalPadding = itemPad) { } HomeNavItemV2("LIVE TV", verticalPadding = itemPad) { onNavigate(AppScreen.LIVE) } HomeNavItemV2("SPORTS", verticalPadding = itemPad) { onNavigate(AppScreen.SPORTS) } HomeNavItemV2("MOVIES", verticalPadding = itemPad) { onNavigate(AppScreen.MOVIES) } HomeNavItemV2("SERIES", verticalPadding = itemPad) { onNavigate(AppScreen.SERIES) } Spacer(Modifier.height(if (compact) 2.dp else 6.dp)) HomeNavItemV2("FAVORITES", verticalPadding = itemPad) { onNavigate(AppScreen.FAVORITES) } HomeNavItemV2("CONTINUE", verticalPadding = itemPad) { onContinue() } HomeNavItemV2("MULTIVIEW", verticalPadding = itemPad) { onNavigate(AppScreen.MULTIVIEW) } HomeNavItemV2("SEARCH", verticalPadding = itemPad) { onNavigate(AppScreen.SEARCH) } HomeNavItemV2("SETTINGS", verticalPadding = itemPad) { onNavigate(AppScreen.SETTINGS) } Spacer(Modifier.weight(1f)) var profileFocused by remember { mutableStateOf(false) } Column( Modifier.fillMaxWidth().clip(RoundedCornerShape(13.dp)) .background(if (profileFocused) Color(0x22E8C38B) else Color(0x141FFFFFF)) .border(1.dp, if (profileFocused) LuxGold else LuxLine, RoundedCornerShape(13.dp)) .onFocusChanged { profileFocused = it.isFocused }.focusable().clickable(onClick = onProfiles) .padding(if (compact) 7.dp else 10.dp), verticalArrangement = Arrangement.spacedBy(if (compact) 1.dp else 3.dp), ) { Text(activeProfile.name.uppercase(), color = LuxText, fontSize = if (compact) 9.sp else 10.sp, fontWeight = FontWeight.Bold, maxLines = 1, overflow = TextOverflow.Ellipsis) Text(if (profilesCount > 1) "SWITCH PROFILE" else "PROFILE", color = LuxGold, fontSize = 7.sp, fontWeight = FontWeight.Bold) if (!compact) { session?.username?.takeIf { it.isNotBlank() }?.let { Text(it, color = LuxMuted, fontSize = 7.sp, maxLines = 1, overflow = TextOverflow.Ellipsis) } } } } } @Composable private fun HomeNavItemV2( text: String, active: Boolean = false, requestFocus: Boolean = false, verticalPadding: androidx.compose.ui.unit.Dp = 9.dp, onClick: () -> Unit, ) { var focused by remember { mutableStateOf(false) } val focusRequester = remember { FocusRequester() } LaunchedEffect(requestFocus) { if (requestFocus) { delay(100) runCatching { focusRequester.requestFocus() } } } Row( Modifier.fillMaxWidth().focusRequester(focusRequester).clip(RoundedCornerShape(11.dp)) .background(if (active || focused) Color(0x26E8C38B) else Color.Transparent) .border(1.dp, if (focused) LuxGold else if (active) LuxGold.copy(alpha = .42f) else Color.Transparent, RoundedCornerShape(11.dp)) .onFocusChanged { focused = it.isFocused }.focusable().clickable(onClick = onClick) .padding(horizontal = 11.dp, vertical = verticalPadding), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp), ) { Box(Modifier.size(5.dp).background(if (active || focused) LuxGold else LuxMuted.copy(alpha = .45f), RoundedCornerShape(50))) Text(text, color = if (active || focused) LuxText else LuxMuted, fontSize = 9.sp, fontWeight = if (active || focused) FontWeight.Bold else FontWeight.Medium, letterSpacing = .55.sp) } } @Composable private fun HomeHeroV2( height: androidx.compose.ui.unit.Dp, image: String, kicker: String, title: String, description: String, sportsLiveCount: Int, sportsChannelCount: Int, primaryAction: String, onPrimary: () -> Unit, onSecondary: () -> Unit, ) { Box( Modifier.fillMaxWidth().height(height).clip(RoundedCornerShape(24.dp)) .background( Brush.horizontalGradient( listOf(Color(0xFF07101A), Color(0xFF102338), Color(0xFF0B1119)) ) ) .border(1.dp, LuxGold.copy(alpha = .26f), RoundedCornerShape(24.dp)), ) { if (image.isNotBlank()) { AsyncImage( model = image, contentDescription = null, modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight().fillMaxWidth(.62f), contentScale = ContentScale.Crop, ) } Box( Modifier.fillMaxSize().background( Brush.horizontalGradient( listOf(Color(0xF5080C12), Color(0xDF080D14), Color(0x75080D14), Color(0xE30A0F16)) ) ) ) Box( Modifier.align(Alignment.BottomCenter).fillMaxWidth().height(72.dp).background( Brush.verticalGradient(listOf(Color.Transparent, Color(0xC9080C12))) ) ) Column( Modifier.align(Alignment.CenterStart).fillMaxWidth(.64f).padding(horizontal = 28.dp, vertical = 22.dp), verticalArrangement = Arrangement.spacedBy(8.dp), ) { Text(kicker, color = LuxGold, fontSize = 9.sp, fontWeight = FontWeight.Black, letterSpacing = 1.55.sp) Text(title, color = LuxText, fontSize = 31.sp, lineHeight = 34.sp, fontWeight = FontWeight.Black, maxLines = 2, overflow = TextOverflow.Ellipsis) Text(description, color = Color(0xFFD2D7DE), fontSize = 11.sp, lineHeight = 16.sp, maxLines = 3, overflow = TextOverflow.Ellipsis) Row(horizontalArrangement = Arrangement.spacedBy(9.dp), verticalAlignment = Alignment.CenterVertically) { LuxButton(primaryAction, onPrimary, primary = true) if (sportsLiveCount > 0) { LuxButton("GAME CENTER", onSecondary) } } } if (sportsChannelCount > 0) { Row( Modifier.align(Alignment.BottomEnd).padding(16.dp) .background(Color(0xC20A1119), RoundedCornerShape(12.dp)) .border(1.dp, LuxLine, RoundedCornerShape(12.dp)).padding(horizontal = 12.dp, vertical = 8.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(7.dp), ) { if (sportsLiveCount > 0) Box(Modifier.size(7.dp).background(LuxGreen, RoundedCornerShape(50))) Text("$sportsChannelCount SPORTS FEEDS", color = LuxText, fontSize = 8.sp, fontWeight = FontWeight.Bold) } } } } @Composable private fun HomeActionCardV2( title: String, subtitle: String, tag: String, modifier: Modifier, onClick: () -> Unit, ) { var focused by remember { mutableStateOf(false) } val scale = if (focused) 1.015f else 1f Column( modifier.scale(scale).clip(RoundedCornerShape(17.dp)) .background( Brush.verticalGradient( if (focused) listOf(Color(0xFF2A241B), Color(0xFF16191F)) else listOf(Color(0xFF171D25), Color(0xFF11151B)) ) ) .border(1.dp, if (focused) LuxGold else LuxLine, RoundedCornerShape(17.dp)) .onFocusChanged { focused = it.isFocused }.focusable().clickable(onClick = onClick).padding(13.dp), verticalArrangement = Arrangement.SpaceBetween, ) { Text(tag, color = LuxGold, fontSize = 7.sp, fontWeight = FontWeight.Black, letterSpacing = .8.sp) Column(verticalArrangement = Arrangement.spacedBy(2.dp)) { Text(title, color = LuxText, fontSize = 14.sp, fontWeight = FontWeight.Bold) Text(subtitle, color = LuxMuted, fontSize = 8.sp, maxLines = 1, overflow = TextOverflow.Ellipsis) } } } @Composable private fun HomeSportsCardV2( sportsLiveCount: Int, sportsChannelCount: Int, loading: Boolean, loadingCategory: String, ready: Boolean, scanning: Boolean, modifier: Modifier, onClick: () -> Unit, ) { var focused by remember { mutableStateOf(false) } Column( modifier.scale(if (focused) 1.015f else 1f).clip(RoundedCornerShape(17.dp)) .background(Brush.verticalGradient(listOf(Color(0xFF312718), Color(0xFF151920)))) .border(1.dp, if (focused) LuxGold else LuxGold.copy(alpha = .42f), RoundedCornerShape(17.dp)) .onFocusChanged { focused = it.isFocused }.focusable().clickable(onClick = onClick).padding(13.dp), verticalArrangement = Arrangement.SpaceBetween, ) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(7.dp)) { if (sportsLiveCount > 0) Box(Modifier.size(7.dp).background(LuxGreen, RoundedCornerShape(50))) Text("SPORTS ZONE", color = LuxGold, fontSize = 8.sp, fontWeight = FontWeight.Black, letterSpacing = .85.sp) if (loading) CircularProgressIndicator(Modifier.size(10.dp), strokeWidth = 1.5.dp, color = LuxGold) } Column(verticalArrangement = Arrangement.spacedBy(2.dp)) { Text( when { sportsLiveCount > 0 -> "$sportsLiveCount LIVE • $sportsChannelCount FEEDS" scanning -> "SCANNING TODAY'S GAMES" sportsChannelCount > 0 -> "$sportsChannelCount MATCHED FEEDS" else -> "GAME CENTER" }, color = LuxText, fontSize = 13.sp, fontWeight = FontWeight.Bold, maxLines = 1, overflow = TextOverflow.Ellipsis, ) Text( when { loading && loadingCategory.isNotBlank() -> "Loading $loadingCategory…" loading -> "Building Game Center…" ready -> "READY" else -> "Scores • schedules • feeds" }, color = if (ready && !loading) LuxGreen else LuxMuted, fontSize = 8.sp, maxLines = 1, overflow = TextOverflow.Ellipsis, ) } } } @Composable private fun HomeUtilityCardV2(title: String, subtitle: String, modifier: Modifier, onClick: () -> Unit) { var focused by remember { mutableStateOf(false) } Column( modifier.fillMaxHeight().clip(RoundedCornerShape(17.dp)) .background(if (focused) Color(0xFF222831) else LuxPanel) .border(1.dp, if (focused) LuxGold else LuxLine, RoundedCornerShape(17.dp)) .onFocusChanged { focused = it.isFocused }.focusable().clickable(onClick = onClick).padding(15.dp), verticalArrangement = Arrangement.Center, ) { Text(title, color = if (focused) LuxGold else LuxText, fontSize = 12.sp, fontWeight = FontWeight.Bold) Spacer(Modifier.height(4.dp)) Text(subtitle, color = LuxMuted, fontSize = 8.sp, maxLines = 2, overflow = TextOverflow.Ellipsis) } } @Composable private fun ContinueWatchingCardV2( progress: PlaybackProgress, modifier: Modifier, onClick: () -> Unit, onRemoveRequested: () -> Unit, ) { var focused by remember { mutableStateOf(false) } var selectHeld by remember { mutableStateOf(false) } var longPressTriggered by remember { mutableStateOf(false) } var holdJob by remember { mutableStateOf(null) } val scope = rememberCoroutineScope() val item = progress.item val percent = if (progress.durationMs > 0L) { ((progress.positionMs.toDouble() / progress.durationMs.toDouble()) * 100.0).toInt().coerceIn(0, 100) } else 0 Row( modifier.clip(RoundedCornerShape(16.dp)) .background(if (focused) Color(0xFF222A34) else LuxPanel) .border(1.dp, if (focused) LuxGold else LuxLine, RoundedCornerShape(16.dp)) .onFocusChanged { focused = it.isFocused }.focusable() .onPreviewKeyEvent { event -> if (event.key !in setOf(Key.Enter, Key.DirectionCenter)) return@onPreviewKeyEvent false when (event.type) { KeyEventType.KeyDown -> { if (!selectHeld) { selectHeld = true longPressTriggered = false holdJob?.cancel() holdJob = scope.launch { delay(550) if (selectHeld && !longPressTriggered) { longPressTriggered = true onRemoveRequested() } } } true } KeyEventType.KeyUp -> { val wasLong = longPressTriggered selectHeld = false holdJob?.cancel() holdJob = null longPressTriggered = false if (!wasLong) onClick() true } else -> false } } .clickable(onClick = onClick), verticalAlignment = Alignment.CenterVertically, ) { Box(Modifier.width(92.dp).fillMaxHeight().background(LuxPanel2)) { AsyncImage( model = item.image.takeIf { it.isNotBlank() }, contentDescription = item.name, modifier = Modifier.fillMaxSize(), contentScale = ContentScale.Crop, ) if (item.image.isBlank()) Text(item.name.take(1).uppercase(), color = LuxMuted, fontSize = 28.sp, modifier = Modifier.align(Alignment.Center)) } Column(Modifier.weight(1f).padding(12.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) { Text(if (item.season > 0) "NEXT UP" else "CONTINUE", color = LuxGold, fontSize = 7.sp, fontWeight = FontWeight.Black, letterSpacing = .7.sp) Text(item.seriesName.ifBlank { item.name }, color = LuxText, fontSize = 12.sp, fontWeight = FontWeight.Bold, maxLines = 2, overflow = TextOverflow.Ellipsis) if (item.season > 0 && item.episodeNumber > 0) { Text("S${item.season} E${item.episodeNumber} • ${item.name}", color = LuxMuted, fontSize = 8.sp, maxLines = 1, overflow = TextOverflow.Ellipsis) } if (percent > 0) { Box(Modifier.fillMaxWidth().height(3.dp).background(Color(0x22FFFFFF), RoundedCornerShape(50))) { Box(Modifier.fillMaxWidth(percent / 100f).fillMaxHeight().background(LuxGold, RoundedCornerShape(50))) } Text("$percent% watched", color = LuxMuted, fontSize = 7.sp) } } } } @Composable private fun RemoveContinueDialogV2(progress: PlaybackProgress, onDismiss: () -> Unit, onRemove: () -> Unit) { val removeFocus = remember { FocusRequester() } LaunchedEffect(Unit) { delay(80) runCatching { removeFocus.requestFocus() } } Dialog(onDismissRequest = onDismiss) { Column( Modifier.widthIn(min = 500.dp, max = 680.dp).background(Color(0xFF0D131A), RoundedCornerShape(20.dp)) .border(1.dp, LuxGold.copy(alpha = .62f), RoundedCornerShape(20.dp)).padding(22.dp), verticalArrangement = Arrangement.spacedBy(13.dp), ) { Text("CONTINUE WATCHING", color = LuxGold, fontSize = 9.sp, fontWeight = FontWeight.Black, letterSpacing = 1.2.sp) Text("Remove from Continue Watching?", color = LuxText, fontSize = 21.sp, fontWeight = FontWeight.SemiBold) Text(progress.item.seriesName.ifBlank { progress.item.name }, color = LuxMuted, fontSize = 12.sp, maxLines = 2, overflow = TextOverflow.Ellipsis) Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) { LuxButton("REMOVE", onRemove, modifier = Modifier.focusRequester(removeFocus), primary = true) LuxButton("CANCEL", onDismiss) } } } } private fun formatClockV2(ms: Long): String = runCatching { SimpleDateFormat("h:mm a", Locale.getDefault()).format(Date(ms)) }.getOrDefault("") private fun formatDateV2(ms: Long): String = runCatching { SimpleDateFormat("EEE, MMM d", Locale.getDefault()).format(Date(ms)) }.getOrDefault("")