colour letter placeholders by name and seed artwork themes from them

This commit is contained in:
austinried
2026-10-04 00:30:05 +00:00
parent 065bd99086
commit f33266113b
10 changed files with 60 additions and 9 deletions
@@ -3,6 +3,7 @@ package com.subtracks.ui.theme
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.luminance
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
import org.junit.Assert.assertTrue
import org.junit.Test
@@ -27,6 +28,14 @@ class ArtworkColorsTest {
}
}
@Test
fun placeholderColourDependsOnTheNameAndIsNotGrey() {
assertEquals(0, placeholderSeed(""))
assertNotEquals(placeholderSeed("Kid A"), placeholderSeed("Amnesiac"))
val (_, saturation, _) = Color(placeholderSeed("Kid A")).toHsl()
assertTrue("placeholder should carry colour", saturation > 0f)
}
@Test
fun independentOfAlphaBits() {
assertEquals(
@@ -77,6 +77,18 @@ class ArtworkExtractionTest {
assertTrue(colors!!.scheme.background.luminance() < 0.1f)
}
@Test
fun fallsBackToAPlaceholderColourWhenThereIsNoArt() {
var colors: ArtworkColors? = null
composeRule.setContent {
SubtracksTheme {
colors = rememberArtworkColors(null, fallbackName = "Kid A")
}
}
composeRule.waitForIdle()
assertEquals(artworkColorsFromSeed(placeholderSeed("Kid A")).scheme.primary, colors?.scheme?.primary)
}
@Test
fun keepsContentStateWhenArtworkArrives() {
val artwork = mutableStateOf<ArtworkColors?>(null)