Modern Apps git

← Modern-Apps.git

library: dense tv grid, info cards, slim rail; drop heroes

Commit
d1aee59856d481c9ad39c1a12090c3242f2b30aa
Author
vayun-mathur <[email protected]>
When
2026-10-26 00:25 UTC (1 month ago)
Parents
34680dc

Diff

library/tv/src/main/java/com/vayunmathur/library/tv/TvAppFrame.kt
diff --git a/library/tv/src/main/java/com/vayunmathur/library/tv/TvAppFrame.kt b/library/tv/src/main/java/com/vayunmathur/library/tv/TvAppFrame.ktindex e501cdb80a..ba7d583dd2 100644--- a/library/tv/src/main/java/com/vayunmathur/library/tv/TvAppFrame.kt+++ b/library/tv/src/main/java/com/vayunmathur/library/tv/TvAppFrame.kt@@ -1,24 +1,18 @@ package com.vayunmathur.library.tv  import androidx.activity.compose.BackHandler-import androidx.compose.animation.core.animateDpAsState-import androidx.compose.animation.core.animateFloatAsState import androidx.compose.foundation.background import androidx.compose.foundation.focusGroup 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.Spacer 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.layout.wrapContentWidth-import androidx.compose.foundation.shape.CircleShape import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.getValue@@ -27,16 +21,14 @@ 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.clipToBounds import androidx.compose.ui.focus.FocusDirection import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.focus.focusRestorer import androidx.compose.ui.focus.onFocusChanged-import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color-import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.platform.LocalFocusManager+import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.tv.material3.MaterialTheme@@ -48,10 +40,10 @@ import androidx.tv.material3.Text class TvDestination(val label: String, val icon: @Composable () -> Unit)  /**- * The TV app shell: a collapsed icon rail on the left that expands over the content with a- * scrim while it holds focus. Moving focus onto an item selects it (the Google TV pattern),- * CENTER jumps into the content, and BACK from the content returns to the rail so the next- * BACK exits instead of the app vanishing mid-browse.+ * The TV app shell: a slim fixed rail (icon over a short label, like the phone's bottom bar+ * turned sideways) and the selected destination's content beside it. The rail never expands+ * or overlays content. Focusing an item selects it, CENTER jumps into the content, and BACK+ * from the content returns to the rail so the next BACK exits.  *  * @param backReturnsToRail pass `false` when this frame is not the top of the back stack.  */@@ -61,7 +53,6 @@ fun TvAppFrame(     selected: Int,     onSelect: (Int) -> Unit,     modifier: Modifier = Modifier,-    brand: (@Composable () -> Unit)? = null,     backReturnsToRail: Boolean = true,     content: @Composable () -> Unit, ) {@@ -69,54 +60,27 @@ fun TvAppFrame(     val requesters = remember(destinations.size) { List(destinations.size) { FocusRequester() } }     val selectedRequester = requesters.getOrElse(selected) { FocusRequester.Default }     val focusManager = LocalFocusManager.current-    val railWidth by animateDpAsState(if (railFocused) TvDimens.RailExpanded else TvDimens.RailCollapsed)-    val scrimAlpha by animateFloatAsState(if (railFocused) 1f else 0f)-    val background = MaterialTheme.colorScheme.background      // Registered before content so screen-level BackHandlers (closing a panel, clearing search) win.     BackHandler(enabled = backReturnsToRail && !railFocused) {         runCatching { selectedRequester.requestFocus() }     }-    Box(modifier.fillMaxSize().background(background)) {-        Box(Modifier.fillMaxSize().padding(start = TvDimens.RailCollapsed)) {-            CompositionLocalProvider(LocalTvContentStart provides TvDimens.InsideFrameStart) {-                content()-            }-        }-        Box(-            Modifier-                .fillMaxHeight()-                .width(TvDimens.RailExpanded + 360.dp)-                .graphicsLayer { alpha = scrimAlpha }-                .background(-                    Brush.horizontalGradient(-                        0f to background,-                        0.45f to background.copy(alpha = 0.92f),-                        1f to Color.Transparent,-                    ),-                ),-        )+    Row(modifier.fillMaxSize().background(MaterialTheme.colorScheme.background)) {         Column(             Modifier                 .fillMaxHeight()-                .width(railWidth)+                .width(TvDimens.Rail)                 .onFocusChanged { railFocused = it.hasFocus }                 .focusRestorer(selectedRequester)                 .focusGroup()-                .padding(horizontal = 16.dp, vertical = TvDimens.SafeVertical),-            verticalArrangement = Arrangement.spacedBy(6.dp),+                .padding(horizontal = 8.dp, vertical = TvDimens.SafeVertical),+            verticalArrangement = Arrangement.spacedBy(6.dp, Alignment.CenterVertically),+            horizontalAlignment = Alignment.CenterHorizontally,         ) {-            Box(Modifier.height(56.dp).fillMaxWidth().clipToBounds(), contentAlignment = Alignment.CenterStart) {-                if (brand != null) {-                    Box(Modifier.wrapContentWidth(Alignment.Start, unbounded = true)) { brand() }-                }-            }-            Spacer(Modifier.weight(1f))             destinations.forEachIndexed { index, destination ->                 RailItem(                     destination = destination,                     selected = index == selected,-                    expanded = railFocused,                     onFocused = { if (index != selected) onSelect(index) },                     onClick = {                         onSelect(index)@@ -125,7 +89,11 @@ fun TvAppFrame(                     modifier = Modifier.focusRequester(requesters[index]),                 )             }-            Spacer(Modifier.weight(1.4f))+        }+        Box(Modifier.weight(1f).fillMaxHeight()) {+            CompositionLocalProvider(LocalTvContentStart provides TvDimens.InsideFrameStart) {+                content()+            }         }     } }@@ -134,7 +102,6 @@ fun TvAppFrame( private fun RailItem(     destination: TvDestination,     selected: Boolean,-    expanded: Boolean,     onFocused: () -> Unit,     onClick: () -> Unit,     modifier: Modifier = Modifier,@@ -145,10 +112,9 @@ private fun RailItem(         onClick = onClick,         modifier = modifier             .fillMaxWidth()-            .height(52.dp)             .onFocusChanged { if (it.isFocused) onFocused() },-        shape = SelectableSurfaceDefaults.shape(CircleShape),-        scale = SelectableSurfaceDefaults.scale(focusedScale = 1.04f),+        shape = SelectableSurfaceDefaults.shape(MaterialTheme.shapes.medium),+        scale = SelectableSurfaceDefaults.scale(focusedScale = 1.05f),         colors = SelectableSurfaceDefaults.colors(             containerColor = Color.Transparent,             contentColor = scheme.onSurfaceVariant,@@ -160,23 +126,21 @@ private fun RailItem(             focusedSelectedContentColor = scheme.inverseOnSurface,         ),     ) {-        Row(-            Modifier.fillMaxSize().padding(horizontal = 16.dp),-            verticalAlignment = Alignment.CenterVertically,+        Column(+            Modifier.fillMaxWidth().padding(vertical = 10.dp, horizontal = 4.dp),+            horizontalAlignment = Alignment.CenterHorizontally,         ) {             Box(Modifier.size(24.dp), contentAlignment = Alignment.Center) {                 TvIcon(destination.icon)             }-            if (expanded) {-                Text(-                    text = destination.label,-                    style = MaterialTheme.typography.titleMedium,-                    maxLines = 1,-                    softWrap = false,-                    overflow = TextOverflow.Clip,-                    modifier = Modifier.padding(start = 16.dp),-                )-            }+            Text(+                text = destination.label,+                style = MaterialTheme.typography.labelMedium,+                maxLines = 1,+                overflow = TextOverflow.Ellipsis,+                textAlign = TextAlign.Center,+                modifier = Modifier.padding(top = 4.dp),+            )         }     } }
library/tv/src/main/java/com/vayunmathur/library/tv/TvCards.kt
diff --git a/library/tv/src/main/java/com/vayunmathur/library/tv/TvCards.kt b/library/tv/src/main/java/com/vayunmathur/library/tv/TvCards.ktindex 3196bc37e1..b314402834 100644--- a/library/tv/src/main/java/com/vayunmathur/library/tv/TvCards.kt+++ b/library/tv/src/main/java/com/vayunmathur/library/tv/TvCards.kt@@ -2,17 +2,13 @@ package com.vayunmathur.library.tv  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.BoxScope-import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxHeight 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.runtime.Composable import androidx.compose.ui.Alignment@@ -25,12 +21,9 @@ import androidx.compose.ui.unit.dp import androidx.tv.material3.Border import androidx.tv.material3.Card import androidx.tv.material3.CardDefaults-import androidx.tv.material3.ClickableSurfaceDefaults import androidx.tv.material3.Glow-import androidx.tv.material3.LocalContentColor import androidx.tv.material3.MaterialTheme import androidx.tv.material3.StandardCardContainer-import androidx.tv.material3.Surface import androidx.tv.material3.Text  object TvAspect {@@ -40,8 +33,9 @@ object TvAspect { }  /**- * The one card for media and catalog rows: image on top that scales and gets a white ring on- * focus, title/subtitle underneath (outside the image, so text never sits on artwork).+ * The one card for media and catalog grids: image on top that scales and gets a white ring on+ * focus, title/subtitle underneath (outside the image, so text never sits on artwork). Fills+ * its grid cell unless [width] is given (for horizontal rows).  *  * @param image fills the card; use `ContentScale.Crop`. Draw nothing for a tinted placeholder.  * @param progress 0..1 resume bar along the image bottom, `null` hides it.@@ -52,7 +46,7 @@ fun TvMediaCard(     onClick: () -> Unit,     image: @Composable BoxScope.() -> Unit,     modifier: Modifier = Modifier,-    width: Dp = 280.dp,+    width: Dp = Dp.Unspecified,     aspectRatio: Float = TvAspect.Landscape,     title: String? = null,     subtitle: String? = null,@@ -64,14 +58,14 @@ fun TvMediaCard(     val scheme = MaterialTheme.colorScheme     val shape = MaterialTheme.shapes.medium     StandardCardContainer(-        modifier = modifier.width(width).onFocusChanged { if (it.hasFocus) onFocus?.invoke() },+        modifier = modifier.cellWidth(width).onFocusChanged { if (it.hasFocus) onFocus?.invoke() },         imageCard = { interactionSource ->             Card(                 onClick = onClick,                 onLongClick = onLongClick,                 interactionSource = interactionSource,                 shape = CardDefaults.shape(shape),-                scale = CardDefaults.scale(focusedScale = 1.06f),+                scale = CardDefaults.scale(focusedScale = 1.04f),                 colors = CardDefaults.colors(containerColor = scheme.surfaceVariant),                 border = CardDefaults.border(                     focusedBorder = Border(BorderStroke(3.dp, scheme.inverseSurface), shape = shape),@@ -101,7 +95,7 @@ fun TvMediaCard(                     style = MaterialTheme.typography.titleSmall,                     maxLines = 2,                     overflow = TextOverflow.Ellipsis,-                    modifier = Modifier.padding(top = 10.dp),+                    modifier = Modifier.fillMaxWidth().padding(top = 10.dp),                 )             }         },@@ -113,84 +107,13 @@ fun TvMediaCard(                     color = scheme.onSurfaceVariant,                     maxLines = 1,                     overflow = TextOverflow.Ellipsis,-                    modifier = Modifier.padding(top = 2.dp),+                    modifier = Modifier.fillMaxWidth().padding(top = 2.dp),                 )             }         },     ) } -/**- * A horizontal tile: leading art, two lines of text, optional trailing slot. For app listings,- * channels, playlists, downloads - anything that reads better as a row than as artwork.- */-@Composable-fun TvRowCard(-    title: String,-    onClick: () -> Unit,-    modifier: Modifier = Modifier,-    width: Dp = 380.dp,-    subtitle: String? = null,-    supporting: String? = null,-    leading: (@Composable BoxScope.() -> Unit)? = null,-    leadingSize: Dp = 72.dp,-    trailing: (@Composable () -> Unit)? = null,-    onLongClick: (() -> Unit)? = null,-    onFocus: (() -> Unit)? = null,-) {-    val scheme = MaterialTheme.colorScheme-    Surface(-        onClick = onClick,-        onLongClick = onLongClick,-        modifier = modifier.width(width).onFocusChanged { if (it.hasFocus) onFocus?.invoke() },-        shape = ClickableSurfaceDefaults.shape(MaterialTheme.shapes.medium),-        scale = ClickableSurfaceDefaults.scale(focusedScale = 1.04f),-        colors = ClickableSurfaceDefaults.colors(-            containerColor = scheme.surface,-            contentColor = scheme.onSurface,-            focusedContainerColor = scheme.inverseSurface,-            focusedContentColor = scheme.inverseOnSurface,-        ),-    ) {-        Row(Modifier.padding(14.dp), verticalAlignment = Alignment.CenterVertically) {-            if (leading != null) {-                Box(-                    Modifier.size(leadingSize).background(scheme.surfaceVariant, MaterialTheme.shapes.small),-                    contentAlignment = Alignment.Center,-                    content = leading,-                )-            }-            Column(-                Modifier.weight(1f).padding(start = if (leading != null) 16.dp else 4.dp),-                verticalArrangement = Arrangement.spacedBy(2.dp),-            ) {-                Text(title, style = MaterialTheme.typography.titleMedium, maxLines = 1, overflow = TextOverflow.Ellipsis)-                if (subtitle != null) {-                    Text(-                        subtitle,-                        style = MaterialTheme.typography.bodyMedium,-                        color = LocalContentColor.current.copy(alpha = 0.78f),-                        maxLines = 1,-                        overflow = TextOverflow.Ellipsis,-                    )-                }-                if (supporting != null) {-                    Text(-                        supporting,-                        style = MaterialTheme.typography.bodySmall,-                        color = LocalContentColor.current.copy(alpha = 0.62f),-                        maxLines = 1,-                        overflow = TextOverflow.Ellipsis,-                    )-                }-            }-            if (trailing != null) {-                Box(Modifier.padding(start = 12.dp)) { TvIcon(trailing) }-            }-        }-    }-}- /** A thin accent progress bar, used along image bottoms and in download rows. */ @Composable fun TvProgressStrip(progress: Float, modifier: Modifier = Modifier, height: Dp = 4.dp) {
library/tv/src/main/java/com/vayunmathur/library/tv/TvControls.kt
diff --git a/library/tv/src/main/java/com/vayunmathur/library/tv/TvControls.kt b/library/tv/src/main/java/com/vayunmathur/library/tv/TvControls.ktindex 56941ea216..2a753d0490 100644--- a/library/tv/src/main/java/com/vayunmathur/library/tv/TvControls.kt+++ b/library/tv/src/main/java/com/vayunmathur/library/tv/TvControls.kt@@ -43,6 +43,7 @@ fun TvButton(         onClick = onClick,         modifier = modifier,         enabled = enabled,+        scale = ButtonDefaults.scale(focusedScale = 1.04f),         colors = ButtonDefaults.colors(             containerColor = if (primary) scheme.primary else scheme.surfaceVariant,             contentColor = if (primary) scheme.onPrimary else scheme.onSurface,
library/tv/src/main/java/com/vayunmathur/library/tv/TvGrid.kt
diff --git a/library/tv/src/main/java/com/vayunmathur/library/tv/TvGrid.kt b/library/tv/src/main/java/com/vayunmathur/library/tv/TvGrid.ktnew file mode 100644index 0000000000..ab48fb2f72--- /dev/null+++ b/library/tv/src/main/java/com/vayunmathur/library/tv/TvGrid.kt@@ -0,0 +1,88 @@+package com.vayunmathur.library.tv++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.lazy.grid.GridCells+import androidx.compose.foundation.lazy.grid.GridItemSpan+import androidx.compose.foundation.lazy.grid.LazyGridScope+import androidx.compose.foundation.lazy.grid.LazyGridState+import androidx.compose.foundation.lazy.grid.LazyVerticalGrid+import androidx.compose.foundation.lazy.grid.rememberLazyGridState+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import androidx.tv.material3.MaterialTheme+import androidx.tv.material3.Text++/**+ * The screen body: one vertically scrolling grid. Phone lists become grids of full-information+ * cards ([TvInfoCard]); phone sections become [tvGridHeader]s spanning the full width. Use+ * [GridCells.Fixed] (3 for info cards, 4-5 for thumbnails, 6-7 for posters).+ */+@Composable+fun TvGrid(+    columns: Int,+    modifier: Modifier = Modifier,+    state: LazyGridState = rememberLazyGridState(),+    content: LazyGridScope.() -> Unit,+) {+    LazyVerticalGrid(+        columns = GridCells.Fixed(columns),+        state = state,+        modifier = modifier.fillMaxSize(),+        contentPadding = tvContentPadding(top = TvDimens.SafeVertical),+        horizontalArrangement = Arrangement.spacedBy(TvDimens.ItemGap),+        verticalArrangement = Arrangement.spacedBy(TvDimens.ItemGap),+        content = content,+    )+}++/** Something that spans the whole grid row: a banner, a chip row, a header. */+fun LazyGridScope.tvFullWidth(key: Any, content: @Composable () -> Unit) {+    item(key = key, span = { GridItemSpan(maxLineSpan) }, contentType = "full-width") { content() }+}++/**+ * A section header spanning the grid: title, optional one-line subtitle, optional trailing+ * action (typically a "Browse"/"See all" [TvButton]). Mirrors the phone's section headers.+ */+fun LazyGridScope.tvGridHeader(+    key: Any,+    title: String,+    subtitle: String? = null,+    first: Boolean = false,+    action: (@Composable () -> Unit)? = null,+) {+    item(key = key, span = { GridItemSpan(maxLineSpan) }, contentType = "header") {+        Row(+            Modifier.fillMaxWidth().padding(top = if (first) 0.dp else TvDimens.ShelfGap),+            verticalAlignment = Alignment.CenterVertically,+        ) {+            Column(Modifier.weight(1f)) {+                Text(+                    text = title,+                    style = MaterialTheme.typography.titleLarge,+                    color = MaterialTheme.colorScheme.onSurface,+                    maxLines = 1,+                    overflow = TextOverflow.Ellipsis,+                )+                if (subtitle != null) {+                    Text(+                        text = subtitle,+                        style = MaterialTheme.typography.bodyMedium,+                        color = MaterialTheme.colorScheme.onSurfaceVariant,+                        maxLines = 1,+                        overflow = TextOverflow.Ellipsis,+                    )+                }+            }+            if (action != null) action()+        }+    }+}
library/tv/src/main/java/com/vayunmathur/library/tv/TvHero.kt
diff --git a/library/tv/src/main/java/com/vayunmathur/library/tv/TvHero.kt b/library/tv/src/main/java/com/vayunmathur/library/tv/TvHero.ktdeleted file mode 100644index c617842d90..0000000000--- a/library/tv/src/main/java/com/vayunmathur/library/tv/TvHero.kt+++ /dev/null@@ -1,138 +0,0 @@-package com.vayunmathur.library.tv--import androidx.compose.animation.Crossfade-import androidx.compose.animation.core.tween-import androidx.compose.foundation.background-import androidx.compose.foundation.horizontalScroll-import androidx.compose.foundation.rememberScrollState-import androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.BoxScope-import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.Row-import androidx.compose.foundation.layout.RowScope-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.padding-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.text.style.TextOverflow-import androidx.compose.ui.unit.dp-import androidx.tv.material3.MaterialTheme-import androidx.tv.material3.Text--/**- * Full-bleed artwork behind a screen, cross-fading when [key] changes (e.g. the focused card),- * with scrims that fade it into the background on the start edge and bottom so text over it- * stays legible. [image] draws for a given key; draw nothing to show only the background.- */-@Composable-fun <K> TvBackdrop(-    key: K,-    modifier: Modifier = Modifier,-    image: @Composable BoxScope.(K) -> Unit,-) {-    val background = MaterialTheme.colorScheme.background-    Box(modifier.fillMaxSize()) {-        Crossfade(targetState = key, animationSpec = tween(BACKDROP_FADE_MS), label = "tv-backdrop") { k ->-            Box(Modifier.fillMaxSize()) { image(k) }-        }-        Box(-            Modifier.fillMaxSize().background(-                Brush.horizontalGradient(-                    0f to background,-                    0.35f to background.copy(alpha = 0.85f),-                    0.7f to Color.Transparent,-                ),-            ),-        )-        Box(-            Modifier.fillMaxSize().background(-                Brush.verticalGradient(-                    0f to Color.Transparent,-                    0.55f to background.copy(alpha = 0.35f),-                    1f to background,-                ),-            ),-        )-    }-}--/**- * Hero text block for a featured item or a detail page: eyebrow, big title, a meta line,- * a few lines of description and an action row. The text is sized to the left ~half of the- * screen so the backdrop art stays visible; the action row spans the full width and scrolls.- */-@Composable-fun TvHeroText(-    title: String,-    modifier: Modifier = Modifier,-    eyebrow: String? = null,-    meta: List<String> = emptyList(),-    description: String? = null,-    descriptionLines: Int = 3,-    chips: (@Composable RowScope.() -> Unit)? = null,-    actions: (@Composable RowScope.() -> Unit)? = null,-) {-    val scheme = MaterialTheme.colorScheme-    Column(modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(10.dp)) {-        Column(Modifier.fillMaxWidth(0.52f), verticalArrangement = Arrangement.spacedBy(10.dp)) {-            if (eyebrow != null) {-                Text(-                    text = eyebrow.uppercase(),-                    style = MaterialTheme.typography.labelLarge,-                    color = scheme.primary,-                    maxLines = 1,-                )-            }-            Text(-                text = title,-                style = MaterialTheme.typography.displaySmall,-                color = scheme.onSurface,-                maxLines = 2,-                overflow = TextOverflow.Ellipsis,-            )-            if (meta.isNotEmpty()) {-                Text(-                    text = meta.filter { it.isNotBlank() }.joinToString("  •  "),-                    style = MaterialTheme.typography.titleSmall,-                    color = scheme.onSurfaceVariant,-                    maxLines = 1,-                    overflow = TextOverflow.Ellipsis,-                )-            }-            if (chips != null) {-                Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically) {-                    chips()-                }-            }-            if (!description.isNullOrBlank()) {-                Text(-                    text = description,-                    style = MaterialTheme.typography.bodyLarge,-                    color = scheme.onSurface.copy(alpha = 0.85f),-                    maxLines = descriptionLines,-                    overflow = TextOverflow.Ellipsis,-                )-            }-        }-        if (actions != null) {-            // Full width and scrollable, not confined to the text column: detail pages carry many-            // actions and a squeezed button is one the D-pad can't reach.-            Row(-                horizontalArrangement = Arrangement.spacedBy(12.dp),-                verticalAlignment = Alignment.CenterVertically,-                modifier = Modifier-                    .fillMaxWidth()-                    .horizontalScroll(rememberScrollState())-                    .padding(top = 6.dp, bottom = 6.dp, end = TvDimens.SafeHorizontal),-                content = actions,-            )-        }-    }-}--private const val BACKDROP_FADE_MS = 450
library/tv/src/main/java/com/vayunmathur/library/tv/TvInfoCard.kt
diff --git a/library/tv/src/main/java/com/vayunmathur/library/tv/TvInfoCard.kt b/library/tv/src/main/java/com/vayunmathur/library/tv/TvInfoCard.ktnew file mode 100644index 0000000000..e6dcda5a34--- /dev/null+++ b/library/tv/src/main/java/com/vayunmathur/library/tv/TvInfoCard.kt@@ -0,0 +1,123 @@+package com.vayunmathur.library.tv++import androidx.compose.foundation.background+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.BoxScope+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.RowScope+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.width+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.focus.onFocusChanged+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.Dp+import androidx.compose.ui.unit.dp+import androidx.tv.material3.ClickableSurfaceDefaults+import androidx.tv.material3.LocalContentColor+import androidx.tv.material3.MaterialTheme+import androidx.tv.material3.Surface+import androidx.tv.material3.Text++/**+ * The full-information card a phone list row becomes on TV: leading art, title, a byline,+ * a couple of lines of description, a badge row and an optional trailing status/progress -+ * everything a phone search result shows. Fills its grid cell; lay them out 3 across in a+ * [TvGrid] so a screen shows a dozen at once.+ *+ * @param badges source/tier/installed pills, rendered in a row under the text.+ * @param progress 0..1 bar along the card bottom (downloads, installs, resume); `null` hides it.+ */+@Composable+fun TvInfoCard(+    title: String,+    onClick: () -> Unit,+    modifier: Modifier = Modifier,+    width: Dp = Dp.Unspecified,+    subtitle: String? = null,+    description: String? = null,+    descriptionLines: Int = 2,+    leading: (@Composable BoxScope.() -> Unit)? = null,+    leadingSize: Dp = 64.dp,+    badges: (@Composable RowScope.() -> Unit)? = null,+    trailing: (@Composable () -> Unit)? = null,+    progress: Float? = null,+    onLongClick: (() -> Unit)? = null,+    onFocus: (() -> Unit)? = null,+) {+    val scheme = MaterialTheme.colorScheme+    Surface(+        onClick = onClick,+        onLongClick = onLongClick,+        modifier = modifier.cellWidth(width).onFocusChanged { if (it.hasFocus) onFocus?.invoke() },+        shape = ClickableSurfaceDefaults.shape(MaterialTheme.shapes.medium),+        scale = ClickableSurfaceDefaults.scale(focusedScale = 1.03f),+        colors = ClickableSurfaceDefaults.colors(+            containerColor = scheme.surface,+            contentColor = scheme.onSurface,+            focusedContainerColor = scheme.inverseSurface,+            focusedContentColor = scheme.inverseOnSurface,+        ),+    ) {+        Column {+            Row(Modifier.padding(14.dp), verticalAlignment = Alignment.Top) {+                if (leading != null) {+                    Box(+                        Modifier+                            .size(leadingSize)+                            .clip(MaterialTheme.shapes.small)+                            .background(scheme.surfaceVariant),+                        contentAlignment = Alignment.Center,+                        content = leading,+                    )+                }+                Column(+                    Modifier.weight(1f).padding(start = if (leading != null) 14.dp else 0.dp),+                    verticalArrangement = Arrangement.spacedBy(2.dp),+                ) {+                    Text(title, style = MaterialTheme.typography.titleMedium, maxLines = 1, overflow = TextOverflow.Ellipsis)+                    if (subtitle != null) {+                        Text(+                            subtitle,+                            style = MaterialTheme.typography.bodySmall,+                            color = LocalContentColor.current.copy(alpha = 0.72f),+                            maxLines = 1,+                            overflow = TextOverflow.Ellipsis,+                        )+                    }+                    if (!description.isNullOrBlank()) {+                        Text(+                            description,+                            style = MaterialTheme.typography.bodyMedium,+                            color = LocalContentColor.current.copy(alpha = 0.86f),+                            maxLines = descriptionLines,+                            overflow = TextOverflow.Ellipsis,+                        )+                    }+                    if (badges != null) {+                        Row(+                            Modifier.padding(top = 4.dp),+                            horizontalArrangement = Arrangement.spacedBy(6.dp),+                            verticalAlignment = Alignment.CenterVertically,+                            content = badges,+                        )+                    }+                }+                if (trailing != null) {+                    Box(Modifier.padding(start = 10.dp)) { TvIcon(trailing) }+                }+            }+            if (progress != null) TvProgressStrip(progress)+        }+    }+}++/** Fixed width when given, otherwise fill the grid cell / parent. */+internal fun Modifier.cellWidth(width: Dp): Modifier =+    if (width == Dp.Unspecified) fillMaxWidth() else width(width)
library/tv/src/main/java/com/vayunmathur/library/tv/TvLayout.kt
diff --git a/library/tv/src/main/java/com/vayunmathur/library/tv/TvLayout.kt b/library/tv/src/main/java/com/vayunmathur/library/tv/TvLayout.ktindex 72d455092d..0c1aa39c69 100644--- a/library/tv/src/main/java/com/vayunmathur/library/tv/TvLayout.kt+++ b/library/tv/src/main/java/com/vayunmathur/library/tv/TvLayout.kt@@ -48,13 +48,13 @@ fun TvScreenHeader(     Row(         modifier             .fillMaxWidth()-            .padding(start = tvContentStart(), end = TvDimens.SafeHorizontal, top = TvDimens.SafeVertical, bottom = 16.dp),+            .padding(start = tvContentStart(), end = TvDimens.SafeHorizontal, top = TvDimens.SafeVertical, bottom = 8.dp),         verticalAlignment = Alignment.CenterVertically,     ) {         Column(Modifier.weight(1f)) {             Text(                 text = title,-                style = MaterialTheme.typography.headlineLarge,+                style = MaterialTheme.typography.headlineSmall,                 color = MaterialTheme.colorScheme.onSurface,                 maxLines = 1,                 overflow = TextOverflow.Ellipsis,
library/tv/src/main/java/com/vayunmathur/library/tv/TvTheme.kt
diff --git a/library/tv/src/main/java/com/vayunmathur/library/tv/TvTheme.kt b/library/tv/src/main/java/com/vayunmathur/library/tv/TvTheme.ktindex 4947a216a1..413d9c0df8 100644--- a/library/tv/src/main/java/com/vayunmathur/library/tv/TvTheme.kt+++ b/library/tv/src/main/java/com/vayunmathur/library/tv/TvTheme.kt@@ -14,6 +14,8 @@ import androidx.tv.material3.LocalContentColor import androidx.tv.material3.MaterialTheme import androidx.tv.material3.darkColorScheme import androidx.compose.material3.LocalContentColor as M3LocalContentColor+import androidx.compose.material3.MaterialTheme as M3MaterialTheme+import androidx.compose.material3.darkColorScheme as m3DarkColorScheme  /** One accent per app, so each TV app is recognisable at a glance from across the room. */ object TvAccent {@@ -27,11 +29,10 @@ object TvAccent { object TvDimens {     val SafeHorizontal: Dp = 48.dp     val SafeVertical: Dp = 28.dp-    val RailCollapsed: Dp = 88.dp-    val RailExpanded: Dp = 264.dp-    val ItemGap: Dp = 20.dp-    val ShelfGap: Dp = 32.dp-    val InsideFrameStart: Dp = 24.dp+    val Rail: Dp = 120.dp+    val ItemGap: Dp = 16.dp+    val ShelfGap: Dp = 24.dp+    val InsideFrameStart: Dp = 16.dp }  /** Start inset for screen content: smaller inside [TvAppFrame] because the rail already insets it. */@@ -40,16 +41,23 @@ internal val LocalTvContentStart = compositionLocalOf { TvDimens.SafeHorizontal /**  * Always-dark TV theme keyed off one accent. Focused surfaces flip to near-white with dark  * content (the Google TV convention), so focus is legible on any backdrop.+ *+ * Also installs a matching dark Material 3 scheme: `MainNavigation` paints each route with the+ * M3 background and `:library:ui` pieces read M3 colours, which otherwise default to light.+ * Paints nothing itself, so it can wrap overlays above a video surface.  */ @Composable fun MaTvTheme(accent: Color, content: @Composable () -> Unit) {     val scheme = remember(accent) { tvColorScheme(accent) }-    MaterialTheme(colorScheme = scheme) {-        CompositionLocalProvider(-            LocalContentColor provides scheme.onSurface,-            M3LocalContentColor provides scheme.onSurface,-            content = content,-        )+    val m3Scheme = remember(accent) { m3ColorScheme(scheme) }+    M3MaterialTheme(colorScheme = m3Scheme) {+        MaterialTheme(colorScheme = scheme) {+            CompositionLocalProvider(+                LocalContentColor provides scheme.onSurface,+                M3LocalContentColor provides scheme.onSurface,+                content = content,+            )+        }     } } @@ -97,3 +105,32 @@ private fun tvColorScheme(accent: Color): ColorScheme {         scrim = Color.Black,     ) }++private fun m3ColorScheme(tv: ColorScheme) = m3DarkColorScheme(+    primary = tv.primary,+    onPrimary = tv.onPrimary,+    primaryContainer = tv.primaryContainer,+    onPrimaryContainer = tv.onPrimaryContainer,+    secondary = tv.secondary,+    onSecondary = tv.onSecondary,+    secondaryContainer = tv.secondaryContainer,+    onSecondaryContainer = tv.onSecondaryContainer,+    tertiary = tv.tertiary,+    background = tv.background,+    onBackground = tv.onBackground,+    surface = tv.surface,+    onSurface = tv.onSurface,+    surfaceVariant = tv.surfaceVariant,+    onSurfaceVariant = tv.onSurfaceVariant,+    surfaceContainer = tv.surface,+    surfaceContainerHigh = tv.surfaceVariant,+    inverseSurface = tv.inverseSurface,+    inverseOnSurface = tv.inverseOnSurface,+    error = tv.error,+    onError = tv.onError,+    errorContainer = tv.errorContainer,+    onErrorContainer = tv.onErrorContainer,+    outline = tv.border,+    outlineVariant = tv.borderVariant,+    scrim = tv.scrim,+)
library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.ktindex 8dcd436036..fdc0dfdbe3 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt@@ -143,6 +143,7 @@ import androidx.compose.material.icons.filled.CastConnected import androidx.compose.material.icons.filled.ScreenShare import androidx.compose.material.icons.filled.Speaker import androidx.compose.material.icons.filled.Movie+import androidx.compose.material.icons.filled.ClosedCaption import androidx.compose.material.icons.filled.Tv import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.Cloud@@ -1779,3 +1780,7 @@ fun IconMovie(modifier: Modifier = Modifier, tint: Color = LocalContentColor.cur @Composable fun IconStore(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) =     AppIcon(Icons.Filled.Store, "Store", modifier, tint)++@Composable+fun IconClosedCaption(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) =+    AppIcon(Icons.Filled.ClosedCaption, "Captions", modifier, tint)