Commit 3788f2e7f7

3788f2e7f709eb8b05549ca5e793f43d740a5d88

parent: f97aeb320e

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-15 07:14 UTC

Theme and icon review minors: localized names, App Icon row, theme-file note, widget reload, one-appearance colors on iOS

Layout: unified · split

Sources/OrgPresentation/AppIcons.swift +18 −1
@@ -1,3 +1,5 @@
1import Foundation
2
1/// The app icons `scripts/make-icon.swift` draws, by id, in its order. 3/// The app icons `scripts/make-icon.swift` draws, by id, in its order.
2public enum AppIcons { 4public enum AppIcons {
3 public static let ids = [ 5 public static let ids = [
@@ -7,7 +9,22 @@ public enum AppIcons {
7 9
8 private static func words(_ id: String) -> [String] { id.split(separator: "-").map { $0.prefix(1).uppercased() + $0.dropFirst() } } 10 private static func words(_ id: String) -> [String] { id.split(separator: "-").map { $0.prefix(1).uppercased() + $0.dropFirst() } }
9 11
10 public static func name(_ id: String) -> String { words(id).joined(separator: " ") } 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 }
11 28
12 /// The iOS alternate icon's name; nil for the primary icon. 29 /// The iOS alternate icon's name; nil for the primary icon.
13 public static func alternateName(_ id: String) -> String? { 30 public static func alternateName(_ id: String) -> String? {
Sources/OrgPresentation/Palettes.swift +20
@@ -1,3 +1,5 @@
1import Foundation
2
1/// A built-in theme for one appearance, chosen with `light-theme` or `dark-theme`. 3/// A built-in theme for one appearance, chosen with `light-theme` or `dark-theme`.
2public struct Palette: Sendable, Equatable { 4public struct Palette: Sendable, Equatable {
3 public enum Appearance: String, Sendable { case light, dark } 5 public enum Appearance: String, Sendable { case light, dark }
@@ -7,6 +9,15 @@ public struct Palette: Sendable, Equatable {
7 public let appearance: Appearance 9 public let appearance: Appearance
8 public let colors: [String: RGBA] 10 public let colors: [String: RGBA]
9 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
10 public init(id: String, name: String, appearance: Appearance, colors: [String: RGBA]) { 21 public init(id: String, name: String, appearance: Appearance, colors: [String: RGBA]) {
11 self.id = id 22 self.id = id
12 self.name = name 23 self.name = name
@@ -29,6 +40,15 @@ extension ThemeSpec {
29 "default-" + appearance.rawValue 40 "default-" + appearance.rawValue
30 } 41 }
31 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
32 /// The default theme with each appearance's colors from the palette `light-theme` and 52 /// The default theme with each appearance's colors from the palette `light-theme` and
33 /// `dark-theme` name; Default where one is unset or unknown, with a problem for unknown. 53 /// `dark-theme` name; Default where one is unset or unknown, with a problem for unknown.
34 public static func base(light: String?, dark: String?) -> (ThemeSpec, [String]) { 54 public static func base(light: String?, dark: String?) -> (ThemeSpec, [String]) {
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/ThemePickerSection.swift +11 −3
@@ -20,15 +20,20 @@ struct ThemePickerSection: View {
20 } header: { 20 } header: {
21 Text("Theme") 21 Text("Theme")
22 } footer: { 22 } footer: {
23 Text(message ?? String(localized: "Colors set in config.toml or in the theme file apply on top of these.")) 23 Text(message ?? footer)
24 .settingsFooter() 24 .settingsFooter()
25 } 25 }
26 } 26 }
27 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
28 private func picker(_ title: LocalizedStringKey, _ appearance: Palette.Appearance, _ selection: Binding<String>) -> some View { 33 private func picker(_ title: LocalizedStringKey, _ appearance: Palette.Appearance, _ selection: Binding<String>) -> some View {
29 Picker(title, selection: selection) { 34 Picker(title, selection: selection) {
30 ForEach(ThemeSpec.palettes(appearance), id: \.id) { palette in 35 ForEach(ThemeSpec.palettes(appearance), id: \.id) { palette in
31 Label { Text(palette.name) } icon: { Image(nsImage: Self.swatch(palette)) }.tag(palette.id) 36 Label { Text(palette.displayName) } icon: { Image(nsImage: Self.swatch(palette)) }.tag(palette.id)
32 } 37 }
33 if ThemeSpec.palette(selection.wrappedValue, appearance) == nil { 38 if ThemeSpec.palette(selection.wrappedValue, appearance) == nil {
34 Text(selection.wrappedValue).tag(selection.wrappedValue) 39 Text(selection.wrappedValue).tag(selection.wrappedValue)
@@ -59,8 +64,11 @@ struct ThemePickerSection: View {
59 message = String(localized: "my-theme.toml is already in the config folder; it was left as it is.") 64 message = String(localized: "my-theme.toml is already in the config folder; it was left as it is.")
60 return 65 return
61 } 66 }
67 let previous = themeFile
62 themeFile = UserConfig.copiedThemeFile 68 themeFile = UserConfig.copiedThemeFile
63 message = String(localized: "Copied to my-theme.toml, now the theme file.") 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).")
64 } catch { 72 } catch {
65 message = error.localizedDescription 73 message = error.localizedDescription
66 } 74 }
Sources/OrgstarMobile/AppIconScreen.swift +2 −1
@@ -5,7 +5,8 @@ import UIKit
5 5
6/// The app icons, as previews; tapping one makes it the home screen's icon. 6/// The app icons, as previews; tapping one makes it the home screen's icon.
7struct AppIconScreen: View { 7struct AppIconScreen: View {
8 @State private var current = AppIcons.id(alternateName: UIApplication.shared.alternateIconName) 8 /// The icon in use, shared with the Settings row.
9 @Binding var current: String
9 @State private var failure: String? 10 @State private var failure: String?
10 11
11 var body: some View { 12 var body: some View {
Sources/OrgstarMobile/MobileTheme.swift +20 −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 {
Sources/OrgstarMobile/SettingsScreen.swift +7 −6
@@ -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
@@ -94,17 +95,17 @@ struct SettingsScreen: View {
94 NavigationLink { 95 NavigationLink {
95 ThemePickerScreen(model: model, appearance: .light) 96 ThemePickerScreen(model: model, appearance: .light)
96 } label: { 97 } label: {
97 LabeledContent("Light Theme", value: ThemePickerScreen.current(.light).name) 98 LabeledContent("Light Theme", value: ThemePickerScreen.current(.light).displayName)
98 } 99 }
99 NavigationLink { 100 NavigationLink {
100 ThemePickerScreen(model: model, appearance: .dark) 101 ThemePickerScreen(model: model, appearance: .dark)
101 } label: { 102 } label: {
102 LabeledContent("Dark Theme", value: ThemePickerScreen.current(.dark).name) 103 LabeledContent("Dark Theme", value: ThemePickerScreen.current(.dark).displayName)
103 } 104 }
104 NavigationLink { 105 NavigationLink {
105 AppIconScreen() 106 AppIconScreen(current: $appIcon)
106 } label: { 107 } label: {
107 LabeledContent("App Icon", value: AppIcons.name(AppIcons.id(alternateName: UIApplication.shared.alternateIconName))) 108 LabeledContent("App Icon", value: AppIcons.name(appIcon))
108 } 109 }
109 } 110 }
110 calendarSection 111 calendarSection
@@ -127,14 +128,14 @@ struct SettingsScreen: View {
127 } 128 }
128 } 129 }
129 130
130 /// `calendar-events` and `calendar-event-calendars`, written to config.toml.
131 /// The two palettes' names, and the theme file's when there is one. 131 /// The two palettes' names, and the theme file's when there is one.
132 private var themeInUse: String { 132 private var themeInUse: String {
133 let names = "\(ThemePickerScreen.current(.light).name) / \(ThemePickerScreen.current(.dark).name)" 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 } 134 guard let file = UserDefaults.standard.string(forKey: "themeFile"), !file.isEmpty else { return names }
135 return "\(names), \(file)" 135 return "\(names), \(file)"
136 } 136 }
137 137
138 /// `calendar-events` and `calendar-event-calendars`, written to config.toml.
138 private var calendarSection: some View { 139 private var calendarSection: some View {
139 let _ = model.settingsVersion 140 let _ = model.settingsVersion
140 let on = OrgPreferences.calendarEvents() 141 let on = OrgPreferences.calendarEvents()
Sources/OrgstarMobile/ThemePickerScreen.swift +1 −1
@@ -17,7 +17,7 @@ struct ThemePickerScreen: View {
17 } label: { 17 } label: {
18 HStack { 18 HStack {
19 VStack(alignment: .leading, spacing: 6) { 19 VStack(alignment: .leading, spacing: 6) {
20 Text(palette.name).foregroundStyle(.primary) 20 Text(palette.displayName).foregroundStyle(.primary)
21 Self.sample(palette) 21 Self.sample(palette)
22 } 22 }
23 Spacer() 23 Spacer()
Tests/OrgPresentationTests/PaletteTests.swift +14
@@ -109,4 +109,18 @@ struct PaletteTests {
109 #expect(spec.color(key, dark: true) != nil, "\(key)") 109 #expect(spec.color(key, dark: true) != nil, "\(key)")
110 } 110 }
111 } 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 }
112} 126}
l10n/Localizable.xcstrings +110
@@ -1424,6 +1424,16 @@
1424 } 1424 }
1425 } 1425 }
1426 }, 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 },
1427 "Copied to my-theme.toml, now the theme file.": { 1437 "Copied to my-theme.toml, now the theme file.": {
1428 "localizations": { 1438 "localizations": {
1429 "de": { 1439 "de": {
@@ -1654,6 +1664,16 @@
1654 } 1664 }
1655 } 1665 }
1656 }, 1666 },
1667 "Default": {
1668 "localizations": {
1669 "de": {
1670 "stringUnit": {
1671 "state": "translated",
1672 "value": "Standard"
1673 }
1674 }
1675 }
1676 },
1657 "Default TODO keywords": { 1677 "Default TODO keywords": {
1658 "localizations": { 1678 "localizations": {
1659 "de": { 1679 "de": {
@@ -2309,6 +2329,16 @@
2309 } 2329 }
2310 } 2330 }
2311 }, 2331 },
2332 "Forest": {
2333 "localizations": {
2334 "de": {
2335 "stringUnit": {
2336 "state": "translated",
2337 "value": "Wald"
2338 }
2339 }
2340 }
2341 },
2312 "Forget Encryption Passphrase": { 2342 "Forget Encryption Passphrase": {
2313 "localizations": { 2343 "localizations": {
2314 "de": { 2344 "de": {
@@ -2986,6 +3016,16 @@
2986 } 3016 }
2987 } 3017 }
2988 }, 3018 },
3019 "Midnight": {
3020 "localizations": {
3021 "de": {
3022 "stringUnit": {
3023 "state": "translated",
3024 "value": "Mitternacht"
3025 }
3026 }
3027 }
3028 },
2989 "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.": {
2990 "localizations": { 3030 "localizations": {
2991 "de": { 3031 "de": {
@@ -3809,6 +3849,16 @@
3809 } 3849 }
3810 } 3850 }
3811 }, 3851 },
3852 "Paper": {
3853 "localizations": {
3854 "de": {
3855 "stringUnit": {
3856 "state": "translated",
3857 "value": "Papier"
3858 }
3859 }
3860 }
3861 },
3812 "Passphrase": { 3862 "Passphrase": {
3813 "localizations": { 3863 "localizations": {
3814 "de": { 3864 "de": {
@@ -3999,6 +4049,16 @@
3999 } 4049 }
4000 } 4050 }
4001 }, 4051 },
4052 "Rainbow": {
4053 "localizations": {
4054 "de": {
4055 "stringUnit": {
4056 "state": "translated",
4057 "value": "Regenbogen"
4058 }
4059 }
4060 }
4061 },
4002 "Read-only: not UTF-8": { 4062 "Read-only: not UTF-8": {
4003 "localizations": { 4063 "localizations": {
4004 "de": { 4064 "de": {
@@ -5009,6 +5069,16 @@
5009 } 5069 }
5010 } 5070 }
5011 }, 5071 },
5072 "Sunset": {
5073 "localizations": {
5074 "de": {
5075 "stringUnit": {
5076 "state": "translated",
5077 "value": "Sonnenuntergang"
5078 }
5079 }
5080 }
5081 },
5012 "Switch to Buffer…": { 5082 "Switch to Buffer…": {
5013 "localizations": { 5083 "localizations": {
5014 "de": { 5084 "de": {
@@ -5343,6 +5413,16 @@
5343 } 5413 }
5344 } 5414 }
5345 }, 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 },
5346 "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.": {
5347 "localizations": { 5427 "localizations": {
5348 "de": { 5428 "de": {
@@ -5493,6 +5573,36 @@
5493 } 5573 }
5494 } 5574 }
5495 }, 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 },
5496 "Unmark": { 5606 "Unmark": {
5497 "localizations": { 5607 "localizations": {
5498 "de": { 5608 "de": {
scripts/build-app.sh +1 −1
@@ -57,7 +57,7 @@ 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
60# The icon, in the system's default, dark and tinted styles, and the Dock icons Settings offers. 60# The icon (macOS derives its dark and tinted styles), and the Dock icons Settings offers.
61work="$(mktemp -d)" 61work="$(mktemp -d)"
62xcrun actool packaging/AppIcons.xcassets --compile "$app/Contents/Resources" --platform macosx \ 62xcrun actool packaging/AppIcons.xcassets --compile "$app/Contents/Resources" --platform macosx \
63 --minimum-deployment-target 26.0 --app-icon AppIcon --output-partial-info-plist "$work/icon.plist" > /dev/null 63 --minimum-deployment-target 26.0 --app-icon AppIcon --output-partial-info-plist "$work/icon.plist" > /dev/null