docs/plans/2026-10-14-themes-and-icons-design.md
163 lines · 9954 bytes
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. actool keeps only the default rendition for macOS, so macOS derives the dark and tinted styles itself.
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 defined in Swift, in `Sources/OrgPresentation/Palettes.swift`, by 12 named colors (`ThemeSpec.Roles`: `bg`, `alt`, `fg`, `dim`, `red`, `orange`, `yellow`, `green`, `cyan`, `blue`, `purple`, `accent`). One table, `Roles.slots`, maps those colors onto every slot, so each palette is a dozen hex values, and the same table keeps every palette's slots in step when slots are added. Palettes 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| Light | Dark |
31| --- | --- |
32| `default-light` Default | `default-dark` Default |
33| `solarized-light` Solarized Light | `solarized-dark` Solarized Dark |
34| `gruvbox-light` Gruvbox Light | `gruvbox-dark` Gruvbox Dark |
35| `modus-operandi` Modus Operandi | `modus-vivendi` Modus Vivendi |
36| `catppuccin-latte` Catppuccin Latte | `catppuccin-mocha` Catppuccin Mocha |
37| `tomorrow` Tomorrow | `nord` Nord |
38| `paper` Paper | `dracula` Dracula |
39| | `tokyo-night` Tokyo Night |
40| | `doom-one` doom-one |
41
42`default-light` and `default-dark` are `ThemeSpec.default`'s light and dark colors, unchanged and not through `Roles`. 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.
43
44Where a ported palette's color fails the contrast test on its background, the palette uses a darker or lighter value of the same hue; the palette's comment in `Palettes.swift` lists those. Each ported palette's upstream license is recorded in `THIRD_PARTY.org`. Paper is original.
45
46`ThemeSpec.palettes(_ appearance:) -> [Palette]` lists the palettes in the table's order. `Palette` has `id`, `name`, `appearance` and `colors: [String: RGBA]`.
47
48### Settings
49
50Two entries in `UserConfig`'s `Setting` registry, section `theme`:
51
52| Key | Defaults key | Fallback |
53| --- | --- | --- |
54| `light-theme` | `themeLight` | `"default-light"` |
55| `dark-theme` | `themeDark` | `"default-dark"` |
56
57An 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.
58
59### Layering
60
61`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.
62
63`default-theme.toml` is still written at launch from `ThemeSpec.default`.
64
65### Accent
66
67`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()`:
68
69- Mac: on each scene root that sets `.environment(\.orgTheme, …)` in `OrgstarApp.swift`.
70- iOS: on the root tab view.
71
72Existing `.tint(` call sites are left alone.
73
74### Copy to Config Folder
75
76Writes the two selected palettes as `my-theme.toml` into the configuration folder, `[theme.light]` from the light palette and `[theme.dark]` from the dark, every slot written out, and sets `theme-file` to it. An existing file of that name is not overwritten; the button reports it instead.
77
78### Picker UI
79
80Mac, Settings ▸ Appearance, a new first section "Theme":
81
82- 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`.
83- Copy to Config Folder.
84- Footer: colors in `config.toml` and the theme file apply on top.
85
86iOS, Settings tab, a new section "Appearance":
87
88- 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`.
89- The choice is written to the configuration folder's `config.toml`, so it syncs with the Mac.
90- "In use ▸ Theme" shows `<light name> / <dark name>`, plus the theme file's name when set.
91
92The choice applies at once on both platforms; the open editor is the preview.
93
94### Widgets
95
96Widgets 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.
97
98## Icons
99
100### Catalog
101
102| Id | Look |
103| --- | --- |
104| `default` | Gold ✱ and white bars on blue-violet (today's icon) |
105| `midnight` | Gold ✱ on near-black |
106| `paper` | Dark ✱ and bars on off-white |
107| `org` | Gold ✱ on Org mode's green-teal |
108| `sunset` | White ✱ on orange-to-pink |
109| `forest` | Cream ✱ on deep green |
110| `mono` | White ✱ on graphite |
111| `rainbow` | White ✱ on a rainbow gradient |
112| `outline` | Line drawing of the ✱ and bars on white |
113| `terminal` | Green ✱ and bars on black |
114| `unicorn` | White unicorn head in profile on green-teal, the gold ✱ at the horn's tip |
115| `unicorn-night` | The unicorn on deep indigo, silver ✱ |
116| `unicorn-pastel` | The unicorn on pink-to-lavender |
117
118The unicorn is drawn for orgstar in `make-icon.swift`; the Org mode logo is not copied.
119
120### Generation
121
122`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:
123
124- default: the icon as today.
125- dark: the glyph and bars on a transparent background, which the system places on its dark background.
126- tinted: a grayscale glyph and bars on a transparent background, which the system tints.
127
128Outputs:
129
130- `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`.
131- `packaging/AppIcons.xcassets` for the Mac: the `AppIcon` set only, at the Mac's sizes, compiled by `build-app.sh`.
132- Previews: on iOS an `IconPreview-<id>` image set (256 pixels, light and dark appearances) in `Assets.xcassets`; on the Mac `packaging/IconPreviews/<id>-light.png` and `<id>-dark.png` (512 pixels), which `build-app.sh` copies into `Contents/Resources/IconPreviews/`, loaded with `Bundle.main`.
133
134The generated files are committed; `swift scripts/make-icon.swift` is run by hand when the icons change.
135
136### iOS
137
138- The Xcode project sets `ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES` for the app target, so every `AppIcon-*` set is an alternate.
139- 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.
140- The choice is per device and is not written to `config.toml`.
141
142### Mac
143
144- `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).
145- Settings ▸ Appearance: an App Icon row with a grid of previews. The choice is kept in `UserDefaults` (`appIcon`), per Mac, not in `config.toml`.
146- 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.
147
148## Testing
149
150- `OrgPresentationTests`:
151 - Each bundled palette parses with no problems, has a known `appearance`, and sets every slot outside `systemDefaults` (Default palettes) or every slot (the others).
152 - Contrast against `background`: `foreground` and `table` at least 4.5:1; headings, TODO classes, `link`, `timestamp`, `code` and `syntax-*` at least 3:1.
153 - Every palette's `colors` has exactly the keys of `ThemeSpec.slots` (Default palettes: minus `systemDefaults`).
154- `OrgAppTests` (`UserConfig.theme`):
155 - Default/Default with no overrides equals today's output.
156 - `light-theme = "nord"` (wrong appearance) and an unknown id give a problem and Default.
157 - `theme-file` and `[theme.dark]` still layer over the chosen palettes.
158- Icons: manual check on an iOS 26 device and macOS 26 of each icon in default, dark and tinted styles.
159
160## Risks
161
162- 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.
163- 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.