Merge pull request 'Rebrand the Android TV app as Wolfskin' (#16) from fm/wolfskin-2-rebrand into main
This commit is contained in:
commit
bc220021a8
62 changed files with 237 additions and 93 deletions
|
|
@ -0,0 +1,44 @@
|
|||
package com.github.damontecres.wholphin.ui
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.luminance
|
||||
import com.github.damontecres.wholphin.ui.theme.colors.WolfskinThemeColors
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
/** Normal and focused TV text must remain readable on the fork's dark palette. */
|
||||
class WolfskinThemeColorsTest {
|
||||
@Test
|
||||
fun darkPaletteHasReadableNormalAndFocusedText() {
|
||||
val television = WolfskinThemeColors.darkScheme
|
||||
val material = WolfskinThemeColors.darkSchemeMaterial
|
||||
val textAndBackgrounds =
|
||||
listOf(
|
||||
television.onBackground to television.background,
|
||||
television.onSurface to television.surface,
|
||||
television.onSurfaceVariant to television.surfaceVariant,
|
||||
television.onPrimary to television.primary,
|
||||
television.onPrimaryContainer to television.primaryContainer,
|
||||
television.onSecondary to television.secondary,
|
||||
television.onSecondaryContainer to television.secondaryContainer,
|
||||
television.onTertiary to television.tertiary,
|
||||
television.onTertiaryContainer to television.tertiaryContainer,
|
||||
material.onBackground to material.background,
|
||||
material.onSurface to material.surface,
|
||||
material.onPrimary to material.primary,
|
||||
material.onPrimaryContainer to material.primaryContainer,
|
||||
)
|
||||
textAndBackgrounds.forEach { (text, background) ->
|
||||
assertReadable(text, background)
|
||||
}
|
||||
}
|
||||
|
||||
private fun assertReadable(text: Color, background: Color) {
|
||||
val textLuminance = text.luminance()
|
||||
val backgroundLuminance = background.luminance()
|
||||
val contrast =
|
||||
(maxOf(textLuminance, backgroundLuminance) + .05f) /
|
||||
(minOf(textLuminance, backgroundLuminance) + .05f)
|
||||
assertTrue("Text contrast $contrast is below 4.5:1", contrast >= 4.5f)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue