StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.
Kotlin iptv-player
feat(live): add live presentation primitives
David Nashash37536305dbf9
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeSidebarComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeSidebarComponents.ktindex 6e7cf36f..64031ee0 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeSidebarComponents.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeSidebarComponents.kt@@ -51,7 +51,7 @@ import androidx.tv.material3.SurfaceDefaultsimport androidx.tv.material3.Textimport com.streamvault.app.Rimport com.streamvault.app.device.rememberIsTelevisionDevice-import com.streamvault.app.ui.components.FocusedMarqueeText+import com.streamvault.feature.live.presentation.components.LiveFocusedMarqueeTextimport com.streamvault.player.ui.PlayerRenderViewimport com.streamvault.core.ui.interaction.TvButtonimport com.streamvault.core.ui.interaction.TvClickableSurface@@ -325,7 +325,7 @@ internal fun CategoryItem(modifier = Modifier.padding(end = 8.dp))}- FocusedMarqueeText(+ LiveFocusedMarqueeText(text = category.name,isFocused = isFocused,style = MaterialTheme.typography.bodyMedium,diff --git a/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveCategoryRow.kt b/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveCategoryRow.ktnew file mode 100644index 00000000..399a8938--- /dev/null+++ b/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveCategoryRow.kt@@ -0,0 +1,145 @@+package com.streamvault.feature.live.presentation.components++import androidx.compose.foundation.BorderStroke+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.lazy.LazyRow+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.runtime.remember+import androidx.compose.ui.Alignment+import androidx.compose.ui.ExperimentalComposeUiApi+import androidx.compose.ui.Modifier+import androidx.compose.ui.focus.FocusRequester+import androidx.compose.ui.focus.focusRequester+import androidx.compose.ui.focus.focusRestorer+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.unit.dp+import androidx.tv.material3.Border+import androidx.tv.material3.ClickableSurfaceDefaults+import androidx.tv.material3.Icon+import androidx.tv.material3.MaterialTheme+import androidx.tv.material3.Surface+import androidx.tv.material3.Text+import androidx.compose.material.icons.Icons+import androidx.compose.material.icons.filled.PushPin+import androidx.compose.material.icons.outlined.PushPin+import com.streamvault.core.ui.components.shell.AppSectionHeader+import com.streamvault.core.ui.interaction.mouseClickable+import com.streamvault.core.ui.theme.FocusBorder+import com.streamvault.core.ui.theme.OnSurface+import com.streamvault.core.ui.theme.Primary+import com.streamvault.core.ui.theme.SurfaceElevated+import com.streamvault.core.ui.theme.SurfaceHighlight++/** Netflix-style horizontal category row for Live browse surfaces. */+@OptIn(ExperimentalComposeUiApi::class)+@Composable+fun <T : Any> LiveCategoryRow(+ title: String,+ items: List<T>,+ modifier: Modifier = Modifier,+ onSeeAll: (() -> Unit)? = null,+ onPinToggle: (() -> Unit)? = null,+ isPinned: Boolean = false,+ keySelector: (T) -> Any,+ contentTypeSelector: ((T) -> Any?)? = null,+ seeAllLabel: String = "See all",+ pinLabel: String = "Pin category",+ unpinLabel: String = "Unpin category",+ itemContent: @Composable (T) -> Unit+) {+ val resolvedContentTypeSelector: (T) -> Any? = contentTypeSelector ?: { null }+ Column(modifier = modifier.fillMaxWidth()) {+ if (onSeeAll != null) {+ val seeAllRequester = remember { FocusRequester() }+ val pinRequester = remember { FocusRequester() }+ Column(+ modifier = Modifier.fillMaxWidth().padding(start = 20.dp, end = 20.dp, top = 14.dp, bottom = 6.dp),+ verticalArrangement = Arrangement.spacedBy(8.dp)+ ) {+ Row(+ modifier = Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.spacedBy(8.dp),+ verticalAlignment = Alignment.CenterVertically+ ) {+ AppSectionHeader(title = title, modifier = Modifier.weight(1f))+ LiveCategoryAction(+ label = seeAllLabel,+ onClick = onSeeAll,+ requester = seeAllRequester,+ contentColor = Primary+ )+ if (onPinToggle != null) {+ Surface(+ onClick = onPinToggle,+ modifier = Modifier.focusRequester(pinRequester).mouseClickable(focusRequester = pinRequester, onClick = onPinToggle),+ colors = ClickableSurfaceDefaults.colors(+ containerColor = if (isPinned) Primary.copy(alpha = 0.18f) else SurfaceElevated,+ focusedContainerColor = SurfaceHighlight,+ contentColor = if (isPinned) Primary else OnSurface,+ focusedContentColor = OnSurface+ ),+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(999.dp)),+ border = ClickableSurfaceDefaults.border(+ focusedBorder = Border(+ border = BorderStroke(2.dp, FocusBorder),+ shape = RoundedCornerShape(999.dp)+ )+ )+ ) {+ Icon(+ imageVector = if (isPinned) Icons.Filled.PushPin else Icons.Outlined.PushPin,+ contentDescription = if (isPinned) unpinLabel else pinLabel,+ modifier = Modifier.padding(8.dp),+ tint = if (isPinned) Primary else OnSurface+ )+ }+ }+ }+ }+ } else {+ AppSectionHeader(title = title, modifier = Modifier.fillMaxWidth().padding(start = 20.dp, end = 20.dp, top = 14.dp, bottom = 6.dp))+ }+ LazyRow(+ modifier = Modifier.focusRestorer(),+ contentPadding = PaddingValues(horizontal = 20.dp, vertical = 10.dp),+ horizontalArrangement = Arrangement.spacedBy(8.dp)+ ) {+ items(items = items, key = keySelector, contentType = resolvedContentTypeSelector) { item -> itemContent(item) }+ }+ }+}++@Composable+private fun LiveCategoryAction(+ label: String,+ onClick: () -> Unit,+ requester: FocusRequester,+ contentColor: Color+) {+ Surface(+ onClick = onClick,+ modifier = Modifier.focusRequester(requester).mouseClickable(focusRequester = requester, onClick = onClick),+ colors = ClickableSurfaceDefaults.colors(+ containerColor = SurfaceElevated,+ focusedContainerColor = SurfaceHighlight,+ contentColor = contentColor,+ focusedContentColor = OnSurface+ ),+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(999.dp)),+ border = ClickableSurfaceDefaults.border(+ focusedBorder = Border(+ border = BorderStroke(2.dp, FocusBorder),+ shape = RoundedCornerShape(999.dp)+ )+ )+ ) {+ Text(text = label, modifier = Modifier.padding(horizontal = 12.dp, vertical = 7.dp), style = MaterialTheme.typography.labelMedium)+ }+}diff --git a/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveChannelRowSurface.kt b/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveChannelRowSurface.ktnew file mode 100644index 00000000..4d2d2b4d--- /dev/null+++ b/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveChannelRowSurface.kt@@ -0,0 +1,172 @@+package com.streamvault.feature.live.presentation.components++import androidx.compose.animation.core.animateFloatAsState+import androidx.compose.foundation.BorderStroke+import androidx.compose.foundation.background+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxHeight+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.material.icons.Icons+import androidx.compose.material.icons.filled.Star+import androidx.compose.material3.Icon+import androidx.compose.material3.LinearProgressIndicator+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+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.focus.FocusRequester+import androidx.compose.ui.focus.focusRequester+import androidx.compose.ui.focus.onFocusChanged+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.Dp+import androidx.compose.ui.unit.dp+import androidx.tv.material3.Border+import androidx.tv.material3.ClickableSurfaceDefaults+import androidx.tv.material3.MaterialTheme+import androidx.tv.material3.Surface+import androidx.tv.material3.Text+import com.streamvault.core.ui.components.shell.StatusPill+import com.streamvault.core.ui.design.AppColors+import com.streamvault.core.ui.design.AppMotion+import com.streamvault.core.ui.design.FocusSpec+import com.streamvault.core.ui.image.ChannelLogoBadge+import com.streamvault.core.ui.interaction.mouseClickable+import com.streamvault.core.ui.interaction.rememberTvInteractionSounds+import com.streamvault.domain.model.Channel+import com.streamvault.domain.playback.archivePlaybackCapability++@Composable+fun LiveChannelRowSurface(+ channel: Channel,+ nowMs: Long,+ onClick: () -> Unit,+ sourceBadgeLabel: String? = null,+ modifier: Modifier = Modifier,+ onLongClick: (() -> Unit)? = null,+ isLocked: Boolean = false,+ isReorderMode: Boolean = false,+ isDragging: Boolean = false,+ rowHeight: Dp = 68.dp,+ liveLabel: String = "LIVE",+ noScheduleLabel: String = "No schedule",+ lockedLabel: String = "Locked",+ movingLabel: String = "Moving"+) {+ var isFocused by remember { mutableStateOf(false) }+ val sounds = rememberTvInteractionSounds()+ val focusRequester = remember { FocusRequester() }+ val hasArchive = channel.archivePlaybackCapability().canBuildReplayCandidate+ val scale by animateFloatAsState(+ targetValue = if (isDragging) FocusSpec.FocusedScale else 1f,+ animationSpec = AppMotion.FocusSpec,+ label = "liveRowScale"+ )+ val channelDescription = buildString {+ append(channel.number.takeIf { it > 0 }?.let { "$it ${channel.name}" } ?: channel.name)+ channel.currentProgram?.title?.takeIf { it.isNotBlank() }?.let { append(". $it") }+ if (channel.isFavorite) append(". Favorite")+ if (hasArchive) append(". Catch-up available")+ }+ Surface(+ onClick = { sounds.playSelect(); onClick() },+ onLongClick = onLongClick,+ modifier = modifier+ .focusRequester(focusRequester)+ .fillMaxWidth()+ .mouseClickable(focusRequester = focusRequester, onLongClick = onLongClick, onClick = { sounds.playSelect(); onClick() })+ .graphicsLayer { scaleX = scale; scaleY = scale }+ .onFocusChanged { if (it.isFocused && !isFocused) sounds.playNavigate(); isFocused = it.isFocused },+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(16.dp)),+ colors = ClickableSurfaceDefaults.colors(containerColor = AppColors.SurfaceElevated, focusedContainerColor = AppColors.SurfaceEmphasis),+ border = ClickableSurfaceDefaults.border(+ focusedBorder = Border(+ border = BorderStroke(if (isDragging) 4.dp else FocusSpec.BorderWidth, if (isDragging) AppColors.Warning else AppColors.Focus),+ shape = RoundedCornerShape(16.dp)+ )+ )+ ) {+ Box {+ LiveChannelRowCard(+ channel = channel,+ nowMs = nowMs,+ sourceBadgeLabel = sourceBadgeLabel,+ modifier = Modifier.fillMaxWidth(),+ rowHeight = rowHeight,+ liveLabel = liveLabel,+ noScheduleLabel = noScheduleLabel+ )+ if (isLocked) {+ Box(modifier = Modifier.fillMaxSize().background(AppColors.HeroBottom.copy(alpha = 0.82f)), contentAlignment = Alignment.Center) {+ StatusPill(label = lockedLabel, containerColor = AppColors.SurfaceEmphasis, contentColor = AppColors.TextPrimary)+ }+ }+ if (isReorderMode && isDragging) {+ Box(modifier = Modifier.align(Alignment.TopEnd).padding(12.dp)) {+ StatusPill(label = movingLabel, containerColor = AppColors.Warning, contentColor = Color.Black)+ }+ }+ if (!isLocked && !isReorderMode && channel.isFavorite) {+ Box(modifier = Modifier.align(Alignment.TopEnd).padding(10.dp).background(Color.Black.copy(alpha = 0.55f), RoundedCornerShape(4.dp)).padding(4.dp)) {+ Icon(imageVector = Icons.Filled.Star, contentDescription = null, tint = AppColors.Warning, modifier = Modifier.size(11.dp))+ }+ }+ }+ }+}++@Composable+fun LiveChannelRowCard(+ channel: Channel,+ nowMs: Long,+ sourceBadgeLabel: String? = null,+ modifier: Modifier = Modifier,+ rowHeight: Dp = 68.dp,+ liveLabel: String = "LIVE",+ noScheduleLabel: String = "No schedule"+) {+ val dense = rowHeight <= 56.dp+ val ultraCompact = rowHeight <= 60.dp+ val logoWidth = if (dense) 42.dp else if (ultraCompact) 46.dp else 52.dp+ val hasArchive = channel.archivePlaybackCapability().canBuildReplayCandidate+ Box(modifier = modifier.clip(RoundedCornerShape(18.dp)).background(AppColors.SurfaceElevated).fillMaxWidth().height(rowHeight)) {+ Row(modifier = Modifier.fillMaxSize().padding(horizontal = if (ultraCompact) 8.dp else 10.dp, vertical = if (ultraCompact) 5.dp else 6.dp), horizontalArrangement = Arrangement.spacedBy(if (ultraCompact) 8.dp else 10.dp), verticalAlignment = Alignment.CenterVertically) {+ Box(modifier = Modifier.width(logoWidth).fillMaxHeight().clip(RoundedCornerShape(12.dp))) {+ ChannelLogoBadge(channelName = channel.name, logoUrl = channel.logoUrl, backgroundColor = AppColors.SurfaceEmphasis, contentPadding = PaddingValues(if (dense) 5.dp else 8.dp), textStyle = MaterialTheme.typography.titleLarge, textColor = AppColors.TextSecondary, modifier = Modifier.fillMaxSize())+ }+ Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {+ if (!dense) {+ Row(horizontalArrangement = Arrangement.spacedBy(4.dp), verticalAlignment = Alignment.CenterVertically) {+ StatusPill(label = liveLabel, containerColor = AppColors.Live)+ sourceBadgeLabel?.takeIf { it.isNotBlank() }?.let { StatusPill(label = it, containerColor = AppColors.SurfaceEmphasis, contentColor = AppColors.TextPrimary) }+ if (channel.isFavorite) StatusPill(label = "Saved", containerColor = AppColors.Warning, contentColor = Color.Black)+ if (hasArchive) StatusPill(label = "Catch-up", containerColor = AppColors.Brand)+ }+ }+ Text(text = buildString { channel.number.takeIf { it > 0 }?.let { append(it.toString().padStart(2, '0')); append(" ") } ?: append("-- "); append(channel.name) }, style = if (dense) MaterialTheme.typography.bodyLarge else MaterialTheme.typography.titleSmall, color = AppColors.TextPrimary, maxLines = 1, overflow = TextOverflow.Ellipsis)+ channel.currentProgram?.let { program ->+ Text(text = program.title, style = if (dense) MaterialTheme.typography.labelMedium else MaterialTheme.typography.bodySmall, color = AppColors.TextSecondary, maxLines = 1, overflow = TextOverflow.Ellipsis)+ if (!dense) {+ LinearProgressIndicator(progress = { liveChannelProgressFraction(nowMs, program.startTime, program.endTime) }, modifier = Modifier.fillMaxWidth().height(2.dp).clip(RoundedCornerShape(999.dp)), color = AppColors.Info, trackColor = AppColors.SurfaceEmphasis)+ }+ } ?: Text(text = noScheduleLabel, style = if (dense) MaterialTheme.typography.labelMedium else MaterialTheme.typography.bodySmall, color = AppColors.TextTertiary)+ }+ }+ }+}diff --git a/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveFocusedMarqueeText.kt b/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveFocusedMarqueeText.ktnew file mode 100644index 00000000..cc6a25e1--- /dev/null+++ b/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveFocusedMarqueeText.kt@@ -0,0 +1,81 @@+package com.streamvault.feature.live.presentation.components++import androidx.compose.foundation.basicMarquee+import androidx.compose.runtime.Composable+import androidx.compose.runtime.CompositionLocalProvider+import androidx.compose.runtime.remember+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.platform.LocalLayoutDirection+import androidx.compose.ui.text.TextStyle+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.LayoutDirection+import androidx.compose.ui.unit.dp+import androidx.tv.material3.Text++@Composable+fun LiveFocusedMarqueeText(+ text: String,+ isFocused: Boolean,+ modifier: Modifier = Modifier,+ style: TextStyle = TextStyle.Default,+ color: Color = Color.Unspecified,+ maxLines: Int = 1,+) {+ val ambientLayoutDirection = LocalLayoutDirection.current+ val marqueeLayoutDirection = remember(text, ambientLayoutDirection) {+ when {+ hasMixedDirectionalText(text) -> LayoutDirection.Ltr+ hasStrongRtlText(text) -> LayoutDirection.Rtl+ else -> ambientLayoutDirection+ }+ }++ CompositionLocalProvider(LocalLayoutDirection provides marqueeLayoutDirection) {+ Text(+ text = text,+ style = style,+ color = color,+ maxLines = maxLines,+ overflow = if (isFocused) TextOverflow.Clip else TextOverflow.Ellipsis,+ modifier = modifier.then(+ if (isFocused) {+ Modifier.basicMarquee(+ iterations = Int.MAX_VALUE,+ initialDelayMillis = 900,+ repeatDelayMillis = 1200,+ velocity = 24.dp,+ )+ } else {+ Modifier+ }+ ),+ )+ }+}++private fun hasMixedDirectionalText(text: String): Boolean {+ var hasStrongLtr = false+ var hasStrongRtl = false+ text.forEach { char ->+ when (Character.getDirectionality(char)) {+ Character.DIRECTIONALITY_LEFT_TO_RIGHT -> hasStrongLtr = true+ Character.DIRECTIONALITY_RIGHT_TO_LEFT,+ Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC -> hasStrongRtl = true+ }+ if (hasStrongLtr && hasStrongRtl) return true+ }+ return false+}++private fun hasStrongRtlText(text: String): Boolean {+ var hasStrongRtl = false+ text.forEach { char ->+ when (Character.getDirectionality(char)) {+ Character.DIRECTIONALITY_LEFT_TO_RIGHT -> return false+ Character.DIRECTIONALITY_RIGHT_TO_LEFT,+ Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC -> hasStrongRtl = true+ }+ }+ return hasStrongRtl+}diff --git a/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveReorderTopBar.kt b/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveReorderTopBar.ktnew file mode 100644index 00000000..868c2a1d--- /dev/null+++ b/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveReorderTopBar.kt@@ -0,0 +1,90 @@+package com.streamvault.feature.live.presentation.components++import androidx.compose.animation.AnimatedVisibility+import androidx.compose.animation.slideInVertically+import androidx.compose.animation.slideOutVertically+import androidx.compose.foundation.BorderStroke+import androidx.compose.foundation.background+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+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.unit.dp+import androidx.tv.material3.Border+import androidx.tv.material3.ButtonDefaults+import androidx.tv.material3.MaterialTheme+import androidx.tv.material3.Surface+import androidx.tv.material3.SurfaceDefaults+import androidx.tv.material3.Text+import com.streamvault.core.ui.design.FocusSpec+import com.streamvault.core.ui.interaction.TvButton+import com.streamvault.core.ui.theme.FocusBorder+import com.streamvault.core.ui.theme.OnSurface+import com.streamvault.core.ui.theme.Primary+import com.streamvault.core.ui.theme.SurfaceElevated+import com.streamvault.core.ui.theme.TextPrimary+import com.streamvault.core.ui.theme.TextSecondary++@Composable+fun LiveReorderTopBar(+ categoryName: String,+ onSave: () -> Unit,+ onCancel: () -> Unit,+ visible: Boolean = true,+ subtitle: String? = null,+ modifier: Modifier = Modifier,+ titleFormat: (String) -> String = { "Reordering $it" },+ cancelLabel: String = "Cancel",+ saveLabel: String = "Save order"+) {+ AnimatedVisibility(+ visible = visible,+ enter = slideInVertically(initialOffsetY = { -it }),+ exit = slideOutVertically(targetOffsetY = { -it }),+ modifier = modifier.fillMaxWidth().padding(bottom = 20.dp)+ ) {+ Surface(shape = RoundedCornerShape(24.dp), colors = SurfaceDefaults.colors(containerColor = SurfaceElevated)) {+ Row(+ modifier = Modifier.fillMaxWidth().background(Brush.horizontalGradient(listOf(Primary.copy(alpha = 0.08f), Color.Transparent))).padding(horizontal = 24.dp, vertical = 18.dp),+ horizontalArrangement = Arrangement.SpaceBetween,+ verticalAlignment = Alignment.CenterVertically+ ) {+ Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(4.dp)) {+ Text(text = titleFormat(categoryName), style = MaterialTheme.typography.titleLarge, color = TextPrimary)+ subtitle?.takeIf { it.isNotBlank() }?.let { Text(text = it, style = MaterialTheme.typography.bodySmall, color = TextSecondary) }+ }+ Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {+ TvButton(+ onClick = onCancel,+ colors = ButtonDefaults.colors(+ containerColor = MaterialTheme.colorScheme.surfaceVariant,+ contentColor = OnSurface,+ focusedContainerColor = MaterialTheme.colorScheme.surface,+ focusedContentColor = OnSurface+ ),+ border = ButtonDefaults.border(focusedBorder = Border(border = BorderStroke(FocusSpec.BorderWidth, FocusBorder))),+ scale = ButtonDefaults.scale(focusedScale = FocusSpec.FocusedScale)+ ) { Text(cancelLabel, modifier = Modifier.padding(horizontal = 8.dp)) }+ TvButton(+ onClick = onSave,+ colors = ButtonDefaults.colors(+ containerColor = Primary,+ contentColor = Color.White,+ focusedContainerColor = Primary.copy(alpha = 0.88f),+ focusedContentColor = Color.White+ ),+ border = ButtonDefaults.border(focusedBorder = Border(border = BorderStroke(FocusSpec.BorderWidth, FocusBorder))),+ scale = ButtonDefaults.scale(focusedScale = FocusSpec.FocusedScale)+ ) { Text(saveLabel, modifier = Modifier.padding(horizontal = 8.dp)) }+ }+ }+ }+ }+}diff --git a/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveSelectionChipRow.kt b/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveSelectionChipRow.ktnew file mode 100644index 00000000..0deeca0b--- /dev/null+++ b/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveSelectionChipRow.kt@@ -0,0 +1,153 @@+package com.streamvault.feature.live.presentation.components++import androidx.compose.foundation.BorderStroke+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.lazy.LazyRow+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Modifier+import androidx.compose.ui.focus.FocusRequester+import androidx.compose.ui.focus.focusRequester+import androidx.compose.ui.focus.onFocusChanged+import androidx.compose.ui.text.TextStyle+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import androidx.tv.material3.Border+import androidx.tv.material3.ClickableSurfaceDefaults+import androidx.tv.material3.MaterialTheme+import androidx.tv.material3.Surface+import androidx.tv.material3.Text+import com.streamvault.core.ui.interaction.mouseClickable+import com.streamvault.core.ui.interaction.rememberTvInteractionSounds+import com.streamvault.core.ui.theme.FocusBorder+import com.streamvault.core.ui.theme.OnSurface+import com.streamvault.core.ui.theme.OnSurfaceDim+import com.streamvault.core.ui.theme.Primary+import com.streamvault.core.ui.theme.SurfaceElevated+import com.streamvault.core.ui.theme.SurfaceHighlight++data class LiveSelectionChip(+ val key: String,+ val label: String,+ val supportingText: String? = null+)++data class LiveChipRowItem(+ val key: String,+ val label: String,+ val supportingText: String? = null,+ val onClick: () -> Unit+)++@Composable+fun LiveSelectionChipRow(+ title: String,+ chips: List<LiveSelectionChip>,+ selectedKey: String?,+ onChipSelected: (String) -> Unit,+ modifier: Modifier = Modifier,+ subtitle: String? = null,+ contentPadding: PaddingValues = PaddingValues(horizontal = 24.dp)+) {+ LiveChipRowSection(+ title = title,+ subtitle = subtitle,+ selectedKey = selectedKey,+ chips = chips.map { chip ->+ LiveChipRowItem(+ key = chip.key,+ label = chip.label,+ supportingText = chip.supportingText,+ onClick = { onChipSelected(chip.key) }+ )+ },+ modifier = modifier,+ contentPadding = contentPadding+ )+}++@Composable+fun LiveChipRowSection(+ chips: List<LiveChipRowItem>,+ selectedKey: String?,+ modifier: Modifier = Modifier,+ title: String? = null,+ subtitle: String? = null,+ headerHorizontalPadding: Int = 24,+ contentPadding: PaddingValues = PaddingValues(horizontal = 24.dp),+ chipHorizontalPadding: Int = 16,+ supportingTextStyle: TextStyle = MaterialTheme.typography.bodySmall,+ supportingTextMaxLines: Int = Int.MAX_VALUE,+ focusedContainerBoostWhenSelected: Boolean = false+) {+ if (chips.isEmpty()) return+ val sounds = rememberTvInteractionSounds()+ Column(modifier = modifier.fillMaxWidth().padding(vertical = 6.dp)) {+ if (!title.isNullOrBlank()) {+ Text(+ text = title,+ style = MaterialTheme.typography.labelMedium,+ color = OnSurfaceDim,+ modifier = Modifier.padding(horizontal = headerHorizontalPadding.dp)+ )+ }+ if (!subtitle.isNullOrBlank()) {+ Text(+ text = subtitle,+ style = MaterialTheme.typography.bodySmall,+ color = OnSurfaceDim,+ modifier = Modifier.padding(horizontal = headerHorizontalPadding.dp, vertical = 2.dp)+ )+ }+ LazyRow(contentPadding = contentPadding, horizontalArrangement = Arrangement.spacedBy(10.dp)) {+ items(items = chips, key = { it.key }, contentType = { "live_selection_chip" }) { chip ->+ val selected = chip.key == selectedKey+ var wasFocused by remember(chip.key) { mutableStateOf(false) }+ val requester = remember(chip.key) { FocusRequester() }+ Surface(+ onClick = { sounds.playSelect(); chip.onClick() },+ modifier = Modifier+ .focusRequester(requester)+ .mouseClickable(focusRequester = requester, onClick = { sounds.playSelect(); chip.onClick() })+ .onFocusChanged {+ if (it.isFocused && !wasFocused) sounds.playNavigate()+ wasFocused = it.isFocused+ },+ colors = ClickableSurfaceDefaults.colors(+ containerColor = if (selected) Primary.copy(alpha = 0.18f) else SurfaceElevated,+ focusedContainerColor = if (selected && focusedContainerBoostWhenSelected) Primary.copy(alpha = 0.28f) else SurfaceHighlight,+ contentColor = if (selected) Primary else OnSurface,+ focusedContentColor = OnSurface+ ),+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(999.dp)),+ border = ClickableSurfaceDefaults.border(+ focusedBorder = Border(+ border = BorderStroke(2.dp, FocusBorder),+ shape = RoundedCornerShape(999.dp)+ )+ ),+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)+ ) {+ Column(+ modifier = Modifier.padding(horizontal = chipHorizontalPadding.dp, vertical = 10.dp),+ verticalArrangement = Arrangement.spacedBy(2.dp)+ ) {+ Text(text = chip.label, style = MaterialTheme.typography.labelLarge, maxLines = 1, overflow = TextOverflow.Ellipsis)+ chip.supportingText?.takeIf { it.isNotBlank() }?.let {+ Text(text = it, style = supportingTextStyle, color = OnSurfaceDim, maxLines = supportingTextMaxLines, overflow = TextOverflow.Ellipsis)+ }+ }+ }+ }+ }+ }+}diff --git a/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveSourceSwitcher.kt b/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveSourceSwitcher.ktnew file mode 100644index 00000000..829a458a--- /dev/null+++ b/feature/live/src/main/java/com/streamvault/feature/live/presentation/components/LiveSourceSwitcher.kt@@ -0,0 +1,163 @@+package com.streamvault.feature.live.presentation.components++import androidx.activity.compose.BackHandler+import androidx.compose.foundation.BorderStroke+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.defaultMinSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.layout.widthIn+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.material.icons.Icons+import androidx.compose.material.icons.filled.KeyboardArrowDown+import androidx.compose.material.icons.filled.KeyboardArrowUp+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.focus.FocusRequester+import androidx.compose.ui.focus.focusRequester+import androidx.compose.ui.focus.onFocusChanged+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.platform.LocalConfiguration+import androidx.compose.ui.unit.dp+import androidx.tv.material3.Border+import androidx.tv.material3.ClickableSurfaceDefaults+import androidx.tv.material3.Icon+import androidx.tv.material3.MaterialTheme+import androidx.tv.material3.Surface+import androidx.tv.material3.SurfaceDefaults+import androidx.tv.material3.Text+import com.streamvault.core.ui.interaction.mouseClickable+import com.streamvault.core.ui.theme.FocusBorder+import com.streamvault.core.ui.theme.OnBackground+import com.streamvault.core.ui.theme.OnSurfaceDim+import com.streamvault.core.ui.theme.Primary+import com.streamvault.core.ui.theme.SurfaceElevated+import com.streamvault.domain.model.ActiveLiveSource+import com.streamvault.domain.model.ActiveLiveSourceOption++@Composable+fun LiveSourceSwitcher(+ currentSource: ActiveLiveSource?,+ options: List<ActiveLiveSourceOption>,+ onSourceSelected: (ActiveLiveSource) -> Unit,+ compact: Boolean = false,+ modifier: Modifier = Modifier,+ noSourceLabel: String = "No provider",+ selectedLabel: String = "Selected",+ unavailableLabel: String = "Unavailable"+) {+ var showSourceList by remember { mutableStateOf(false) }+ var isFocused by remember { mutableStateOf(false) }+ val toggleRequester = remember { FocusRequester() }+ val screenWidth = LocalConfiguration.current.screenWidthDp.dp+ val controlWidth = when {+ compact -> if (screenWidth < 700.dp) 132.dp else 156.dp+ screenWidth < 700.dp -> 180.dp+ else -> 220.dp+ }+ val dropdownWidth = when {+ compact -> if (screenWidth < 700.dp) 200.dp else 240.dp+ screenWidth < 700.dp -> 220.dp+ else -> 300.dp+ }+ val currentOption = options.firstOrNull { it.source == currentSource }+ BackHandler(enabled = showSourceList) { showSourceList = false }++ Box(modifier = modifier) {+ Surface(+ onClick = { showSourceList = !showSourceList },+ modifier = Modifier+ .defaultMinSize(minWidth = controlWidth)+ .focusRequester(toggleRequester)+ .mouseClickable(focusRequester = toggleRequester, onClick = { showSourceList = !showSourceList })+ .onFocusChanged { isFocused = it.isFocused },+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(12.dp)),+ colors = ClickableSurfaceDefaults.colors(+ containerColor = if (isFocused) Primary.copy(alpha = 0.12f) else SurfaceElevated.copy(alpha = 0.96f),+ focusedContainerColor = Primary.copy(alpha = 0.18f)+ ),+ border = ClickableSurfaceDefaults.border(+ border = Border(+ border = BorderStroke(1.dp, Primary.copy(alpha = 0.14f)),+ shape = RoundedCornerShape(12.dp)+ ),+ focusedBorder = Border(+ border = BorderStroke(2.dp, FocusBorder),+ shape = RoundedCornerShape(12.dp)+ )+ )+ ) {+ Row(+ modifier = Modifier.padding(horizontal = if (compact) 10.dp else 12.dp, vertical = if (compact) 5.dp else 7.dp),+ verticalAlignment = Alignment.CenterVertically,+ horizontalArrangement = Arrangement.spacedBy(6.dp)+ ) {+ Text(+ text = currentOption?.title ?: noSourceLabel,+ style = if (compact) MaterialTheme.typography.labelMedium else MaterialTheme.typography.bodyMedium,+ modifier = Modifier.weight(1f).widthIn(max = if (compact) 180.dp else 280.dp),+ color = if (isFocused) Primary else OnBackground+ )+ Icon(imageVector = if (showSourceList) Icons.Default.KeyboardArrowUp else Icons.Default.KeyboardArrowDown, contentDescription = null, tint = OnSurfaceDim)+ }+ }++ if (showSourceList && options.isNotEmpty()) {+ Surface(+ modifier = Modifier.padding(top = if (compact) 38.dp else 46.dp).width(dropdownWidth),+ shape = RoundedCornerShape(12.dp),+ colors = SurfaceDefaults.colors(containerColor = SurfaceElevated)+ ) {+ Column(modifier = Modifier.padding(8.dp)) {+ options.forEach { option ->+ LiveSourceItem(+ option = option,+ isSelected = option.source == currentSource,+ onClick = { onSourceSelected(option.source); showSourceList = false },+ selectedLabel = selectedLabel,+ unavailableLabel = unavailableLabel+ )+ }+ }+ }+ }+ }+}++@Composable+private fun LiveSourceItem(+ option: ActiveLiveSourceOption,+ isSelected: Boolean,+ onClick: () -> Unit,+ selectedLabel: String,+ unavailableLabel: String+) {+ var isFocused by remember { mutableStateOf(false) }+ val requester = remember { FocusRequester() }+ Surface(+ onClick = onClick,+ modifier = Modifier.fillMaxWidth().focusRequester(requester).mouseClickable(focusRequester = requester, onClick = onClick).onFocusChanged { isFocused = it.isFocused },+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(4.dp)),+ colors = ClickableSurfaceDefaults.colors(+ containerColor = if (isSelected) Primary.copy(alpha = 0.2f) else Color.Transparent,+ focusedContainerColor = Primary.copy(alpha = 0.3f)+ )+ ) {+ Row(modifier = Modifier.padding(horizontal = 12.dp, vertical = 8.dp), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically) {+ Column(modifier = Modifier.weight(1f)) {+ Text(text = option.title, style = MaterialTheme.typography.bodyMedium, color = if (isFocused || isSelected) Primary else OnBackground)+ option.subtitle?.takeIf { it.isNotBlank() }?.let { Text(text = it, style = MaterialTheme.typography.labelSmall, color = OnSurfaceDim) }+ }+ Text(text = when { isSelected -> selectedLabel; !option.isEnabled -> unavailableLabel; else -> "" }, style = MaterialTheme.typography.labelSmall, color = if (isSelected) Primary else OnSurfaceDim)+ }+ }+}diff --git a/feature/live/src/main/java/com/streamvault/feature/live/presentation/remote/LiveRemoteShortcutPolicy.kt b/feature/live/src/main/java/com/streamvault/feature/live/presentation/remote/LiveRemoteShortcutPolicy.ktnew file mode 100644index 00000000..129af651--- /dev/null+++ b/feature/live/src/main/java/com/streamvault/feature/live/presentation/remote/LiveRemoteShortcutPolicy.kt@@ -0,0 +1,43 @@+package com.streamvault.feature.live.presentation.remote++import com.streamvault.domain.model.RemoteColorButton+import com.streamvault.domain.model.RemoteShortcutAction+import com.streamvault.domain.model.RemoteShortcutProfile+import com.streamvault.domain.model.RemoteShortcutPreferences++/** The focus target used when dispatching shortcuts from the Live browse surface. */+enum class LiveBrowseTarget {+ CHANNEL,+ CATEGORY+}++/**+ * Resolves a configured color button using the same profile semantics as the app-wide+ * remote preferences, while keeping Live presentation independent from the app dispatcher.+ */+fun resolveLiveRemoteShortcut(+ preferences: RemoteShortcutPreferences,+ profile: RemoteShortcutProfile,+ button: RemoteColorButton+): RemoteShortcutAction = preferences.resolvedAction(profile, button)++/** Returns whether an action is meaningful for the currently focused Live browse target. */+fun RemoteShortcutAction.isSupportedInLiveBrowse(target: LiveBrowseTarget): Boolean = when (target) {+ LiveBrowseTarget.CHANNEL -> when (this) {+ RemoteShortcutAction.NONE,+ RemoteShortcutAction.OPEN_GUIDE,+ RemoteShortcutAction.TOGGLE_FAVORITE,+ RemoteShortcutAction.PLAY_CHANNEL,+ RemoteShortcutAction.ADD_TO_SPLIT_SCREEN -> true+ else -> false+ }++ LiveBrowseTarget.CATEGORY -> when (this) {+ RemoteShortcutAction.NONE,+ RemoteShortcutAction.OPEN_GUIDE,+ RemoteShortcutAction.PIN_CATEGORY,+ RemoteShortcutAction.TOGGLE_CATEGORY_LOCK,+ RemoteShortcutAction.HIDE_CATEGORY -> true+ else -> false+ }+}diff --git a/feature/live/src/test/java/com/streamvault/feature/live/presentation/remote/LiveRemoteShortcutPolicyTest.kt b/feature/live/src/test/java/com/streamvault/feature/live/presentation/remote/LiveRemoteShortcutPolicyTest.ktnew file mode 100644index 00000000..de1692ff--- /dev/null+++ b/feature/live/src/test/java/com/streamvault/feature/live/presentation/remote/LiveRemoteShortcutPolicyTest.kt@@ -0,0 +1,39 @@+package com.streamvault.feature.live.presentation.remote++import com.google.common.truth.Truth.assertThat+import com.streamvault.domain.model.RemoteColorButton+import com.streamvault.domain.model.RemoteShortcutAction+import com.streamvault.domain.model.RemoteShortcutProfile+import com.streamvault.domain.model.RemoteShortcutPreferences+import org.junit.Test++class LiveRemoteShortcutPolicyTest {+ @Test+ fun `browse profile keeps red green yellow blue defaults`() {+ val preferences = RemoteShortcutPreferences()++ assertThat(resolveLiveRemoteShortcut(preferences, RemoteShortcutProfile.BROWSE, RemoteColorButton.RED))+ .isEqualTo(RemoteShortcutAction.TOGGLE_FAVORITE)+ assertThat(resolveLiveRemoteShortcut(preferences, RemoteShortcutProfile.BROWSE, RemoteColorButton.GREEN))+ .isEqualTo(RemoteShortcutAction.PIN_CATEGORY)+ assertThat(resolveLiveRemoteShortcut(preferences, RemoteShortcutProfile.BROWSE, RemoteColorButton.YELLOW))+ .isEqualTo(RemoteShortcutAction.HIDE_CATEGORY)+ assertThat(resolveLiveRemoteShortcut(preferences, RemoteShortcutProfile.BROWSE, RemoteColorButton.BLUE))+ .isEqualTo(RemoteShortcutAction.ADD_TO_SPLIT_SCREEN)+ }++ @Test+ fun `channel and category support remain distinct`() {+ assertThat(RemoteShortcutAction.TOGGLE_FAVORITE.isSupportedInLiveBrowse(LiveBrowseTarget.CHANNEL)).isTrue()+ assertThat(RemoteShortcutAction.PIN_CATEGORY.isSupportedInLiveBrowse(LiveBrowseTarget.CATEGORY)).isTrue()+ assertThat(RemoteShortcutAction.PIN_CATEGORY.isSupportedInLiveBrowse(LiveBrowseTarget.CHANNEL)).isFalse()+ assertThat(RemoteShortcutAction.PLAY_CHANNEL.isSupportedInLiveBrowse(LiveBrowseTarget.CATEGORY)).isFalse()+ }++ @Test+ fun `unmapped actions are rejected`() {+ assertThat(RemoteShortcutAction.OPEN_PLAYER_CONTROLS.isSupportedInLiveBrowse(LiveBrowseTarget.CHANNEL))+ .isFalse()+ assertThat(RemoteShortcutAction.NONE.isSupportedInLiveBrowse(LiveBrowseTarget.CATEGORY)).isTrue()+ }+}