Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -101,7 +102,7 @@ fun NavTab(
selected: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier,
ink: Color? = null,
ink: HeaderInk? = null,
) {
FocusSurface(
onClick = onClick,
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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),
)
}
}
}
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Double?>) {
/** 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
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
}
}
Binary file modified android-tv/app/src/test/screenshots/shell_header_over_hero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android-tv/app/src/test/screenshots/shell_header_over_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android-tv/app/src/test/screenshots/shell_header_over_mid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading