diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f85367f..56d324a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,9 +31,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- **TV header**: the logo, the tabs and the account's name each pick their ink - from the luminance of what is behind them, the still's fade included, with - the same pass as the channel logos. +- **TV header**: what sits on the hero's still gets a plate, light or dark from + the luminance behind it, the fade included, with the same pass as the channel + logos: no ink alone reads on a busy picture. ## [1.6.4] - 2026-10-31 diff --git a/android-tv/app/src/main/java/studio/kahn/iris/tv/ui/components/Header.kt b/android-tv/app/src/main/java/studio/kahn/iris/tv/ui/components/Header.kt index 8090ded7..80a3b6ee 100644 --- a/android-tv/app/src/main/java/studio/kahn/iris/tv/ui/components/Header.kt +++ b/android-tv/app/src/main/java/studio/kahn/iris/tv/ui/components/Header.kt @@ -1,6 +1,7 @@ package studio.kahn.iris.tv.ui.components import studio.kahn.iris.tv.ui.nav.HeaderBackdrop +import studio.kahn.iris.tv.ui.nav.HeaderInk import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.layout.findRootCoordinates import androidx.compose.ui.layout.boundsInRoot @@ -101,7 +102,7 @@ fun NavTab( selected: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier, - ink: Color? = null, + ink: HeaderInk? = null, ) { FocusSurface( onClick = onClick, @@ -113,8 +114,8 @@ fun NavTab( }, shape = IrisShape.pill, colors = FocusColors.Quiet.copy( - container = if (selected) IrisColor.accentWash else Color.Transparent, - content = if (selected) IrisColor.accent else ink ?: IrisColor.inkMuted, + container = if (selected) IrisColor.accentWash else ink?.plate ?: Color.Transparent, + content = if (selected) IrisColor.accent else ink?.words ?: IrisColor.inkMuted, ), ) { Box(Modifier.padding(horizontal = 12.dp), contentAlignment = Alignment.Center) { @@ -150,7 +151,12 @@ fun TvHeader( modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically, ) { - OverBackdrop(backdrop) { ink, probe -> IrisWordmark(probe, ink = ink ?: IrisColor.ink) } + OverBackdrop(backdrop) { ink, probe -> + IrisWordmark( + probe.then(if (ink != null) Modifier.background(ink.plate, IrisShape.pill) else Modifier), + ink = ink?.words ?: IrisColor.ink, + ) + } Spacer(Modifier.width(IrisSpace.s6)) Row( Modifier @@ -178,13 +184,13 @@ fun TvHeader( onClick = onAccount, modifier = probe.heightIn(min = IrisSize.controlSmall), shape = IrisShape.pill, - colors = FocusColors.Quiet.copy(content = IrisColor.inkMuted), + colors = FocusColors.Quiet.copy(container = ink?.plate ?: Color.Transparent, content = IrisColor.inkMuted), ) { focused -> Account( accountName, focused, updateAvailable, - ink, + ink?.words, Modifier .padding(start = 3.dp, end = 12.dp) .clearAndSetSemantics { @@ -197,7 +203,13 @@ fun TvHeader( ) } } else { - Account(accountName, focused = false, update = false, ink = ink, modifier = probe) + Account( + accountName, + focused = false, + update = false, + ink = ink?.words, + modifier = probe.then(if (ink != null) Modifier.background(ink.plate, IrisShape.pill) else Modifier), + ) } } } @@ -206,7 +218,7 @@ fun TvHeader( /** [content] in the words that read over the part of [backdrop] behind it, told by the probe it wears. */ @Composable -private fun OverBackdrop(backdrop: HeaderBackdrop?, content: @Composable (ink: Color?, probe: Modifier) -> Unit) { +private fun OverBackdrop(backdrop: HeaderBackdrop?, content: @Composable (ink: HeaderInk?, probe: Modifier) -> Unit) { var span by remember { mutableStateOf(0f to 0f) } val probe = Modifier.onGloballyPositioned { at -> val width = at.findRootCoordinates().size.width.toFloat() diff --git a/android-tv/app/src/main/java/studio/kahn/iris/tv/ui/nav/HeaderBackdrop.kt b/android-tv/app/src/main/java/studio/kahn/iris/tv/ui/nav/HeaderBackdrop.kt index 52c31ee5..ac8b1e56 100644 --- a/android-tv/app/src/main/java/studio/kahn/iris/tv/ui/nav/HeaderBackdrop.kt +++ b/android-tv/app/src/main/java/studio/kahn/iris/tv/ui/nav/HeaderBackdrop.kt @@ -2,25 +2,39 @@ package studio.kahn.iris.tv.ui.nav import androidx.compose.runtime.Immutable import androidx.compose.ui.graphics.Color +import studio.kahn.iris.tv.ui.screens.live.LogoTone import studio.kahn.iris.tv.ui.screens.live.toneOf +import studio.kahn.iris.tv.ui.theme.IrisColor + +/** Words over a still, on their [plate]: a mean tells nothing of a busy picture, no ink alone reads on it. */ +@Immutable +data class HeaderInk(val words: Color, val plate: Color) /** * What the header sits on, across the screen: a relative luminance per cell, null where only the * ground shows. Each thing in the header reads the part behind it, so the logo on the ground keeps - * its colours while the name beside it goes dark over a bright still. + * its colours while the name beside it takes a plate over the still. */ @Immutable class HeaderBackdrop(private val cells: List) { - /** The words that read best between [from] and [to], fractions of the screen; null: the usual ones. */ - fun inkAt(from: Float, to: Float): Color? { + /** How to read between [from] and [to], fractions of the screen; null: as usual. */ + fun inkAt(from: Float, to: Float): HeaderInk? { if (cells.isEmpty()) return null val first = (from * cells.size).toInt().coerceIn(0, cells.lastIndex) val last = (to * cells.size).toInt().coerceIn(first, cells.lastIndex) val seen = cells.subList(first, last + 1).filterNotNull() val mean = if (seen.isEmpty()) return null else seen.average() - return if (mean < NEAR_GROUND) null else toneOf(mean).plate + if (mean < NEAR_GROUND) return null + return if (toneOf(mean) == LogoTone.Dark) { + HeaderInk(LogoTone.Dark.plate, IrisColor.artInk.copy(alpha = LIGHT_PLATE_ALPHA)) + } else { + HeaderInk(LogoTone.Light.plate, IrisColor.stage.copy(alpha = DARK_PLATE_ALPHA)) + } } } /** Below this a still reads as the ground: the usual words hold, and two tabs side by side stay alike. */ private const val NEAR_GROUND = 0.04 + +private const val LIGHT_PLATE_ALPHA = 0.85f +private const val DARK_PLATE_ALPHA = 0.75f diff --git a/android-tv/app/src/test/java/studio/kahn/iris/tv/ui/nav/HeaderBackdropTest.kt b/android-tv/app/src/test/java/studio/kahn/iris/tv/ui/nav/HeaderBackdropTest.kt index faf8185a..ad1ac5a9 100644 --- a/android-tv/app/src/test/java/studio/kahn/iris/tv/ui/nav/HeaderBackdropTest.kt +++ b/android-tv/app/src/test/java/studio/kahn/iris/tv/ui/nav/HeaderBackdropTest.kt @@ -1,7 +1,9 @@ package studio.kahn.iris.tv.ui.nav +import androidx.compose.ui.graphics.luminance import org.junit.Assert.assertEquals import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue import org.junit.Test import studio.kahn.iris.tv.ui.screens.home.heroBackdrop import studio.kahn.iris.tv.ui.screens.live.LogoTone @@ -11,7 +13,7 @@ class HeaderBackdropTest { fun aBrightStillDarkensOnlyWhatSitsOnIt() { val backdrop = heroBackdrop { _, _ -> 0.8 } assertNull("the logo sits on the ground", backdrop.inkAt(0.05f, 0.1f)) - assertEquals("the name sits on the still", LogoTone.Dark.plate, backdrop.inkAt(0.9f, 0.95f)) + assertEquals("the name sits on the still", LogoTone.Dark.plate, backdrop.inkAt(0.9f, 0.95f)?.words) } @Test @@ -21,7 +23,7 @@ class HeaderBackdropTest { @Test fun aMidStillTakesTheLightWords() { - assertEquals(LogoTone.Light.plate, heroBackdrop { _, _ -> 0.12 }.inkAt(0.9f, 0.95f)) + assertEquals(LogoTone.Light.plate, heroBackdrop { _, _ -> 0.12 }.inkAt(0.9f, 0.95f)?.words) } @Test @@ -34,4 +36,12 @@ class HeaderBackdropTest { assertNull(HeaderBackdrop(emptyList()).inkAt(0f, 1f)) assertNull(heroBackdrop { _, _ -> null }.inkAt(0.9f, 0.95f)) } + + @Test + fun overAStillTheWordsHaveAPlate() { + val bright = heroBackdrop { _, _ -> 0.8 }.inkAt(0.9f, 0.95f) + val mid = heroBackdrop { _, _ -> 0.12 }.inkAt(0.9f, 0.95f) + assertTrue(bright!!.plate.luminance() > 0.5f && bright.plate.alpha > 0.7f) + assertTrue(mid!!.plate.luminance() < 0.1f && mid.plate.alpha > 0.7f) + } } diff --git a/android-tv/app/src/test/screenshots/shell_header_over_hero.png b/android-tv/app/src/test/screenshots/shell_header_over_hero.png index 23c830a3..4a878fc5 100644 Binary files a/android-tv/app/src/test/screenshots/shell_header_over_hero.png and b/android-tv/app/src/test/screenshots/shell_header_over_hero.png differ diff --git a/android-tv/app/src/test/screenshots/shell_header_over_light.png b/android-tv/app/src/test/screenshots/shell_header_over_light.png index 82bc016d..549f9411 100644 Binary files a/android-tv/app/src/test/screenshots/shell_header_over_light.png and b/android-tv/app/src/test/screenshots/shell_header_over_light.png differ diff --git a/android-tv/app/src/test/screenshots/shell_header_over_mid.png b/android-tv/app/src/test/screenshots/shell_header_over_mid.png index 39066561..ac589241 100644 Binary files a/android-tv/app/src/test/screenshots/shell_header_over_mid.png and b/android-tv/app/src/test/screenshots/shell_header_over_mid.png differ