Built-in themes and alternate app icons !347

merged merged by cmc on 2026-10-15 07:18 UTC · krz/orgstar:themes-and-icons into main

166 files changed, +3878 −73

Layout: unified · split

Sources/OrgApp/AgendaSnapshot.swift +7 −1
@@ -145,7 +145,13 @@ public struct AgendaSnapshot: Codable, Equatable, Sendable {
145 } 145 }
146 var colors: [String: Hex] = [:] 146 var colors: [String: Hex] = [:]
147 for key in ["agenda-today", "agenda-time", "agenda-date", "foreground", "agenda-background"] { 147 for key in ["agenda-today", "agenda-time", "agenda-date", "foreground", "agenda-background"] {
148 colors[key] = Hex { theme.color(key, dark: $0) } 148 if ThemeSpec.systemDefaults.contains(key) {
149 // Left to the system in an appearance the theme doesn't set: "" there.
150 let (light, dark) = (theme.color(key, dark: false), theme.color(key, dark: true))
151 if light != nil || dark != nil { colors[key] = Hex(light: light?.hex ?? "", dark: dark?.hex ?? "") }
152 } else {
153 colors[key] = Hex { theme.color(key, dark: $0) }
154 }
149 } 155 }
150 self.colors = colors 156 self.colors = colors
151 self.generated = generated 157 self.generated = generated
Sources/OrgApp/ConfigSync.swift +5 −1
@@ -117,7 +117,9 @@ public final class ConfigSync {
117 /// The theme from the file read last and its theme file. 117 /// The theme from the file read last and its theme file.
118 func readTheme() { 118 func readTheme() {
119 guard let text, let read = UserConfig.theme( 119 guard let text, let read = UserConfig.theme(
120 config: text, themeFile: defaults.string(forKey: "themeFile"), in: url.deletingLastPathComponent() 120 config: text, themeFile: defaults.string(forKey: "themeFile"),
121 lightTheme: defaults.string(forKey: "themeLight"), darkTheme: defaults.string(forKey: "themeDark"),
122 in: url.deletingLastPathComponent()
121 ) else { return } 123 ) else { return }
122 if read.theme != theme { theme = read.theme } 124 if read.theme != theme { theme = read.theme }
123 problems = configProblems + read.problems 125 problems = configProblems + read.problems
@@ -142,6 +144,8 @@ public final class ConfigSync {
142 guard current != original else { return } 144 guard current != original else { return }
143 text = current 145 text = current
144 try? current.write(to: target, atomically: true, encoding: .utf8) 146 try? current.write(to: target, atomically: true, encoding: .utf8)
147 // A theme picked in Settings; the watcher's reload sees the text unchanged and skips it.
148 readTheme()
145 } 149 }
146} 150}
147#endif 151#endif
Sources/OrgApp/UserConfig.swift +23 −6
@@ -24,19 +24,20 @@ public enum UserConfig {
24 } 24 }
25 25
26 /// The theme `config.toml` (`text`) sets: its `[theme]` tables' colors over those of 26 /// The theme `config.toml` (`text`) sets: its `[theme]` tables' colors over those of
27 /// `theme-file` (a path relative to `folder`), over the default theme; with problems in 27 /// `theme-file` (a path relative to `folder`), over the palettes `light-theme` and
28 /// both. Nil when `text` isn't TOML. 28 /// `dark-theme` name; with problems in all three. Nil when `text` isn't TOML.
29 public static func theme( 29 public static func theme(
30 config text: String, themeFile name: String?, in folder: URL, 30 config text: String, themeFile name: String?, lightTheme: String? = nil, darkTheme: String? = nil, in folder: URL,
31 read: (URL) -> String? = { try? String(contentsOf: $0, encoding: .utf8) } 31 read: (URL) -> String? = { try? String(contentsOf: $0, encoding: .utf8) }
32 ) -> (theme: ThemeSpec, problems: [String])? { 32 ) -> (theme: ThemeSpec, problems: [String])? {
33 guard let tables = try? TOML.parse(text) else { return nil } 33 guard let tables = try? TOML.parse(text) else { return nil }
34 var spec = ThemeSpec.default 34 var (spec, problems) = ThemeSpec.base(light: lightTheme, dark: darkTheme)
35 var problems: [String] = []
36 if let name, !name.isEmpty { 35 if let name, !name.isEmpty {
37 if let themeText = read(folder.appendingPathComponent(name)) { 36 if let themeText = read(folder.appendingPathComponent(name)) {
38 do { 37 do {
39 (spec, problems) = ThemeSpec.reading(try TOML.parse(themeText), file: name) 38 let (read, more) = ThemeSpec.reading(try TOML.parse(themeText), over: spec, file: name)
39 spec = read
40 problems += more
40 } catch { 41 } catch {
41 problems.append("\(name): \(error)") 42 problems.append("\(name): \(error)")
42 } 43 }
@@ -48,6 +49,18 @@ public enum UserConfig {
48 return (merged, problems + more) 49 return (merged, problems + more)
49 } 50 }
50 51
52 /// The file Copy to Config Folder writes.
53 public static let copiedThemeFile = "my-theme.toml"
54
55 /// Writes the two palettes into `folder` as `copiedThemeFile`; false, writing nothing, when
56 /// the file is already there.
57 public static func copyTheme(light: Palette, dark: Palette, to folder: URL) throws -> Bool {
58 let file = folder.appendingPathComponent(copiedThemeFile)
59 guard !FileManager.default.fileExists(atPath: file.path) else { return false }
60 try ThemeSpec.themeFile(light: light, dark: dark).write(to: file, atomically: true, encoding: .utf8)
61 return true
62 }
63
51 /// Where earlier versions kept the configuration files. 64 /// Where earlier versions kept the configuration files.
52 public static var legacyDirectory: URL { 65 public static var legacyDirectory: URL {
53 FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0].appendingPathComponent("Orgstar") 66 FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0].appendingPathComponent("Orgstar")
@@ -307,6 +320,10 @@ public enum UserConfig {
307 comment: "points a heading is larger than the level below; level 4 and deeper are body size", legacy: ""), 320 comment: "points a heading is larger than the level below; level 4 and deeper are body size", legacy: ""),
308 Setting(section: "theme", key: "theme-file", defaultsKey: "themeFile", kind: .string, fallback: .string(""), 321 Setting(section: "theme", key: "theme-file", defaultsKey: "themeFile", kind: .string, fallback: .string(""),
309 comment: "a theme in its own file in this folder, under the colors set here; colors: see default-theme.toml", legacy: ""), 322 comment: "a theme in its own file in this folder, under the colors set here; colors: see default-theme.toml", legacy: ""),
323 Setting(section: "theme", key: "light-theme", defaultsKey: "themeLight", kind: .string, fallback: .string("default-light"),
324 comment: "the built-in theme for the light appearance: default-light, solarized-light, gruvbox-light, modus-operandi, catppuccin-latte, tomorrow or paper", legacy: ""),
325 Setting(section: "theme", key: "dark-theme", defaultsKey: "themeDark", kind: .string, fallback: .string("default-dark"),
326 comment: "the built-in theme for the dark appearance: default-dark, solarized-dark, gruvbox-dark, modus-vivendi, catppuccin-mocha, nord, dracula, tokyo-night or doom-one", legacy: ""),
310 Setting(section: "orgstar", key: "save", defaultsKey: "saveMode", kind: .choice([("automatic", "automatic"), ("explicit", "explicit")]), 327 Setting(section: "orgstar", key: "save", defaultsKey: "saveMode", kind: .choice([("automatic", "automatic"), ("explicit", "explicit")]),
311 fallback: .string("automatic"), comment: "automatic (1 s after typing stops) or explicit (only with ⌘S)", legacy: "general.save"), 328 fallback: .string("automatic"), comment: "automatic (1 s after typing stops) or explicit (only with ⌘S)", legacy: "general.save"),
312 Setting(section: "orgstar", key: "keymap", defaultsKey: "keymap", kind: .choice([("emacs", "emacs"), ("mac", "mac"), ("doom", "doom")]), 329 Setting(section: "orgstar", key: "keymap", defaultsKey: "keymap", kind: .choice([("emacs", "emacs"), ("mac", "mac"), ("doom", "doom")]),
Sources/OrgPresentation/AppIcons.swift added +46
@@ -0,0 +1,46 @@
1import Foundation
2
3/// The app icons `scripts/make-icon.swift` draws, by id, in its order.
4public enum AppIcons {
5 public static let ids = [
6 "default", "midnight", "paper", "org", "sunset", "forest", "mono", "rainbow", "outline", "terminal",
7 "unicorn", "unicorn-night", "unicorn-pastel",
8 ]
9
10 private static func words(_ id: String) -> [String] { id.split(separator: "-").map { $0.prefix(1).uppercased() + $0.dropFirst() } }
11
12 /// The icon's name in the user's language.
13 public static func name(_ id: String) -> String {
14 switch id {
15 case "default": String(localized: "Default")
16 case "midnight": String(localized: "Midnight")
17 case "paper": String(localized: "Paper")
18 case "sunset": String(localized: "Sunset")
19 case "forest": String(localized: "Forest")
20 case "rainbow": String(localized: "Rainbow")
21 case "outline": String(localized: "Outline")
22 case "unicorn": String(localized: "Unicorn")
23 case "unicorn-night": String(localized: "Unicorn Night")
24 case "unicorn-pastel": String(localized: "Unicorn Pastel")
25 default: words(id).joined(separator: " ")
26 }
27 }
28
29 /// The iOS alternate icon's name; nil for the primary icon.
30 public static func alternateName(_ id: String) -> String? {
31 id == "default" ? nil : "AppIcon-" + words(id).joined()
32 }
33
34 public static func id(alternateName: String?) -> String {
35 ids.first { self.alternateName($0) == alternateName && alternateName != nil } ?? "default"
36 }
37}
38
39extension AppIcons {
40 /// The Mac's Dock icon file for `id` in an appearance, in `Contents/Resources/IconPreviews`;
41 /// nil for the default, which is the bundle's own icon.
42 public static func dockFile(_ id: String, dark: Bool) -> String? {
43 guard id != "default", ids.contains(id) else { return nil }
44 return "\(id)-\(dark ? "dark" : "light")"
45 }
46}
Sources/OrgPresentation/Palettes.swift added +183
@@ -0,0 +1,183 @@
1import Foundation
2
3/// A built-in theme for one appearance, chosen with `light-theme` or `dark-theme`.
4public struct Palette: Sendable, Equatable {
5 public enum Appearance: String, Sendable { case light, dark }
6
7 public let id: String
8 public let name: String
9 public let appearance: Appearance
10 public let colors: [String: RGBA]
11
12 /// `name` in the user's language: Default and Paper are translated, the others are names.
13 public var displayName: String {
14 switch id {
15 case "default-light", "default-dark": String(localized: "Default")
16 case "paper": String(localized: "Paper")
17 default: name
18 }
19 }
20
21 public init(id: String, name: String, appearance: Appearance, colors: [String: RGBA]) {
22 self.id = id
23 self.name = name
24 self.appearance = appearance
25 self.colors = colors
26 }
27}
28
29extension ThemeSpec {
30 /// The built-in palettes of `appearance`, Default first.
31 public static func palettes(_ appearance: Palette.Appearance) -> [Palette] {
32 appearance == .light ? lightPalettes : darkPalettes
33 }
34
35 public static func palette(_ id: String, _ appearance: Palette.Appearance) -> Palette? {
36 palettes(appearance).first { $0.id == id }
37 }
38
39 public static func defaultPaletteID(_ appearance: Palette.Appearance) -> String {
40 "default-" + appearance.rawValue
41 }
42
43 /// `key`'s color in one appearance for the editor: the spec's own, else the default
44 /// theme's, else the spec's for the other appearance. Nil for a `systemDefaults` key the
45 /// spec leaves unset in this appearance, which the system colors there.
46 public func editorColor(_ key: String, dark isDark: Bool) -> RGBA? {
47 if let own = color(key, dark: isDark) { return own }
48 guard !Self.systemDefaults.contains(key) else { return nil }
49 return Self.default.color(key, dark: isDark) ?? color(key, dark: !isDark)
50 }
51
52 /// The default theme with each appearance's colors from the palette `light-theme` and
53 /// `dark-theme` name; Default where one is unset or unknown, with a problem for unknown.
54 public static func base(light: String?, dark: String?) -> (ThemeSpec, [String]) {
55 var spec = ThemeSpec.default
56 var problems: [String] = []
57 for (id, appearance) in [(light, Palette.Appearance.light), (dark, .dark)] {
58 guard let id, !id.isEmpty, id != defaultPaletteID(appearance) else { continue }
59 guard let palette = palette(id, appearance) else {
60 problems.append("config.toml: unknown \(appearance.rawValue)-theme \(id)")
61 continue
62 }
63 if appearance == .light { spec.light = palette.colors } else { spec.dark = palette.colors }
64 }
65 return (spec, problems)
66 }
67
68 // Upstream palettes; see THIRD_PARTY.org. Colors darkened from upstream to read at 3:1 on
69 // the background: Solarized Light yellow, green and cyan; Catppuccin Latte orange, yellow
70 // and green; Tomorrow orange and yellow.
71 static let lightPalettes: [Palette] = [
72 Palette(id: "default-light", name: "Default", appearance: .light, colors: ThemeSpec.default.light),
73 ported("solarized-light", "Solarized Light", .light, Roles(
74 bg: "#fdf6e3", alt: "#eee8d5", fg: "#586e75", dim: "#93a1a1", red: "#dc322f", orange: "#cb4b16", yellow: "#a57c00",
75 green: "#738a05", cyan: "#258f86", blue: "#268bd2", purple: "#6c71c4", accent: "#268bd2")),
76 ported("gruvbox-light", "Gruvbox Light", .light, Roles(
77 bg: "#fbf1c7", alt: "#ebdbb2", fg: "#3c3836", dim: "#928374", red: "#9d0006", orange: "#af3a03", yellow: "#b57614",
78 green: "#79740e", cyan: "#427b58", blue: "#076678", purple: "#8f3f71", accent: "#076678")),
79 ported("modus-operandi", "Modus Operandi", .light, Roles(
80 bg: "#ffffff", alt: "#f2f2f2", fg: "#000000", dim: "#595959", red: "#a60000", orange: "#972500", yellow: "#6f5500",
81 green: "#006800", cyan: "#005e8b", blue: "#0031a9", purple: "#721045", accent: "#0031a9")),
82 ported("catppuccin-latte", "Catppuccin Latte", .light, Roles(
83 bg: "#eff1f5", alt: "#e6e9ef", fg: "#4c4f69", dim: "#8c8fa1", red: "#d20f39", orange: "#d0590a", yellow: "#b06f13",
84 green: "#388c24", cyan: "#179299", blue: "#1e66f5", purple: "#8839ef", accent: "#8839ef")),
85 ported("tomorrow", "Tomorrow", .light, Roles(
86 bg: "#ffffff", alt: "#efefef", fg: "#4d4d4c", dim: "#8e908c", red: "#c82829", orange: "#c76b17", yellow: "#a87e00",
87 green: "#718c00", cyan: "#3e999f", blue: "#4271ae", purple: "#8959a8", accent: "#4271ae")),
88 // orgstar's own: warm paper and ink, for long reading.
89 ported("paper", "Paper", .light, Roles(
90 bg: "#f8f3e6", alt: "#efe8d6", fg: "#3b3428", dim: "#7d7262", red: "#a8322d", orange: "#a85a1f", yellow: "#8a6d1a",
91 green: "#4d6b2f", cyan: "#2f6b6b", blue: "#2f5486", purple: "#6b4a85", accent: "#a85a1f")),
92 ]
93
94 static let darkPalettes: [Palette] = [
95 Palette(id: "default-dark", name: "Default", appearance: .dark, colors: ThemeSpec.default.dark),
96 ported("solarized-dark", "Solarized Dark", .dark, Roles(
97 bg: "#002b36", alt: "#073642", fg: "#93a1a1", dim: "#586e75", red: "#dc322f", orange: "#cb4b16", yellow: "#b58900",
98 green: "#859900", cyan: "#2aa198", blue: "#268bd2", purple: "#6c71c4", accent: "#268bd2")),
99 ported("gruvbox-dark", "Gruvbox Dark", .dark, Roles(
100 bg: "#282828", alt: "#3c3836", fg: "#ebdbb2", dim: "#928374", red: "#fb4934", orange: "#fe8019", yellow: "#fabd2f",
101 green: "#b8bb26", cyan: "#8ec07c", blue: "#83a598", purple: "#d3869b", accent: "#83a598")),
102 ported("modus-vivendi", "Modus Vivendi", .dark, Roles(
103 bg: "#000000", alt: "#1e1e1e", fg: "#ffffff", dim: "#989898", red: "#ff5f59", orange: "#fec43f", yellow: "#d0bc00",
104 green: "#44bc44", cyan: "#00d3d0", blue: "#2fafff", purple: "#b6a0ff", accent: "#2fafff")),
105 ported("catppuccin-mocha", "Catppuccin Mocha", .dark, Roles(
106 bg: "#1e1e2e", alt: "#181825", fg: "#cdd6f4", dim: "#7f849c", red: "#f38ba8", orange: "#fab387", yellow: "#f9e2af",
107 green: "#a6e3a1", cyan: "#94e2d5", blue: "#89b4fa", purple: "#cba6f7", accent: "#cba6f7")),
108 ported("nord", "Nord", .dark, Roles(
109 bg: "#2e3440", alt: "#3b4252", fg: "#d8dee9", dim: "#616e88", red: "#bf616a", orange: "#d08770", yellow: "#ebcb8b",
110 green: "#a3be8c", cyan: "#8fbcbb", blue: "#88c0d0", purple: "#b48ead", accent: "#88c0d0")),
111 ported("dracula", "Dracula", .dark, Roles(
112 bg: "#282a36", alt: "#44475a", fg: "#f8f8f2", dim: "#6272a4", red: "#ff5555", orange: "#ffb86c", yellow: "#f1fa8c",
113 green: "#50fa7b", cyan: "#8be9fd", blue: "#8be9fd", purple: "#bd93f9", accent: "#bd93f9")),
114 ported("tokyo-night", "Tokyo Night", .dark, Roles(
115 bg: "#1a1b26", alt: "#16161e", fg: "#c0caf5", dim: "#565f89", red: "#f7768e", orange: "#ff9e64", yellow: "#e0af68",
116 green: "#9ece6a", cyan: "#7dcfff", blue: "#7aa2f7", purple: "#bb9af7", accent: "#7aa2f7")),
117 ported("doom-one", "doom-one", .dark, Roles(
118 bg: "#282c34", alt: "#21242b", fg: "#bbc2cf", dim: "#5b6268", red: "#ff6c6b", orange: "#da8548", yellow: "#ecbe7b",
119 green: "#98be65", cyan: "#46d9ff", blue: "#51afef", purple: "#c678dd", accent: "#51afef")),
120 ]
121}
122
123extension ThemeSpec {
124 /// A palette's named colors, from which every slot is set.
125 public struct Roles: Sendable {
126 public var bg, alt, fg, dim, red, orange, yellow, green, cyan, blue, purple, accent: String
127
128 /// Slot → role. `selection` and `inline-background` are translucent roles.
129 static let slots: [String: KeyPath<Roles, String> & Sendable] = [
130 "background": \.bg, "foreground": \.fg, "cursor": \.accent, "accent": \.accent,
131 "heading-1": \.blue, "heading-2": \.purple, "heading-3": \.green, "heading-4": \.orange,
132 "heading-5": \.blue, "heading-6": \.purple, "heading-7": \.green, "heading-8": \.orange,
133 "todo": \.red, "todo-next": \.blue, "todo-waiting": \.yellow, "done": \.green, "todo-cancelled": \.dim,
134 "priority": \.orange, "priority-a": \.red, "priority-b": \.orange, "priority-c": \.dim,
135 "tags": \.dim, "link": \.blue, "timestamp": \.purple, "code": \.orange, "verbatim": \.cyan,
136 "markup": \.dim, "comment": \.dim, "keyword": \.dim, "metadata": \.dim, "special": \.cyan,
137 "block-background": \.alt, "block-delimiter": \.dim, "table": \.fg,
138 "line-number": \.dim, "line-number-current": \.fg,
139 "syntax-keyword": \.purple, "syntax-string": \.green, "syntax-comment": \.dim, "syntax-function": \.blue,
140 "syntax-type": \.yellow, "syntax-number": \.orange, "syntax-property": \.cyan, "syntax-label": \.purple,
141 "sidebar-background": \.alt, "sidebar-foreground": \.fg, "sidebar-header": \.dim,
142 "modeline-background": \.alt, "modeline-foreground": \.fg, "modeline-highlight": \.accent,
143 "state-normal": \.blue, "state-insert": \.green, "state-visual": \.orange,
144 "agenda-background": \.bg, "agenda-date": \.fg, "agenda-today": \.accent, "agenda-time": \.dim, "agenda-category": \.dim,
145 "agenda-overdue": \.red, "agenda-due-soon": \.orange, "agenda-event": \.purple,
146 "habit-clear": \.blue, "habit-ready": \.green, "habit-alert": \.yellow, "habit-overdue": \.red,
147 ]
148
149 /// Alphas are whole bytes (`#…33`, `#…59`), so a palette written out as a theme file
150 /// reads back equal.
151 public func colors(dark: Bool) -> [String: RGBA] {
152 var out = Self.slots.compactMapValues { RGBA(hex: self[keyPath: $0]) }
153 if var selection = RGBA(hex: accent) {
154 selection.alpha = (dark ? 0x59 : 0x33) / 255
155 out["selection"] = selection
156 }
157 if var inline = RGBA(hex: dim) {
158 inline.alpha = 0x33 / 255
159 out["inline-background"] = inline
160 }
161 return out
162 }
163 }
164
165 private static func ported(_ id: String, _ name: String, _ appearance: Palette.Appearance, _ roles: Roles) -> Palette {
166 Palette(id: id, name: name, appearance: appearance, colors: roles.colors(dark: appearance == .dark))
167 }
168}
169
170extension ThemeSpec {
171 /// Two palettes as a theme file, every color written out, in slot order.
172 public static func themeFile(light: Palette, dark: Palette) -> String {
173 var out = "# \(light.name) and \(dark.name), copied from orgstar's built-in themes. Used with\n"
174 + "# theme-file = \"my-theme.toml\" under [theme] in config.toml; colors there apply on top.\n"
175 for (table, palette) in [("theme.light", light), ("theme.dark", dark)] {
176 out += "\n[\(table)]\n"
177 for slot in slots {
178 if let color = palette.colors[slot.key] { out += "\(slot.key) = \"\(color.hex)\"\n" }
179 }
180 }
181 return out
182 }
183}
Sources/OrgPresentation/ThemeSpec.swift +3 −1
@@ -73,6 +73,7 @@ public struct ThemeSpec: Equatable, Sendable {
73 ("foreground", "body text"), 73 ("foreground", "body text"),
74 ("cursor", "the caret"), 74 ("cursor", "the caret"),
75 ("selection", "selected text's background"), 75 ("selection", "selected text's background"),
76 ("accent", "buttons, toggles and selection in lists; unset: the system's"),
76 ("heading-1", "level 1 headings"), ("heading-2", "level 2 headings"), ("heading-3", "level 3 headings"), 77 ("heading-1", "level 1 headings"), ("heading-2", "level 2 headings"), ("heading-3", "level 3 headings"),
77 ("heading-4", "level 4 headings"), ("heading-5", "level 5 headings"), ("heading-6", "level 6 headings"), 78 ("heading-4", "level 4 headings"), ("heading-5", "level 5 headings"), ("heading-6", "level 6 headings"),
78 ("heading-7", "level 7 headings"), ("heading-8", "level 8 and deeper headings"), 79 ("heading-7", "level 7 headings"), ("heading-8", "level 8 and deeper headings"),
@@ -135,6 +136,7 @@ public struct ThemeSpec: Equatable, Sendable {
135 /// Keys the default theme leaves to the system, so windows keep the macOS look. 136 /// Keys the default theme leaves to the system, so windows keep the macOS look.
136 public static let systemDefaults: Set<String> = [ 137 public static let systemDefaults: Set<String> = [
137 "sidebar-background", "sidebar-foreground", "sidebar-header", "modeline-background", "modeline-foreground", "agenda-background", 138 "sidebar-background", "sidebar-foreground", "sidebar-header", "modeline-background", "modeline-foreground", "agenda-background",
139 "accent",
138 ] 140 ]
139 141
140 // MARK: - The default theme 142 // MARK: - The default theme
@@ -188,7 +190,7 @@ public struct ThemeSpec: Equatable, Sendable {
188 // MARK: - Reading 190 // MARK: - Reading
189 191
190 /// Keys of `[theme]` that aren't colors; config.toml's settings handle them. 192 /// Keys of `[theme]` that aren't colors; config.toml's settings handle them.
191 public static let typeKeys: Set<String> = ["font", "body-font", "font-size", "line-spacing", "text-width", "heading-size-step", "theme-file"] 193 public static let typeKeys: Set<String> = ["font", "body-font", "font-size", "line-spacing", "text-width", "heading-size-step", "theme-file", "light-theme", "dark-theme"]
192 194
193 /// Whether a table holds theme colors. 195 /// Whether a table holds theme colors.
194 public static func isThemeTable(_ name: String) -> Bool { 196 public static func isThemeTable(_ name: String) -> Bool {
Sources/Orgstar/AppIconSection.swift added +42
@@ -0,0 +1,42 @@
1import AppKit
2import OrgPresentation
3import SwiftUI
4
5/// Settings ▸ Appearance ▸ App Icon: the icon the Dock shows while orgstar runs.
6struct AppIconSection: View {
7 @AppStorage("appIcon") private var appIcon = "default"
8
9 var body: some View {
10 Section {
11 LazyVGrid(columns: [GridItem(.adaptive(minimum: 72), spacing: 12)], spacing: 12) {
12 ForEach(AppIcons.ids, id: \.self) { id in
13 Button {
14 appIcon = id
15 DockIcon.apply()
16 } label: {
17 VStack(spacing: 4) {
18 preview(id)
19 .resizable()
20 .frame(width: 56, height: 56)
21 .padding(4)
22 .background(id == appIcon ? Color.accentColor.opacity(0.25) : .clear, in: RoundedRectangle(cornerRadius: 10))
23 Text(AppIcons.name(id)).font(.caption)
24 }
25 }
26 .buttonStyle(.plain)
27 .accessibilityAddTraits(id == appIcon ? .isSelected : [])
28 }
29 }
30 } header: {
31 Text("App Icon")
32 } footer: {
33 Text("The icon shows in the Dock while orgstar runs. Finder, and the Dock after orgstar quits, show the default icon.")
34 .settingsFooter()
35 }
36 }
37
38 private func preview(_ id: String) -> Image {
39 let url = Bundle.main.url(forResource: "\(id)-light", withExtension: "png", subdirectory: "IconPreviews")
40 return url.flatMap { NSImage(contentsOf: $0) }.map { Image(nsImage: $0) } ?? Image(nsImage: NSApp.applicationIconImage)
41 }
42}
Sources/Orgstar/BacklinksPane.swift +2 −1
@@ -13,6 +13,7 @@ struct BacklinksPane: View {
13 @State private var toHeading: [HeadingLocation] = [] 13 @State private var toHeading: [HeadingLocation] = []
14 @State private var toFile: [HeadingLocation] = [] 14 @State private var toFile: [HeadingLocation] = []
15 @Environment(\.orgTheme) private var theme 15 @Environment(\.orgTheme) private var theme
16 @Environment(\.colorScheme) private var colorScheme
16 17
17 /// The heading at the caret. 18 /// The heading at the caret.
18 private var heading: OutlineEntry? { session.outline.last { $0.start <= commands.selection.location } } 19 private var heading: OutlineEntry? { session.outline.last { $0.start <= commands.selection.location } }
@@ -30,7 +31,7 @@ struct BacklinksPane: View {
30 } 31 }
31 Section("Links to this file") { rows(toFile) } 32 Section("Links to this file") { rows(toFile) }
32 } 33 }
33 .themedListBackground(theme.color("sidebar-background")) 34 .themedListBackground(theme.color("sidebar-background", in: colorScheme))
34 .task(id: Key(path: session.path, heading: heading?.start, version: session.editVersion)) { refresh() } 35 .task(id: Key(path: session.path, heading: heading?.start, version: session.editVersion)) { refresh() }
35 } 36 }
36 37
Sources/Orgstar/BoardView.swift +2 −1
@@ -24,6 +24,7 @@ struct BoardView: View {
24 @AppStorage("agendaSubfolders") private var includeSubfolders = false 24 @AppStorage("agendaSubfolders") private var includeSubfolders = false
25 @Environment(\.openWindow) private var openWindow 25 @Environment(\.openWindow) private var openWindow
26 @Environment(\.orgTheme) private var theme 26 @Environment(\.orgTheme) private var theme
27 @Environment(\.colorScheme) private var colorScheme
27 28
28 init(workspace: WorkspaceModel, session: DocumentSession, commands: AppCommands) { 29 init(workspace: WorkspaceModel, session: DocumentSession, commands: AppCommands) {
29 self.workspace = workspace 30 self.workspace = workspace
@@ -137,7 +138,7 @@ struct BoardView: View {
137 } 138 }
138 .padding(12) 139 .padding(12)
139 } 140 }
140 .background(theme.color("agenda-background") ?? .clear) 141 .background(theme.color("agenda-background", in: colorScheme) ?? .clear)
141 } 142 }
142 143
143 private func column(_ keyword: String) -> some View { 144 private func column(_ keyword: String) -> some View {
Sources/Orgstar/BufferTabs.swift +2 −1
@@ -33,6 +33,7 @@ struct BufferTabs: View {
33 let pane: EditorPane 33 let pane: EditorPane
34 let close: (String) -> Void 34 let close: (String) -> Void
35 @Environment(\.orgTheme) private var theme 35 @Environment(\.orgTheme) private var theme
36 @Environment(\.colorScheme) private var colorScheme
36 37
37 var body: some View { 38 var body: some View {
38 ScrollView(.horizontal, showsIndicators: false) { 39 ScrollView(.horizontal, showsIndicators: false) {
@@ -43,7 +44,7 @@ struct BufferTabs: View {
43 } 44 }
44 } 45 }
45 .frame(height: 28) 46 .frame(height: 28)
46 .background { Rectangle().fill(theme.color("modeline-background").map(AnyShapeStyle.init) ?? AnyShapeStyle(.bar)) } 47 .background { Rectangle().fill(theme.color("modeline-background", in: colorScheme).map(AnyShapeStyle.init) ?? AnyShapeStyle(.bar)) }
47 .overlay(alignment: .bottom) { Divider() } 48 .overlay(alignment: .bottom) { Divider() }
48 } 49 }
49 50
Sources/Orgstar/ContentView.swift +4 −2
@@ -460,7 +460,7 @@ struct ContentView: View {
460 } 460 }
461 .task(id: ReminderKey( 461 .task(id: ReminderKey(
462 enabled: remindersEnabled, lead: reminderLead, subfolders: agendaSubfolders, files: workspace.files.count, 462 enabled: remindersEnabled, lead: reminderLead, subfolders: agendaSubfolders, files: workspace.files.count,
463 changed: workspace.changedFile?.version, edits: session.editVersion, hour: hour 463 changed: workspace.changedFile?.version, edits: session.editVersion, hour: hour, theme: theme
464 )) { 464 )) {
465 await updateReminders() 465 await updateReminders()
466 await updateWidgets() 466 await updateWidgets()
@@ -905,7 +905,7 @@ struct ContentView: View {
905 } 905 }
906 } 906 }
907 907
908 private struct ReminderKey: Hashable { 908 private struct ReminderKey: Equatable {
909 var enabled: Bool 909 var enabled: Bool
910 var lead: Int 910 var lead: Int
911 var subfolders: Bool 911 var subfolders: Bool
@@ -913,6 +913,8 @@ struct ContentView: View {
913 var changed: Int? 913 var changed: Int?
914 var edits: Int 914 var edits: Int
915 var hour: Int 915 var hour: Int
916 /// The widgets' colors.
917 var theme: ThemeSpec
916 } 918 }
917 919
918 /// Sets the notifications for the next week's timed entries, once edits pause. 920 /// Sets the notifications for the next week's timed entries, once edits pause.
Sources/Orgstar/DockIcon.swift added +28
@@ -0,0 +1,28 @@
1import AppKit
2import OrgPresentation
3
4/// The icon chosen in Settings ▸ Appearance, shown in the Dock while orgstar runs, in the
5/// variant for the current appearance.
6@MainActor
7enum DockIcon {
8 private static var observation: NSKeyValueObservation?
9
10 static func apply() {
11 let id = UserDefaults.standard.string(forKey: "appIcon") ?? "default"
12 let dark = NSApp.effectiveAppearance.bestMatch(from: [.aqua, .darkAqua]) == .darkAqua
13 guard let file = AppIcons.dockFile(id, dark: dark),
14 let url = Bundle.main.url(forResource: file, withExtension: "png", subdirectory: "IconPreviews") else {
15 NSApp.applicationIconImage = nil
16 return
17 }
18 NSApp.applicationIconImage = NSImage(contentsOf: url)
19 }
20
21 /// Applies now, and again whenever the appearance changes.
22 static func start() {
23 apply()
24 observation = NSApp.observe(\.effectiveAppearance) { _, _ in
25 Task { @MainActor in apply() }
26 }
27 }
28}
Sources/Orgstar/Keys.swift +2 −1
@@ -14,6 +14,7 @@ struct KeyHint: Hashable {
14struct EchoArea: View { 14struct EchoArea: View {
15 let commands: AppCommands 15 let commands: AppCommands
16 @Environment(\.orgTheme) private var theme 16 @Environment(\.orgTheme) private var theme
17 @Environment(\.colorScheme) private var colorScheme
17 @State private var showingHints = false 18 @State private var showingHints = false
18 @State private var answer = "" 19 @State private var answer = ""
19 @FocusState private var answerFocused: Bool 20 @FocusState private var answerFocused: Bool
@@ -107,7 +108,7 @@ struct EchoArea: View {
107 } 108 }
108 } 109 }
109 .foregroundStyle(theme.color("modeline-foreground") ?? .primary) 110 .foregroundStyle(theme.color("modeline-foreground") ?? .primary)
110 .background { if let bg = theme.color("modeline-background") { bg } else { Rectangle().fill(.bar) } } 111 .background { if let bg = theme.color("modeline-background", in: colorScheme) { bg } else { Rectangle().fill(.bar) } }
111 .task(id: commands.pendingKeys) { 112 .task(id: commands.pendingKeys) {
112 showingHints = false 113 showingHints = false
113 guard commands.pendingKeys != nil else { return } 114 guard commands.pendingKeys != nil else { return }
Sources/Orgstar/ModeLine.swift +2 −1
@@ -13,6 +13,7 @@ struct ModeLine: View {
13 /// Runs an app command (clock out, go to the clocked entry). 13 /// Runs an app command (clock out, go to the clocked entry).
14 let perform: (String) -> Void 14 let perform: (String) -> Void
15 @Environment(\.orgTheme) private var theme 15 @Environment(\.orgTheme) private var theme
16 @Environment(\.colorScheme) private var colorScheme
16 @State private var words: Int? 17 @State private var words: Int?
17 @State private var characters = 0 18 @State private var characters = 0
18 @State private var crlf = false 19 @State private var crlf = false
@@ -99,7 +100,7 @@ struct ModeLine: View {
99 .foregroundStyle(theme.color("modeline-foreground") ?? .secondary) 100 .foregroundStyle(theme.color("modeline-foreground") ?? .secondary)
100 .padding(.horizontal, 10) 101 .padding(.horizontal, 10)
101 .frame(height: 22) 102 .frame(height: 22)
102 .background { if let bg = theme.color("modeline-background") { bg } else { Rectangle().fill(.bar) } } 103 .background { if let bg = theme.color("modeline-background", in: colorScheme) { bg } else { Rectangle().fill(.bar) } }
103 .overlay(alignment: .top) { Divider() } 104 .overlay(alignment: .top) { Divider() }
104 .task(id: session.path) { 105 .task(id: session.path) {
105 // HEAD changes outside the app, so look again every few seconds. 106 // HEAD changes outside the app, so look again every few seconds.
Sources/Orgstar/OrgstarApp.swift +9 −2
@@ -182,6 +182,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
182 let updates = Updates() 182 let updates = Updates()
183 183
184 func applicationDidFinishLaunching(_ notification: Notification) { 184 func applicationDidFinishLaunching(_ notification: Notification) {
185 DockIcon.start()
185 if SystemReminderCenter.isAvailable { UNUserNotificationCenter.current().delegate = self } 186 if SystemReminderCenter.isAvailable { UNUserNotificationCenter.current().delegate = self }
186 updates.start() 187 updates.start()
187 } 188 }
@@ -337,6 +338,7 @@ struct OrgstarApp: App {
337 case .success(let model): 338 case .success(let model):
338 ContentView(workspace: model, session: session, commands: commands, scheduler: scheduler, clock: clock) 339 ContentView(workspace: model, session: session, commands: commands, scheduler: scheduler, clock: clock)
339 .environment(\.orgTheme, ConfigSync.shared.theme) 340 .environment(\.orgTheme, ConfigSync.shared.theme)
341 .tint(ConfigSync.shared.theme.color("accent"))
340 .onAppear { 342 .onAppear {
341 delegate.session = session 343 delegate.session = session
342 delegate.commands = commands 344 delegate.commands = commands
@@ -351,6 +353,7 @@ struct OrgstarApp: App {
351 if case .success = workspace { 353 if case .success = workspace {
352 EditorWindowView(session: session, commands: commands, clock: clock) 354 EditorWindowView(session: session, commands: commands, clock: clock)
353 .environment(\.orgTheme, ConfigSync.shared.theme) 355 .environment(\.orgTheme, ConfigSync.shared.theme)
356 .tint(ConfigSync.shared.theme.color("accent"))
354 } 357 }
355 } 358 }
356 .defaultSize(width: 900, height: 700) 359 .defaultSize(width: 900, height: 700)
@@ -359,6 +362,7 @@ struct OrgstarApp: App {
359 if case .success(let model) = workspace { 362 if case .success(let model) = workspace {
360 AgendaView(workspace: model, session: session, commands: commands, scheduler: scheduler, clock: clock) 363 AgendaView(workspace: model, session: session, commands: commands, scheduler: scheduler, clock: clock)
361 .environment(\.orgTheme, ConfigSync.shared.theme) 364 .environment(\.orgTheme, ConfigSync.shared.theme)
365 .tint(ConfigSync.shared.theme.color("accent"))
362 } 366 }
363 } 367 }
364 .defaultSize(width: 760, height: 720) 368 .defaultSize(width: 760, height: 720)
@@ -366,6 +370,7 @@ struct OrgstarApp: App {
366 if case .success(let model) = workspace { 370 if case .success(let model) = workspace {
367 BoardView(workspace: model, session: session, commands: commands) 371 BoardView(workspace: model, session: session, commands: commands)
368 .environment(\.orgTheme, ConfigSync.shared.theme) 372 .environment(\.orgTheme, ConfigSync.shared.theme)
373 .tint(ConfigSync.shared.theme.color("accent"))
369 } 374 }
370 } 375 }
371 .defaultSize(width: 1100, height: 700) 376 .defaultSize(width: 1100, height: 700)
@@ -775,6 +780,8 @@ struct SettingsView: View {
775 780
776 private var appearance: some View { 781 private var appearance: some View {
777 Form { 782 Form {
783 ThemePickerSection()
784 AppIconSection()
778 Section { 785 Section {
779 Picker("Font", selection: $themeFont) { 786 Picker("Font", selection: $themeFont) {
780 Text("System monospaced").tag("") 787 Text("System monospaced").tag("")
@@ -817,7 +824,7 @@ struct SettingsView: View {
817 } 824 }
818 } 825 }
819 .formStyle(.grouped) 826 .formStyle(.grouped)
820 .frame(height: 380) 827 .frame(height: 620)
821 } 828 }
822 829
823 private var agenda: some View { 830 private var agenda: some View {
@@ -946,7 +953,7 @@ struct SettingsView: View {
946 } 953 }
947} 954}
948 955
949private extension Text { 956extension Text {
950 func settingsFooter() -> some View { 957 func settingsFooter() -> some View {
951 font(.caption) 958 font(.caption)
952 .foregroundStyle(.secondary) 959 .foregroundStyle(.secondary)
Sources/Orgstar/Sidebar.swift +4 −2
@@ -14,6 +14,7 @@ struct Sidebar: View {
14 @State private var removing: String? 14 @State private var removing: String?
15 /// A file operation waiting for a name or a confirmation. 15 /// A file operation waiting for a name or a confirmation.
16 @Environment(\.orgTheme) private var theme 16 @Environment(\.orgTheme) private var theme
17 @Environment(\.colorScheme) private var colorScheme
17 @State var pending: FileOperation? 18 @State var pending: FileOperation?
18 @State var name = "" 19 @State var name = ""
19 @State var failure: String? 20 @State var failure: String?
@@ -50,7 +51,7 @@ struct Sidebar: View {
50 } 51 }
51 } 52 }
52 .listStyle(.sidebar) 53 .listStyle(.sidebar)
53 .themedListBackground(theme.color("sidebar-background")) 54 .themedListBackground(theme.color("sidebar-background", in: colorScheme))
54 .safeAreaInset(edge: .bottom, spacing: 0) { 55 .safeAreaInset(edge: .bottom, spacing: 0) {
55 HStack(spacing: 4) { 56 HStack(spacing: 4) {
56 Button("Add Folder…", systemImage: "plus", action: addFolder) 57 Button("Add Folder…", systemImage: "plus", action: addFolder)
@@ -120,6 +121,7 @@ struct Sidebar: View {
120struct OutlineColumn: View { 121struct OutlineColumn: View {
121 let session: DocumentSession 122 let session: DocumentSession
122 @Environment(\.orgTheme) private var theme 123 @Environment(\.orgTheme) private var theme
124 @Environment(\.colorScheme) private var colorScheme
123 125
124 var body: some View { 126 var body: some View {
125 List(Array(session.outline.enumerated()), id: \.element.start) { _, entry in 127 List(Array(session.outline.enumerated()), id: \.element.start) { _, entry in
@@ -133,7 +135,7 @@ struct OutlineColumn: View {
133 } 135 }
134 .buttonStyle(.plain) 136 .buttonStyle(.plain)
135 } 137 }
136 .themedListBackground(theme.color("sidebar-background")) 138 .themedListBackground(theme.color("sidebar-background", in: colorScheme))
137 .overlay { 139 .overlay {
138 if session.path != nil, !session.isOrg { 140 if session.path != nil, !session.isOrg {
139 ContentUnavailableView("No outline", systemImage: "doc.plaintext", description: Text("Only org files have an outline.")) 141 ContentUnavailableView("No outline", systemImage: "doc.plaintext", description: Text("Only org files have an outline."))
Sources/Orgstar/ThemeColors.swift +7
@@ -21,6 +21,12 @@ extension ThemeSpec {
21 }) 21 })
22 } 22 }
23 23
24 /// `key` in `scheme` only, nil where the theme leaves it to the system there, for
25 /// backgrounds that fall back to a material rather than a color.
26 func color(_ key: String, in scheme: ColorScheme) -> Color? {
27 color(key, dark: scheme == .dark).map { Color(.sRGB, red: $0.red, green: $0.green, blue: $0.blue, opacity: $0.alpha) }
28 }
29
24 /// A color that follows the appearance from a helper taking `dark:` (`todoColor`, 30 /// A color that follows the appearance from a helper taking `dark:` (`todoColor`,
25 /// `statusColor`, …), or `fallback` where it gives none. 31 /// `statusColor`, …), or `fallback` where it gives none.
26 func dynamic(_ fallback: NSColor = .labelColor, _ pick: @escaping @Sendable (_ dark: Bool) -> RGBA?) -> Color { 32 func dynamic(_ fallback: NSColor = .labelColor, _ pick: @escaping @Sendable (_ dark: Bool) -> RGBA?) -> Color {
@@ -37,6 +43,7 @@ extension ThemeSpec {
37 case "sidebar-background", "modeline-background": .windowBackgroundColor 43 case "sidebar-background", "modeline-background": .windowBackgroundColor
38 case "agenda-background", "background": .textBackgroundColor 44 case "agenda-background", "background": .textBackgroundColor
39 case "sidebar-header", "modeline-foreground", "agenda-time", "agenda-category", "tags": .secondaryLabelColor 45 case "sidebar-header", "modeline-foreground", "agenda-time", "agenda-category", "tags": .secondaryLabelColor
46 case "accent": .controlAccentColor
40 default: .labelColor 47 default: .labelColor
41 } 48 }
42 } 49 }
Sources/Orgstar/ThemePickerSection.swift added +76
@@ -0,0 +1,76 @@
1import AppKit
2import OrgApp
3import OrgPresentation
4import SwiftUI
5
6/// Settings ▸ Appearance ▸ Theme: the built-in palette for each appearance.
7struct ThemePickerSection: View {
8 @AppStorage("themeLight") private var themeLight = "default-light"
9 @AppStorage("themeDark") private var themeDark = "default-dark"
10 @AppStorage("themeFile") private var themeFile = ""
11 @State private var message: String?
12
13 var body: some View {
14 Section {
15 picker("Light", .light, $themeLight)
16 picker("Dark", .dark, $themeDark)
17 LabeledContent("Starting point") {
18 Button("Copy to Config Folder") { copy() }
19 }
20 } header: {
21 Text("Theme")
22 } footer: {
23 Text(message ?? footer)
24 .settingsFooter()
25 }
26 }
27
28 private var footer: String {
29 themeFile.isEmpty ? String(localized: "Colors set in config.toml or in the theme file apply on top of these.")
30 : String(localized: "The theme file \(themeFile) sets colors over these, and config.toml's colors apply on top of both.")
31 }
32
33 private func picker(_ title: LocalizedStringKey, _ appearance: Palette.Appearance, _ selection: Binding<String>) -> some View {
34 Picker(title, selection: selection) {
35 ForEach(ThemeSpec.palettes(appearance), id: \.id) { palette in
36 Label { Text(palette.displayName) } icon: { Image(nsImage: Self.swatch(palette)) }.tag(palette.id)
37 }
38 if ThemeSpec.palette(selection.wrappedValue, appearance) == nil {
39 Text(selection.wrappedValue).tag(selection.wrappedValue)
40 }
41 }
42 }
43
44 /// Background, text, heading, TODO and accent, side by side.
45 static func swatch(_ palette: Palette) -> NSImage {
46 let keys = ["background", "foreground", "heading-1", "todo", "accent"]
47 return NSImage(size: NSSize(width: 40, height: 12), flipped: false) { rect in
48 for (i, key) in keys.enumerated() {
49 let c = palette.colors[key] ?? palette.colors["cursor"] ?? RGBA(red: 0.5, green: 0.5, blue: 0.5)
50 NSColor(srgbRed: c.red, green: c.green, blue: c.blue, alpha: 1).setFill()
51 NSRect(x: CGFloat(i) * 8, y: 0, width: 8, height: rect.height).fill()
52 }
53 NSColor.separatorColor.setStroke()
54 NSBezierPath(rect: rect.insetBy(dx: 0.5, dy: 0.5)).stroke()
55 return true
56 }
57 }
58
59 private func copy() {
60 let light = ThemeSpec.palette(themeLight, .light) ?? ThemeSpec.palettes(.light)[0]
61 let dark = ThemeSpec.palette(themeDark, .dark) ?? ThemeSpec.palettes(.dark)[0]
62 do {
63 guard try UserConfig.copyTheme(light: light, dark: dark, to: UserConfig.directory) else {
64 message = String(localized: "my-theme.toml is already in the config folder; it was left as it is.")
65 return
66 }
67 let previous = themeFile
68 themeFile = UserConfig.copiedThemeFile
69 message = previous.isEmpty || previous == UserConfig.copiedThemeFile
70 ? String(localized: "Copied to my-theme.toml, now the theme file.")
71 : String(localized: "Copied to my-theme.toml, now the theme file in place of \(previous).")
72 } catch {
73 message = error.localizedDescription
74 }
75 }
76}
Sources/OrgstarMobile/AppIconScreen.swift added +50
@@ -0,0 +1,50 @@
1#if os(iOS)
2import OrgPresentation
3import SwiftUI
4import UIKit
5
6/// The app icons, as previews; tapping one makes it the home screen's icon.
7struct AppIconScreen: View {
8 /// The icon in use, shared with the Settings row.
9 @Binding var current: String
10 @State private var failure: String?
11
12 var body: some View {
13 ScrollView {
14 LazyVGrid(columns: [GridItem(.adaptive(minimum: 88), spacing: 16)], spacing: 20) {
15 ForEach(AppIcons.ids, id: \.self) { id in
16 Button { choose(id) } label: {
17 VStack(spacing: 6) {
18 Image("IconPreview-\(id)")
19 .resizable()
20 .frame(width: 72, height: 72)
21 .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
22 .overlay(RoundedRectangle(cornerRadius: 16, style: .continuous)
23 .strokeBorder(id == current ? Color.accentColor : .clear, lineWidth: 3).padding(-4))
24 Text(AppIcons.name(id)).font(.caption).foregroundStyle(.primary)
25 }
26 }
27 .buttonStyle(.plain)
28 .accessibilityAddTraits(id == current ? .isSelected : [])
29 }
30 }
31 .padding()
32 if let failure { Text(failure).foregroundStyle(.red).padding(.horizontal) }
33 }
34 .navigationTitle("App Icon")
35 }
36
37 private func choose(_ id: String) {
38 guard id != current, UIApplication.shared.supportsAlternateIcons else { return }
39 Task {
40 do {
41 try await UIApplication.shared.setAlternateIconName(AppIcons.alternateName(id))
42 current = id
43 failure = nil
44 } catch {
45 failure = error.localizedDescription
46 }
47 }
48 }
49}
50#endif
Sources/OrgstarMobile/MobileModel.swift +10 −3
@@ -238,12 +238,19 @@ final class MobileModel {
238 } 238 }
239 239
240 private static func readConfig(_ folder: URL?) -> ([String], ThemeSpec) { 240 private static func readConfig(_ folder: URL?) -> ([String], ThemeSpec) {
241 guard let folder else { return ([], .default) } 241 let defaults = UserDefaults.standard
242 guard let folder else {
243 let (base, problems) = ThemeSpec.base(light: defaults.string(forKey: "themeLight"), dark: defaults.string(forKey: "themeDark"))
244 return (problems, base)
245 }
242 guard let text = read(folder.appendingPathComponent("config.toml")) else { 246 guard let text = read(folder.appendingPathComponent("config.toml")) else {
243 return (["No config.toml in \(folder.lastPathComponent); the defaults apply."], .default) 247 return (["No config.toml in \(folder.lastPathComponent); the defaults apply."], .default)
244 } 248 }
245 let problems = UserConfig.apply(text, to: .standard) 249 let problems = UserConfig.apply(text, to: defaults)
246 guard let theme = UserConfig.theme(config: text, themeFile: UserDefaults.standard.string(forKey: "themeFile"), in: folder, read: read) else { 250 guard let theme = UserConfig.theme(
251 config: text, themeFile: defaults.string(forKey: "themeFile"),
252 lightTheme: defaults.string(forKey: "themeLight"), darkTheme: defaults.string(forKey: "themeDark"), in: folder, read: read
253 ) else {
247 return (problems, .default) 254 return (problems, .default)
248 } 255 }
249 return (problems + theme.problems, theme.theme) 256 return (problems + theme.problems, theme.theme)
Sources/OrgstarMobile/MobileTheme.swift +32 −5
@@ -41,11 +41,26 @@ struct MobileTheme {
41 41
42 /// A color that follows the appearance, or nil when the theme has none for `key`. 42 /// A color that follows the appearance, or nil when the theme has none for `key`.
43 func color(_ key: String) -> UIColor? { 43 func color(_ key: String) -> UIColor? {
44 // As on the Mac: a key the theme has for one appearance only takes the default for the other. 44 // As on the Mac: a key the theme has for one appearance only takes the default for the
45 let light = spec.light[key] ?? ThemeSpec.default.light[key] ?? spec.dark[key] 45 // other, except a key the system colors there.
46 let dark = spec.dark[key] ?? ThemeSpec.default.dark[key] ?? spec.light[key] 46 let (light, dark) = (spec.editorColor(key, dark: false), spec.editorColor(key, dark: true))
47 guard let light, let dark else { return nil } 47 if let light, let dark { return Self.dynamic(light, dark) }
48 return Self.dynamic(light, dark) 48 guard light != nil || dark != nil else { return nil }
49 return UIColor { traits in
50 guard let c = traits.userInterfaceStyle == .dark ? dark : light else { return Self.systemColor(key) }
51 return UIColor(red: c.red, green: c.green, blue: c.blue, alpha: c.alpha)
52 }
53 }
54
55 /// What the system shows for a `ThemeSpec.systemDefaults` key the theme leaves unset.
56 static func systemColor(_ key: String) -> UIColor {
57 switch key {
58 case "sidebar-background", "modeline-background": .secondarySystemBackground
59 case "agenda-background": .systemBackground
60 case "sidebar-header", "modeline-foreground": .secondaryLabel
61 case "accent": .systemBlue
62 default: .label
63 }
49 } 64 }
50 65
51 static func dynamic(_ light: RGBA, _ dark: RGBA) -> UIColor { 66 static func dynamic(_ light: RGBA, _ dark: RGBA) -> UIColor {
@@ -153,4 +168,16 @@ struct MobileTheme {
153 /// A theme color for SwiftUI views. 168 /// A theme color for SwiftUI views.
154 func swiftColor(_ key: String) -> Color? { color(key).map { Color(uiColor: $0) } } 169 func swiftColor(_ key: String) -> Color? { color(key).map { Color(uiColor: $0) } }
155} 170}
171extension ThemeSpec {
172 /// `accent` for `.tint`, the system's blue in an appearance the theme leaves it unset; nil
173 /// when neither appearance sets it.
174 var accentColor: Color? {
175 let (light, dark) = (light["accent"], dark["accent"])
176 guard light != nil || dark != nil else { return nil }
177 return Color(uiColor: UIColor { traits in
178 guard let c = traits.userInterfaceStyle == .dark ? dark : light else { return .systemBlue }
179 return UIColor(red: c.red, green: c.green, blue: c.blue, alpha: c.alpha)
180 })
181 }
182}
156#endif 183#endif
Sources/OrgstarMobile/OrgstarMobileApp.swift +1
@@ -190,6 +190,7 @@ struct RootView: View {
190 } 190 }
191 } 191 }
192 .clockAccessory(model.clock, perform: clock) 192 .clockAccessory(model.clock, perform: clock)
193 .tint(model.theme.accentColor)
193 // Until a folder is added there is nothing for the agenda to show. 194 // Until a folder is added there is nothing for the agenda to show.
194 .onAppear { if workspace.rootPaths.isEmpty { tab = .folders } } 195 .onAppear { if workspace.rootPaths.isEmpty { tab = .folders } }
195 .sheet(item: Binding(get: { model.clockPrompts.pending }, set: { if $0 == nil { model.clockPrompts.answer(nil) } })) { pending in 196 .sheet(item: Binding(get: { model.clockPrompts.pending }, set: { if $0 == nil { model.clockPrompts.answer(nil) } })) { pending in
Sources/OrgstarMobile/SettingsScreen.swift +27 −1
@@ -13,6 +13,7 @@ struct SettingsScreen: View {
13 @State private var calendars: [CalendarChoice] = [] 13 @State private var calendars: [CalendarChoice] = []
14 @State private var reminderLists: [CalendarChoice] = [] 14 @State private var reminderLists: [CalendarChoice] = []
15 @State private var badges: Bool? 15 @State private var badges: Bool?
16 @State private var appIcon = AppIcons.id(alternateName: UIApplication.shared.alternateIconName)
16 @Environment(\.openURL) private var openURL 17 @Environment(\.openURL) private var openURL
17 @Environment(\.scenePhase) private var scenePhase 18 @Environment(\.scenePhase) private var scenePhase
18 19
@@ -89,6 +90,24 @@ struct SettingsScreen: View {
89 } footer: { 90 } footer: {
90 if badges == false { Text("Turn on Badges in orgstar's notification settings.") } 91 if badges == false { Text("Turn on Badges in orgstar's notification settings.") }
91 } 92 }
93 Section("Appearance") {
94 let _ = model.settingsVersion
95 NavigationLink {
96 ThemePickerScreen(model: model, appearance: .light)
97 } label: {
98 LabeledContent("Light Theme", value: ThemePickerScreen.current(.light).displayName)
99 }
100 NavigationLink {
101 ThemePickerScreen(model: model, appearance: .dark)
102 } label: {
103 LabeledContent("Dark Theme", value: ThemePickerScreen.current(.dark).displayName)
104 }
105 NavigationLink {
106 AppIconScreen(current: $appIcon)
107 } label: {
108 LabeledContent("App Icon", value: AppIcons.name(appIcon))
109 }
110 }
92 calendarSection 111 calendarSection
93 reminderSection 112 reminderSection
94 Section("In use") { 113 Section("In use") {
@@ -97,7 +116,7 @@ struct SettingsScreen: View {
97 LabeledContent("Agenda", value: agenda) 116 LabeledContent("Agenda", value: agenda)
98 LabeledContent("Reminders", value: OrgPreferences.reminders() ? "\(OrgPreferences.reminderLead()) min before" : "Off") 117 LabeledContent("Reminders", value: OrgPreferences.reminders() ? "\(OrgPreferences.reminderLead()) min before" : "Off")
99 LabeledContent("Capture templates", value: CaptureTemplates.load().templates.map(\.key).joined(separator: " ")) 118 LabeledContent("Capture templates", value: CaptureTemplates.load().templates.map(\.key).joined(separator: " "))
100 LabeledContent("Theme", value: UserDefaults.standard.string(forKey: "themeFile").flatMap { $0.isEmpty ? nil : $0 } ?? "Default") 119 LabeledContent("Theme", value: themeInUse)
101 LabeledContent("Font", value: font) 120 LabeledContent("Font", value: font)
102 } 121 }
103 } 122 }
@@ -109,6 +128,13 @@ struct SettingsScreen: View {
109 } 128 }
110 } 129 }
111 130
131 /// The two palettes' names, and the theme file's when there is one.
132 private var themeInUse: String {
133 let names = "\(ThemePickerScreen.current(.light).displayName) / \(ThemePickerScreen.current(.dark).displayName)"
134 guard let file = UserDefaults.standard.string(forKey: "themeFile"), !file.isEmpty else { return names }
135 return "\(names), \(file)"
136 }
137
112 /// `calendar-events` and `calendar-event-calendars`, written to config.toml. 138 /// `calendar-events` and `calendar-event-calendars`, written to config.toml.
113 private var calendarSection: some View { 139 private var calendarSection: some View {
114 let _ = model.settingsVersion 140 let _ = model.settingsVersion
Sources/OrgstarMobile/ThemePickerScreen.swift added +59
@@ -0,0 +1,59 @@
1#if os(iOS)
2import OrgCore
3import OrgPresentation
4import SwiftUI
5
6/// The built-in palettes of one appearance, each as a few lines of Org in its colors.
7struct ThemePickerScreen: View {
8 let model: MobileModel
9 let appearance: Palette.Appearance
10
11 var body: some View {
12 let _ = model.settingsVersion
13 let current = Self.current(appearance).id
14 List(ThemeSpec.palettes(appearance), id: \.id) { palette in
15 Button {
16 model.set(appearance == .light ? "themeLight" : "themeDark", to: .string(palette.id))
17 } label: {
18 HStack {
19 VStack(alignment: .leading, spacing: 6) {
20 Text(palette.displayName).foregroundStyle(.primary)
21 Self.sample(palette)
22 }
23 Spacer()
24 if palette.id == current { Image(systemName: "checkmark").foregroundStyle(.tint) }
25 }
26 }
27 .buttonStyle(.plain)
28 }
29 .navigationTitle(appearance == .light ? "Light Theme" : "Dark Theme")
30 }
31
32 /// The palette `light-theme` or `dark-theme` names, Default when unknown.
33 static func current(_ appearance: Palette.Appearance) -> Palette {
34 let id = UserDefaults.standard.string(forKey: appearance == .light ? "themeLight" : "themeDark") ?? ""
35 return ThemeSpec.palette(id, appearance) ?? ThemeSpec.palettes(appearance)[0]
36 }
37
38 private static func sample(_ palette: Palette) -> some View {
39 func color(_ key: String) -> Color {
40 guard let c = palette.colors[key] else { return .primary }
41 return Color(.sRGB, red: c.red, green: c.green, blue: c.blue, opacity: c.alpha)
42 }
43 let font = Font.system(.footnote, design: .monospaced)
44 return VStack(alignment: .leading, spacing: 2) {
45 (Text(verbatim: "* ").foregroundColor(color("heading-1")) + Text(verbatim: "TODO ").foregroundColor(color("todo")).bold()
46 + Text(verbatim: "Plan the trip ").foregroundColor(color("heading-1")).bold() + Text(verbatim: ":travel:").foregroundColor(color("tags")))
47 (Text(verbatim: " SCHEDULED: ").foregroundColor(color("metadata")) + Text(verbatim: "<2026-10-20 Tue>").foregroundColor(color("timestamp")))
48 (Text(verbatim: " Book via ").foregroundColor(color("foreground")) + Text(verbatim: "the site").foregroundColor(color("link")).underline()
49 + Text(verbatim: ", ").foregroundColor(color("foreground")) + Text(verbatim: "~code~").foregroundColor(color("code")))
50 (Text(verbatim: "** ").foregroundColor(color("heading-2")) + Text(verbatim: "DONE ").foregroundColor(color("done")).bold()
51 + Text(verbatim: "Passport").foregroundColor(color("heading-2")).bold())
52 }
53 .font(font)
54 .padding(8)
55 .frame(maxWidth: .infinity, alignment: .leading)
56 .background(color("background"), in: RoundedRectangle(cornerRadius: 8))
57 }
58}
59#endif
Sources/OrgstarWidgets/AgendaTimeline.swift +2 −1
@@ -51,8 +51,9 @@ extension AgendaSnapshot.Hex {
51} 51}
52 52
53extension AgendaSnapshot { 53extension AgendaSnapshot {
54 /// Nil where the theme leaves `key` to the system in `scheme`.
54 func color(_ key: String, _ scheme: ColorScheme) -> Color? { 55 func color(_ key: String, _ scheme: ColorScheme) -> Color? {
55 colors[key]?.color(scheme) 56 colors[key].flatMap { AgendaSnapshot.Hex.parse(scheme == .dark ? $0.dark : $0.light) }
56 } 57 }
57 58
58 /// A day for the gallery and previews. 59 /// A day for the gallery and previews.
THIRD_PARTY.org +10 −1
@@ -11,5 +11,14 @@ Orgstar is 0BSD. It builds on these projects, under their own licenses.
11| [[https://github.com/6cdh/tree-sitter-scheme][tree-sitter-scheme]] | Highlighting | MIT | 11| [[https://github.com/6cdh/tree-sitter-scheme][tree-sitter-scheme]] | Highlighting | MIT |
12| [[https://github.com/Wilfred/tree-sitter-elisp][tree-sitter-elisp]] | Highlighting (vendored in =Sources/TreeSitterElisp=) | MIT | 12| [[https://github.com/Wilfred/tree-sitter-elisp][tree-sitter-elisp]] | Highlighting (vendored in =Sources/TreeSitterElisp=) | MIT |
13| [[https://github.com/sogaiu/tree-sitter-clojure][tree-sitter-clojure]] | Highlighting (vendored in =Sources/TreeSitterClojure=) | CC0-1.0 | 13| [[https://github.com/sogaiu/tree-sitter-clojure][tree-sitter-clojure]] | Highlighting (vendored in =Sources/TreeSitterClojure=) | CC0-1.0 |
14| [[https://ethanschoonover.com/solarized/][Solarized]] | Colors of the Solarized themes | MIT |
15| [[https://github.com/morhetz/gruvbox][Gruvbox]] | Colors of the Gruvbox themes | MIT |
16| [[https://protesilaos.com/emacs/modus-themes][Modus themes]] | Colors of Modus Operandi and Modus Vivendi (color values only, no code) | GPL-3.0-or-later |
17| [[https://github.com/catppuccin/catppuccin][Catppuccin]] | Colors of Catppuccin Latte and Mocha | MIT |
18| [[https://github.com/chriskempson/tomorrow-theme][Tomorrow]] | Colors of the Tomorrow theme | MIT |
19| [[https://www.nordtheme.com][Nord]] | Colors of the Nord theme | MIT |
20| [[https://draculatheme.com][Dracula]] | Colors of the Dracula theme | MIT |
21| [[https://github.com/folke/tokyonight.nvim][Tokyo Night]] | Colors of the Tokyo Night theme | Apache-2.0 |
22| [[https://github.com/doomemacs/themes][doom-themes]] | Colors of doom-one | MIT |
14 23
15The JavaScript, Lua, Python and YAML scanners are copied into =Sources/TreeSitterScanners= with their licenses. Highlight queries are embedded in =Sources/OrgHighlight/Queries.swift= by =scripts/update-highlight-queries.sh=. 24The JavaScript, Lua, Python and YAML scanners are copied into =Sources/TreeSitterScanners= with their licenses. Highlight queries are embedded in =Sources/OrgHighlight/Queries.swift= by =scripts/update-highlight-queries.sh=. The theme colors are in =Sources/OrgPresentation/Palettes.swift=; a few light-theme colors are darkened from upstream for contrast, as noted there.
Tests/OrgAppTests/AgendaSnapshotTests.swift +7
@@ -78,6 +78,13 @@ struct AgendaSnapshotTests {
78 #expect(snapshot.colors["agenda-background"] == nil) 78 #expect(snapshot.colors["agenda-background"] == nil)
79 } 79 }
80 80
81 @Test func aColorTheSystemKeepsInOneAppearanceStaysUnsetThere() throws {
82 let theme = ThemeSpec.base(light: nil, dark: "nord").0
83 let snapshot = AgendaSnapshot(groups: [], today: Self.today, theme: theme, generated: Date())
84 let background = try #require(snapshot.colors["agenda-background"])
85 #expect(background.light == "" && background.dark == "#2e3440")
86 }
87
81 @Test func encodesAndDecodes() throws { 88 @Test func encodesAndDecodes() throws {
82 let snapshot = Self.snapshot() 89 let snapshot = Self.snapshot()
83 let data = try AgendaSnapshot.encoder.encode(snapshot) 90 let data = try AgendaSnapshot.encoder.encode(snapshot)
Tests/OrgAppTests/UserConfigTests.swift +57
@@ -253,4 +253,61 @@ struct ThemeReadingTests {
253 #expect(bad.problems == ["t.toml: unknown theme color nope", "config.toml: theme.link must be a color such as \"#1f2328\""]) 253 #expect(bad.problems == ["t.toml: unknown theme color nope", "config.toml: theme.link must be a color such as \"#1f2328\""])
254 #expect(UserConfig.theme(config: "[theme", themeFile: nil, in: folder)?.theme == nil) 254 #expect(UserConfig.theme(config: "[theme", themeFile: nil, in: folder)?.theme == nil)
255 } 255 }
256
257 @Test @MainActor func chosenPalettesSitUnderTheThemeFileAndConfig() throws {
258 let name = "orgstar-palette-\(UUID().uuidString)"
259 let defaults = UserDefaults(suiteName: name)!
260 defer { defaults.removePersistentDomain(forName: name) }
261 let folder = FileManager.default.temporaryDirectory.appendingPathComponent(name)
262 defer { try? FileManager.default.removeItem(at: folder) }
263 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
264 try "[theme.dark]\nlink = \"#000001\"\n".write(to: folder.appendingPathComponent("mine.toml"), atomically: true, encoding: .utf8)
265 try "[theme]\nlight-theme = \"paper\"\ndark-theme = \"nord\"\ntheme-file = \"mine.toml\"\n[theme.dark]\ntodo = \"#000002\"\n"
266 .write(to: folder.appendingPathComponent("config.toml"), atomically: true, encoding: .utf8)
267 let sync = ConfigSync(url: folder.appendingPathComponent("config.toml"), defaults: defaults)
268 sync.start(watch: false)
269 #expect(sync.problems.isEmpty, "\(sync.problems)")
270 #expect(defaults.string(forKey: "themeLight") == "paper" && defaults.string(forKey: "themeDark") == "nord")
271 let nord = try #require(ThemeSpec.palette("nord", .dark))
272 #expect(sync.theme.light["background"] == ThemeSpec.palette("paper", .light)?.colors["background"])
273 #expect(sync.theme.dark["background"] == nord.colors["background"])
274 #expect(sync.theme.dark["link"]?.hex == "#000001")
275 #expect(sync.theme.dark["todo"]?.hex == "#000002")
276 }
277
278 @Test func noThemeSettingsGiveTheDefaultTheme() throws {
279 let folder = FileManager.default.temporaryDirectory
280 let theme = try #require(UserConfig.theme(config: "", themeFile: nil, lightTheme: nil, darkTheme: nil, in: folder))
281 #expect(theme.theme == ThemeSpec.default && theme.problems.isEmpty)
282 }
283
284 @Test func copyingAThemeNeverOverwrites() throws {
285 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-copy-\(UUID().uuidString)")
286 defer { try? FileManager.default.removeItem(at: folder) }
287 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
288 let light = try #require(ThemeSpec.palette("paper", .light))
289 let dark = try #require(ThemeSpec.palette("nord", .dark))
290 #expect(try UserConfig.copyTheme(light: light, dark: dark, to: folder))
291 let file = folder.appendingPathComponent(UserConfig.copiedThemeFile)
292 #expect(try String(contentsOf: file, encoding: .utf8) == ThemeSpec.themeFile(light: light, dark: dark))
293 try "mine".write(to: file, atomically: true, encoding: .utf8)
294 #expect(try !UserConfig.copyTheme(light: light, dark: dark, to: folder))
295 #expect(try String(contentsOf: file, encoding: .utf8) == "mine")
296 }
297
298 @Test @MainActor func aThemePickedInTheAppAppliesAtOnce() throws {
299 let name = "orgstar-pick-\(UUID().uuidString)"
300 let defaults = UserDefaults(suiteName: name)!
301 defer { defaults.removePersistentDomain(forName: name) }
302 let folder = FileManager.default.temporaryDirectory.appendingPathComponent(name)
303 defer { try? FileManager.default.removeItem(at: folder) }
304 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
305 try "[theme]\n".write(to: folder.appendingPathComponent("config.toml"), atomically: true, encoding: .utf8)
306 let sync = ConfigSync(url: folder.appendingPathComponent("config.toml"), defaults: defaults)
307 sync.start(watch: false)
308 defaults.set("nord", forKey: "themeDark")
309 sync.writeBack()
310 #expect(try String(contentsOf: folder.appendingPathComponent("config.toml"), encoding: .utf8).contains("dark-theme = \"nord\""))
311 #expect(sync.theme.dark["background"] == ThemeSpec.palette("nord", .dark)?.colors["background"])
312 }
256} 313}
Tests/OrgPresentationTests/PaletteTests.swift added +126
@@ -0,0 +1,126 @@
1import Foundation
2import OrgCore
3import OrgPresentation
4import Testing
5
6struct PaletteTests {
7 @Test func defaultPalettesAreTheDefaultTheme() throws {
8 let light = try #require(ThemeSpec.palette("default-light", .light))
9 let dark = try #require(ThemeSpec.palette("default-dark", .dark))
10 #expect(light.colors == ThemeSpec.default.light && dark.colors == ThemeSpec.default.dark)
11 #expect(light.name == "Default" && ThemeSpec.palettes(.light).first == light && ThemeSpec.palettes(.dark).first == dark)
12 #expect(ThemeSpec.defaultPaletteID(.light) == "default-light" && ThemeSpec.defaultPaletteID(.dark) == "default-dark")
13 }
14
15 @Test func aPaletteIsFoundOnlyInItsAppearance() {
16 #expect(ThemeSpec.palette("default-light", .dark) == nil)
17 #expect(ThemeSpec.palette("nope", .light) == nil)
18 }
19
20 @Test func accentIsASlotTheDefaultLeavesToTheSystem() {
21 #expect(ThemeSpec.slots.contains { $0.key == "accent" })
22 #expect(ThemeSpec.systemDefaults.contains("accent"))
23 #expect(ThemeSpec.default.light["accent"] == nil && ThemeSpec.default.dark["accent"] == nil)
24 }
25
26 @Test func everyPaletteHasExactlyTheSlotKeys() {
27 let all = Set(ThemeSpec.slots.map(\.key))
28 for palette in ThemeSpec.palettes(.light) + ThemeSpec.palettes(.dark) {
29 let expected = palette.id.hasPrefix("default-") ? all.subtracting(ThemeSpec.systemDefaults) : all
30 #expect(Set(palette.colors.keys) == expected, "\(palette.id): \(expected.symmetricDifference(palette.colors.keys))")
31 }
32 }
33 @Test func theCatalogIsInOrder() {
34 #expect(ThemeSpec.palettes(.light).map(\.id) == ["default-light", "solarized-light", "gruvbox-light", "modus-operandi", "catppuccin-latte", "tomorrow", "paper"])
35 #expect(ThemeSpec.palettes(.dark).map(\.id) == ["default-dark", "solarized-dark", "gruvbox-dark", "modus-vivendi", "catppuccin-mocha", "nord", "dracula", "tokyo-night", "doom-one"])
36 }
37
38 /// WCAG 2 contrast ratio.
39 static func contrast(_ a: RGBA, _ b: RGBA) -> Double {
40 func luminance(_ c: RGBA) -> Double {
41 func channel(_ v: Double) -> Double { v <= 0.03928 ? v / 12.92 : pow((v + 0.055) / 1.055, 2.4) }
42 return 0.2126 * channel(c.red) + 0.7152 * channel(c.green) + 0.0722 * channel(c.blue)
43 }
44 let (x, y) = (luminance(a), luminance(b))
45 return (max(x, y) + 0.05) / (min(x, y) + 0.05)
46 }
47
48 @Test func textReadsOnTheBackground() throws {
49 let body = ["foreground", "table"]
50 let marks = ["heading-1", "heading-2", "heading-3", "heading-4", "todo", "todo-next", "todo-waiting", "done", "link", "timestamp", "code",
51 "syntax-keyword", "syntax-string", "syntax-function", "syntax-type", "syntax-number", "syntax-property", "syntax-label"]
52 for palette in ThemeSpec.palettes(.light) + ThemeSpec.palettes(.dark) {
53 let background = try #require(palette.colors["background"])
54 for key in body {
55 let ratio = Self.contrast(try #require(palette.colors[key]), background)
56 #expect(ratio >= 4.5, "\(palette.id) \(key): \(ratio)")
57 }
58 for key in marks {
59 let ratio = Self.contrast(try #require(palette.colors[key]), background)
60 #expect(ratio >= 3, "\(palette.id) \(key): \(ratio)")
61 }
62 }
63 }
64
65 @Test func baseTakesEachAppearanceFromItsPalette() throws {
66 let (spec, problems) = ThemeSpec.base(light: "paper", dark: "nord")
67 #expect(problems.isEmpty)
68 #expect(spec.light == ThemeSpec.palette("paper", .light)?.colors && spec.dark == ThemeSpec.palette("nord", .dark)?.colors)
69 #expect(ThemeSpec.base(light: nil, dark: nil).0 == ThemeSpec.default)
70 #expect(ThemeSpec.base(light: "", dark: "").0 == ThemeSpec.default)
71 }
72
73 @Test func aPaletteOfTheOtherAppearanceIsAProblem() {
74 let (spec, problems) = ThemeSpec.base(light: "nord", dark: "unknown")
75 #expect(spec == ThemeSpec.default)
76 #expect(problems == ["config.toml: unknown light-theme nord", "config.toml: unknown dark-theme unknown"])
77 }
78
79 @Test func aCopiedThemeReadsBackAsThePalettes() throws {
80 let light = try #require(ThemeSpec.palette("paper", .light))
81 let dark = try #require(ThemeSpec.palette("nord", .dark))
82 let text = ThemeSpec.themeFile(light: light, dark: dark)
83 #expect(text.hasPrefix("# Paper and Nord, copied from orgstar's built-in themes."))
84 let (spec, problems) = ThemeSpec.reading(try TOML.parse(text))
85 #expect(problems.isEmpty, "\(problems)")
86 #expect(spec.light.filter { light.colors[$0.key] != nil } == light.colors && spec.dark.filter { dark.colors[$0.key] != nil } == dark.colors)
87 }
88
89 @Test func iconIdsMapToAlternateNames() {
90 #expect(AppIcons.ids.first == "default" && AppIcons.ids.count == 13)
91 #expect(AppIcons.alternateName("default") == nil)
92 #expect(AppIcons.alternateName("unicorn-night") == "AppIcon-UnicornNight")
93 #expect(AppIcons.id(alternateName: "AppIcon-UnicornNight") == "unicorn-night")
94 #expect(AppIcons.id(alternateName: nil) == "default" && AppIcons.id(alternateName: "AppIcon-Gone") == "default")
95 #expect(AppIcons.name("unicorn-pastel") == "Unicorn Pastel")
96 }
97
98 @Test func dockFilesFollowTheAppearance() {
99 #expect(AppIcons.dockFile("default", dark: true) == nil)
100 #expect(AppIcons.dockFile("gone", dark: false) == nil)
101 #expect(AppIcons.dockFile("unicorn", dark: false) == "unicorn-light")
102 #expect(AppIcons.dockFile("unicorn", dark: true) == "unicorn-dark")
103 }
104
105 @Test func aDarkOnlyChoiceLeavesTheLightSideToTheSystem() {
106 let spec = ThemeSpec.base(light: nil, dark: "nord").0
107 for key in ThemeSpec.systemDefaults {
108 #expect(spec.color(key, dark: false) == nil, "\(key)")
109 #expect(spec.color(key, dark: true) != nil, "\(key)")
110 }
111 }
112
113 @Test func editorColorsFallBackExceptForSystemKeys() {
114 let spec = ThemeSpec.base(light: nil, dark: "nord").0
115 // A system key the light side leaves unset stays unset there, not the dark side's.
116 #expect(spec.editorColor("sidebar-background", dark: false) == nil)
117 #expect(spec.editorColor("sidebar-background", dark: true) == spec.dark["sidebar-background"])
118 // Other keys keep the default theme's color for a side the spec lacks.
119 var partial = ThemeSpec.default
120 partial.light["link"] = nil
121 #expect(partial.editorColor("link", dark: false) == ThemeSpec.default.light["link"])
122 // A key neither the spec's side nor the default has takes the spec's other side.
123 let oneSided = ThemeSpec(light: [:], dark: ["custom": RGBA(red: 1, green: 0, blue: 0)])
124 #expect(oneSided.editorColor("custom", dark: false) == RGBA(red: 1, green: 0, blue: 0))
125 }
126}
docs/manual/guide/02-the-editor.org +3 −1
@@ -338,7 +338,9 @@ In the relative and visual kinds the caret's line shows its own number, as =disp
338 338
339* Themes 339* Themes
340 340
341The editor's font, size, line spacing and heading sizes are in Settings ▸ Appearance. Colours for the editor, the sidebar, the modeline, line numbers, the selection and the caret come from =config.toml=, under =[theme]= for both appearances, =[theme.light]= and =[theme.dark]= for one, and =[theme.todo]= for colours of TODO keywords. Settings ▸ Appearance ▸ Show Default Theme opens =default-theme.toml=, which lists every colour with its default value. Changes apply while orgstar runs. See [[file:13-configuration.org][Configuration]]. 341The editor's font, size, line spacing and heading sizes are in Settings ▸ Appearance. Settings ▸ Appearance ▸ Theme chooses a built-in theme for the light appearance and one for the dark: Default, Solarized Light, Gruvbox Light, Modus Operandi, Catppuccin Latte, Tomorrow or Paper; and Default, Solarized Dark, Gruvbox Dark, Modus Vivendi, Catppuccin Mocha, Nord, Dracula, Tokyo Night or doom-one. They are =light-theme= and =dark-theme= under =[theme]= in =config.toml=. Colours set in =config.toml=, under =[theme]= for both appearances, =[theme.light]= and =[theme.dark]= for one and =[theme.todo]= for TODO keywords, apply on top, as do those of a theme file named by =theme-file=. Copy to Config Folder writes the two chosen themes, every colour, into =my-theme.toml= and makes it the theme file, to start a theme of your own. Show Default Theme opens =default-theme.toml=, which lists every colour with its default value. Changes apply while orgstar runs. See [[file:13-configuration.org][Configuration]].
342
343Settings ▸ Appearance ▸ App Icon chooses the icon the Dock shows while orgstar runs. Finder, and the Dock once orgstar has quit, show the default icon, in the system's icon style (Default, Dark or Tinted).
342 344
343The iOS editor uses the same theme and display settings, read from the synced =config.toml=; see [[file:14-ios.org][iPhone and iPad]]. 345The iOS editor uses the same theme and display settings, read from the synced =config.toml=; see [[file:14-ios.org][iPhone and iPad]].
344 346
docs/manual/guide/13-configuration.org +13 −2
@@ -102,6 +102,10 @@ orgstar's menus, settings and agenda are in English and German, and follow the l
102 102
103| Control | Range | Default | Key | 103| Control | Range | Default | Key |
104|---------------------------------+-----------------------------------------------+--------------------+---------------------| 104|---------------------------------+-----------------------------------------------+--------------------+---------------------|
105| Theme: Light | A built-in light theme | Default | =light-theme= |
106| Theme: Dark | A built-in dark theme | Default | =dark-theme= |
107| Theme: Copy to Config Folder | Writes =my-theme.toml= and makes it =theme-file= | | |
108| App Icon | One of 13 icons, shown in the Dock while orgstar runs | Default | (this Mac only) |
105| Font | System monospaced, or any installed monospaced family | System monospaced | =font= | 109| Font | System monospaced, or any installed monospaced family | System monospaced | =font= |
106| Body text | Same as Font, System, or any installed proportional family | Same as Font | =body-font= | 110| Body text | Same as Font, System, or any installed proportional family | Same as Font | =body-font= |
107| Size | 8 to 36 pt | 13 pt | =font-size= | 111| Size | 8 to 36 pt | 13 pt | =font-size= |
@@ -367,6 +371,8 @@ Publishing projects, one table each, as =org-publish-project-alist= has them. Th
367| =line-spacing= | integer | =2= | Points between lines. | 371| =line-spacing= | integer | =2= | Points between lines. |
368| =text-width= | integer | =0= | The widest the text runs, in columns of =font=, centred in a wider editor. =0= uses the whole width. | 372| =text-width= | integer | =0= | The widest the text runs, in columns of =font=, centred in a wider editor. =0= uses the whole width. |
369| =heading-size-step= | integer | =1= | Points a heading is larger than the level below. Level 4 and deeper are body size. | 373| =heading-size-step= | integer | =1= | Points a heading is larger than the level below. Level 4 and deeper are body size. |
374| =light-theme= | string | ="default-light"= | The built-in theme for light appearance: =default-light=, =solarized-light=, =gruvbox-light=, =modus-operandi=, =catppuccin-latte=, =tomorrow= or =paper=. |
375| =dark-theme= | string | ="default-dark"= | The built-in theme for dark appearance: =default-dark=, =solarized-dark=, =gruvbox-dark=, =modus-vivendi=, =catppuccin-mocha=, =nord=, =dracula=, =tokyo-night= or =doom-one=. |
370| =theme-file= | string | =""= | A theme in its own file in the configuration folder, applied under the colors in =config.toml=. | 376| =theme-file= | string | =""= | A theme in its own file in the configuration folder, applied under the colors in =config.toml=. |
371 377
372Any other key in =[theme]= is a color; see Themes below. 378Any other key in =[theme]= is a color; see Themes below.
@@ -643,7 +649,11 @@ Key bindings are imported when the command is one orgstar has a counterpart for,
643 649
644* Themes 650* Themes
645 651
646orgstar has one built-in theme, the default theme, with light and dark colors after GitHub's light and dark themes for text and code. TODO keywords, priorities and the agenda's statuses use the system's red, orange, blue and green, as iOS and macOS show them. You change it by setting colors in =config.toml=, or by keeping a theme in its own file. 652The default theme has light and dark colors after GitHub's light and dark themes for text and code. TODO keywords, priorities and the agenda's statuses use the system's red, orange, blue and green, as iOS and macOS show them. It leaves the sidebar, the modeline, the agenda's background and the accent of buttons and toggles to the system.
653
654=light-theme= and =dark-theme= choose a built-in theme for each appearance instead (Settings ▸ Appearance ▸ Theme). The light themes are Default, Solarized Light, Gruvbox Light, Modus Operandi, Catppuccin Latte, Tomorrow and Paper; the dark themes are Default, Solarized Dark, Gruvbox Dark, Modus Vivendi, Catppuccin Mocha, Nord, Dracula, Tokyo Night and doom-one. Every one but Default sets every color key, the sidebar, modeline, agenda and accent included. An unknown name, or one of the other appearance, is reported and Default is used.
655
656You change any of them by setting colors in =config.toml=, or by keeping a theme in its own file. Copy to Config Folder writes the two chosen themes, every color written out, into =my-theme.toml= and sets =theme-file= to it; it leaves an existing =my-theme.toml= as it is.
647 657
648Colors are strings in the form ="#rrggbb"= or ="#rrggbbaa"=. They go in these tables: 658Colors are strings in the form ="#rrggbb"= or ="#rrggbbaa"=. They go in these tables:
649 659
@@ -696,7 +706,7 @@ To keep a theme in its own file, put it in the configuration folder with the sam
696theme-file = "solarized.toml" 706theme-file = "solarized.toml"
697#+END_SRC 707#+END_SRC
698 708
699The colors stack in this order, each over the one before: the default theme, the theme file, then the colors in =config.toml=. The path is relative to the configuration folder and may name a subfolder, as =themes/solarized.toml=. orgstar reloads the theme file when it changes. Only colors are read from a theme file; =font= and the other type keys in its =[theme]= table are ignored. 709The colors stack in this order, each over the one before: the themes chosen with =light-theme= and =dark-theme=, the theme file, then the colors in =config.toml=. The path is relative to the configuration folder and may name a subfolder, as =themes/solarized.toml=. orgstar reloads the theme file when it changes. Only colors are read from a theme file; =font= and the other type keys in its =[theme]= table are ignored.
700 710
701** Color keys 711** Color keys
702 712
@@ -706,6 +716,7 @@ The colors stack in this order, each over the one before: the default theme, the
706| =foreground= | body text | 716| =foreground= | body text |
707| =cursor= | the caret | 717| =cursor= | the caret |
708| =selection= | selected text's background | 718| =selection= | selected text's background |
719| =accent= | buttons, toggles and selection in lists; unset: the system's |
709| =heading-1= … =heading-7= | headings of that level | 720| =heading-1= … =heading-7= | headings of that level |
710| =heading-8= | level 8 and deeper headings | 721| =heading-8= | level 8 and deeper headings |
711| =todo= | TODO keywords not yet done | 722| =todo= | TODO keywords not yet done |
docs/manual/guide/14-ios.org +4 −2
@@ -80,7 +80,9 @@ Files that aren't valid UTF-8 open read-only; commands that would change them sa
80 80
81** Themes and display 81** Themes and display
82 82
83The editor and the reader use the theme set in the configuration folder's =config.toml=, stacked as on the Mac: the default theme, then the theme file named by =theme-file=, then the colours in =[theme]=, =[theme.light]=, =[theme.dark]=, =[theme.todo]= and =[theme.category]=. A TODO keyword without a colour in =[theme.todo]= takes its class's colour: =todo-next= for =NEXT= and =STRT=, =todo-waiting= for =WAIT= and =HOLD=, =todo-cancelled= for =KILL= and =CANCELLED=, and so on (see [[file:13-configuration.org][Configuration]] for the lists). Colours follow the system's light or dark appearance. Problems in the theme show in the Settings tab with the other problems. A change to =config.toml= or the theme file applies as it syncs, to open editors too. See [[file:13-configuration.org][Configuration]] for the colour keys. 83The editor and the reader use the theme set in the configuration folder's =config.toml=, stacked as on the Mac: the themes chosen with =light-theme= and =dark-theme=, then the theme file named by =theme-file=, then the colours in =[theme]=, =[theme.light]=, =[theme.dark]=, =[theme.todo]= and =[theme.category]=. A TODO keyword without a colour in =[theme.todo]= takes its class's colour: =todo-next= for =NEXT= and =STRT=, =todo-waiting= for =WAIT= and =HOLD=, =todo-cancelled= for =KILL= and =CANCELLED=, and so on (see [[file:13-configuration.org][Configuration]] for the lists). Colours follow the system's light or dark appearance. Problems in the theme show in the Settings tab with the other problems. A change to =config.toml= or the theme file applies as it syncs, to open editors too. See [[file:13-configuration.org][Configuration]] for the colour keys.
84
85Settings ▸ Light Theme and Dark Theme choose the built-in themes, shown as a few lines of Org in each theme's colours; with a configuration folder the choice is written to its =config.toml=, so the Mac uses it too. Settings ▸ App Icon chooses the home screen icon from the same thirteen as the Mac; iOS confirms the change. The icon is chosen per device.
84 86
85- Font :: =font= when that family is installed on the device, otherwise the system's monospaced font. =body-font=, when set, is used for prose as on the Mac. 87- Font :: =font= when that family is installed on the device, otherwise the system's monospaced font. =body-font=, when set, is used for prose as on the Mac.
86- Size :: =font-size= is the size at the default Dynamic Type setting, 13 pt by default. Text grows and shrinks with the text size chosen in the system Settings app. 88- Size :: =font-size= is the size at the default Dynamic Type setting, 13 pt by default. Text grows and shrinks with the text size chosen in the system Settings app.
@@ -395,7 +397,7 @@ The Agenda, TODO Dependencies, Calendar and Reminders sections are the only plac
395 397
396These write =config.toml= in the configuration folder, as the Mac's Settings window does, so the Mac sees the change too. Without a configuration folder they are kept on the device. 398These write =config.toml= in the configuration folder, as the Mac's Settings window does, so the Mac sees the change too. Without a configuration folder they are kept on the device.
397 399
398The In use section shows the TODO keywords, the agenda span and start (for example =10 days, starting today=), the reminder lead time, the capture template keys, the theme (=Default=, or the theme file's name), and the font with its size. When =font= names a family that isn't installed on the device, Font shows the system's font with a note, as =System monospaced, 13 pt (JetBrains Mono isn't installed)=. 400The In use section shows the TODO keywords, the agenda span and start (for example =10 days, starting today=), the reminder lead time, the capture template keys, the light and dark themes, and the theme file's name when there is one, and the font with its size. When =font= names a family that isn't installed on the device, Font shows the system's font with a note, as =System monospaced, 13 pt (JetBrains Mono isn't installed)=.
399 401
400These settings from =config.toml= apply on iOS: 402These settings from =config.toml= apply on iOS:
401 403
docs/plans/2026-10-14-themes-and-icons-design.md added +163
@@ -0,0 +1,163 @@
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.
docs/plans/2026-10-14-themes-and-icons.md added +1604
@@ -0,0 +1,1604 @@
1# Built-in Themes and Alternate App Icons Implementation Plan
2
3> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
4
5**Goal:** Users pick a built-in light theme and dark theme, and an app icon, in Settings on the Mac and on iOS.
6
7**Architecture:** Palettes are Swift values in `OrgPresentation`: the two Default palettes are today's `ThemeSpec.default` colors, the 14 others are 12 named colors each, mapped onto every slot by one table. Two new `[theme]` settings choose them; `UserConfig.theme` puts them under `theme-file` and `config.toml`'s colors. Icons are drawn by `scripts/make-icon.swift` from a variant table into committed asset catalogs: iOS alternate app icons with dark and tinted appearances, and on the Mac an `actool`-compiled `AppIcon` plus Dock previews set with `NSApp.applicationIconImage`.
8
9**Tech Stack:** Swift 6, SwiftUI, AppKit, UIKit, Swift Testing, `actool`, `xcodebuild`.
10
11**Spec:** `docs/plans/2026-10-14-themes-and-icons-design.md`
12
13## Global constraints
14
15- macOS 26 and iOS 26 only.
16- No hand-written Swift file over 1,000 lines (`scripts/check-file-sizes.sh`). `Sources/Orgstar/OrgstarApp.swift` is at 956, so new Mac settings UI goes in new files.
17- No SwiftPM resources in `OrgPresentation`: it is linked into app extensions that don't carry resource bundles.
18- With `light-theme` and `dark-theme` at their defaults and no other theme settings, every color is what it is today.
19- The icon choice is per device, in `UserDefaults` (Mac) or `UIApplication.alternateIconName` (iOS), never in `config.toml`.
20- `ios/Orgstar.xcodeproj/project.pbxproj` has uncommitted changes in the working tree that predate this plan. Before Task 8, ask whether to commit or stash them; do not mix them into this branch's commits.
21- Commit messages: plain, no trailers.
22- Every task ends with `swift build` and `swift test` green, and `scripts/check-file-sizes.sh` passing.
23
24## Decisions
25
26| Question | Decision | Reason |
27| --- | --- | --- |
28| Palette storage | Swift values in `Sources/OrgPresentation/Palettes.swift` | No resource bundle in extensions; type-checked |
29| Ported palettes | 12 named colors through `ThemeSpec.Roles.slots` | A dozen hex values per palette; new slots stay in step |
30| Default palettes | `ThemeSpec.default.light` / `.dark` as they are | Zero change to the default look |
31| Where the theme ids are read | `UserDefaults` keys `themeLight` / `themeDark`, passed into `UserConfig.theme` like `themeFile` | `UserConfig.apply` has already copied the file into defaults; iOS without a config folder still works |
32| Accent fallback | Mac `.controlAccentColor`, iOS `.systemBlue` per appearance | A theme set for one appearance only leaves the other to the system |
33| Mac bundle icon | `Assets.car` from `actool`, `CFBundleIconName` | The system's dark and tinted icon styles need a catalog |
34| Mac alternate icon | `NSApp.applicationIconImage` from preview PNGs | The only supported way; Dock only, while running |
35| Icon PNG check | None | PNG bytes vary with the ImageIO version; the generator is the source |
36
37## Review focus
38
39- A `config.toml` from 0.5.0 with `theme-file` and `[theme.dark]` colors must look the same after upgrading: the layering order is palettes, then `theme-file`, then `config.toml`. Test in Task 4.
40- `light-theme = "nord"` (a dark palette in the light key) must report a problem and use Default, not apply Nord to light. Test in Task 4.
41- An iOS device with no config folder chosen must still apply a picked theme. Test in Task 4 (`ThemeSpec.base`), used in Task 7.
42- Copy to Config Folder must never overwrite an existing `my-theme.toml`. Test in Task 6.
43- A Dock icon set at launch must follow a light/dark appearance change while the app runs, and `default` must restore the bundle's icon (`nil`), not a preview PNG. Test in Task 10.
44
45---
46
47### Task 1: Icon pipeline for the default icon (risk check)
48
49Settles both risks in the spec before anything else is drawn: dark and tinted appearances from an `actool`-compiled catalog on macOS 26, and on iOS 26.
50
51**Files:**
52- Modify: `scripts/make-icon.swift` (whole file)
53- Create: `packaging/AppIcons.xcassets/Contents.json`, `packaging/AppIcons.xcassets/AppIcon.appiconset/*`
54- Modify: `ios/Orgstar/Assets.xcassets/AppIcon.appiconset/Contents.json`, add `AppIcon-dark.png`, `AppIcon-tinted.png`
55- Modify: `scripts/build-app.sh:60-62`, its Info.plist heredoc (`CFBundleIconFile` → `CFBundleIconName`)
56
57**Interfaces:**
58- Produces: `swift scripts/make-icon.swift` with no arguments regenerates every committed icon file. A `Variant` struct and `variants` array that Task 8 extends.
59
60- [ ] **Step 1: Rewrite `make-icon.swift` around a variant table**
61
62```swift
63// Draws orgstar's app icons from the variant table below into the committed asset catalogs:
64// ios/Orgstar/Assets.xcassets (iOS app icons and their previews), packaging/AppIcons.xcassets
65// (the Mac's icon) and packaging/IconPreviews (the Mac's Dock icons).
66// Usage: swift scripts/make-icon.swift
67import AppKit
68
69struct Variant {
70 enum Style { case filled, outline, unicorn }
71 let id: String
72 /// The gradient, top-left to bottom-right.
73 let top: NSColor, bottom: NSColor
74 let glyph: NSColor
75 let bars: NSColor
76 var style: Style = .filled
77}
78
79func rgb(_ hex: UInt32) -> NSColor {
80 NSColor(srgbRed: CGFloat(hex >> 16 & 0xFF) / 255, green: CGFloat(hex >> 8 & 0xFF) / 255, blue: CGFloat(hex & 0xFF) / 255, alpha: 1)
81}
82
83let variants: [Variant] = [
84 Variant(id: "default", top: NSColor(srgbRed: 0.13, green: 0.20, blue: 0.55, alpha: 1), bottom: NSColor(srgbRed: 0.40, green: 0.22, blue: 0.70, alpha: 1),
85 glyph: NSColor(srgbRed: 1, green: 0.78, blue: 0.30, alpha: 1), bars: NSColor(white: 1, alpha: 0.92)),
86]
87
88enum Look { case light, dark, tinted }
89
90/// The macOS icon grid: an 824-point rounded square in a 1024 canvas; `fullBleed` fills the
91/// canvas, as iOS wants. Dark and tinted leave the background clear (dark) or black (tinted)
92/// for the system to fill.
93func draw(_ v: Variant, _ size: CGFloat, look: Look = .light, fullBleed: Bool = false) -> NSBitmapImageRep {
94 let rep = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: Int(size), pixelsHigh: Int(size), bitsPerSample: 8,
95 samplesPerPixel: 4, hasAlpha: true, isPlanar: false, colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0)!
96 NSGraphicsContext.saveGraphicsState()
97 NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: rep)
98 let s = size / 1024
99 if fullBleed {
100 let transform = NSAffineTransform()
101 transform.scale(by: 1024 / 824)
102 transform.translateX(by: -100 * s, yBy: -100 * s)
103 transform.concat()
104 }
105 let square = NSRect(x: 100 * s, y: 100 * s, width: 824 * s, height: 824 * s)
106 let shape = fullBleed ? NSBezierPath(rect: square) : NSBezierPath(roundedRect: square, xRadius: 185 * s, yRadius: 185 * s)
107 switch look {
108 case .light: NSGradient(colors: [v.top, v.bottom])!.draw(in: shape, angle: -60)
109 case .dark: break
110 case .tinted: NSColor.black.setFill(); shape.fill()
111 }
112 let glyph = look == .tinted ? NSColor(white: 0.95, alpha: 1) : v.glyph
113 let bars = look == .tinted ? NSColor(white: 0.75, alpha: 1) : v.bars
114 switch v.style {
115 case .filled: drawOutline(s, glyph: glyph, bars: bars, filled: true)
116 case .outline: drawOutline(s, glyph: glyph, bars: bars, filled: false)
117 case .unicorn: drawUnicorn(s, glyph: glyph, head: bars)
118 }
119 NSGraphicsContext.restoreGraphicsState()
120 return rep
121}
122
123/// The heading star over three outline lines, indented like a heading's children.
124func drawOutline(_ s: CGFloat, glyph: NSColor, bars: NSColor, filled: Bool) {
125 let star = NSAttributedString(string: "✱", attributes: [
126 .font: NSFont.systemFont(ofSize: 330 * s, weight: filled ? .heavy : .light), .foregroundColor: glyph,
127 ])
128 star.draw(at: NSPoint(x: 190 * s, y: 520 * s))
129 for (i, (x, width)) in [(470.0, 330.0), (300.0, 500.0), (380.0, 420.0)].enumerated() {
130 let y = (650 - Double(i) * 150) * s
131 let line = NSRect(x: x * s, y: y, width: width * s, height: (i == 0 ? 70 : 56) * s)
132 let path = NSBezierPath(roundedRect: line, xRadius: 28 * s, yRadius: 28 * s)
133 if filled {
134 bars.setFill(); path.fill()
135 } else {
136 bars.setStroke(); path.lineWidth = 10 * s; path.stroke()
137 }
138 }
139}
140
141/// Task 8 draws the unicorn.
142func drawUnicorn(_ s: CGFloat, glyph: NSColor, head: NSColor) {
143 drawOutline(s, glyph: glyph, bars: head, filled: true)
144}
145
146func png(_ rep: NSBitmapImageRep) -> Data { rep.representation(using: .png, properties: [:])! }
147
148/// Without an alpha channel, as the App Store requires for the light icon.
149func opaque(_ rep: NSBitmapImageRep) -> NSBitmapImageRep {
150 let size = rep.pixelsWide
151 let context = CGContext(data: nil, width: size, height: size, bitsPerComponent: 8, bytesPerRow: 0,
152 space: CGColorSpace(name: CGColorSpace.sRGB)!, bitmapInfo: CGImageAlphaInfo.noneSkipLast.rawValue)!
153 context.draw(rep.cgImage!, in: CGRect(x: 0, y: 0, width: size, height: size))
154 return NSBitmapImageRep(cgImage: context.makeImage()!)
155}
156
157func write(_ data: Data, _ path: String) throws {
158 let url = URL(fileURLWithPath: path)
159 try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)
160 try data.write(to: url)
161}
162
163func json(_ object: Any, _ path: String) throws {
164 try write(JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted, .sortedKeys]), path)
165}
166
167let info = ["author": "xcode", "version": 1] as [String: Any]
168let appearances: [(Look, String, [[String: String]])] = [
169 (.light, "", []),
170 (.dark, "-dark", [["appearance": "luminosity", "value": "dark"]]),
171 (.tinted, "-tinted", [["appearance": "luminosity", "value": "tinted"]]),
172]
173
174for v in variants {
175 // iOS: one set per icon, named AppIcon for the default and AppIcon-<Id> for the others.
176 let setName = v.id == "default" ? "AppIcon" : "AppIcon-" + v.id.split(separator: "-").map(\.capitalized).joined()
177 let set = "ios/Orgstar/Assets.xcassets/\(setName).appiconset"
178 var images: [[String: Any]] = []
179 for (look, suffix, appearance) in appearances {
180 let rep = draw(v, 1024, look: look, fullBleed: true)
181 try write(png(look == .light ? opaque(rep) : rep), "\(set)/AppIcon\(suffix).png")
182 var image: [String: Any] = ["filename": "AppIcon\(suffix).png", "idiom": "universal", "platform": "ios", "size": "1024x1024"]
183 if !appearance.isEmpty { image["appearances"] = appearance }
184 images.append(image)
185 }
186 try json(["images": images, "info": info], "\(set)/Contents.json")
187
188 // Previews for the iOS picker, light and dark.
189 let preview = "ios/Orgstar/Assets.xcassets/IconPreview-\(v.id).imageset"
190 try write(png(draw(v, 256, fullBleed: true)), "\(preview)/light.png")
191 try write(png(draw(v, 256, look: .dark, fullBleed: true)), "\(preview)/dark.png")
192 try json(["images": [
193 ["filename": "light.png", "idiom": "universal"],
194 ["filename": "dark.png", "idiom": "universal", "appearances": [["appearance": "luminosity", "value": "dark"]]],
195 ], "info": info], "\(preview)/Contents.json")
196
197 // The Mac's Dock icons and picker previews.
198 try write(png(draw(v, 512)), "packaging/IconPreviews/\(v.id)-light.png")
199 try write(png(draw(v, 512, look: .dark)), "packaging/IconPreviews/\(v.id)-dark.png")
200}
201
202// The Mac's bundle icon: the default variant at the Mac's sizes, in each appearance.
203let mac = "packaging/AppIcons.xcassets/AppIcon.appiconset"
204var macImages: [[String: Any]] = []
205for base in [16, 32, 128, 256, 512] {
206 for scale in [1, 2] {
207 for (look, suffix, appearance) in appearances {
208 let name = "icon_\(base)x\(base)\(scale == 2 ? "@2x" : "")\(suffix).png"
209 try write(png(draw(variants[0], CGFloat(base * scale), look: look)), "\(mac)/\(name)")
210 var image: [String: Any] = ["filename": name, "idiom": "mac", "scale": "\(scale)x", "size": "\(base)x\(base)"]
211 if !appearance.isEmpty { image["appearances"] = appearance }
212 macImages.append(image)
213 }
214 }
215}
216try json(["images": macImages, "info": info], "\(mac)/Contents.json")
217try json(["info": info], "packaging/AppIcons.xcassets/Contents.json")
218```
219
220- [ ] **Step 2: Generate and check the default icon is unchanged**
221
222Run: `swift scripts/make-icon.swift && git diff --stat ios/Orgstar/Assets.xcassets/AppIcon.appiconset/AppIcon.png`
223Then open the old and new `AppIcon.png` side by side (`git show HEAD:ios/Orgstar/Assets.xcassets/AppIcon.appiconset/AppIcon.png > /tmp/old.png; open /tmp/old.png ios/Orgstar/Assets.xcassets/AppIcon.appiconset/AppIcon.png`).
224Expected: they look the same. The bytes may differ.
225
226- [ ] **Step 3: Compile the Mac catalog in `build-app.sh`**
227
228Replace lines 60–62 (`iconset=…` through `rm -rf "$(dirname "$iconset")"`) with:
229
230```sh
231# The icon, in the system's default, dark and tinted styles, and the Dock icons Settings offers.
232work="$(mktemp -d)"
233xcrun actool packaging/AppIcons.xcassets --compile "$app/Contents/Resources" --platform macosx \
234 --minimum-deployment-target 26.0 --app-icon AppIcon --output-partial-info-plist "$work/icon.plist" > /dev/null
235rm -rf "$work"
236mkdir -p "$app/Contents/Resources/IconPreviews"
237cp packaging/IconPreviews/*.png "$app/Contents/Resources/IconPreviews/"
238```
239
240In the Info.plist heredoc, replace
241
242```
243 <key>CFBundleIconFile</key>
244 <string>AppIcon</string>
245```
246
247with
248
249```
250 <key>CFBundleIconName</key>
251 <string>AppIcon</string>
252```
253
254- [ ] **Step 4: Check on macOS 26**
255
256Run: `scripts/build-app.sh && ls .build/*.app/Contents/Resources/Assets.car && open -R .build/*.app`
257In System Settings ▸ Appearance ▸ Icon & widget style, switch between Default, Dark and Tinted, and look at the app in Finder and in the Dock after launching it.
258Expected: Dark shows the star and bars on the system's dark background; Tinted shows them tinted.
259If Dark and Tinted show the same image as Default, delete the `-dark`/`-tinted` entries from the Mac set in `make-icon.swift` (keep only `look == .light` in the Mac loop), regenerate, and record under Decisions: "Mac bundle icon: default variant only; macOS derives dark and tinted."
260
261- [ ] **Step 5: Check on iOS 26**
262
263Build and run the `Orgstar` scheme from `ios/Orgstar.xcodeproj` on a device or the iOS 26 Simulator. On the home screen, long-press ▸ Edit ▸ Customize, and switch between Dark and Tinted.
264Expected: the dark and tinted images show. If not, record that in Decisions and stop before Task 8; ask how to proceed.
265
266- [ ] **Step 6: Commit**
267
268```bash
269git add scripts/make-icon.swift scripts/build-app.sh packaging/AppIcons.xcassets packaging/IconPreviews ios/Orgstar/Assets.xcassets
270git commit -m "Icons from a variant table, with dark and tinted styles; Mac icon from an asset catalog"
271```
272
273---
274
275### Task 2: Palettes, the Default palettes and the accent slot
276
277**Files:**
278- Create: `Sources/OrgPresentation/Palettes.swift`
279- Modify: `Sources/OrgPresentation/ThemeSpec.swift` (`slots`, `systemDefaults`, `typeKeys`)
280- Modify: `Sources/Orgstar/ThemeColors.swift` (`systemColor`)
281- Test: `Tests/OrgPresentationTests/PaletteTests.swift`
282
283**Interfaces:**
284- Produces:
285 - `public struct Palette: Sendable, Equatable { public enum Appearance: String, Sendable { case light, dark }; public let id: String; public let name: String; public let appearance: Appearance; public let colors: [String: RGBA] }`
286 - `extension ThemeSpec { public static func palettes(_ appearance: Palette.Appearance) -> [Palette]; public static func palette(_ id: String, _ appearance: Palette.Appearance) -> Palette?; public static func defaultPaletteID(_ appearance: Palette.Appearance) -> String }`
287 - Theme slot `accent`, in `systemDefaults`.
288
289- [ ] **Step 1: Write the failing tests**
290
291```swift
292import OrgPresentation
293import Testing
294
295struct PaletteTests {
296 @Test func defaultPalettesAreTheDefaultTheme() throws {
297 let light = try #require(ThemeSpec.palette("default-light", .light))
298 let dark = try #require(ThemeSpec.palette("default-dark", .dark))
299 #expect(light.colors == ThemeSpec.default.light && dark.colors == ThemeSpec.default.dark)
300 #expect(light.name == "Default" && ThemeSpec.palettes(.light).first == light && ThemeSpec.palettes(.dark).first == dark)
301 #expect(ThemeSpec.defaultPaletteID(.light) == "default-light" && ThemeSpec.defaultPaletteID(.dark) == "default-dark")
302 }
303
304 @Test func aPaletteIsFoundOnlyInItsAppearance() {
305 #expect(ThemeSpec.palette("default-light", .dark) == nil)
306 #expect(ThemeSpec.palette("nope", .light) == nil)
307 }
308
309 @Test func accentIsASlotTheDefaultLeavesToTheSystem() {
310 #expect(ThemeSpec.slots.contains { $0.key == "accent" })
311 #expect(ThemeSpec.systemDefaults.contains("accent"))
312 #expect(ThemeSpec.default.light["accent"] == nil && ThemeSpec.default.dark["accent"] == nil)
313 }
314
315 @Test func everyPaletteHasExactlyTheSlotKeys() {
316 let all = Set(ThemeSpec.slots.map(\.key))
317 for palette in ThemeSpec.palettes(.light) + ThemeSpec.palettes(.dark) {
318 let expected = palette.id.hasPrefix("default-") ? all.subtracting(ThemeSpec.systemDefaults) : all
319 #expect(Set(palette.colors.keys) == expected, "\(palette.id): \(expected.symmetricDifference(palette.colors.keys))")
320 }
321 }
322}
323```
324
325- [ ] **Step 2: Run them to see them fail**
326
327Run: `swift test --filter PaletteTests`
328Expected: compile error, `Palette` not found.
329
330- [ ] **Step 3: Add the slot**
331
332In `ThemeSpec.slots`, after `("selection", "selected text's background"),` add:
333
334```swift
335 ("accent", "buttons, toggles and selection in lists; unset: the system's"),
336```
337
338In `systemDefaults` add `"accent"`. In `typeKeys` add `"light-theme", "dark-theme"` (Task 4 uses them; adding them now keeps `[theme] light-theme = …` from being read as a color).
339
340In `Sources/Orgstar/ThemeColors.swift` `systemColor`, add a case before `default`:
341
342```swift
343 case "accent": .controlAccentColor
344```
345
346- [ ] **Step 4: Write `Palettes.swift`**
347
348```swift
349/// A built-in theme for one appearance, chosen with `light-theme` or `dark-theme`.
350public struct Palette: Sendable, Equatable {
351 public enum Appearance: String, Sendable { case light, dark }
352
353 public let id: String
354 public let name: String
355 public let appearance: Appearance
356 public let colors: [String: RGBA]
357
358 public init(id: String, name: String, appearance: Appearance, colors: [String: RGBA]) {
359 self.id = id
360 self.name = name
361 self.appearance = appearance
362 self.colors = colors
363 }
364}
365
366extension ThemeSpec {
367 /// The built-in palettes of `appearance`, Default first.
368 public static func palettes(_ appearance: Palette.Appearance) -> [Palette] {
369 appearance == .light ? lightPalettes : darkPalettes
370 }
371
372 public static func palette(_ id: String, _ appearance: Palette.Appearance) -> Palette? {
373 palettes(appearance).first { $0.id == id }
374 }
375
376 public static func defaultPaletteID(_ appearance: Palette.Appearance) -> String {
377 "default-" + appearance.rawValue
378 }
379
380 static let lightPalettes: [Palette] = [
381 Palette(id: "default-light", name: "Default", appearance: .light, colors: ThemeSpec.default.light),
382 ]
383
384 static let darkPalettes: [Palette] = [
385 Palette(id: "default-dark", name: "Default", appearance: .dark, colors: ThemeSpec.default.dark),
386 ]
387}
388```
389
390- [ ] **Step 5: Run the tests**
391
392Run: `swift test --filter PaletteTests && swift test`
393Expected: PASS. Existing tests that print `default-theme.toml` gain a commented `# accent = "#rrggbb"` line; if a test compares that text exactly, update its expected text to include the line.
394
395- [ ] **Step 6: Commit**
396
397```bash
398git add Sources/OrgPresentation Sources/Orgstar/ThemeColors.swift Tests/OrgPresentationTests/PaletteTests.swift
399git commit -m "Palettes, with the default theme as Default; accent theme color"
400```
401
402---
403
404### Task 3: The ported palettes
405
406**Files:**
407- Modify: `Sources/OrgPresentation/Palettes.swift`
408- Modify: `THIRD_PARTY.org`
409- Test: `Tests/OrgPresentationTests/PaletteTests.swift`
410
411**Interfaces:**
412- Consumes: `Palette`, `ThemeSpec.palettes` (Task 2).
413- Produces: `public struct ThemeSpec.Roles` with `public func colors(dark: Bool) -> [String: RGBA]`; 14 more palettes with the ids in the spec.
414
415- [ ] **Step 1: Write the failing tests**
416
417Add to `PaletteTests`:
418
419```swift
420 @Test func theCatalogIsInOrder() {
421 #expect(ThemeSpec.palettes(.light).map(\.id) == ["default-light", "solarized-light", "gruvbox-light", "modus-operandi", "catppuccin-latte", "tomorrow", "paper"])
422 #expect(ThemeSpec.palettes(.dark).map(\.id) == ["default-dark", "solarized-dark", "gruvbox-dark", "modus-vivendi", "catppuccin-mocha", "nord", "dracula", "tokyo-night", "doom-one"])
423 }
424
425 /// WCAG 2 contrast ratio.
426 static func contrast(_ a: RGBA, _ b: RGBA) -> Double {
427 func luminance(_ c: RGBA) -> Double {
428 func channel(_ v: Double) -> Double { v <= 0.03928 ? v / 12.92 : pow((v + 0.055) / 1.055, 2.4) }
429 return 0.2126 * channel(c.red) + 0.7152 * channel(c.green) + 0.0722 * channel(c.blue)
430 }
431 let (x, y) = (luminance(a), luminance(b))
432 return (max(x, y) + 0.05) / (min(x, y) + 0.05)
433 }
434
435 @Test func textReadsOnTheBackground() throws {
436 let body = ["foreground", "table"]
437 let marks = ["heading-1", "heading-2", "heading-3", "heading-4", "todo", "todo-next", "todo-waiting", "done", "link", "timestamp", "code",
438 "syntax-keyword", "syntax-string", "syntax-function", "syntax-type", "syntax-number", "syntax-property", "syntax-label"]
439 for palette in ThemeSpec.palettes(.light) + ThemeSpec.palettes(.dark) {
440 let background = try #require(palette.colors["background"])
441 for key in body {
442 let ratio = Self.contrast(try #require(palette.colors[key]), background)
443 #expect(ratio >= 4.5, "\(palette.id) \(key): \(ratio)")
444 }
445 for key in marks {
446 let ratio = Self.contrast(try #require(palette.colors[key]), background)
447 #expect(ratio >= 3, "\(palette.id) \(key): \(ratio)")
448 }
449 }
450 }
451```
452
453Add `import Foundation` at the top of the file for `pow`.
454
455- [ ] **Step 2: Run them to see them fail**
456
457Run: `swift test --filter PaletteTests`
458Expected: `theCatalogIsInOrder` fails. `textReadsOnTheBackground` passes for Default; if it fails for Default, stop and report the key and ratio: the threshold or the default needs a decision.
459
460- [ ] **Step 3: Add `Roles` and the palettes**
461
462Append to `Palettes.swift`:
463
464```swift
465extension ThemeSpec {
466 /// A palette's named colors, from which every slot is set.
467 public struct Roles: Sendable {
468 public var bg, alt, fg, dim, red, orange, yellow, green, cyan, blue, purple, accent: String
469
470 /// Slot → role. `selection` and `inline-background` are translucent roles.
471 static let slots: [String: KeyPath<Roles, String>] = [
472 "background": \.bg, "foreground": \.fg, "cursor": \.accent, "accent": \.accent,
473 "heading-1": \.blue, "heading-2": \.purple, "heading-3": \.green, "heading-4": \.orange,
474 "heading-5": \.blue, "heading-6": \.purple, "heading-7": \.green, "heading-8": \.orange,
475 "todo": \.red, "todo-next": \.blue, "todo-waiting": \.yellow, "done": \.green, "todo-cancelled": \.dim,
476 "priority": \.orange, "priority-a": \.red, "priority-b": \.orange, "priority-c": \.dim,
477 "tags": \.dim, "link": \.blue, "timestamp": \.purple, "code": \.orange, "verbatim": \.cyan,
478 "markup": \.dim, "comment": \.dim, "keyword": \.dim, "metadata": \.dim, "special": \.cyan,
479 "block-background": \.alt, "block-delimiter": \.dim, "table": \.fg,
480 "line-number": \.dim, "line-number-current": \.fg,
481 "syntax-keyword": \.purple, "syntax-string": \.green, "syntax-comment": \.dim, "syntax-function": \.blue,
482 "syntax-type": \.yellow, "syntax-number": \.orange, "syntax-property": \.cyan, "syntax-label": \.purple,
483 "sidebar-background": \.alt, "sidebar-foreground": \.fg, "sidebar-header": \.dim,
484 "modeline-background": \.alt, "modeline-foreground": \.fg, "modeline-highlight": \.accent,
485 "state-normal": \.blue, "state-insert": \.green, "state-visual": \.orange,
486 "agenda-background": \.bg, "agenda-date": \.fg, "agenda-today": \.accent, "agenda-time": \.dim, "agenda-category": \.dim,
487 "agenda-overdue": \.red, "agenda-due-soon": \.orange, "agenda-event": \.purple,
488 "habit-clear": \.blue, "habit-ready": \.green, "habit-alert": \.yellow, "habit-overdue": \.red,
489 ]
490
491 /// Alphas are whole bytes (`#…33`, `#…59`), so a palette written out as a theme file
492 /// reads back equal.
493 public func colors(dark: Bool) -> [String: RGBA] {
494 var out = Self.slots.compactMapValues { RGBA(hex: self[keyPath: $0]) }
495 if var selection = RGBA(hex: accent) {
496 selection.alpha = (dark ? 0x59 : 0x33) / 255
497 out["selection"] = selection
498 }
499 if var inline = RGBA(hex: dim) {
500 inline.alpha = 0x33 / 255
501 out["inline-background"] = inline
502 }
503 return out
504 }
505 }
506
507 private static func ported(_ id: String, _ name: String, _ appearance: Palette.Appearance, _ roles: Roles) -> Palette {
508 Palette(id: id, name: name, appearance: appearance, colors: roles.colors(dark: appearance == .dark))
509 }
510}
511```
512
513Replace `lightPalettes` and `darkPalettes` with:
514
515```swift
516 // Upstream palettes; see THIRD_PARTY.org. Colors darkened from upstream to read at 3:1 on
517 // the background: Solarized Light yellow, green and cyan; Catppuccin Latte orange, yellow
518 // and green; Tomorrow orange and yellow.
519 static let lightPalettes: [Palette] = [
520 Palette(id: "default-light", name: "Default", appearance: .light, colors: ThemeSpec.default.light),
521 ported("solarized-light", "Solarized Light", .light, Roles(
522 bg: "#fdf6e3", alt: "#eee8d5", fg: "#586e75", dim: "#93a1a1", red: "#dc322f", orange: "#cb4b16", yellow: "#a57c00",
523 green: "#738a05", cyan: "#258f86", blue: "#268bd2", purple: "#6c71c4", accent: "#268bd2")),
524 ported("gruvbox-light", "Gruvbox Light", .light, Roles(
525 bg: "#fbf1c7", alt: "#ebdbb2", fg: "#3c3836", dim: "#928374", red: "#9d0006", orange: "#af3a03", yellow: "#b57614",
526 green: "#79740e", cyan: "#427b58", blue: "#076678", purple: "#8f3f71", accent: "#076678")),
527 ported("modus-operandi", "Modus Operandi", .light, Roles(
528 bg: "#ffffff", alt: "#f2f2f2", fg: "#000000", dim: "#595959", red: "#a60000", orange: "#972500", yellow: "#6f5500",
529 green: "#006800", cyan: "#005e8b", blue: "#0031a9", purple: "#721045", accent: "#0031a9")),
530 ported("catppuccin-latte", "Catppuccin Latte", .light, Roles(
531 bg: "#eff1f5", alt: "#e6e9ef", fg: "#4c4f69", dim: "#8c8fa1", red: "#d20f39", orange: "#d0590a", yellow: "#b06f13",
532 green: "#388c24", cyan: "#179299", blue: "#1e66f5", purple: "#8839ef", accent: "#8839ef")),
533 ported("tomorrow", "Tomorrow", .light, Roles(
534 bg: "#ffffff", alt: "#efefef", fg: "#4d4d4c", dim: "#8e908c", red: "#c82829", orange: "#c76b17", yellow: "#a87e00",
535 green: "#718c00", cyan: "#3e999f", blue: "#4271ae", purple: "#8959a8", accent: "#4271ae")),
536 // orgstar's own: warm paper and ink, for long reading.
537 ported("paper", "Paper", .light, Roles(
538 bg: "#f8f3e6", alt: "#efe8d6", fg: "#3b3428", dim: "#7d7262", red: "#a8322d", orange: "#a85a1f", yellow: "#8a6d1a",
539 green: "#4d6b2f", cyan: "#2f6b6b", blue: "#2f5486", purple: "#6b4a85", accent: "#a85a1f")),
540 ]
541
542 static let darkPalettes: [Palette] = [
543 Palette(id: "default-dark", name: "Default", appearance: .dark, colors: ThemeSpec.default.dark),
544 ported("solarized-dark", "Solarized Dark", .dark, Roles(
545 bg: "#002b36", alt: "#073642", fg: "#93a1a1", dim: "#586e75", red: "#dc322f", orange: "#cb4b16", yellow: "#b58900",
546 green: "#859900", cyan: "#2aa198", blue: "#268bd2", purple: "#6c71c4", accent: "#268bd2")),
547 ported("gruvbox-dark", "Gruvbox Dark", .dark, Roles(
548 bg: "#282828", alt: "#3c3836", fg: "#ebdbb2", dim: "#928374", red: "#fb4934", orange: "#fe8019", yellow: "#fabd2f",
549 green: "#b8bb26", cyan: "#8ec07c", blue: "#83a598", purple: "#d3869b", accent: "#83a598")),
550 ported("modus-vivendi", "Modus Vivendi", .dark, Roles(
551 bg: "#000000", alt: "#1e1e1e", fg: "#ffffff", dim: "#989898", red: "#ff5f59", orange: "#fec43f", yellow: "#d0bc00",
552 green: "#44bc44", cyan: "#00d3d0", blue: "#2fafff", purple: "#b6a0ff", accent: "#2fafff")),
553 ported("catppuccin-mocha", "Catppuccin Mocha", .dark, Roles(
554 bg: "#1e1e2e", alt: "#181825", fg: "#cdd6f4", dim: "#7f849c", red: "#f38ba8", orange: "#fab387", yellow: "#f9e2af",
555 green: "#a6e3a1", cyan: "#94e2d5", blue: "#89b4fa", purple: "#cba6f7", accent: "#cba6f7")),
556 ported("nord", "Nord", .dark, Roles(
557 bg: "#2e3440", alt: "#3b4252", fg: "#d8dee9", dim: "#616e88", red: "#bf616a", orange: "#d08770", yellow: "#ebcb8b",
558 green: "#a3be8c", cyan: "#8fbcbb", blue: "#88c0d0", purple: "#b48ead", accent: "#88c0d0")),
559 ported("dracula", "Dracula", .dark, Roles(
560 bg: "#282a36", alt: "#44475a", fg: "#f8f8f2", dim: "#6272a4", red: "#ff5555", orange: "#ffb86c", yellow: "#f1fa8c",
561 green: "#50fa7b", cyan: "#8be9fd", blue: "#8be9fd", purple: "#bd93f9", accent: "#bd93f9")),
562 ported("tokyo-night", "Tokyo Night", .dark, Roles(
563 bg: "#1a1b26", alt: "#16161e", fg: "#c0caf5", dim: "#565f89", red: "#f7768e", orange: "#ff9e64", yellow: "#e0af68",
564 green: "#9ece6a", cyan: "#7dcfff", blue: "#7aa2f7", purple: "#bb9af7", accent: "#7aa2f7")),
565 ported("doom-one", "doom-one", .dark, Roles(
566 bg: "#282c34", alt: "#21242b", fg: "#bbc2cf", dim: "#5b6268", red: "#ff6c6b", orange: "#da8548", yellow: "#ecbe7b",
567 green: "#98be65", cyan: "#46d9ff", blue: "#51afef", purple: "#c678dd", accent: "#51afef")),
568 ]
569```
570
571- [ ] **Step 4: Run the tests**
572
573Run: `swift test --filter PaletteTests`
574Expected: PASS. If `everyPaletteHasExactlyTheSlotKeys` names a key, add it to `Roles.slots`.
575
576- [ ] **Step 5: Record the sources in `THIRD_PARTY.org`**
577
578Add a heading `* Color themes` listing, one line each, the palette, its upstream URL and license:
579
580```org
581* Color themes
582The built-in palettes in =Sources/OrgPresentation/Palettes.swift= take their colors from:
583- Solarized, https://ethanschoonover.com/solarized/, MIT
584- Gruvbox, https://github.com/morhetz/gruvbox, MIT
585- Modus themes, https://protesilaos.com/emacs/modus-themes, GPL-3.0-or-later (colors only)
586- Catppuccin, https://github.com/catppuccin/catppuccin, MIT
587- Tomorrow, https://github.com/chriskempson/tomorrow-theme, MIT
588- Nord, https://www.nordtheme.com, MIT
589- Dracula, https://draculatheme.com, MIT
590- Tokyo Night, https://github.com/folke/tokyonight.nvim, Apache-2.0
591- doom-one, https://github.com/doomemacs/themes, MIT
592```
593
594Check each license on the upstream page before committing; if any differs, correct the line, and if one is not MIT, Apache or BSD, stop and report it.
595
596- [ ] **Step 6: Commit**
597
598```bash
599git add Sources/OrgPresentation/Palettes.swift Tests/OrgPresentationTests/PaletteTests.swift THIRD_PARTY.org
600git commit -m "Fourteen built-in palettes, with a contrast test"
601```
602
603---
604
605### Task 4: `light-theme` and `dark-theme`
606
607**Files:**
608- Modify: `Sources/OrgPresentation/Palettes.swift`
609- Modify: `Sources/OrgApp/UserConfig.swift:29-49` (`theme`), the `settings` array after `theme-file`
610- Modify: `Sources/OrgApp/ConfigSync.swift` (`readTheme`)
611- Modify: `Sources/OrgstarMobile/MobileModel.swift` (`readConfig`)
612- Test: `Tests/OrgPresentationTests/PaletteTests.swift`, `Tests/OrgAppTests/UserConfigTests.swift`
613
614**Interfaces:**
615- Consumes: `ThemeSpec.palette`, `defaultPaletteID` (Task 2).
616- Produces:
617 - `extension ThemeSpec { public static func base(light: String?, dark: String?) -> (ThemeSpec, [String]) }`
618 - `UserConfig.theme(config:themeFile:lightTheme:darkTheme:in:read:)`, both new parameters `String?`, defaulting to `nil`.
619 - Settings with defaults keys `themeLight` and `themeDark`.
620
621- [ ] **Step 1: Write the failing tests**
622
623In `PaletteTests`:
624
625```swift
626 @Test func baseTakesEachAppearanceFromItsPalette() throws {
627 let (spec, problems) = ThemeSpec.base(light: "paper", dark: "nord")
628 #expect(problems.isEmpty)
629 #expect(spec.light == ThemeSpec.palette("paper", .light)?.colors && spec.dark == ThemeSpec.palette("nord", .dark)?.colors)
630 #expect(ThemeSpec.base(light: nil, dark: nil).0 == ThemeSpec.default)
631 #expect(ThemeSpec.base(light: "", dark: "").0 == ThemeSpec.default)
632 }
633
634 @Test func aPaletteOfTheOtherAppearanceIsAProblem() {
635 let (spec, problems) = ThemeSpec.base(light: "nord", dark: "unknown")
636 #expect(spec == ThemeSpec.default)
637 #expect(problems == ["config.toml: unknown light-theme nord", "config.toml: unknown dark-theme unknown"])
638 }
639```
640
641In `UserConfigTests`:
642
643```swift
644 @Test func chosenPalettesSitUnderTheThemeFileAndConfig() throws {
645 let name = "orgstar-palette-\(UUID().uuidString)"
646 let defaults = UserDefaults(suiteName: name)!
647 defer { defaults.removePersistentDomain(forName: name) }
648 let folder = FileManager.default.temporaryDirectory.appendingPathComponent(name)
649 defer { try? FileManager.default.removeItem(at: folder) }
650 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
651 try "[theme.dark]\nlink = \"#000001\"\n".write(to: folder.appendingPathComponent("mine.toml"), atomically: true, encoding: .utf8)
652 try "[theme]\nlight-theme = \"paper\"\ndark-theme = \"nord\"\ntheme-file = \"mine.toml\"\n[theme.dark]\ntodo = \"#000002\"\n"
653 .write(to: folder.appendingPathComponent("config.toml"), atomically: true, encoding: .utf8)
654 let sync = ConfigSync(url: folder.appendingPathComponent("config.toml"), defaults: defaults)
655 sync.start(watch: false)
656 #expect(sync.problems.isEmpty, "\(sync.problems)")
657 #expect(defaults.string(forKey: "themeLight") == "paper" && defaults.string(forKey: "themeDark") == "nord")
658 let nord = try #require(ThemeSpec.palette("nord", .dark))
659 #expect(sync.theme.light["background"] == ThemeSpec.palette("paper", .light)?.colors["background"])
660 #expect(sync.theme.dark["background"] == nord.colors["background"])
661 #expect(sync.theme.dark["link"]?.hex == "#000001")
662 #expect(sync.theme.dark["todo"]?.hex == "#000002")
663 }
664
665 @Test func noThemeSettingsGiveTheDefaultTheme() throws {
666 let folder = FileManager.default.temporaryDirectory
667 let theme = try #require(UserConfig.theme(config: "", themeFile: nil, lightTheme: nil, darkTheme: nil, in: folder))
668 #expect(theme.theme == ThemeSpec.default && theme.problems.isEmpty)
669 }
670```
671
672- [ ] **Step 2: Run them to see them fail**
673
674Run: `swift test --filter "PaletteTests|UserConfigTests"`
675Expected: compile errors for `base` and the new `theme` parameters.
676
677- [ ] **Step 3: Implement `ThemeSpec.base`**
678
679Append to the first `extension ThemeSpec` in `Palettes.swift`:
680
681```swift
682 /// The default theme with each appearance's colors from the palette `light-theme` and
683 /// `dark-theme` name; Default where one is unset or unknown, with a problem for unknown.
684 public static func base(light: String?, dark: String?) -> (ThemeSpec, [String]) {
685 var spec = ThemeSpec.default
686 var problems: [String] = []
687 for (id, appearance) in [(light, Palette.Appearance.light), (dark, .dark)] {
688 guard let id, !id.isEmpty, id != defaultPaletteID(appearance) else { continue }
689 guard let palette = palette(id, appearance) else {
690 problems.append("config.toml: unknown \(appearance.rawValue)-theme \(id)")
691 continue
692 }
693 if appearance == .light { spec.light = palette.colors } else { spec.dark = palette.colors }
694 }
695 return (spec, problems)
696 }
697```
698
699- [ ] **Step 4: Use it in `UserConfig.theme`**
700
701Change the signature and body:
702
703```swift
704 public static func theme(
705 config text: String, themeFile name: String?, lightTheme: String? = nil, darkTheme: String? = nil, in folder: URL,
706 read: (URL) -> String? = { try? String(contentsOf: $0, encoding: .utf8) }
707 ) -> (theme: ThemeSpec, problems: [String])? {
708 guard let tables = try? TOML.parse(text) else { return nil }
709 var (spec, problems) = ThemeSpec.base(light: lightTheme, dark: darkTheme)
710 if let name, !name.isEmpty {
711 if let themeText = read(folder.appendingPathComponent(name)) {
712 do {
713 let (read, more) = ThemeSpec.reading(try TOML.parse(themeText), over: spec, file: name)
714 spec = read
715 problems += more
716 } catch {
717 problems.append("\(name): \(error)")
718 }
719 } else {
720 problems.append("config.toml: theme-file \(name) can't be read")
721 }
722 }
723 let (merged, more) = ThemeSpec.reading(tables, over: spec)
724 return (merged, problems + more)
725 }
726```
727
728Update the doc comment above it to: "The theme `config.toml` (`text`) sets: its `[theme]` tables' colors over those of `theme-file` (a path relative to `folder`), over the palettes `light-theme` and `dark-theme` name; with problems in all three. Nil when `text` isn't TOML."
729
730After the `theme-file` entry in `settings`, add:
731
732```swift
733 Setting(section: "theme", key: "light-theme", defaultsKey: "themeLight", kind: .string, fallback: .string("default-light"),
734 comment: "the built-in theme for the light appearance: default-light, solarized-light, gruvbox-light, modus-operandi, catppuccin-latte, tomorrow or paper", legacy: ""),
735 Setting(section: "theme", key: "dark-theme", defaultsKey: "themeDark", kind: .string, fallback: .string("default-dark"),
736 comment: "the built-in theme for the dark appearance: default-dark, solarized-dark, gruvbox-dark, modus-vivendi, catppuccin-mocha, nord, dracula, tokyo-night or doom-one", legacy: ""),
737```
738
739- [ ] **Step 5: Pass the settings from both callers**
740
741`ConfigSync.readTheme`:
742
743```swift
744 guard let text, let read = UserConfig.theme(
745 config: text, themeFile: defaults.string(forKey: "themeFile"),
746 lightTheme: defaults.string(forKey: "themeLight"), darkTheme: defaults.string(forKey: "themeDark"),
747 in: url.deletingLastPathComponent()
748 ) else { return }
749```
750
751`MobileModel.readConfig`, so a device without a config folder still applies a chosen palette:
752
753```swift
754 private static func readConfig(_ folder: URL?) -> ([String], ThemeSpec) {
755 let defaults = UserDefaults.standard
756 guard let folder else {
757 let (base, problems) = ThemeSpec.base(light: defaults.string(forKey: "themeLight"), dark: defaults.string(forKey: "themeDark"))
758 return (problems, base)
759 }
760 guard let text = read(folder.appendingPathComponent("config.toml")) else {
761 return (["No config.toml in \(folder.lastPathComponent); the defaults apply."], .default)
762 }
763 let problems = UserConfig.apply(text, to: defaults)
764 guard let theme = UserConfig.theme(
765 config: text, themeFile: defaults.string(forKey: "themeFile"),
766 lightTheme: defaults.string(forKey: "themeLight"), darkTheme: defaults.string(forKey: "themeDark"), in: folder, read: read
767 ) else {
768 return (problems, .default)
769 }
770 return (problems + theme.problems, theme.theme)
771 }
772```
773
774- [ ] **Step 6: Run the tests**
775
776Run: `swift test && xcodebuild -scheme OrgstarMobile -destination 'generic/platform=iOS Simulator' -derivedDataPath .build/ios build -quiet`
777Expected: PASS and the iOS build succeeds. A test that compares the full `config.toml` template text gains the two new lines; update its expected text.
778
779- [ ] **Step 7: Commit**
780
781```bash
782git add Sources/OrgPresentation/Palettes.swift Sources/OrgApp Sources/OrgstarMobile/MobileModel.swift Tests
783git commit -m "light-theme and dark-theme settings, under theme-file and config.toml colors"
784```
785
786---
787
788### Task 5: Accent tint
789
790**Files:**
791- Modify: `Sources/Orgstar/OrgstarApp.swift:339,353,361,368` (scene roots)
792- Modify: `Sources/OrgstarMobile/MobileTheme.swift` (append extension)
793- Modify: `Sources/OrgstarMobile/OrgstarMobileApp.swift` (root `TabView`)
794
795**Interfaces:**
796- Consumes: `accent` slot (Task 2); Mac `ThemeSpec.color(_:) -> Color?` in `ThemeColors.swift`.
797- Produces: iOS `extension ThemeSpec { var accentColor: Color? }`.
798
799- [ ] **Step 1: Mac**
800
801On each of the four lines `.environment(\.orgTheme, ConfigSync.shared.theme)` at OrgstarApp.swift:339, 353, 361, 368, add on the following line:
802
803```swift
804 .tint(ConfigSync.shared.theme.color("accent"))
805```
806
807`color` returns nil when no palette sets `accent`, which leaves the system's tint.
808
809- [ ] **Step 2: iOS**
810
811Append to `MobileTheme.swift`, inside `#if os(iOS)`:
812
813```swift
814extension ThemeSpec {
815 /// `accent` for `.tint`, the system's blue in an appearance the theme leaves it unset; nil
816 /// when neither appearance sets it.
817 var accentColor: Color? {
818 let (light, dark) = (light["accent"], dark["accent"])
819 guard light != nil || dark != nil else { return nil }
820 return Color(uiColor: UIColor { traits in
821 guard let c = traits.userInterfaceStyle == .dark ? dark : light else { return .systemBlue }
822 return UIColor(red: c.red, green: c.green, blue: c.blue, alpha: c.alpha)
823 })
824 }
825}
826```
827
828In `OrgstarMobileApp.swift`, after `.clockAccessory(model.clock, perform: clock)` on the root `TabView`, add:
829
830```swift
831 .tint(model.theme.accentColor)
832```
833
834- [ ] **Step 3: Check by hand**
835
836Run: `swift build && scripts/build-app.sh`, open the app, set `dark-theme = "dracula"` under `[theme]` in `~/.config/orgstar/config.toml`, switch to dark appearance.
837Expected: toggles and the sidebar's selection turn Dracula purple; in light appearance they stay the system accent.
838
839- [ ] **Step 4: Commit**
840
841```bash
842git add Sources/Orgstar/OrgstarApp.swift Sources/OrgstarMobile/MobileTheme.swift Sources/OrgstarMobile/OrgstarMobileApp.swift
843git commit -m "Theme accent tints controls"
844```
845
846---
847
848### Task 6: Mac theme picker and Copy to Config Folder
849
850**Files:**
851- Create: `Sources/Orgstar/ThemePickerSection.swift`
852- Modify: `Sources/OrgPresentation/Palettes.swift` (`themeFile(light:dark:)`)
853- Modify: `Sources/Orgstar/OrgstarApp.swift:776-778` (first section of `appearance`)
854- Test: `Tests/OrgPresentationTests/PaletteTests.swift`
855
856**Interfaces:**
857- Consumes: `ThemeSpec.palettes`, `palette`, `defaultPaletteID`; settings `themeLight`, `themeDark`, `themeFile`.
858- Produces: `extension ThemeSpec { public static func themeFile(light: Palette, dark: Palette) -> String }`; `struct ThemePickerSection: View`.
859
860- [ ] **Step 1: Write the failing test**
861
862```swift
863 @Test func aCopiedThemeReadsBackAsThePalettes() throws {
864 let light = try #require(ThemeSpec.palette("paper", .light))
865 let dark = try #require(ThemeSpec.palette("nord", .dark))
866 let text = ThemeSpec.themeFile(light: light, dark: dark)
867 #expect(text.hasPrefix("# Paper and Nord, copied from orgstar's built-in themes."))
868 let (spec, problems) = ThemeSpec.reading(try TOML.parse(text))
869 #expect(problems.isEmpty, "\(problems)")
870 #expect(spec.light.filter { light.colors[$0.key] != nil } == light.colors && spec.dark.filter { dark.colors[$0.key] != nil } == dark.colors)
871 }
872```
873
874Add `import OrgCore` to the test file for `TOML`.
875
876- [ ] **Step 2: Run it to see it fail**
877
878Run: `swift test --filter PaletteTests/aCopiedThemeReadsBackAsThePalettes`
879Expected: compile error, `themeFile(light:dark:)` not found.
880
881- [ ] **Step 3: Implement `themeFile`**
882
883Append to `Palettes.swift`:
884
885```swift
886extension ThemeSpec {
887 /// Two palettes as a theme file, every color written out, in slot order.
888 public static func themeFile(light: Palette, dark: Palette) -> String {
889 var out = "# \(light.name) and \(dark.name), copied from orgstar's built-in themes. Used with\n"
890 + "# theme-file = \"my-theme.toml\" under [theme] in config.toml; colors there apply on top.\n"
891 for (table, palette) in [("theme.light", light), ("theme.dark", dark)] {
892 out += "\n[\(table)]\n"
893 for slot in slots {
894 if let color = palette.colors[slot.key] { out += "\(slot.key) = \"\(color.hex)\"\n" }
895 }
896 }
897 return out
898 }
899}
900```
901
902- [ ] **Step 4: Run the test**
903
904Run: `swift test --filter PaletteTests`
905Expected: PASS.
906
907- [ ] **Step 5: Write `ThemePickerSection.swift`**
908
909```swift
910import AppKit
911import OrgApp
912import OrgPresentation
913import SwiftUI
914
915/// Settings ▸ Appearance ▸ Theme: the built-in palette for each appearance.
916struct ThemePickerSection: View {
917 @AppStorage("themeLight") private var themeLight = "default-light"
918 @AppStorage("themeDark") private var themeDark = "default-dark"
919 @AppStorage("themeFile") private var themeFile = ""
920 @State private var message: String?
921
922 var body: some View {
923 Section {
924 picker("Light", .light, $themeLight)
925 picker("Dark", .dark, $themeDark)
926 LabeledContent("Starting point") {
927 Button("Copy to Config Folder") { copy() }
928 }
929 } header: {
930 Text("Theme")
931 } footer: {
932 Text(message ?? "Colors set in config.toml or in the theme file apply on top of these.")
933 .settingsFooter()
934 }
935 }
936
937 private func picker(_ title: LocalizedStringKey, _ appearance: Palette.Appearance, _ selection: Binding<String>) -> some View {
938 Picker(title, selection: selection) {
939 ForEach(ThemeSpec.palettes(appearance), id: \.id) { palette in
940 Label { Text(palette.name) } icon: { Image(nsImage: Self.swatch(palette)) }.tag(palette.id)
941 }
942 if ThemeSpec.palette(selection.wrappedValue, appearance) == nil {
943 Text(selection.wrappedValue).tag(selection.wrappedValue)
944 }
945 }
946 }
947
948 /// Background, text, heading, TODO and accent, side by side.
949 static func swatch(_ palette: Palette) -> NSImage {
950 let keys = ["background", "foreground", "heading-1", "todo", "accent"]
951 return NSImage(size: NSSize(width: 40, height: 12), flipped: false) { rect in
952 for (i, key) in keys.enumerated() {
953 let c = palette.colors[key] ?? palette.colors["cursor"] ?? RGBA(red: 0.5, green: 0.5, blue: 0.5)
954 NSColor(srgbRed: c.red, green: c.green, blue: c.blue, alpha: 1).setFill()
955 NSRect(x: CGFloat(i) * 8, y: 0, width: 8, height: rect.height).fill()
956 }
957 NSColor.separatorColor.setStroke()
958 NSBezierPath(rect: rect.insetBy(dx: 0.5, dy: 0.5)).stroke()
959 return true
960 }
961 }
962
963 private func copy() {
964 let file = UserConfig.directory.appendingPathComponent("my-theme.toml")
965 guard !FileManager.default.fileExists(atPath: file.path) else {
966 message = String(localized: "my-theme.toml is already in the config folder; it was left as it is.")
967 return
968 }
969 let light = ThemeSpec.palette(themeLight, .light) ?? ThemeSpec.palettes(.light)[0]
970 let dark = ThemeSpec.palette(themeDark, .dark) ?? ThemeSpec.palettes(.dark)[0]
971 do {
972 try ThemeSpec.themeFile(light: light, dark: dark).write(to: file, atomically: true, encoding: .utf8)
973 themeFile = "my-theme.toml"
974 message = String(localized: "Copied to my-theme.toml, now the theme file.")
975 } catch {
976 message = error.localizedDescription
977 }
978 }
979}
980```
981
982If `settingsFooter()` is `private` in `OrgstarApp.swift`, make it `internal` (drop `private`) so this file can use it.
983
984- [ ] **Step 6: Insert the section**
985
986In `OrgstarApp.swift`, in `private var appearance: some View`, make the first line inside `Form {`:
987
988```swift
989 ThemePickerSection()
990```
991
992- [ ] **Step 7: Check by hand**
993
994Run: `scripts/check-file-sizes.sh && scripts/build-app.sh`, open Settings ▸ Appearance.
995Expected: Light and Dark menus list the palettes with swatches; choosing one recolors the open editor at once and writes `light-theme`/`dark-theme` into `config.toml`; Copy to Config Folder writes `my-theme.toml` once and on the second press shows the "already in the config folder" message without changing the file.
996
997- [ ] **Step 8: Commit**
998
999```bash
1000git add Sources/Orgstar Sources/OrgPresentation/Palettes.swift Tests/OrgPresentationTests/PaletteTests.swift
1001git commit -m "Theme pickers in Settings ▸ Appearance; Copy to Config Folder"
1002```
1003
1004---
1005
1006### Task 7: iOS theme picker
1007
1008**Files:**
1009- Create: `Sources/OrgstarMobile/ThemePickerScreen.swift`
1010- Modify: `Sources/OrgstarMobile/SettingsScreen.swift` (new section before `calendarSection`; "In use ▸ Theme")
1011
1012**Interfaces:**
1013- Consumes: `ThemeSpec.palettes`, `palette`; `MobileModel.set(_:to:)`, `model.settingsVersion`.
1014- Produces: `struct ThemePickerScreen: View { init(model: MobileModel, appearance: Palette.Appearance) }`; `ThemePickerScreen.current(_:) -> Palette`.
1015
1016- [ ] **Step 1: Write `ThemePickerScreen.swift`**
1017
1018```swift
1019#if os(iOS)
1020import OrgCore
1021import OrgPresentation
1022import SwiftUI
1023
1024/// The built-in palettes of one appearance, each as a few lines of Org in its colors.
1025struct ThemePickerScreen: View {
1026 let model: MobileModel
1027 let appearance: Palette.Appearance
1028
1029 var body: some View {
1030 let _ = model.settingsVersion
1031 let current = Self.current(appearance).id
1032 List(ThemeSpec.palettes(appearance), id: \.id) { palette in
1033 Button {
1034 model.set(appearance == .light ? "themeLight" : "themeDark", to: .string(palette.id))
1035 } label: {
1036 HStack {
1037 VStack(alignment: .leading, spacing: 6) {
1038 Text(palette.name).foregroundStyle(.primary)
1039 Self.sample(palette)
1040 }
1041 Spacer()
1042 if palette.id == current { Image(systemName: "checkmark").foregroundStyle(.tint) }
1043 }
1044 }
1045 }
1046 .navigationTitle(appearance == .light ? "Light Theme" : "Dark Theme")
1047 }
1048
1049 /// The palette `light-theme` or `dark-theme` names, Default when unknown.
1050 static func current(_ appearance: Palette.Appearance) -> Palette {
1051 let id = UserDefaults.standard.string(forKey: appearance == .light ? "themeLight" : "themeDark") ?? ""
1052 return ThemeSpec.palette(id, appearance) ?? ThemeSpec.palettes(appearance)[0]
1053 }
1054
1055 private static func sample(_ palette: Palette) -> some View {
1056 func color(_ key: String) -> Color {
1057 guard let c = palette.colors[key] else { return .primary }
1058 return Color(.sRGB, red: c.red, green: c.green, blue: c.blue, opacity: c.alpha)
1059 }
1060 let font = Font.system(.footnote, design: .monospaced)
1061 return VStack(alignment: .leading, spacing: 2) {
1062 (Text("* ").foregroundColor(color("heading-1")) + Text("TODO ").foregroundColor(color("todo")).bold()
1063 + Text("Plan the trip ").foregroundColor(color("heading-1")).bold() + Text(":travel:").foregroundColor(color("tags")))
1064 (Text(" SCHEDULED: ").foregroundColor(color("metadata")) + Text("<2026-10-20 Tue>").foregroundColor(color("timestamp")))
1065 (Text(" Book via ").foregroundColor(color("foreground")) + Text("the site").foregroundColor(color("link")).underline()
1066 + Text(", ").foregroundColor(color("foreground")) + Text("~code~").foregroundColor(color("code")))
1067 (Text("** ").foregroundColor(color("heading-2")) + Text("DONE ").foregroundColor(color("done")).bold()
1068 + Text("Passport").foregroundColor(color("heading-2")).bold())
1069 }
1070 .font(font)
1071 .padding(8)
1072 .frame(maxWidth: .infinity, alignment: .leading)
1073 .background(color("background"), in: RoundedRectangle(cornerRadius: 8))
1074 }
1075}
1076#endif
1077```
1078
1079- [ ] **Step 2: Add the section to `SettingsScreen`**
1080
1081Before `calendarSection` in `body`:
1082
1083```swift
1084 Section("Appearance") {
1085 let _ = model.settingsVersion
1086 NavigationLink {
1087 ThemePickerScreen(model: model, appearance: .light)
1088 } label: {
1089 LabeledContent("Light Theme", value: ThemePickerScreen.current(.light).name)
1090 }
1091 NavigationLink {
1092 ThemePickerScreen(model: model, appearance: .dark)
1093 } label: {
1094 LabeledContent("Dark Theme", value: ThemePickerScreen.current(.dark).name)
1095 }
1096 }
1097```
1098
1099Replace the "In use" Theme row with:
1100
1101```swift
1102 LabeledContent("Theme", value: themeInUse)
1103```
1104
1105and add to `SettingsScreen`:
1106
1107```swift
1108 /// The two palettes' names, and the theme file's when there is one.
1109 private var themeInUse: String {
1110 let names = "\(ThemePickerScreen.current(.light).name) / \(ThemePickerScreen.current(.dark).name)"
1111 guard let file = UserDefaults.standard.string(forKey: "themeFile"), !file.isEmpty else { return names }
1112 return "\(names), \(file)"
1113 }
1114```
1115
1116- [ ] **Step 3: Build and check**
1117
1118Run: `xcodebuild -scheme OrgstarMobile -destination 'generic/platform=iOS Simulator' -derivedDataPath .build/ios build -quiet && scripts/build-ios-app.sh && xcrun simctl install booted .build/ios-app/orgstar.app`
1119Open Settings ▸ Light Theme, pick Paper, go back to an open file.
1120Expected: the file shows Paper's colors; with a config folder set, its `config.toml` has `light-theme = "paper"`; without one, the choice still applies.
1121
1122- [ ] **Step 4: Commit**
1123
1124```bash
1125git add Sources/OrgstarMobile
1126git commit -m "Theme pickers in the iOS Settings tab"
1127```
1128
1129---
1130
1131### Task 8: The other twelve icons, as iOS alternates
1132
1133Before this task: ask about the pre-existing uncommitted change to `project.pbxproj` (Global constraints).
1134
1135**Files:**
1136- Modify: `scripts/make-icon.swift` (`variants`, `drawUnicorn`)
1137- Modify: `ios/Orgstar.xcodeproj/project.pbxproj` (the `Orgstar` app target's Debug and Release build settings, beside `ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;` at lines 792 and 816; confirm those two belong to the `Orgstar` target, not the Watch)
1138- Generated: `ios/Orgstar/Assets.xcassets/AppIcon-*.appiconset`, `IconPreview-*.imageset`, `packaging/IconPreviews/*`
1139
1140**Interfaces:**
1141- Consumes: `Variant`, `draw` (Task 1).
1142- Produces: icon ids `default midnight paper org sunset forest mono rainbow outline terminal unicorn unicorn-night unicorn-pastel`; iOS alternate names `AppIcon-<Id>` with the id in CamelCase (`AppIcon-UnicornNight`).
1143
1144- [ ] **Step 1: Add the variants**
1145
1146Append to `variants`:
1147
1148```swift
1149 Variant(id: "midnight", top: rgb(0x1a1d24), bottom: rgb(0x0b0c10), glyph: rgb(0xffc74d), bars: NSColor(white: 1, alpha: 0.85)),
1150 Variant(id: "paper", top: rgb(0xfbf8f1), bottom: rgb(0xece4d2), glyph: rgb(0x3b3428), bars: rgb(0x7d7262)),
1151 Variant(id: "org", top: rgb(0x77aa99), bottom: rgb(0x3e7a6a), glyph: rgb(0xffc74d), bars: NSColor(white: 1, alpha: 0.92)),
1152 Variant(id: "sunset", top: rgb(0xff9a3c), bottom: rgb(0xe23e7a), glyph: .white, bars: NSColor(white: 1, alpha: 0.85)),
1153 Variant(id: "forest", top: rgb(0x2f5d3a), bottom: rgb(0x173322), glyph: rgb(0xf4ecd0), bars: NSColor(white: 1, alpha: 0.8)),
1154 Variant(id: "mono", top: rgb(0x5a5d63), bottom: rgb(0x2c2e33), glyph: .white, bars: NSColor(white: 1, alpha: 0.8)),
1155 Variant(id: "rainbow", top: rgb(0xe40303), bottom: rgb(0x732982), glyph: .white, bars: NSColor(white: 1, alpha: 0.9)),
1156 Variant(id: "outline", top: .white, bottom: rgb(0xf2f2f2), glyph: rgb(0x2f5486), bars: rgb(0x2f5486), style: .outline),
1157 Variant(id: "terminal", top: rgb(0x0a0f0a), bottom: .black, glyph: rgb(0x39ff6a), bars: rgb(0x2bcc55)),
1158 Variant(id: "unicorn", top: rgb(0x77aa99), bottom: rgb(0x3e7a6a), glyph: rgb(0xffc74d), bars: .white, style: .unicorn),
1159 Variant(id: "unicorn-night", top: rgb(0x2b2a6b), bottom: rgb(0x14133a), glyph: rgb(0xd8dde6), bars: rgb(0xeae8ff), style: .unicorn),
1160 Variant(id: "unicorn-pastel", top: rgb(0xffc6dd), bottom: rgb(0xc7b8ff), glyph: rgb(0xffc74d), bars: .white, style: .unicorn),
1161```
1162
1163For `rainbow`, the two-color gradient is a placeholder for the stripes; in `draw`, `case .light:`, draw stripes when `v.id == "rainbow"`:
1164
1165```swift
1166 case .light where v.id == "rainbow":
1167 NSGraphicsContext.saveGraphicsState()
1168 shape.addClip()
1169 let stripes = [0xe40303, 0xff8c00, 0xffed00, 0x008026, 0x004dff, 0x750787].map(rgb)
1170 let band = square.height / CGFloat(stripes.count)
1171 for (i, color) in stripes.enumerated() {
1172 color.setFill()
1173 NSRect(x: square.minX, y: square.maxY - band * CGFloat(i + 1), width: square.width, height: band).fill()
1174 }
1175 NSGraphicsContext.restoreGraphicsState()
1176```
1177
1178Put this case before the plain `case .light:`.
1179
1180- [ ] **Step 2: Draw the unicorn**
1181
1182Replace `drawUnicorn` with a head in profile facing left, its horn rising to the upper left, the ✱ at the horn's tip. Coordinates are on the 1024 grid, origin bottom-left:
1183
1184```swift
1185/// A unicorn's head in profile, facing left, with a mane; its horn ends in the heading star.
1186func drawUnicorn(_ s: CGFloat, glyph: NSColor, head: NSColor) {
1187 func p(_ x: CGFloat, _ y: CGFloat) -> NSPoint { NSPoint(x: x * s, y: y * s) }
1188 let face = NSBezierPath()
1189 face.move(to: p(640, 200)) // neck, back
1190 face.curve(to: p(600, 560), controlPoint1: p(700, 330), controlPoint2: p(690, 480))
1191 face.curve(to: p(470, 640), controlPoint1: p(560, 610), controlPoint2: p(520, 640)) // crown
1192 face.line(to: p(440, 690)) // ear
1193 face.line(to: p(410, 620))
1194 face.curve(to: p(250, 470), controlPoint1: p(340, 590), controlPoint2: p(270, 530)) // brow to nose
1195 face.curve(to: p(290, 400), controlPoint1: p(235, 430), controlPoint2: p(250, 400)) // muzzle
1196 face.curve(to: p(430, 430), controlPoint1: p(340, 400), controlPoint2: p(390, 410)) // jaw
1197 face.curve(to: p(450, 200), controlPoint1: p(470, 360), controlPoint2: p(440, 280)) // throat
1198 face.close()
1199 head.setFill()
1200 face.fill()
1201
1202 let mane = NSBezierPath()
1203 mane.move(to: p(600, 560))
1204 mane.curve(to: p(760, 220), controlPoint1: p(720, 520), controlPoint2: p(800, 360))
1205 mane.line(to: p(690, 210))
1206 mane.curve(to: p(600, 520), controlPoint1: p(730, 330), controlPoint2: p(680, 470))
1207 mane.close()
1208 glyph.withAlphaComponent(0.85).setFill()
1209 mane.fill()
1210
1211 let horn = NSBezierPath()
1212 horn.move(to: p(440, 640))
1213 horn.line(to: p(300, 790))
1214 horn.line(to: p(475, 660))
1215 horn.close()
1216 head.blended(withFraction: 0.25, of: glyph)?.setFill()
1217 horn.fill()
1218
1219 let eye = NSBezierPath(ovalIn: NSRect(x: 360 * s, y: 520 * s, width: 28 * s, height: 28 * s))
1220 NSColor(white: 0.15, alpha: 1).setFill()
1221 eye.fill()
1222
1223 let star = NSAttributedString(string: "✱", attributes: [.font: NSFont.systemFont(ofSize: 190 * s, weight: .heavy), .foregroundColor: glyph])
1224 star.draw(at: p(205, 700))
1225}
1226```
1227
1228- [ ] **Step 3: Generate and look at every icon**
1229
1230Run: `swift scripts/make-icon.swift && open packaging/IconPreviews`
1231Expected: 26 previews. Check each at Finder's largest icon size and at 64 pixels: the star reads in every one; the unicorn reads as a unicorn's head with the star at the horn's tip. Adjust the unicorn's control points in Step 2 until it does, keeping the shape inside the 100–924 square with margin.
1232
1233- [ ] **Step 4: Make every `AppIcon-*` set an alternate**
1234
1235In `project.pbxproj`, in the `Orgstar` target's Debug and Release `buildSettings`, add beside `ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;`:
1236
1237```
1238 ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
1239```
1240
1241- [ ] **Step 5: Build and check the alternates compile in**
1242
1243Run: `xcodebuild -project ios/Orgstar.xcodeproj -scheme Orgstar -destination 'generic/platform=iOS Simulator' -derivedDataPath .build/ios-xc build -quiet && /usr/libexec/PlistBuddy -c 'Print :CFBundleIcons~ipad:CFBundleAlternateIcons' .build/ios-xc/Build/Products/Debug-iphonesimulator/Orgstar.app/Info.plist`
1244Expected: 12 entries, `AppIcon-Midnight` through `AppIcon-UnicornPastel`. If the product's path or name differs, find it with `find .build/ios-xc -name Info.plist -path '*Orgstar.app/*' -maxdepth 6`.
1245
1246- [ ] **Step 6: Commit**
1247
1248```bash
1249git add scripts/make-icon.swift ios/Orgstar/Assets.xcassets packaging/IconPreviews ios/Orgstar.xcodeproj/project.pbxproj
1250git commit -m "Twelve more app icons, three of them unicorns; iOS alternate icons"
1251```
1252
1253Stage only this task's hunks of `project.pbxproj` (`git add -p`) if the earlier uncommitted change is still in the file.
1254
1255---
1256
1257### Task 9: iOS icon picker
1258
1259**Files:**
1260- Create: `Sources/OrgPresentation/AppIcons.swift`
1261- Create: `Sources/OrgstarMobile/AppIconScreen.swift`
1262- Modify: `Sources/OrgstarMobile/SettingsScreen.swift` ("Appearance" section)
1263- Test: `Tests/OrgPresentationTests/PaletteTests.swift`
1264
1265**Interfaces:**
1266- Produces: `public enum AppIcons { public static let ids: [String]; public static func name(_ id: String) -> String; public static func alternateName(_ id: String) -> String?; public static func id(alternateName: String?) -> String }`
1267
1268- [ ] **Step 1: Write the failing test**
1269
1270```swift
1271 @Test func iconIdsMapToAlternateNames() {
1272 #expect(AppIcons.ids.first == "default" && AppIcons.ids.count == 13)
1273 #expect(AppIcons.alternateName("default") == nil)
1274 #expect(AppIcons.alternateName("unicorn-night") == "AppIcon-UnicornNight")
1275 #expect(AppIcons.id(alternateName: "AppIcon-UnicornNight") == "unicorn-night")
1276 #expect(AppIcons.id(alternateName: nil) == "default" && AppIcons.id(alternateName: "AppIcon-Gone") == "default")
1277 #expect(AppIcons.name("unicorn-pastel") == "Unicorn Pastel")
1278 }
1279```
1280
1281- [ ] **Step 2: Run it to see it fail**
1282
1283Run: `swift test --filter PaletteTests/iconIdsMapToAlternateNames`
1284Expected: compile error, `AppIcons` not found.
1285
1286- [ ] **Step 3: Write `AppIcons.swift`**
1287
1288```swift
1289/// The app icons `scripts/make-icon.swift` draws, by id, in its order.
1290public enum AppIcons {
1291 public static let ids = [
1292 "default", "midnight", "paper", "org", "sunset", "forest", "mono", "rainbow", "outline", "terminal",
1293 "unicorn", "unicorn-night", "unicorn-pastel",
1294 ]
1295
1296 private static func words(_ id: String) -> [String] { id.split(separator: "-").map { $0.prefix(1).uppercased() + $0.dropFirst() } }
1297
1298 public static func name(_ id: String) -> String { words(id).joined(separator: " ") }
1299
1300 /// The iOS alternate icon's name; nil for the primary icon.
1301 public static func alternateName(_ id: String) -> String? {
1302 id == "default" ? nil : "AppIcon-" + words(id).joined()
1303 }
1304
1305 public static func id(alternateName: String?) -> String {
1306 ids.first { self.alternateName($0) == alternateName && alternateName != nil } ?? "default"
1307 }
1308}
1309```
1310
1311- [ ] **Step 4: Run the test**
1312
1313Run: `swift test --filter PaletteTests`
1314Expected: PASS.
1315
1316- [ ] **Step 5: Write `AppIconScreen.swift`**
1317
1318```swift
1319#if os(iOS)
1320import OrgPresentation
1321import SwiftUI
1322import UIKit
1323
1324/// The app icons, as previews; tapping one makes it the home screen's icon.
1325struct AppIconScreen: View {
1326 @State private var current = AppIcons.id(alternateName: UIApplication.shared.alternateIconName)
1327 @State private var failure: String?
1328
1329 var body: some View {
1330 ScrollView {
1331 LazyVGrid(columns: [GridItem(.adaptive(minimum: 88), spacing: 16)], spacing: 20) {
1332 ForEach(AppIcons.ids, id: \.self) { id in
1333 Button { choose(id) } label: {
1334 VStack(spacing: 6) {
1335 Image("IconPreview-\(id)")
1336 .resizable()
1337 .frame(width: 72, height: 72)
1338 .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
1339 .overlay(RoundedRectangle(cornerRadius: 16, style: .continuous)
1340 .strokeBorder(id == current ? Color.accentColor : .clear, lineWidth: 3).padding(-4))
1341 Text(AppIcons.name(id)).font(.caption).foregroundStyle(.primary)
1342 }
1343 }
1344 .buttonStyle(.plain)
1345 .accessibilityAddTraits(id == current ? .isSelected : [])
1346 }
1347 }
1348 .padding()
1349 if let failure { Text(failure).foregroundStyle(.red).padding(.horizontal) }
1350 }
1351 .navigationTitle("App Icon")
1352 }
1353
1354 private func choose(_ id: String) {
1355 guard id != current, UIApplication.shared.supportsAlternateIcons else { return }
1356 Task {
1357 do {
1358 try await UIApplication.shared.setAlternateIconName(AppIcons.alternateName(id))
1359 current = id
1360 failure = nil
1361 } catch {
1362 failure = error.localizedDescription
1363 }
1364 }
1365 }
1366}
1367#endif
1368```
1369
1370`Image("IconPreview-<id>")` reads from the app's asset catalog, which the Xcode project builds; the SwiftPM simulator build (`build-ios-app.sh`) has no catalog, so the previews are blank there. Check this screen through the Xcode project.
1371
1372- [ ] **Step 6: Add the row**
1373
1374In `SettingsScreen`'s "Appearance" section, after the Dark Theme link:
1375
1376```swift
1377 NavigationLink {
1378 AppIconScreen()
1379 } label: {
1380 LabeledContent("App Icon", value: AppIcons.name(AppIcons.id(alternateName: UIApplication.shared.alternateIconName)))
1381 }
1382```
1383
1384- [ ] **Step 7: Check on iOS 26**
1385
1386Run the `Orgstar` scheme from Xcode on a device or simulator; Settings ▸ App Icon ▸ Unicorn.
1387Expected: the system alert names the change, the home screen shows the unicorn, and the grid marks Unicorn after reopening the screen. In Customize ▸ Dark and Tinted, the unicorn's dark and tinted versions show.
1388
1389- [ ] **Step 8: Commit**
1390
1391```bash
1392git add Sources/OrgPresentation/AppIcons.swift Sources/OrgstarMobile Tests/OrgPresentationTests/PaletteTests.swift
1393git commit -m "App icon picker in the iOS Settings tab"
1394```
1395
1396---
1397
1398### Task 10: Mac icon picker and Dock icon
1399
1400**Files:**
1401- Create: `Sources/Orgstar/DockIcon.swift`
1402- Create: `Sources/Orgstar/AppIconSection.swift`
1403- Modify: `Sources/Orgstar/OrgstarApp.swift` (`AppDelegate.applicationDidFinishLaunching`, `appearance` form)
1404- Test: `Tests/OrgAppTests/DockIconTests.swift` (only if `DockIcon`'s pure part lives in `OrgApp`; see Step 1)
1405
1406**Interfaces:**
1407- Consumes: `AppIcons` (Task 9); `Contents/Resources/IconPreviews/<id>-light.png` / `-dark.png` (Task 1).
1408- Produces: `@MainActor enum DockIcon { static func previewName(_ id: String, dark: Bool) -> String?; static func apply(); static func start() }`, defaults key `appIcon`.
1409
1410- [ ] **Step 1: Write the failing test**
1411
1412`Orgstar` is an executable target that tests can't import, so the choice of file goes in `OrgPresentation` beside `AppIcons`, and is tested there. Add to `AppIcons.swift`:
1413
1414```swift
1415extension AppIcons {
1416 /// The Mac's Dock icon file for `id` in an appearance, in `Contents/Resources/IconPreviews`;
1417 /// nil for the default, which is the bundle's own icon.
1418 public static func dockFile(_ id: String, dark: Bool) -> String? {
1419 guard id != "default", ids.contains(id) else { return nil }
1420 return "\(id)-\(dark ? "dark" : "light")"
1421 }
1422}
1423```
1424
1425and first the test in `PaletteTests`:
1426
1427```swift
1428 @Test func dockFilesFollowTheAppearance() {
1429 #expect(AppIcons.dockFile("default", dark: true) == nil)
1430 #expect(AppIcons.dockFile("gone", dark: false) == nil)
1431 #expect(AppIcons.dockFile("unicorn", dark: false) == "unicorn-light")
1432 #expect(AppIcons.dockFile("unicorn", dark: true) == "unicorn-dark")
1433 }
1434```
1435
1436- [ ] **Step 2: Run it to see it fail, then add the extension and see it pass**
1437
1438Run: `swift test --filter PaletteTests/dockFilesFollowTheAppearance` (fails: no `dockFile`), add the extension, run again.
1439Expected: PASS.
1440
1441- [ ] **Step 3: Write `DockIcon.swift`**
1442
1443```swift
1444import AppKit
1445import OrgPresentation
1446
1447/// The icon chosen in Settings ▸ Appearance, shown in the Dock while orgstar runs, in the
1448/// variant for the current appearance.
1449@MainActor
1450enum DockIcon {
1451 private static var observation: NSKeyValueObservation?
1452
1453 static func apply() {
1454 let id = UserDefaults.standard.string(forKey: "appIcon") ?? "default"
1455 let dark = NSApp.effectiveAppearance.bestMatch(from: [.aqua, .darkAqua]) == .darkAqua
1456 guard let file = AppIcons.dockFile(id, dark: dark),
1457 let url = Bundle.main.url(forResource: file, withExtension: "png", subdirectory: "IconPreviews") else {
1458 NSApp.applicationIconImage = nil
1459 return
1460 }
1461 NSApp.applicationIconImage = NSImage(contentsOf: url)
1462 }
1463
1464 /// Applies now, and again whenever the appearance changes.
1465 static func start() {
1466 apply()
1467 observation = NSApp.observe(\.effectiveAppearance) { _, _ in
1468 Task { @MainActor in apply() }
1469 }
1470 }
1471}
1472```
1473
1474- [ ] **Step 4: Start it at launch**
1475
1476In `AppDelegate.applicationDidFinishLaunching`, add as its first line:
1477
1478```swift
1479 DockIcon.start()
1480```
1481
1482- [ ] **Step 5: Write `AppIconSection.swift`**
1483
1484```swift
1485import AppKit
1486import OrgPresentation
1487import SwiftUI
1488
1489/// Settings ▸ Appearance ▸ App Icon: the icon the Dock shows while orgstar runs.
1490struct AppIconSection: View {
1491 @AppStorage("appIcon") private var appIcon = "default"
1492
1493 var body: some View {
1494 Section {
1495 LazyVGrid(columns: [GridItem(.adaptive(minimum: 72), spacing: 12)], spacing: 12) {
1496 ForEach(AppIcons.ids, id: \.self) { id in
1497 Button {
1498 appIcon = id
1499 DockIcon.apply()
1500 } label: {
1501 VStack(spacing: 4) {
1502 preview(id)
1503 .resizable()
1504 .frame(width: 56, height: 56)
1505 .padding(4)
1506 .background(id == appIcon ? Color.accentColor.opacity(0.25) : .clear, in: RoundedRectangle(cornerRadius: 10))
1507 Text(AppIcons.name(id)).font(.caption)
1508 }
1509 }
1510 .buttonStyle(.plain)
1511 .accessibilityAddTraits(id == appIcon ? .isSelected : [])
1512 }
1513 }
1514 } header: {
1515 Text("App Icon")
1516 } footer: {
1517 Text("The icon shows in the Dock while orgstar runs. Finder, and the Dock after orgstar quits, show the default icon.")
1518 .settingsFooter()
1519 }
1520 }
1521
1522 private func preview(_ id: String) -> Image {
1523 let url = Bundle.main.url(forResource: "\(id)-light", withExtension: "png", subdirectory: "IconPreviews")
1524 return url.flatMap { NSImage(contentsOf: $0) }.map { Image(nsImage: $0) } ?? Image(nsImage: NSApp.applicationIconImage)
1525 }
1526}
1527```
1528
1529- [ ] **Step 6: Insert the section**
1530
1531In `OrgstarApp.swift`'s `appearance` form, after `ThemePickerSection()`:
1532
1533```swift
1534 AppIconSection()
1535```
1536
1537The Appearance tab's `.frame(height: 380)` is now too short; change it to `.frame(height: 620)` and check it scrolls rather than clips.
1538
1539- [ ] **Step 7: Check by hand**
1540
1541Run: `scripts/check-file-sizes.sh && scripts/build-app.sh`, open the app, Settings ▸ Appearance ▸ App Icon ▸ Unicorn Night.
1542Expected: the Dock icon changes at once; switching the system appearance swaps the light and dark previews while running; Default restores the bundle's icon (its dark and tinted styles included); after quitting and reopening, the chosen icon comes back once the app has launched.
1543
1544- [ ] **Step 8: Commit**
1545
1546```bash
1547git add Sources/Orgstar Sources/OrgPresentation/AppIcons.swift Tests/OrgPresentationTests/PaletteTests.swift
1548git commit -m "App icon picker in Settings ▸ Appearance; Dock icon follows the appearance"
1549```
1550
1551---
1552
1553### Task 11: Manual and strings
1554
1555**Files:**
1556- Modify: `docs/manual/guide/02-the-editor.org:33,341`
1557- Modify: `docs/manual/guide/13-configuration.org` (the theme section)
1558- Modify: `docs/manual/guide/14-ios.org:83,398`
1559- Modify: `l10n/Localizable.xcstrings`
1560
1561- [ ] **Step 1: Manual**
1562
1563`02-the-editor.org:341`, replace the paragraph with:
1564
1565```org
1566Settings ▸ Appearance ▸ Theme chooses a built-in theme for the light appearance and one for the dark: Default, Solarized Light, Gruvbox Light, Modus Operandi, Catppuccin Latte, Tomorrow or Paper; and Default, Solarized Dark, Gruvbox Dark, Modus Vivendi, Catppuccin Mocha, Nord, Dracula, Tokyo Night or doom-one. They are =light-theme= and =dark-theme= under =[theme]= in =config.toml=. Colours set in =config.toml=, under =[theme]= for both appearances, =[theme.light]= and =[theme.dark]= for one and =[theme.todo]= for TODO keywords, apply on top, as do those of a theme file named by =theme-file=. Copy to Config Folder writes the two chosen themes, every colour, into =my-theme.toml= and makes it the theme file, to start a theme of your own. Show Default Theme opens =default-theme.toml=, which lists every colour with its default value. Changes apply while orgstar runs. See [[file:13-configuration.org][Configuration]].
1567
1568Settings ▸ Appearance ▸ App Icon chooses the icon the Dock shows while orgstar runs. Finder, and the Dock once orgstar has quit, show the default icon; it follows the system's icon style (Default, Dark or Tinted).
1569```
1570
1571`13-configuration.org`: in the section on themes, add `light-theme`, `dark-theme` and `accent` with the stacking order "the chosen palettes, then the theme file, then =config.toml=". Read the section first and match its table or list form.
1572
1573`14-ios.org:83`, replace "stacked as on the Mac: the default theme, then the theme file" with "stacked as on the Mac: the themes chosen with =light-theme= and =dark-theme=, then the theme file". After that paragraph add:
1574
1575```org
1576Settings ▸ Light Theme and Dark Theme choose the built-in themes, shown as a few lines of Org in each theme's colours; the choice is written to the configuration folder's =config.toml=, so the Mac uses it too. Settings ▸ App Icon chooses the home screen icon from the same thirteen as the Mac; iOS confirms the change. The icon is chosen per device.
1577```
1578
1579`14-ios.org:398`: replace "the theme (=Default=, or the theme file's name)" with "the light and dark themes, and the theme file's name when there is one".
1580
1581- [ ] **Step 2: Strings**
1582
1583Run: `scripts/sync-strings.sh`
1584Then add German translations in `l10n/Localizable.xcstrings` for each new key (as commit 880a7cf did for the October 13 strings): Theme → Design, Light → Hell, Dark → Dunkel, Light Theme → Helles Design, Dark Theme → Dunkles Design, App Icon → App-Symbol, Starting point → Ausgangspunkt, Copy to Config Folder → In den Konfigurationsordner kopieren, and the footers and messages in full sentences. Palette and icon names stay untranslated.
1585
1586- [ ] **Step 3: Check**
1587
1588Run: `swift test && scripts/check-file-sizes.sh && scripts/build-app.sh`
1589Open Settings with the system language set to German and check the new rows.
1590Expected: all green; German labels show.
1591
1592- [ ] **Step 4: Commit**
1593
1594```bash
1595git add docs/manual l10n
1596git commit -m "Manual and German strings for themes and app icons"
1597```
1598
1599---
1600
1601### Finish
1602
1603- [ ] Run `swift test`, `scripts/check-file-sizes.sh`, `scripts/build-app.sh` and the iOS Xcode build once more.
1604- [ ] Push the branch and open the merge request: `git push -u origin themes-and-icons && gitbay mr create --source themes-and-icons --target main --title "Built-in themes and alternate app icons"`.
ios/Orgstar.xcodeproj/project.pbxproj +2
@@ -765,6 +765,7 @@
765 isa = XCBuildConfiguration; 765 isa = XCBuildConfiguration;
766 buildSettings = { 766 buildSettings = {
767 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 767 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
768 ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
768 CODE_SIGN_ENTITLEMENTS = Orgstar/Orgstar.entitlements; 769 CODE_SIGN_ENTITLEMENTS = Orgstar/Orgstar.entitlements;
769 CODE_SIGN_STYLE = Automatic; 770 CODE_SIGN_STYLE = Automatic;
770 CURRENT_PROJECT_VERSION = 9; 771 CURRENT_PROJECT_VERSION = 9;
@@ -850,6 +851,7 @@
850 isa = XCBuildConfiguration; 851 isa = XCBuildConfiguration;
851 buildSettings = { 852 buildSettings = {
852 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 853 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
854 ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
853 CODE_SIGN_ENTITLEMENTS = Orgstar/Orgstar.entitlements; 855 CODE_SIGN_ENTITLEMENTS = Orgstar/Orgstar.entitlements;
854 CODE_SIGN_STYLE = Automatic; 856 CODE_SIGN_STYLE = Automatic;
855 CURRENT_PROJECT_VERSION = 9; 857 CURRENT_PROJECT_VERSION = 9;
ios/Orgstar/Assets.xcassets/AppIcon-Forest.appiconset/AppIcon-dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Forest.appiconset/AppIcon-tinted.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Forest.appiconset/AppIcon.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Forest.appiconset/Contents.json added +38
@@ -0,0 +1,38 @@
1{
2 "images" : [
3 {
4 "filename" : "AppIcon.png",
5 "idiom" : "universal",
6 "platform" : "ios",
7 "size" : "1024x1024"
8 },
9 {
10 "appearances" : [
11 {
12 "appearance" : "luminosity",
13 "value" : "dark"
14 }
15 ],
16 "filename" : "AppIcon-dark.png",
17 "idiom" : "universal",
18 "platform" : "ios",
19 "size" : "1024x1024"
20 },
21 {
22 "appearances" : [
23 {
24 "appearance" : "luminosity",
25 "value" : "tinted"
26 }
27 ],
28 "filename" : "AppIcon-tinted.png",
29 "idiom" : "universal",
30 "platform" : "ios",
31 "size" : "1024x1024"
32 }
33 ],
34 "info" : {
35 "author" : "xcode",
36 "version" : 1
37 }
38}\ No newline at end of file
ios/Orgstar/Assets.xcassets/AppIcon-Midnight.appiconset/AppIcon-dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Midnight.appiconset/AppIcon-tinted.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Midnight.appiconset/AppIcon.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Midnight.appiconset/Contents.json added +38
@@ -0,0 +1,38 @@
1{
2 "images" : [
3 {
4 "filename" : "AppIcon.png",
5 "idiom" : "universal",
6 "platform" : "ios",
7 "size" : "1024x1024"
8 },
9 {
10 "appearances" : [
11 {
12 "appearance" : "luminosity",
13 "value" : "dark"
14 }
15 ],
16 "filename" : "AppIcon-dark.png",
17 "idiom" : "universal",
18 "platform" : "ios",
19 "size" : "1024x1024"
20 },
21 {
22 "appearances" : [
23 {
24 "appearance" : "luminosity",
25 "value" : "tinted"
26 }
27 ],
28 "filename" : "AppIcon-tinted.png",
29 "idiom" : "universal",
30 "platform" : "ios",
31 "size" : "1024x1024"
32 }
33 ],
34 "info" : {
35 "author" : "xcode",
36 "version" : 1
37 }
38}\ No newline at end of file
ios/Orgstar/Assets.xcassets/AppIcon-Mono.appiconset/AppIcon-dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Mono.appiconset/AppIcon-tinted.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Mono.appiconset/AppIcon.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Mono.appiconset/Contents.json added +38
@@ -0,0 +1,38 @@
1{
2 "images" : [
3 {
4 "filename" : "AppIcon.png",
5 "idiom" : "universal",
6 "platform" : "ios",
7 "size" : "1024x1024"
8 },
9 {
10 "appearances" : [
11 {
12 "appearance" : "luminosity",
13 "value" : "dark"
14 }
15 ],
16 "filename" : "AppIcon-dark.png",
17 "idiom" : "universal",
18 "platform" : "ios",
19 "size" : "1024x1024"
20 },
21 {
22 "appearances" : [
23 {
24 "appearance" : "luminosity",
25 "value" : "tinted"
26 }
27 ],
28 "filename" : "AppIcon-tinted.png",
29 "idiom" : "universal",
30 "platform" : "ios",
31 "size" : "1024x1024"
32 }
33 ],
34 "info" : {
35 "author" : "xcode",
36 "version" : 1
37 }
38}\ No newline at end of file
ios/Orgstar/Assets.xcassets/AppIcon-Org.appiconset/AppIcon-dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Org.appiconset/AppIcon-tinted.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Org.appiconset/AppIcon.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Org.appiconset/Contents.json added +38
@@ -0,0 +1,38 @@
1{
2 "images" : [
3 {
4 "filename" : "AppIcon.png",
5 "idiom" : "universal",
6 "platform" : "ios",
7 "size" : "1024x1024"
8 },
9 {
10 "appearances" : [
11 {
12 "appearance" : "luminosity",
13 "value" : "dark"
14 }
15 ],
16 "filename" : "AppIcon-dark.png",
17 "idiom" : "universal",
18 "platform" : "ios",
19 "size" : "1024x1024"
20 },
21 {
22 "appearances" : [
23 {
24 "appearance" : "luminosity",
25 "value" : "tinted"
26 }
27 ],
28 "filename" : "AppIcon-tinted.png",
29 "idiom" : "universal",
30 "platform" : "ios",
31 "size" : "1024x1024"
32 }
33 ],
34 "info" : {
35 "author" : "xcode",
36 "version" : 1
37 }
38}\ No newline at end of file
ios/Orgstar/Assets.xcassets/AppIcon-Outline.appiconset/AppIcon-dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Outline.appiconset/AppIcon-tinted.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Outline.appiconset/AppIcon.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Outline.appiconset/Contents.json added +38
@@ -0,0 +1,38 @@
1{
2 "images" : [
3 {
4 "filename" : "AppIcon.png",
5 "idiom" : "universal",
6 "platform" : "ios",
7 "size" : "1024x1024"
8 },
9 {
10 "appearances" : [
11 {
12 "appearance" : "luminosity",
13 "value" : "dark"
14 }
15 ],
16 "filename" : "AppIcon-dark.png",
17 "idiom" : "universal",
18 "platform" : "ios",
19 "size" : "1024x1024"
20 },
21 {
22 "appearances" : [
23 {
24 "appearance" : "luminosity",
25 "value" : "tinted"
26 }
27 ],
28 "filename" : "AppIcon-tinted.png",
29 "idiom" : "universal",
30 "platform" : "ios",
31 "size" : "1024x1024"
32 }
33 ],
34 "info" : {
35 "author" : "xcode",
36 "version" : 1
37 }
38}\ No newline at end of file
ios/Orgstar/Assets.xcassets/AppIcon-Paper.appiconset/AppIcon-dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Paper.appiconset/AppIcon-tinted.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Paper.appiconset/AppIcon.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Paper.appiconset/Contents.json added +38
@@ -0,0 +1,38 @@
1{
2 "images" : [
3 {
4 "filename" : "AppIcon.png",
5 "idiom" : "universal",
6 "platform" : "ios",
7 "size" : "1024x1024"
8 },
9 {
10 "appearances" : [
11 {
12 "appearance" : "luminosity",
13 "value" : "dark"
14 }
15 ],
16 "filename" : "AppIcon-dark.png",
17 "idiom" : "universal",
18 "platform" : "ios",
19 "size" : "1024x1024"
20 },
21 {
22 "appearances" : [
23 {
24 "appearance" : "luminosity",
25 "value" : "tinted"
26 }
27 ],
28 "filename" : "AppIcon-tinted.png",
29 "idiom" : "universal",
30 "platform" : "ios",
31 "size" : "1024x1024"
32 }
33 ],
34 "info" : {
35 "author" : "xcode",
36 "version" : 1
37 }
38}\ No newline at end of file
ios/Orgstar/Assets.xcassets/AppIcon-Rainbow.appiconset/AppIcon-dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Rainbow.appiconset/AppIcon-tinted.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Rainbow.appiconset/AppIcon.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Rainbow.appiconset/Contents.json added +38
@@ -0,0 +1,38 @@
1{
2 "images" : [
3 {
4 "filename" : "AppIcon.png",
5 "idiom" : "universal",
6 "platform" : "ios",
7 "size" : "1024x1024"
8 },
9 {
10 "appearances" : [
11 {
12 "appearance" : "luminosity",
13 "value" : "dark"
14 }
15 ],
16 "filename" : "AppIcon-dark.png",
17 "idiom" : "universal",
18 "platform" : "ios",
19 "size" : "1024x1024"
20 },
21 {
22 "appearances" : [
23 {
24 "appearance" : "luminosity",
25 "value" : "tinted"
26 }
27 ],
28 "filename" : "AppIcon-tinted.png",
29 "idiom" : "universal",
30 "platform" : "ios",
31 "size" : "1024x1024"
32 }
33 ],
34 "info" : {
35 "author" : "xcode",
36 "version" : 1
37 }
38}\ No newline at end of file
ios/Orgstar/Assets.xcassets/AppIcon-Sunset.appiconset/AppIcon-dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Sunset.appiconset/AppIcon-tinted.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Sunset.appiconset/AppIcon.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Sunset.appiconset/Contents.json added +38
@@ -0,0 +1,38 @@
1{
2 "images" : [
3 {
4 "filename" : "AppIcon.png",
5 "idiom" : "universal",
6 "platform" : "ios",
7 "size" : "1024x1024"
8 },
9 {
10 "appearances" : [
11 {
12 "appearance" : "luminosity",
13 "value" : "dark"
14 }
15 ],
16 "filename" : "AppIcon-dark.png",
17 "idiom" : "universal",
18 "platform" : "ios",
19 "size" : "1024x1024"
20 },
21 {
22 "appearances" : [
23 {
24 "appearance" : "luminosity",
25 "value" : "tinted"
26 }
27 ],
28 "filename" : "AppIcon-tinted.png",
29 "idiom" : "universal",
30 "platform" : "ios",
31 "size" : "1024x1024"
32 }
33 ],
34 "info" : {
35 "author" : "xcode",
36 "version" : 1
37 }
38}\ No newline at end of file
ios/Orgstar/Assets.xcassets/AppIcon-Terminal.appiconset/AppIcon-dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Terminal.appiconset/AppIcon-tinted.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Terminal.appiconset/AppIcon.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Terminal.appiconset/Contents.json added +38
@@ -0,0 +1,38 @@
1{
2 "images" : [
3 {
4 "filename" : "AppIcon.png",
5 "idiom" : "universal",
6 "platform" : "ios",
7 "size" : "1024x1024"
8 },
9 {
10 "appearances" : [
11 {
12 "appearance" : "luminosity",
13 "value" : "dark"
14 }
15 ],
16 "filename" : "AppIcon-dark.png",
17 "idiom" : "universal",
18 "platform" : "ios",
19 "size" : "1024x1024"
20 },
21 {
22 "appearances" : [
23 {
24 "appearance" : "luminosity",
25 "value" : "tinted"
26 }
27 ],
28 "filename" : "AppIcon-tinted.png",
29 "idiom" : "universal",
30 "platform" : "ios",
31 "size" : "1024x1024"
32 }
33 ],
34 "info" : {
35 "author" : "xcode",
36 "version" : 1
37 }
38}\ No newline at end of file
ios/Orgstar/Assets.xcassets/AppIcon-Unicorn.appiconset/AppIcon-dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Unicorn.appiconset/AppIcon-tinted.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Unicorn.appiconset/AppIcon.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-Unicorn.appiconset/Contents.json added +38
@@ -0,0 +1,38 @@
1{
2 "images" : [
3 {
4 "filename" : "AppIcon.png",
5 "idiom" : "universal",
6 "platform" : "ios",
7 "size" : "1024x1024"
8 },
9 {
10 "appearances" : [
11 {
12 "appearance" : "luminosity",
13 "value" : "dark"
14 }
15 ],
16 "filename" : "AppIcon-dark.png",
17 "idiom" : "universal",
18 "platform" : "ios",
19 "size" : "1024x1024"
20 },
21 {
22 "appearances" : [
23 {
24 "appearance" : "luminosity",
25 "value" : "tinted"
26 }
27 ],
28 "filename" : "AppIcon-tinted.png",
29 "idiom" : "universal",
30 "platform" : "ios",
31 "size" : "1024x1024"
32 }
33 ],
34 "info" : {
35 "author" : "xcode",
36 "version" : 1
37 }
38}\ No newline at end of file
ios/Orgstar/Assets.xcassets/AppIcon-UnicornNight.appiconset/AppIcon-dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-UnicornNight.appiconset/AppIcon-tinted.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-UnicornNight.appiconset/AppIcon.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-UnicornNight.appiconset/Contents.json added +38
@@ -0,0 +1,38 @@
1{
2 "images" : [
3 {
4 "filename" : "AppIcon.png",
5 "idiom" : "universal",
6 "platform" : "ios",
7 "size" : "1024x1024"
8 },
9 {
10 "appearances" : [
11 {
12 "appearance" : "luminosity",
13 "value" : "dark"
14 }
15 ],
16 "filename" : "AppIcon-dark.png",
17 "idiom" : "universal",
18 "platform" : "ios",
19 "size" : "1024x1024"
20 },
21 {
22 "appearances" : [
23 {
24 "appearance" : "luminosity",
25 "value" : "tinted"
26 }
27 ],
28 "filename" : "AppIcon-tinted.png",
29 "idiom" : "universal",
30 "platform" : "ios",
31 "size" : "1024x1024"
32 }
33 ],
34 "info" : {
35 "author" : "xcode",
36 "version" : 1
37 }
38}\ No newline at end of file
ios/Orgstar/Assets.xcassets/AppIcon-UnicornPastel.appiconset/AppIcon-dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-UnicornPastel.appiconset/AppIcon-tinted.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-UnicornPastel.appiconset/AppIcon.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon-UnicornPastel.appiconset/Contents.json added +38
@@ -0,0 +1,38 @@
1{
2 "images" : [
3 {
4 "filename" : "AppIcon.png",
5 "idiom" : "universal",
6 "platform" : "ios",
7 "size" : "1024x1024"
8 },
9 {
10 "appearances" : [
11 {
12 "appearance" : "luminosity",
13 "value" : "dark"
14 }
15 ],
16 "filename" : "AppIcon-dark.png",
17 "idiom" : "universal",
18 "platform" : "ios",
19 "size" : "1024x1024"
20 },
21 {
22 "appearances" : [
23 {
24 "appearance" : "luminosity",
25 "value" : "tinted"
26 }
27 ],
28 "filename" : "AppIcon-tinted.png",
29 "idiom" : "universal",
30 "platform" : "ios",
31 "size" : "1024x1024"
32 }
33 ],
34 "info" : {
35 "author" : "xcode",
36 "version" : 1
37 }
38}\ No newline at end of file
ios/Orgstar/Assets.xcassets/AppIcon.appiconset/AppIcon-dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon.appiconset/AppIcon-tinted.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/AppIcon.appiconset/Contents.json +25 −1
@@ -5,10 +5,34 @@
5 "idiom" : "universal", 5 "idiom" : "universal",
6 "platform" : "ios", 6 "platform" : "ios",
7 "size" : "1024x1024" 7 "size" : "1024x1024"
8 },
9 {
10 "appearances" : [
11 {
12 "appearance" : "luminosity",
13 "value" : "dark"
14 }
15 ],
16 "filename" : "AppIcon-dark.png",
17 "idiom" : "universal",
18 "platform" : "ios",
19 "size" : "1024x1024"
20 },
21 {
22 "appearances" : [
23 {
24 "appearance" : "luminosity",
25 "value" : "tinted"
26 }
27 ],
28 "filename" : "AppIcon-tinted.png",
29 "idiom" : "universal",
30 "platform" : "ios",
31 "size" : "1024x1024"
8 } 32 }
9 ], 33 ],
10 "info" : { 34 "info" : {
11 "author" : "xcode", 35 "author" : "xcode",
12 "version" : 1 36 "version" : 1
13 } 37 }
14} 38}\ No newline at end of file
ios/Orgstar/Assets.xcassets/IconPreview-default.imageset/Contents.json added +22
@@ -0,0 +1,22 @@
1{
2 "images" : [
3 {
4 "filename" : "light.png",
5 "idiom" : "universal"
6 },
7 {
8 "appearances" : [
9 {
10 "appearance" : "luminosity",
11 "value" : "dark"
12 }
13 ],
14 "filename" : "dark.png",
15 "idiom" : "universal"
16 }
17 ],
18 "info" : {
19 "author" : "xcode",
20 "version" : 1
21 }
22}\ No newline at end of file
ios/Orgstar/Assets.xcassets/IconPreview-default.imageset/dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-default.imageset/light.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-forest.imageset/Contents.json added +22
@@ -0,0 +1,22 @@
1{
2 "images" : [
3 {
4 "filename" : "light.png",
5 "idiom" : "universal"
6 },
7 {
8 "appearances" : [
9 {
10 "appearance" : "luminosity",
11 "value" : "dark"
12 }
13 ],
14 "filename" : "dark.png",
15 "idiom" : "universal"
16 }
17 ],
18 "info" : {
19 "author" : "xcode",
20 "version" : 1
21 }
22}\ No newline at end of file
ios/Orgstar/Assets.xcassets/IconPreview-forest.imageset/dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-forest.imageset/light.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-midnight.imageset/Contents.json added +22
@@ -0,0 +1,22 @@
1{
2 "images" : [
3 {
4 "filename" : "light.png",
5 "idiom" : "universal"
6 },
7 {
8 "appearances" : [
9 {
10 "appearance" : "luminosity",
11 "value" : "dark"
12 }
13 ],
14 "filename" : "dark.png",
15 "idiom" : "universal"
16 }
17 ],
18 "info" : {
19 "author" : "xcode",
20 "version" : 1
21 }
22}\ No newline at end of file
ios/Orgstar/Assets.xcassets/IconPreview-midnight.imageset/dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-midnight.imageset/light.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-mono.imageset/Contents.json added +22
@@ -0,0 +1,22 @@
1{
2 "images" : [
3 {
4 "filename" : "light.png",
5 "idiom" : "universal"
6 },
7 {
8 "appearances" : [
9 {
10 "appearance" : "luminosity",
11 "value" : "dark"
12 }
13 ],
14 "filename" : "dark.png",
15 "idiom" : "universal"
16 }
17 ],
18 "info" : {
19 "author" : "xcode",
20 "version" : 1
21 }
22}\ No newline at end of file
ios/Orgstar/Assets.xcassets/IconPreview-mono.imageset/dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-mono.imageset/light.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-org.imageset/Contents.json added +22
@@ -0,0 +1,22 @@
1{
2 "images" : [
3 {
4 "filename" : "light.png",
5 "idiom" : "universal"
6 },
7 {
8 "appearances" : [
9 {
10 "appearance" : "luminosity",
11 "value" : "dark"
12 }
13 ],
14 "filename" : "dark.png",
15 "idiom" : "universal"
16 }
17 ],
18 "info" : {
19 "author" : "xcode",
20 "version" : 1
21 }
22}\ No newline at end of file
ios/Orgstar/Assets.xcassets/IconPreview-org.imageset/dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-org.imageset/light.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-outline.imageset/Contents.json added +22
@@ -0,0 +1,22 @@
1{
2 "images" : [
3 {
4 "filename" : "light.png",
5 "idiom" : "universal"
6 },
7 {
8 "appearances" : [
9 {
10 "appearance" : "luminosity",
11 "value" : "dark"
12 }
13 ],
14 "filename" : "dark.png",
15 "idiom" : "universal"
16 }
17 ],
18 "info" : {
19 "author" : "xcode",
20 "version" : 1
21 }
22}\ No newline at end of file
ios/Orgstar/Assets.xcassets/IconPreview-outline.imageset/dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-outline.imageset/light.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-paper.imageset/Contents.json added +22
@@ -0,0 +1,22 @@
1{
2 "images" : [
3 {
4 "filename" : "light.png",
5 "idiom" : "universal"
6 },
7 {
8 "appearances" : [
9 {
10 "appearance" : "luminosity",
11 "value" : "dark"
12 }
13 ],
14 "filename" : "dark.png",
15 "idiom" : "universal"
16 }
17 ],
18 "info" : {
19 "author" : "xcode",
20 "version" : 1
21 }
22}\ No newline at end of file
ios/Orgstar/Assets.xcassets/IconPreview-paper.imageset/dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-paper.imageset/light.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-rainbow.imageset/Contents.json added +22
@@ -0,0 +1,22 @@
1{
2 "images" : [
3 {
4 "filename" : "light.png",
5 "idiom" : "universal"
6 },
7 {
8 "appearances" : [
9 {
10 "appearance" : "luminosity",
11 "value" : "dark"
12 }
13 ],
14 "filename" : "dark.png",
15 "idiom" : "universal"
16 }
17 ],
18 "info" : {
19 "author" : "xcode",
20 "version" : 1
21 }
22}\ No newline at end of file
ios/Orgstar/Assets.xcassets/IconPreview-rainbow.imageset/dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-rainbow.imageset/light.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-sunset.imageset/Contents.json added +22
@@ -0,0 +1,22 @@
1{
2 "images" : [
3 {
4 "filename" : "light.png",
5 "idiom" : "universal"
6 },
7 {
8 "appearances" : [
9 {
10 "appearance" : "luminosity",
11 "value" : "dark"
12 }
13 ],
14 "filename" : "dark.png",
15 "idiom" : "universal"
16 }
17 ],
18 "info" : {
19 "author" : "xcode",
20 "version" : 1
21 }
22}\ No newline at end of file
ios/Orgstar/Assets.xcassets/IconPreview-sunset.imageset/dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-sunset.imageset/light.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-terminal.imageset/Contents.json added +22
@@ -0,0 +1,22 @@
1{
2 "images" : [
3 {
4 "filename" : "light.png",
5 "idiom" : "universal"
6 },
7 {
8 "appearances" : [
9 {
10 "appearance" : "luminosity",
11 "value" : "dark"
12 }
13 ],
14 "filename" : "dark.png",
15 "idiom" : "universal"
16 }
17 ],
18 "info" : {
19 "author" : "xcode",
20 "version" : 1
21 }
22}\ No newline at end of file
ios/Orgstar/Assets.xcassets/IconPreview-terminal.imageset/dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-terminal.imageset/light.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-unicorn-night.imageset/Contents.json added +22
@@ -0,0 +1,22 @@
1{
2 "images" : [
3 {
4 "filename" : "light.png",
5 "idiom" : "universal"
6 },
7 {
8 "appearances" : [
9 {
10 "appearance" : "luminosity",
11 "value" : "dark"
12 }
13 ],
14 "filename" : "dark.png",
15 "idiom" : "universal"
16 }
17 ],
18 "info" : {
19 "author" : "xcode",
20 "version" : 1
21 }
22}\ No newline at end of file
ios/Orgstar/Assets.xcassets/IconPreview-unicorn-night.imageset/dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-unicorn-night.imageset/light.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-unicorn-pastel.imageset/Contents.json added +22
@@ -0,0 +1,22 @@
1{
2 "images" : [
3 {
4 "filename" : "light.png",
5 "idiom" : "universal"
6 },
7 {
8 "appearances" : [
9 {
10 "appearance" : "luminosity",
11 "value" : "dark"
12 }
13 ],
14 "filename" : "dark.png",
15 "idiom" : "universal"
16 }
17 ],
18 "info" : {
19 "author" : "xcode",
20 "version" : 1
21 }
22}\ No newline at end of file
ios/Orgstar/Assets.xcassets/IconPreview-unicorn-pastel.imageset/dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-unicorn-pastel.imageset/light.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-unicorn.imageset/Contents.json added +22
@@ -0,0 +1,22 @@
1{
2 "images" : [
3 {
4 "filename" : "light.png",
5 "idiom" : "universal"
6 },
7 {
8 "appearances" : [
9 {
10 "appearance" : "luminosity",
11 "value" : "dark"
12 }
13 ],
14 "filename" : "dark.png",
15 "idiom" : "universal"
16 }
17 ],
18 "info" : {
19 "author" : "xcode",
20 "version" : 1
21 }
22}\ No newline at end of file
ios/Orgstar/Assets.xcassets/IconPreview-unicorn.imageset/dark.png added

Binary file not shown.

ios/Orgstar/Assets.xcassets/IconPreview-unicorn.imageset/light.png added

Binary file not shown.

l10n/Localizable.xcstrings +220
@@ -512,6 +512,16 @@
512 } 512 }
513 } 513 }
514 }, 514 },
515 "App Icon": {
516 "localizations": {
517 "de": {
518 "stringUnit": {
519 "state": "translated",
520 "value": "App-Symbol"
521 }
522 }
523 }
524 },
515 "Appearance": { 525 "Appearance": {
516 "localizations": { 526 "localizations": {
517 "de": { 527 "de": {
@@ -1294,6 +1304,16 @@
1294 } 1304 }
1295 } 1305 }
1296 }, 1306 },
1307 "Colors set in config.toml or in the theme file apply on top of these.": {
1308 "localizations": {
1309 "de": {
1310 "stringUnit": {
1311 "state": "translated",
1312 "value": "Farben aus config.toml oder aus der Themendatei gelten zusätzlich zu diesen."
1313 }
1314 }
1315 }
1316 },
1297 "Column": { 1317 "Column": {
1298 "localizations": { 1318 "localizations": {
1299 "de": { 1319 "de": {
@@ -1404,6 +1424,26 @@
1404 } 1424 }
1405 } 1425 }
1406 }, 1426 },
1427 "Copied to my-theme.toml, now the theme file in place of %@.": {
1428 "localizations": {
1429 "de": {
1430 "stringUnit": {
1431 "state": "translated",
1432 "value": "In my-theme.toml kopiert, jetzt die Themendatei anstelle von %@."
1433 }
1434 }
1435 }
1436 },
1437 "Copied to my-theme.toml, now the theme file.": {
1438 "localizations": {
1439 "de": {
1440 "stringUnit": {
1441 "state": "translated",
1442 "value": "In my-theme.toml kopiert, jetzt die Themendatei."
1443 }
1444 }
1445 }
1446 },
1407 "Copy": { 1447 "Copy": {
1408 "localizations": { 1448 "localizations": {
1409 "de": { 1449 "de": {
@@ -1424,6 +1464,16 @@
1424 } 1464 }
1425 } 1465 }
1426 }, 1466 },
1467 "Copy to Config Folder": {
1468 "localizations": {
1469 "de": {
1470 "stringUnit": {
1471 "state": "translated",
1472 "value": "In den Konfigurationsordner kopieren"
1473 }
1474 }
1475 }
1476 },
1427 "Couldn't change the file": { 1477 "Couldn't change the file": {
1428 "localizations": { 1478 "localizations": {
1429 "de": { 1479 "de": {
@@ -1474,6 +1524,26 @@
1474 } 1524 }
1475 } 1525 }
1476 }, 1526 },
1527 "Dark": {
1528 "localizations": {
1529 "de": {
1530 "stringUnit": {
1531 "state": "translated",
1532 "value": "Dunkel"
1533 }
1534 }
1535 }
1536 },
1537 "Dark Theme": {
1538 "localizations": {
1539 "de": {
1540 "stringUnit": {
1541 "state": "translated",
1542 "value": "Dunkles Thema"
1543 }
1544 }
1545 }
1546 },
1477 "Date": { 1547 "Date": {
1478 "localizations": { 1548 "localizations": {
1479 "de": { 1549 "de": {
@@ -1594,6 +1664,16 @@
1594 } 1664 }
1595 } 1665 }
1596 }, 1666 },
1667 "Default": {
1668 "localizations": {
1669 "de": {
1670 "stringUnit": {
1671 "state": "translated",
1672 "value": "Standard"
1673 }
1674 }
1675 }
1676 },
1597 "Default TODO keywords": { 1677 "Default TODO keywords": {
1598 "localizations": { 1678 "localizations": {
1599 "de": { 1679 "de": {
@@ -2249,6 +2329,16 @@
2249 } 2329 }
2250 } 2330 }
2251 }, 2331 },
2332 "Forest": {
2333 "localizations": {
2334 "de": {
2335 "stringUnit": {
2336 "state": "translated",
2337 "value": "Wald"
2338 }
2339 }
2340 }
2341 },
2252 "Forget Encryption Passphrase": { 2342 "Forget Encryption Passphrase": {
2253 "localizations": { 2343 "localizations": {
2254 "de": { 2344 "de": {
@@ -2660,6 +2750,26 @@
2660 } 2750 }
2661 } 2751 }
2662 }, 2752 },
2753 "Light": {
2754 "localizations": {
2755 "de": {
2756 "stringUnit": {
2757 "state": "translated",
2758 "value": "Hell"
2759 }
2760 }
2761 }
2762 },
2763 "Light Theme": {
2764 "localizations": {
2765 "de": {
2766 "stringUnit": {
2767 "state": "translated",
2768 "value": "Helles Thema"
2769 }
2770 }
2771 }
2772 },
2663 "Limit dates": { 2773 "Limit dates": {
2664 "localizations": { 2774 "localizations": {
2665 "de": { 2775 "de": {
@@ -2906,6 +3016,16 @@
2906 } 3016 }
2907 } 3017 }
2908 }, 3018 },
3019 "Midnight": {
3020 "localizations": {
3021 "de": {
3022 "stringUnit": {
3023 "state": "translated",
3024 "value": "Mitternacht"
3025 }
3026 }
3027 }
3028 },
2909 "Modal editing as in Doom Emacs, with SPC as the leader: SPC m t cycles TODO.": { 3029 "Modal editing as in Doom Emacs, with SPC as the leader: SPC m t cycles TODO.": {
2910 "localizations": { 3030 "localizations": {
2911 "de": { 3031 "de": {
@@ -3729,6 +3849,16 @@
3729 } 3849 }
3730 } 3850 }
3731 }, 3851 },
3852 "Paper": {
3853 "localizations": {
3854 "de": {
3855 "stringUnit": {
3856 "state": "translated",
3857 "value": "Papier"
3858 }
3859 }
3860 }
3861 },
3732 "Passphrase": { 3862 "Passphrase": {
3733 "localizations": { 3863 "localizations": {
3734 "de": { 3864 "de": {
@@ -3919,6 +4049,16 @@
3919 } 4049 }
3920 } 4050 }
3921 }, 4051 },
4052 "Rainbow": {
4053 "localizations": {
4054 "de": {
4055 "stringUnit": {
4056 "state": "translated",
4057 "value": "Regenbogen"
4058 }
4059 }
4060 }
4061 },
3922 "Read-only: not UTF-8": { 4062 "Read-only: not UTF-8": {
3923 "localizations": { 4063 "localizations": {
3924 "de": { 4064 "de": {
@@ -4839,6 +4979,16 @@
4839 } 4979 }
4840 } 4980 }
4841 }, 4981 },
4982 "Starting point": {
4983 "localizations": {
4984 "de": {
4985 "stringUnit": {
4986 "state": "translated",
4987 "value": "Ausgangspunkt"
4988 }
4989 }
4990 }
4991 },
4842 "Starts": { 4992 "Starts": {
4843 "localizations": { 4993 "localizations": {
4844 "de": { 4994 "de": {
@@ -4919,6 +5069,16 @@
4919 } 5069 }
4920 } 5070 }
4921 }, 5071 },
5072 "Sunset": {
5073 "localizations": {
5074 "de": {
5075 "stringUnit": {
5076 "state": "translated",
5077 "value": "Sonnenuntergang"
5078 }
5079 }
5080 }
5081 },
4922 "Switch to Buffer…": { 5082 "Switch to Buffer…": {
4923 "localizations": { 5083 "localizations": {
4924 "de": { 5084 "de": {
@@ -5213,6 +5373,16 @@
5213 } 5373 }
5214 } 5374 }
5215 }, 5375 },
5376 "The icon shows in the Dock while orgstar runs. Finder, and the Dock after orgstar quits, show the default icon.": {
5377 "localizations": {
5378 "de": {
5379 "stringUnit": {
5380 "state": "translated",
5381 "value": "Das Symbol erscheint im Dock, solange orgstar läuft. Der Finder und das Dock nach dem Beenden zeigen das Standardsymbol."
5382 }
5383 }
5384 }
5385 },
5216 "The next agenda entry, or how many are open today.": { 5386 "The next agenda entry, or how many are open today.": {
5217 "localizations": { 5387 "localizations": {
5218 "de": { 5388 "de": {
@@ -5243,6 +5413,16 @@
5243 } 5413 }
5244 } 5414 }
5245 }, 5415 },
5416 "The theme file %@ sets colors over these, and config.toml's colors apply on top of both.": {
5417 "localizations": {
5418 "de": {
5419 "stringUnit": {
5420 "state": "translated",
5421 "value": "Die Themendatei %@ legt Farben über diese, und die Farben aus config.toml gelten zusätzlich zu beiden."
5422 }
5423 }
5424 }
5425 },
5246 "The whole file is removed. Files in iCloud Drive go to Recently Deleted in the Files app.": { 5426 "The whole file is removed. Files in iCloud Drive go to Recently Deleted in the Files app.": {
5247 "localizations": { 5427 "localizations": {
5248 "de": { 5428 "de": {
@@ -5393,6 +5573,36 @@
5393 } 5573 }
5394 } 5574 }
5395 }, 5575 },
5576 "Unicorn": {
5577 "localizations": {
5578 "de": {
5579 "stringUnit": {
5580 "state": "translated",
5581 "value": "Einhorn"
5582 }
5583 }
5584 }
5585 },
5586 "Unicorn Night": {
5587 "localizations": {
5588 "de": {
5589 "stringUnit": {
5590 "state": "translated",
5591 "value": "Einhorn Nacht"
5592 }
5593 }
5594 }
5595 },
5596 "Unicorn Pastel": {
5597 "localizations": {
5598 "de": {
5599 "stringUnit": {
5600 "state": "translated",
5601 "value": "Einhorn Pastell"
5602 }
5603 }
5604 }
5605 },
5396 "Unmark": { 5606 "Unmark": {
5397 "localizations": { 5607 "localizations": {
5398 "de": { 5608 "de": {
@@ -5670,6 +5880,16 @@
5670 } 5880 }
5671 } 5881 }
5672 }, 5882 },
5883 "my-theme.toml is already in the config folder; it was left as it is.": {
5884 "localizations": {
5885 "de": {
5886 "stringUnit": {
5887 "state": "translated",
5888 "value": "my-theme.toml liegt bereits im Konfigurationsordner und wurde nicht verändert."
5889 }
5890 }
5891 }
5892 },
5673 "open": { 5893 "open": {
5674 "localizations": { 5894 "localizations": {
5675 "de": { 5895 "de": {
packaging/AppIcons.xcassets/AppIcon.appiconset/Contents.json added +68
@@ -0,0 +1,68 @@
1{
2 "images" : [
3 {
4 "filename" : "icon_16x16.png",
5 "idiom" : "mac",
6 "scale" : "1x",
7 "size" : "16x16"
8 },
9 {
10 "filename" : "icon_16x16@2x.png",
11 "idiom" : "mac",
12 "scale" : "2x",
13 "size" : "16x16"
14 },
15 {
16 "filename" : "icon_32x32.png",
17 "idiom" : "mac",
18 "scale" : "1x",
19 "size" : "32x32"
20 },
21 {
22 "filename" : "icon_32x32@2x.png",
23 "idiom" : "mac",
24 "scale" : "2x",
25 "size" : "32x32"
26 },
27 {
28 "filename" : "icon_128x128.png",
29 "idiom" : "mac",
30 "scale" : "1x",
31 "size" : "128x128"
32 },
33 {
34 "filename" : "icon_128x128@2x.png",
35 "idiom" : "mac",
36 "scale" : "2x",
37 "size" : "128x128"
38 },
39 {
40 "filename" : "icon_256x256.png",
41 "idiom" : "mac",
42 "scale" : "1x",
43 "size" : "256x256"
44 },
45 {
46 "filename" : "icon_256x256@2x.png",
47 "idiom" : "mac",
48 "scale" : "2x",
49 "size" : "256x256"
50 },
51 {
52 "filename" : "icon_512x512.png",
53 "idiom" : "mac",
54 "scale" : "1x",
55 "size" : "512x512"
56 },
57 {
58 "filename" : "icon_512x512@2x.png",
59 "idiom" : "mac",
60 "scale" : "2x",
61 "size" : "512x512"
62 }
63 ],
64 "info" : {
65 "author" : "xcode",
66 "version" : 1
67 }
68}\ No newline at end of file
packaging/AppIcons.xcassets/AppIcon.appiconset/icon_128x128.png added

Binary file not shown.

packaging/AppIcons.xcassets/AppIcon.appiconset/icon_128x128@2x.png added

Binary file not shown.

packaging/AppIcons.xcassets/AppIcon.appiconset/icon_16x16.png added

Binary file not shown.

packaging/AppIcons.xcassets/AppIcon.appiconset/icon_16x16@2x.png added

Binary file not shown.

packaging/AppIcons.xcassets/AppIcon.appiconset/icon_256x256.png added

Binary file not shown.

packaging/AppIcons.xcassets/AppIcon.appiconset/icon_256x256@2x.png added

Binary file not shown.

packaging/AppIcons.xcassets/AppIcon.appiconset/icon_32x32.png added

Binary file not shown.

packaging/AppIcons.xcassets/AppIcon.appiconset/icon_32x32@2x.png added

Binary file not shown.

packaging/AppIcons.xcassets/AppIcon.appiconset/icon_512x512.png added

Binary file not shown.

packaging/AppIcons.xcassets/AppIcon.appiconset/icon_512x512@2x.png added

Binary file not shown.

packaging/AppIcons.xcassets/Contents.json added +6
@@ -0,0 +1,6 @@
1{
2 "info" : {
3 "author" : "xcode",
4 "version" : 1
5 }
6}\ No newline at end of file
packaging/IconPreviews/default-dark.png added

Binary file not shown.

packaging/IconPreviews/default-light.png added

Binary file not shown.

packaging/IconPreviews/forest-dark.png added

Binary file not shown.

packaging/IconPreviews/forest-light.png added

Binary file not shown.

packaging/IconPreviews/midnight-dark.png added

Binary file not shown.

packaging/IconPreviews/midnight-light.png added

Binary file not shown.

packaging/IconPreviews/mono-dark.png added

Binary file not shown.

packaging/IconPreviews/mono-light.png added

Binary file not shown.

packaging/IconPreviews/org-dark.png added

Binary file not shown.

packaging/IconPreviews/org-light.png added

Binary file not shown.

packaging/IconPreviews/outline-dark.png added

Binary file not shown.

packaging/IconPreviews/outline-light.png added

Binary file not shown.

packaging/IconPreviews/paper-dark.png added

Binary file not shown.

packaging/IconPreviews/paper-light.png added

Binary file not shown.

packaging/IconPreviews/rainbow-dark.png added

Binary file not shown.

packaging/IconPreviews/rainbow-light.png added

Binary file not shown.

packaging/IconPreviews/sunset-dark.png added

Binary file not shown.

packaging/IconPreviews/sunset-light.png added

Binary file not shown.

packaging/IconPreviews/terminal-dark.png added

Binary file not shown.

packaging/IconPreviews/terminal-light.png added

Binary file not shown.

packaging/IconPreviews/unicorn-dark.png added

Binary file not shown.

packaging/IconPreviews/unicorn-light.png added

Binary file not shown.

packaging/IconPreviews/unicorn-night-dark.png added

Binary file not shown.

packaging/IconPreviews/unicorn-night-light.png added

Binary file not shown.

packaging/IconPreviews/unicorn-pastel-dark.png added

Binary file not shown.

packaging/IconPreviews/unicorn-pastel-light.png added

Binary file not shown.

scripts/build-app.sh +8 −5
@@ -57,10 +57,13 @@ fi
57# The UI's translations, from l10n/Localizable.xcstrings. 57# The UI's translations, from l10n/Localizable.xcstrings.
58scripts/localize.sh "$app/Contents/Resources" 58scripts/localize.sh "$app/Contents/Resources"
59 59
60iconset="$(mktemp -d)/AppIcon.iconset" 60# The icon (macOS derives its dark and tinted styles), and the Dock icons Settings offers.
61swift scripts/make-icon.swift "$iconset" 61work="$(mktemp -d)"
62iconutil -c icns "$iconset" -o "$app/Contents/Resources/AppIcon.icns" 62xcrun actool packaging/AppIcons.xcassets --compile "$app/Contents/Resources" --platform macosx \
63rm -rf "$(dirname "$iconset")" 63 --minimum-deployment-target 26.0 --app-icon AppIcon --output-partial-info-plist "$work/icon.plist" > /dev/null
64rm -rf "$work"
65mkdir -p "$app/Contents/Resources/IconPreviews"
66cp packaging/IconPreviews/*.png "$app/Contents/Resources/IconPreviews/"
64 67
65cat > "$app/Contents/Info.plist" <<EOF 68cat > "$app/Contents/Info.plist" <<EOF
66<?xml version="1.0" encoding="UTF-8"?> 69<?xml version="1.0" encoding="UTF-8"?>
@@ -81,7 +84,7 @@ cat > "$app/Contents/Info.plist" <<EOF
81 <string>Orgstar</string> 84 <string>Orgstar</string>
82 <key>CFBundlePackageType</key> 85 <key>CFBundlePackageType</key>
83 <string>APPL</string> 86 <string>APPL</string>
84 <key>CFBundleIconFile</key> 87 <key>CFBundleIconName</key>
85 <string>AppIcon</string> 88 <string>AppIcon</string>
86 <key>UTImportedTypeDeclarations</key> 89 <key>UTImportedTypeDeclarations</key>
87 <array> 90 <array>
scripts/make-icon.swift +192 −31
@@ -1,11 +1,48 @@
1// Draws orgstar's app icon: an outline's heading star over three indented lines, on a deep 1// Draws orgstar's app icons from the variant table below into the committed asset catalogs:
2// blue-to-violet square. Usage: swift scripts/make-icon.swift <dir.iconset> for the Mac's 2// ios/Orgstar/Assets.xcassets (iOS app icons and their previews), packaging/AppIcons.xcassets
3// iconset, or swift scripts/make-icon.swift --ios <file.png> for the iOS app's 1024-pixel icon. 3// (the Mac's icon) and packaging/IconPreviews (the Mac's Dock icons).
4// Usage: swift scripts/make-icon.swift
4import AppKit 5import AppKit
5 6
6/// The Mac's icon sits on the macOS grid, a rounded square inset in a clear canvas; the iOS 7struct Variant {
7/// icon is the same square filling an opaque canvas, which iOS rounds itself. 8 enum Style { case filled, outline, unicorn }
8func draw(_ size: CGFloat, fullBleed: Bool = false) -> NSBitmapImageRep { 9 let id: String
10 /// The gradient, top-left to bottom-right.
11 let top: NSColor, bottom: NSColor
12 let glyph: NSColor
13 let bars: NSColor
14 var style: Style = .filled
15}
16
17func rgb(_ hex: UInt32) -> NSColor {
18 NSColor(srgbRed: CGFloat(hex >> 16 & 0xFF) / 255, green: CGFloat(hex >> 8 & 0xFF) / 255, blue: CGFloat(hex & 0xFF) / 255, alpha: 1)
19}
20
21let variants: [Variant] = [
22 Variant(id: "default", top: NSColor(srgbRed: 0.13, green: 0.20, blue: 0.55, alpha: 1), bottom: NSColor(srgbRed: 0.40, green: 0.22, blue: 0.70, alpha: 1),
23 glyph: NSColor(srgbRed: 1, green: 0.78, blue: 0.30, alpha: 1), bars: NSColor(white: 1, alpha: 0.92)),
24 Variant(id: "midnight", top: rgb(0x1a1d24), bottom: rgb(0x0b0c10), glyph: rgb(0xffc74d), bars: NSColor(white: 1, alpha: 0.85)),
25 Variant(id: "paper", top: rgb(0xfbf8f1), bottom: rgb(0xece4d2), glyph: rgb(0x3b3428), bars: rgb(0x7d7262)),
26 Variant(id: "org", top: rgb(0x77aa99), bottom: rgb(0x3e7a6a), glyph: rgb(0xffc74d), bars: NSColor(white: 1, alpha: 0.92)),
27 Variant(id: "sunset", top: rgb(0xff9a3c), bottom: rgb(0xe23e7a), glyph: .white, bars: NSColor(white: 1, alpha: 0.85)),
28 Variant(id: "forest", top: rgb(0x2f5d3a), bottom: rgb(0x173322), glyph: rgb(0xf4ecd0), bars: NSColor(white: 1, alpha: 0.8)),
29 Variant(id: "mono", top: rgb(0x5a5d63), bottom: rgb(0x2c2e33), glyph: .white, bars: NSColor(white: 1, alpha: 0.8)),
30 Variant(id: "rainbow", top: rgb(0xe40303), bottom: rgb(0x732982), glyph: .white, bars: NSColor(white: 1, alpha: 0.9)),
31 Variant(id: "outline", top: .white, bottom: rgb(0xf2f2f2), glyph: rgb(0x2f5486), bars: rgb(0x2f5486), style: .outline),
32 Variant(id: "terminal", top: rgb(0x0a0f0a), bottom: .black, glyph: rgb(0x39ff6a), bars: rgb(0x2bcc55)),
33 Variant(id: "unicorn", top: rgb(0x77aa99), bottom: rgb(0x3e7a6a), glyph: rgb(0xffc74d), bars: .white, style: .unicorn),
34 Variant(id: "unicorn-night", top: rgb(0x2b2a6b), bottom: rgb(0x14133a), glyph: rgb(0xd8dde6), bars: rgb(0xeae8ff), style: .unicorn),
35 Variant(id: "unicorn-pastel", top: rgb(0xffc6dd), bottom: rgb(0xc7b8ff), glyph: rgb(0xffc74d), bars: .white, style: .unicorn),
36]
37
38/// `darkTile`: the dark look on a near-black tile, for the Mac's Dock, which draws nothing
39/// behind an icon set with `NSApp.applicationIconImage`.
40enum Look { case light, dark, darkTile, tinted }
41
42/// The macOS icon grid: an 824-point rounded square in a 1024 canvas; `fullBleed` fills the
43/// canvas, as iOS wants. Dark and tinted leave the background clear (dark) or black (tinted)
44/// for the system to fill.
45func draw(_ v: Variant, _ size: CGFloat, look: Look = .light, fullBleed: Bool = false) -> NSBitmapImageRep {
9 let rep = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: Int(size), pixelsHigh: Int(size), bitsPerSample: 8, 46 let rep = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: Int(size), pixelsHigh: Int(size), bitsPerSample: 8,
10 samplesPerPixel: 4, hasAlpha: true, isPlanar: false, colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0)! 47 samplesPerPixel: 4, hasAlpha: true, isPlanar: false, colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0)!
11 NSGraphicsContext.saveGraphicsState() 48 NSGraphicsContext.saveGraphicsState()
@@ -17,44 +54,168 @@ func draw(_ size: CGFloat, fullBleed: Bool = false) -> NSBitmapImageRep {
17 transform.translateX(by: -100 * s, yBy: -100 * s) 54 transform.translateX(by: -100 * s, yBy: -100 * s)
18 transform.concat() 55 transform.concat()
19 } 56 }
20 // The macOS icon grid: an 824-point rounded square in a 1024 canvas.
21 let square = NSRect(x: 100 * s, y: 100 * s, width: 824 * s, height: 824 * s) 57 let square = NSRect(x: 100 * s, y: 100 * s, width: 824 * s, height: 824 * s)
22 let shape = fullBleed ? NSBezierPath(rect: square) : NSBezierPath(roundedRect: square, xRadius: 185 * s, yRadius: 185 * s) 58 let shape = fullBleed ? NSBezierPath(rect: square) : NSBezierPath(roundedRect: square, xRadius: 185 * s, yRadius: 185 * s)
23 NSGradient(colors: [NSColor(srgbRed: 0.13, green: 0.20, blue: 0.55, alpha: 1), NSColor(srgbRed: 0.40, green: 0.22, blue: 0.70, alpha: 1)])! 59 switch look {
24 .draw(in: shape, angle: -60) 60 case .light where v.id == "rainbow":
25 // The heading star. 61 NSGraphicsContext.saveGraphicsState()
62 shape.addClip()
63 let stripes = [0xe40303, 0xff8c00, 0xffed00, 0x008026, 0x004dff, 0x750787].map(rgb)
64 let band = square.height / CGFloat(stripes.count)
65 for (i, color) in stripes.enumerated() {
66 color.setFill()
67 NSRect(x: square.minX, y: square.maxY - band * CGFloat(i + 1), width: square.width, height: band).fill()
68 }
69 NSGraphicsContext.restoreGraphicsState()
70 case .light: NSGradient(colors: [v.top, v.bottom])!.draw(in: shape, angle: -60)
71 case .dark: break
72 case .darkTile: NSColor(srgbRed: 0.11, green: 0.11, blue: 0.12, alpha: 1).setFill(); shape.fill()
73 case .tinted: NSColor.black.setFill(); shape.fill()
74 }
75 // On a dark background a dark glyph (Paper, Outline) is drawn light.
76 func lifted(_ color: NSColor, _ light: CGFloat) -> NSColor {
77 guard look == .dark || look == .darkTile, let c = color.usingColorSpace(.sRGB),
78 0.2126 * c.redComponent + 0.7152 * c.greenComponent + 0.0722 * c.blueComponent < 0.4 else { return color }
79 return NSColor(white: light, alpha: 1)
80 }
81 let glyph = look == .tinted ? NSColor(white: 0.95, alpha: 1) : lifted(v.glyph, 0.95)
82 let bars = look == .tinted ? NSColor(white: 0.75, alpha: 1) : lifted(v.bars, 0.8)
83 switch v.style {
84 case .filled: drawOutline(s, glyph: glyph, bars: bars, filled: true)
85 case .outline: drawOutline(s, glyph: glyph, bars: bars, filled: false)
86 case .unicorn: drawUnicorn(s, glyph: glyph, head: bars)
87 }
88 NSGraphicsContext.restoreGraphicsState()
89 return rep
90}
91
92/// The heading star over three outline lines, indented like a heading's children.
93func drawOutline(_ s: CGFloat, glyph: NSColor, bars: NSColor, filled: Bool) {
26 let star = NSAttributedString(string: "✱", attributes: [ 94 let star = NSAttributedString(string: "✱", attributes: [
27 .font: NSFont.systemFont(ofSize: 330 * s, weight: .heavy), .foregroundColor: NSColor(srgbRed: 1, green: 0.78, blue: 0.30, alpha: 1), 95 .font: NSFont.systemFont(ofSize: 330 * s, weight: filled ? .heavy : .light), .foregroundColor: glyph,
28 ]) 96 ])
29 star.draw(at: NSPoint(x: 190 * s, y: 520 * s)) 97 star.draw(at: NSPoint(x: 190 * s, y: 520 * s))
30 // Three outline lines, indented like a heading's children.
31 NSColor(white: 1, alpha: 0.92).setFill()
32 for (i, (x, width)) in [(470.0, 330.0), (300.0, 500.0), (380.0, 420.0)].enumerated() { 98 for (i, (x, width)) in [(470.0, 330.0), (300.0, 500.0), (380.0, 420.0)].enumerated() {
33 let y = (650 - Double(i) * 150) * s 99 let y = (650 - Double(i) * 150) * s
34 let line = i == 0 ? NSRect(x: x * s, y: y, width: width * s, height: 70 * s) : NSRect(x: x * s, y: y, width: width * s, height: 56 * s) 100 let line = NSRect(x: x * s, y: y, width: width * s, height: (i == 0 ? 70 : 56) * s)
35 NSBezierPath(roundedRect: line, xRadius: 28 * s, yRadius: 28 * s).fill() 101 let path = NSBezierPath(roundedRect: line, xRadius: 28 * s, yRadius: 28 * s)
102 if filled {
103 bars.setFill(); path.fill()
104 } else {
105 bars.setStroke(); path.lineWidth = 10 * s; path.stroke()
106 }
36 } 107 }
37 NSGraphicsContext.restoreGraphicsState()
38 return rep
39} 108}
40 109
41if CommandLine.arguments[1] == "--ios" { 110/// A unicorn's head in profile, facing left, with a mane; its horn ends in the heading star.
42 // Without an alpha channel, as the App Store requires: drawn, then copied into an opaque image. 111func drawUnicorn(_ s: CGFloat, glyph: NSColor, head: NSColor) {
43 let drawn = draw(1024, fullBleed: true).cgImage! 112 func p(_ x: CGFloat, _ y: CGFloat) -> NSPoint { NSPoint(x: x * s, y: y * s) }
44 let opaque = CGContext(data: nil, width: 1024, height: 1024, bitsPerComponent: 8, bytesPerRow: 0, 113 let face = NSBezierPath()
45 space: CGColorSpace(name: CGColorSpace.sRGB)!, bitmapInfo: CGImageAlphaInfo.noneSkipLast.rawValue)! 114 face.move(to: p(640, 200)) // neck, back
46 opaque.draw(drawn, in: CGRect(x: 0, y: 0, width: 1024, height: 1024)) 115 face.curve(to: p(600, 560), controlPoint1: p(700, 330), controlPoint2: p(690, 480))
47 let file = URL(fileURLWithPath: CommandLine.arguments[2]) 116 face.curve(to: p(470, 640), controlPoint1: p(560, 610), controlPoint2: p(520, 640)) // crown
48 try NSBitmapImageRep(cgImage: opaque.makeImage()!).representation(using: .png, properties: [:])!.write(to: file) 117 face.line(to: p(440, 690)) // ear
49 exit(0) 118 face.line(to: p(410, 620))
119 face.curve(to: p(250, 470), controlPoint1: p(340, 590), controlPoint2: p(270, 530)) // brow to nose
120 face.curve(to: p(290, 400), controlPoint1: p(235, 430), controlPoint2: p(250, 400)) // muzzle
121 face.curve(to: p(430, 430), controlPoint1: p(340, 400), controlPoint2: p(390, 410)) // jaw
122 face.curve(to: p(450, 200), controlPoint1: p(470, 360), controlPoint2: p(440, 280)) // throat
123 face.close()
124 head.setFill()
125 face.fill()
126
127 let mane = NSBezierPath()
128 mane.move(to: p(600, 560))
129 mane.curve(to: p(760, 220), controlPoint1: p(720, 520), controlPoint2: p(800, 360))
130 mane.line(to: p(690, 210))
131 mane.curve(to: p(600, 520), controlPoint1: p(730, 330), controlPoint2: p(680, 470))
132 mane.close()
133 glyph.withAlphaComponent(0.85).setFill()
134 mane.fill()
135
136 let horn = NSBezierPath()
137 horn.move(to: p(440, 640))
138 horn.line(to: p(300, 790))
139 horn.line(to: p(475, 660))
140 horn.close()
141 head.blended(withFraction: 0.25, of: glyph)?.setFill()
142 horn.fill()
143
144 let eye = NSBezierPath(ovalIn: NSRect(x: 360 * s, y: 520 * s, width: 28 * s, height: 28 * s))
145 NSColor(white: 0.15, alpha: 1).setFill()
146 eye.fill()
147
148 let star = NSAttributedString(string: "✱", attributes: [.font: NSFont.systemFont(ofSize: 190 * s, weight: .heavy), .foregroundColor: glyph])
149 star.draw(at: p(205, 700))
150}
151
152func png(_ rep: NSBitmapImageRep) -> Data { rep.representation(using: .png, properties: [:])! }
153
154/// Without an alpha channel, as the App Store requires for the light icon.
155func opaque(_ rep: NSBitmapImageRep) -> NSBitmapImageRep {
156 let size = rep.pixelsWide
157 let context = CGContext(data: nil, width: size, height: size, bitsPerComponent: 8, bytesPerRow: 0,
158 space: CGColorSpace(name: CGColorSpace.sRGB)!, bitmapInfo: CGImageAlphaInfo.noneSkipLast.rawValue)!
159 context.draw(rep.cgImage!, in: CGRect(x: 0, y: 0, width: size, height: size))
160 return NSBitmapImageRep(cgImage: context.makeImage()!)
161}
162
163func write(_ data: Data, _ path: String) throws {
164 let url = URL(fileURLWithPath: path)
165 try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)
166 try data.write(to: url)
167}
168
169func json(_ object: Any, _ path: String) throws {
170 try write(JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted, .sortedKeys]), path)
171}
172
173let info = ["author": "xcode", "version": 1] as [String: Any]
174let appearances: [(Look, String, [[String: String]])] = [
175 (.light, "", []),
176 (.dark, "-dark", [["appearance": "luminosity", "value": "dark"]]),
177 (.tinted, "-tinted", [["appearance": "luminosity", "value": "tinted"]]),
178]
179
180for v in variants {
181 // iOS: one set per icon, named AppIcon for the default and AppIcon-<Id> for the others.
182 let setName = v.id == "default" ? "AppIcon" : "AppIcon-" + v.id.split(separator: "-").map(\.capitalized).joined()
183 let set = "ios/Orgstar/Assets.xcassets/\(setName).appiconset"
184 var images: [[String: Any]] = []
185 for (look, suffix, appearance) in appearances {
186 let rep = draw(v, 1024, look: look, fullBleed: true)
187 try write(png(look == .light ? opaque(rep) : rep), "\(set)/AppIcon\(suffix).png")
188 var image: [String: Any] = ["filename": "AppIcon\(suffix).png", "idiom": "universal", "platform": "ios", "size": "1024x1024"]
189 if !appearance.isEmpty { image["appearances"] = appearance }
190 images.append(image)
191 }
192 try json(["images": images, "info": info], "\(set)/Contents.json")
193
194 // Previews for the iOS picker, light and dark.
195 let preview = "ios/Orgstar/Assets.xcassets/IconPreview-\(v.id).imageset"
196 try write(png(draw(v, 256, fullBleed: true)), "\(preview)/light.png")
197 try write(png(draw(v, 256, look: .dark, fullBleed: true)), "\(preview)/dark.png")
198 try json(["images": [
199 ["filename": "light.png", "idiom": "universal"],
200 ["filename": "dark.png", "idiom": "universal", "appearances": [["appearance": "luminosity", "value": "dark"]]],
201 ], "info": info], "\(preview)/Contents.json")
202
203 // The Mac's Dock icons and picker previews.
204 try write(png(draw(v, 512)), "packaging/IconPreviews/\(v.id)-light.png")
205 try write(png(draw(v, 512, look: .darkTile)), "packaging/IconPreviews/\(v.id)-dark.png")
50} 206}
51 207
52let folder = URL(fileURLWithPath: CommandLine.arguments[1]) 208// The Mac's bundle icon: the default variant at the Mac's sizes. actool drops dark and
53try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true) 209// tinted renditions from a macOS app icon set, so macOS derives those styles itself.
210let mac = "packaging/AppIcons.xcassets/AppIcon.appiconset"
211try? FileManager.default.removeItem(atPath: mac)
212var macImages: [[String: Any]] = []
54for base in [16, 32, 128, 256, 512] { 213for base in [16, 32, 128, 256, 512] {
55 for scale in [1, 2] { 214 for scale in [1, 2] {
56 let name = scale == 1 ? "icon_\(base)x\(base).png" : "icon_\(base)x\(base)@2x.png" 215 let name = "icon_\(base)x\(base)\(scale == 2 ? "@2x" : "").png"
57 let data = draw(CGFloat(base * scale)).representation(using: .png, properties: [:])! 216 try write(png(draw(variants[0], CGFloat(base * scale))), "\(mac)/\(name)")
58 try data.write(to: folder.appendingPathComponent(name)) 217 macImages.append(["filename": name, "idiom": "mac", "scale": "\(scale)x", "size": "\(base)x\(base)"])
59 } 218 }
60} 219}
220try json(["images": macImages, "info": info], "\(mac)/Contents.json")
221try json(["info": info], "packaging/AppIcons.xcassets/Contents.json")