PeachPalette.kt

2.8 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    val SyncWarn: Color,43    // Shell top fade44    val ShellTopSolid: Color,45    val ShellTopFade: Color,46)4748/**49 * The active palette. Provided by [PeachTheme]; reading it without a surrounding50 * theme is a programming error (every Peach surface lives under [PeachTheme]).51 */52val LocalPeachColors = staticCompositionLocalOf<PeachPalette> {53    error("No PeachPalette provided — wrap your composable in PeachTheme {}")54}5556/** Convenience accessor — use this everywhere instead of [PeachColors].* */57val peachColors: PeachPalette58    @Composable get() = LocalPeachColors.current5960/** The Peach palette: the canonical tokens from [PeachColors] plus the live accent. */61fun peachDark(accent: Color = DEFAULT_ACCENT): PeachPalette = PeachPalette(62    Bg = PeachColors.Bg,63    S1 = PeachColors.S1,64    S2 = PeachColors.S2,65    S3 = PeachColors.S3,66    SurfaceCard = PeachColors.SurfaceCard,67    SurfaceElevated = PeachColors.SurfaceElevated,68    SettingsGroupBg = PeachColors.SettingsGroupBg,69    T0 = PeachColors.T0,70    T1 = PeachColors.T1,71    T2 = PeachColors.T2,72    T3 = PeachColors.T3,73    T4 = PeachColors.T4,74    Accent = accent,75    Breach = PeachColors.Breach,76    BreachBg = PeachColors.BreachBg,77    BreachBorder = PeachColors.BreachBorder,78    HealthOk = PeachColors.HealthOk,79    TotpTag = PeachColors.TotpTag,80    SyncOk = PeachColors.SyncOk,81    SyncBusy = PeachColors.SyncBusy,82    SyncErr = PeachColors.SyncErr,83    SyncWarn = PeachColors.SyncBusy,84    ShellTopSolid = PeachColors.ShellTopSolid,85    ShellTopFade = PeachColors.ShellTopFade,86)