From 13654cbedd973fb02605716034151fdcaa87c13b Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Sat, 17 Oct 2026 15:04:36 -0400 Subject: [PATCH] fix(mobile): tint native playlist rows and tune cover palette contrast Co-authored-by: Cursor --- .../app/(app)/(tabs)/home/playlist/[id].tsx | 5 ++++- apps/mobile/lib/cover-palette.ts | 15 +++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx index a886445..f05373d 100644 --- a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx @@ -299,7 +299,10 @@ export default function PlaylistScreen() { listRowInsets({ top: 0, leading: 0, bottom: 0, trailing: 0 }), listRowSeparator("hidden"), ] - const nativeSongRowModifiers = [frame({ height: 32 })] + const nativeSongRowModifiers = [ + frame({ height: 32 }), + listRowBackground(palette.background), + ] const shouldUseNativeSwipeList = Platform.OS === "ios" && playlist.isOwner && playlist.id diff --git a/apps/mobile/lib/cover-palette.ts b/apps/mobile/lib/cover-palette.ts index 9c4253d..fa441fb 100644 --- a/apps/mobile/lib/cover-palette.ts +++ b/apps/mobile/lib/cover-palette.ts @@ -28,7 +28,9 @@ export type CoverSwatches = { accent: string[] } -const PRIMARY_MIN_CONTRAST = 7 +// Best effort: `legibleBackground` only guarantees that white or black reaches +// 7:1, so on some backgrounds primary text settles for pure white or black. +const PRIMARY_MIN_CONTRAST = 10 const SECONDARY_MIN_CONTRAST = 4.5 const SECONDARY_TO_PRIMARY_CONTRAST = 0.62 const ACCENT_MIN_CONTRAST = 3 @@ -97,12 +99,9 @@ export function deriveCoverPalette( ) const accent = pickAccent(swatches.accent, background) ?? foreground - const accentForeground = - contrastRatio(background, accent) >= SECONDARY_MIN_CONTRAST - ? background - : contrastRatio([255, 255, 255], accent) >= contrastRatio([0, 0, 0], accent) - ? ([255, 255, 255] as Rgb) - : ([0, 0, 0] as Rgb) + const accentForeground: Rgb = prefersLightText(accent) + ? [255, 255, 255] + : [0, 0, 0] return { background: toHex(background), @@ -129,7 +128,7 @@ function legibleBackground(color: Rgb, schemeIsDark: boolean): Rgb { return clamped } - const pivot = schemeIsDark ? 0.24 : 0.16 + const pivot = schemeIsDark ? 0.28 : 0.14 return y < pivot ? withLuminance(clamped, DARK_BACKGROUND_MAX_LUMINANCE) : withLuminance(clamped, LIGHT_BACKGROUND_MIN_LUMINANCE)