PeachPalette.kt

2.7 KB · raw

1package com.peachpasswords.ui.theme23import androidx.compose.runtime.Composable4import androidx.compose.runtime.staticCompositionLocalOf5import androidx.compose.ui.graphics.Color67/**8 * A resolved set of Peach colour tokens. Peach is dark-only, so [peachDark] is9 * the sole factory; the indirection survives because it also carries the live10 * accent, which the [PeachColors] singleton cannot.11 *12 * Accent-derived tints (glow, border, dim …) are NOT stored here: they are the13 * `Color.peachGlow()` family in AccentColors.kt, computed from the current accent14 * at the call site so they re-derive whenever the user changes their accent.15 */16data class PeachPalette(17    // Backgrounds / surfaces18    val Bg: Color,19    val S1: Color,20    val S2: Color,21    val S3: Color,22    val SurfaceCard: Color,23    val SurfaceElevated: Color,24    val SettingsGroupBg: Color,25    // Text hierarchy26    val T0: Color,27    val T1: Color,28    val T2: Color,29    val T3: Color,30    val T4: Color,31    // Accent (the live runtime accent — same value LocalPeachAccent carries)32    val Accent: Color,33    // Semantic34    val Breach: Color,35    val BreachBg: Color,36    val BreachBorder: Color,37    val HealthOk: Color,38    val TotpTag: Color,39    val SyncOk: Color,40    val SyncBusy: Color,41    val SyncErr: Color,42    // Shell top fade43    val ShellTopSolid: Color,44    val ShellTopFade: Color,45)4647/**48 * The active palette. Provided by [PeachTheme]; reading it without a surrounding49 * theme is a programming error (every Peach surface lives under [PeachTheme]).50 */51val LocalPeachColors = staticCompositionLocalOf<PeachPalette> {52    error("No PeachPalette provided — wrap your composable in PeachTheme {}")53}5455/** Convenience accessor — use this everywhere instead of [PeachColors].* */56val peachColors: PeachPalette57    @Composable get() = LocalPeachColors.current5859/** The Peach palette: the canonical tokens from [PeachColors] plus the live accent. */60fun peachDark(accent: Color = DEFAULT_ACCENT): PeachPalette = PeachPalette(61    Bg = PeachColors.Bg,62    S1 = PeachColors.S1,63    S2 = PeachColors.S2,64    S3 = PeachColors.S3,65    SurfaceCard = PeachColors.SurfaceCard,66    SurfaceElevated = PeachColors.SurfaceElevated,67    SettingsGroupBg = PeachColors.SettingsGroupBg,68    T0 = PeachColors.T0,69    T1 = PeachColors.T1,70    T2 = PeachColors.T2,71    T3 = PeachColors.T3,72    T4 = PeachColors.T4,73    Accent = accent,74    Breach = PeachColors.Breach,75    BreachBg = PeachColors.BreachBg,76    BreachBorder = PeachColors.BreachBorder,77    HealthOk = PeachColors.HealthOk,78    TotpTag = PeachColors.TotpTag,79    SyncOk = PeachColors.SyncOk,80    SyncBusy = PeachColors.SyncBusy,81    SyncErr = PeachColors.SyncErr,82    ShellTopSolid = PeachColors.ShellTopSolid,83    ShellTopFade = PeachColors.ShellTopFade,84)