From 8c758e8262dafaa56dc893640fae09d859438663 Mon Sep 17 00:00:00 2001 From: Barnabas Balogh Date: Mon, 22 Jun 2026 18:27:09 +0000 Subject: [PATCH] feat(tv-player): add live clock overlay to player controls --- .../ui/screen/player/TvPlayerScreen.kt | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/app-tv/src/main/java/hu/bbara/purefin/ui/screen/player/TvPlayerScreen.kt b/app-tv/src/main/java/hu/bbara/purefin/ui/screen/player/TvPlayerScreen.kt index 4b347a6b..e992bc5b 100644 --- a/app-tv/src/main/java/hu/bbara/purefin/ui/screen/player/TvPlayerScreen.kt +++ b/app-tv/src/main/java/hu/bbara/purefin/ui/screen/player/TvPlayerScreen.kt @@ -26,6 +26,7 @@ import androidx.compose.material.icons.outlined.Pause import androidx.compose.material.icons.outlined.SkipNext import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -49,6 +50,7 @@ import androidx.compose.ui.input.key.onPreviewKeyEvent import androidx.compose.ui.input.key.type import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.testTag +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidView import androidx.hilt.navigation.compose.hiltViewModel @@ -71,6 +73,9 @@ import hu.bbara.purefin.ui.screen.player.components.TvPlayerLoadingErrorEndCard import hu.bbara.purefin.ui.screen.player.components.TvPlayerTimeRow import hu.bbara.purefin.ui.screen.player.components.TvTrackPanelType import hu.bbara.purefin.ui.screen.player.components.TvTrackSelectionPanel +import java.time.LocalTime +import java.time.format.DateTimeFormatter +import java.util.Locale import kotlinx.coroutines.Job import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -326,6 +331,17 @@ fun TvPlayerScreen( ) } + AnimatedVisibility( + visible = controlsVisible, + enter = fadeIn(), + exit = fadeOut(), + modifier = Modifier + .align(Alignment.TopEnd) + .padding(horizontal = 24.dp, vertical = 16.dp) + ) { + TvPlayerClock() + } + AnimatedVisibility( visible = showSkipIntroButton, modifier = Modifier @@ -462,6 +478,25 @@ private fun HiddenTvSeekTimeline( } } +@Composable +private fun TvPlayerClock(modifier: Modifier = Modifier) { + var currentTime by remember { mutableStateOf(LocalTime.now()) } + LaunchedEffect(Unit) { + while (true) { + currentTime = LocalTime.now() + delay(1_000L) + } + } + val formatter = remember { DateTimeFormatter.ofPattern("HH:mm", Locale.getDefault()) } + Text( + text = formatter.format(currentTime), + color = MaterialTheme.colorScheme.onBackground, + style = MaterialTheme.typography.titleLarge, + fontWeight = FontWeight.Bold, + modifier = modifier + ) +} + internal fun handleTvPlayerRootKeyEvent( event: KeyEvent, controlsVisible: Boolean,