Commit 2789f03870

2789f0387067963b74122c8fbf7c6fd2ac783f6e

parent: 7fdcca78d0

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-14 06:01 UTC

Design for built-in themes and alternate app icons

Layout: unified · split

docs/plans/2026-10-14-themes-and-icons-design.md added +174
@@ -0,0 +1,174 @@
1# Built-in Themes and Alternate App Icons
2
3## Goal
4
5Users who don't write TOML pick from a list of built-in color themes, one for the light appearance and one for the dark, on the Mac and on iOS. Users pick an app icon from a list of alternates to suit their taste. Themes and icons are separate choices.
6
7## Scope
8
9In:
10
11- 16 built-in palettes (7 light, 9 dark), selectable per appearance in Settings on both platforms.
12- An `accent` theme slot that tints SwiftUI controls.
13- 13 app icons, each with default, dark and tinted variants for the system icon styles.
14- iOS: alternate app icons through `setAlternateIconName`.
15- Mac: the selected icon shown in the Dock while the app runs; the bundle's icon compiled from an asset catalog so the system's dark and tinted styles apply to it.
16
17Out:
18
19- Changing the Mac app's icon on disk (Finder, Dock after quit).
20- Tying icons to themes.
21- Theming the Watch app or its icon.
22- A theme editor.
23
24## Themes
25
26### Palettes
27
28Each palette covers one appearance and is TOML text in a Swift string literal, one file per palette, `Sources/OrgPresentation/Themes/<Name>.swift`. They are not SwiftPM resources: `OrgPresentation` is linked into the widget, Quick Look and Spotlight extensions, and a resource bundle would have to be copied into each by `build-app.sh` and the Xcode project.
29
30```toml
31name = "Solarized Light"
32appearance = "light"
33
34[theme]
35background = "#fdf6e3"
36foreground = "#657b83"
37accent = "#268bd2"
38# … every slot
39```
40
41| Light | Dark |
42| --- | --- |
43| `default-light` Default | `default-dark` Default |
44| `solarized-light` Solarized Light | `solarized-dark` Solarized Dark |
45| `gruvbox-light` Gruvbox Light | `gruvbox-dark` Gruvbox Dark |
46| `modus-operandi` Modus Operandi | `modus-vivendi` Modus Vivendi |
47| `catppuccin-latte` Catppuccin Latte | `catppuccin-mocha` Catppuccin Mocha |
48| `tomorrow` Tomorrow | `nord` Nord |
49| `paper` Paper | `dracula` Dracula |
50| | `tokyo-night` Tokyo Night |
51| | `doom-one` doom-one |
52
53`default-light` and `default-dark` hold the values now in `ThemeSpec.default`, which is built from them. They leave `ThemeSpec.systemDefaults` and `accent` unset, so the default look does not change. Every other palette sets every slot, the sidebar, modeline and agenda backgrounds included.
54
55Each ported palette's upstream license is recorded in `THIRD_PARTY.org`. Paper is original.
56
57`ThemeSpec.palettes(_ appearance:) -> [Palette]` lists the palettes in the table's order, parsed once with `ThemeSpec.reading`. `Palette` has `id`, `name`, `appearance` and `colors: [String: RGBA]`.
58
59### Settings
60
61Two entries in `UserConfig`'s `Setting` registry, section `theme`:
62
63| Key | Defaults key | Fallback |
64| --- | --- | --- |
65| `light-theme` | `themeLight` | `"default-light"` |
66| `dark-theme` | `themeDark` | `"default-dark"` |
67
68An id that isn't a bundled palette of that appearance adds the problem `config.toml: unknown light-theme <id>` (or `dark-theme`) and uses the Default palette.
69
70### Layering
71
72`UserConfig.theme` builds the base from the two palettes: `light` = the light palette's colors, `dark` = the dark palette's colors. Then `theme-file`, then `config.toml`'s `[theme]`, `[theme.light]`, `[theme.dark]`, `[theme.todo]` and `[theme.category]`, as today. With both settings at Default the result equals today's.
73
74`default-theme.toml` is still written at launch from `default-light` and `default-dark`.
75
76### Accent
77
78`accent` is added to `ThemeSpec.slots` ("buttons, toggles and selection in lists; unset: the system's") and to `systemDefaults`. When set it is applied with `.tint()`:
79
80- Mac: on each scene root that sets `.environment(\.orgTheme, …)` in `OrgstarApp.swift`.
81- iOS: on the root tab view.
82
83Existing `.tint(` call sites are left alone.
84
85### Copy to Config Folder
86
87Writes the selected palette of the current appearance as `<id>.toml` into the configuration folder, as a theme file (`[theme.light]` or `[theme.dark]`), and sets `theme-file` to it. An existing file of that name is not overwritten; the button reports it instead.
88
89### Picker UI
90
91Mac, Settings ▸ Appearance, a new first section "Theme":
92
93- Light and Dark rows, each a menu `Picker` of that appearance's palettes, each item with a swatch strip of `background`, `foreground`, `heading-1`, `todo` and `accent`.
94- Copy to Config Folder.
95- Footer: colors in `config.toml` and the theme file apply on top.
96
97iOS, Settings tab, a new section "Appearance":
98
99- Light Theme and Dark Theme rows, each pushing a list of palettes. Each row is a card of sample Org text (a heading, a TODO keyword, a tag, a link, a timestamp) styled with that palette through `MobileTheme`.
100- The choice is written to the configuration folder's `config.toml`, so it syncs with the Mac.
101- "In use ▸ Theme" shows `<light name> / <dark name>`, plus the theme file's name when set.
102
103The choice applies at once on both platforms; the open editor is the preview.
104
105### Widgets
106
107Widgets take colors from the `ThemeSpec` handed to `WidgetData` and `AgendaSnapshot`, so they follow the palettes. A theme change triggers the same widget reload a config change does now.
108
109## Icons
110
111### Catalog
112
113| Id | Look |
114| --- | --- |
115| `default` | Gold ✱ and white bars on blue-violet (today's icon) |
116| `midnight` | Gold ✱ on near-black |
117| `paper` | Dark ✱ and bars on off-white |
118| `org` | Gold ✱ on Org mode's green-teal |
119| `sunset` | White ✱ on orange-to-pink |
120| `forest` | Cream ✱ on deep green |
121| `mono` | White ✱ on graphite |
122| `rainbow` | White ✱ on a rainbow gradient |
123| `outline` | Line drawing of the ✱ and bars on white |
124| `terminal` | Green ✱ and bars on black |
125| `unicorn` | White unicorn head in profile on green-teal, the gold ✱ at the horn's tip |
126| `unicorn-night` | The unicorn on deep indigo, silver ✱ |
127| `unicorn-pastel` | The unicorn on pink-to-lavender |
128
129The unicorn is drawn for orgstar in `make-icon.swift`; the Org mode logo is not copied.
130
131### Generation
132
133`scripts/make-icon.swift` takes a variant table: background gradient, glyph, glyph color, bar color, and a drawing style (`filled`, `outline`, `unicorn`). For each icon it writes:
134
135- default: the icon as today.
136- dark: the glyph and bars on a transparent background, which the system places on its dark background.
137- tinted: a grayscale glyph and bars on a transparent background, which the system tints.
138
139Outputs:
140
141- `ios/Orgstar/Assets.xcassets/AppIcon.appiconset` and `AppIcon-<Id>.appiconset` for the others, each a 1024-pixel PNG per variant, with `appearances` entries `luminosity: dark` and `luminosity: tinted` in `Contents.json`.
142- `packaging/AppIcons.xcassets` for the Mac, the same sets at the Mac's sizes, compiled by `build-app.sh`.
143- Previews (light and dark, 256 pixels): on iOS an `IconPreview-<id>` image set in `Assets.xcassets`; on the Mac PNGs `build-app.sh` copies into `Contents/Resources/IconPreviews/`, loaded with `Bundle.main`.
144
145The generated catalogs are committed; `make-icon.swift` is run by hand when the icons change, and a check in `scripts/` fails when the committed PNGs differ from a fresh run.
146
147### iOS
148
149- The Xcode project sets `ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES` for the app target, so every `AppIcon-*` set is an alternate.
150- Settings tab, "Appearance" section: an App Icon row pushing a grid of previews. Tapping one calls `UIApplication.shared.setAlternateIconName` (`nil` for `default`); the system's confirmation alert shows. The selection reflects `UIApplication.shared.alternateIconName`, the only source of truth.
151- The choice is per device and is not written to `config.toml`.
152
153### Mac
154
155- `scripts/build-app.sh` compiles `AppIcons.xcassets` with `actool --app-icon AppIcon` into `Contents/Resources/Assets.car` and sets `CFBundleIconName = AppIcon`, replacing `iconutil`, the `.icns` and `CFBundleIconFile` (the app requires macOS 26).
156- Settings ▸ Appearance: an App Icon row with a grid of previews. The choice is kept in `UserDefaults` (`appIcon`), per Mac, not in `config.toml`.
157- At launch and on change, a choice other than `default` sets `NSApp.applicationIconImage` to its light or dark preview by `NSApp.effectiveAppearance`, and again when the appearance changes. `default` sets it to `nil`. The footer says the icon shows in the Dock while orgstar runs.
158
159## Testing
160
161- `OrgPresentationTests`:
162 - Each bundled palette parses with no problems, has a known `appearance`, and sets every slot outside `systemDefaults` (Default palettes) or every slot (the others).
163 - Contrast against `background`: `foreground` and `table` at least 4.5:1; headings, TODO classes, `link`, `timestamp`, `code` and `syntax-*` at least 3:1.
164 - `ThemeSpec.default` equals the result of `default-light` + `default-dark`.
165- `OrgAppTests` (`UserConfig.theme`):
166 - Default/Default with no overrides equals today's output.
167 - `light-theme = "nord"` (wrong appearance) and an unknown id give a problem and Default.
168 - `theme-file` and `[theme.dark]` still layer over the chosen palettes.
169- Icons: the generated-asset check; manual check on an iOS 26 device and macOS 26 of each icon in default, dark and tinted styles.
170
171## Risks
172
173- Whether macOS 26 applies `luminosity` appearances from an `.appiconset` compiled by `actool` to the bundle's icon. Checked first in the plan. If it doesn't, the Mac bundle icon uses only the default variant and the system derives dark and tinted versions itself.
174- iOS alternate icons with dark and tinted appearances require the per-set `appearances` entries to compile into the alternates. Checked on a device before the other 12 icons are drawn.