| Paint the phone in COSMIC's own theme, read from cosmic-config ba4e71b nandi 8d ago | 1 | (ns frq.theme |
| 2 | "COSMIC's design tokens, as Flutter values. |
| 3 | |
| 4 | The colours, radii and spacing are the user's own, read out of cosmic-config |
| 5 | by tools/cosmic2cljd.py into `frq.theme.cosmic` — so the phone is painted in |
| 6 | whatever accent and surfaces COSMIC Settings is set to, rather than in a |
| 7 | guess at what COSMIC looks like. `just theme` moves them. |
| 8 | |
| 9 | What is not in cosmic-config is the typography scale: libcosmic carries |
| 10 | title1..title4, heading, body and caption as code rather than as |
| 11 | configuration. Those numbers are here, and the mapping from glimmer's tags |
| 12 | to them is `crates/jolt-cosmic`'s — `:title` is title3, `:title-2` is title4, |
| 13 | `:label` is body, `:dim-label` is caption." |
| 14 | (:require ["package:flutter/material.dart" :as m] |
| 15 | [frq.theme.cosmic :as c])) |
| 16 | |
| 17 | ;; ------------------------------------------------------------------ scale |
| 18 | |
| 19 | (def space-xxxs c/space-xxxs) |
| 20 | (def space-xxs c/space-xxs) |
| 21 | (def space-xs c/space-xs) |
| 22 | (def space-s c/space-s) |
| 23 | (def space-m c/space-m) |
| 24 | |
| 25 | (def radius-xs c/radius-xs) |
| 26 | (def radius-s c/radius-s) |
| 27 | (def radius-m c/radius-m) |
| 28 | |
| 29 | ;; libcosmic's typography, which is code rather than config. |
| 30 | (def text-title-3 24.0) ; :title |
| 31 | (def text-title-4 20.0) ; :title-2 |
| 32 | (def text-body 14.0) ; :label |
| 33 | (def text-caption 12.0) ; :dim-label, :status, :spinner |
| 34 | |
| 35 | ;; ---------------------------------------------------------------- palette |
| 36 | |
| 37 | (def accent c/accent) |
| 38 | (def on-accent c/on-accent) |
| 39 | (def bg c/bg) |
| 40 | (def on-bg c/on-bg) |
| 41 | (def component c/component) |
| 42 | (def component-hover c/component-hover) |
| 43 | (def card c/card) |
| 44 | (def card-component c/card-component) |
| 45 | (def on-card c/on-card) |
| 46 | (def destructive c/destructive) |
| 47 | (def on-destructive c/on-destructive) |
| 48 | (def success c/success) |
| 49 | (def divider c/divider) |
| 50 | |
| 51 | (def dim |
| 52 | "`:dim-label` is libcosmic's caption class, which is the body colour stepped |
| 53 | back rather than a colour of its own." |
| Say what every dart call is talking to a036bb4 nandi 7d ago | 54 | (.withValues ^m/Color on-bg .alpha 0.7)) |
| Paint the phone in COSMIC's own theme, read from cosmic-config ba4e71b nandi 8d ago | 55 | |
| 56 | (def brightness (if c/dark? m/Brightness.dark m/Brightness.light)) |
| 57 | |
| 58 | (defn app-theme [] |
| 59 | (m/ThemeData |
| 60 | .useMaterial3 true |
| 61 | .brightness brightness |
| 62 | .scaffoldBackgroundColor bg |
| 63 | .canvasColor bg |
| 64 | .colorScheme (m/ColorScheme.fromSeed |
| 65 | .seedColor accent |
| 66 | .brightness brightness |
| 67 | .surface bg |
| 68 | .primary accent |
| 69 | .onPrimary on-accent) |
| 70 | ;; COSMIC's own UI font. Absent on Android, where the fallback is Roboto — |
| 71 | ;; a difference the tokens cannot fix and the only one that shows. |
| 72 | .fontFamily "Fira Sans")) |