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
13/// The app icons `scripts/make-icon.swift` draws, by id, in its order.
24public enum AppIcons {
35 public static let ids = [
@@ -7,7 +9,22 @@ public enum AppIcons {
79
810 private static func words(_ id: String) -> [String] { id.split(separator: "-").map { $0.prefix(1).uppercased() + $0.dropFirst() } }
911
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 }
1128
1229 /// The iOS alternate icon's name; nil for the primary icon.
1330 public static func alternateName(_ id: String) -> String? {
Sources/OrgPresentation/Palettes.swift +20
@@ -1,3 +1,5 @@
1import Foundation
2
13/// A built-in theme for one appearance, chosen with `light-theme` or `dark-theme`.
24public struct Palette: Sendable, Equatable {
35 public enum Appearance: String, Sendable { case light, dark }
@@ -7,6 +9,15 @@ public struct Palette: Sendable, Equatable {
79 public let appearance: Appearance
810 public let colors: [String: RGBA]
911
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
1021 public init(id: String, name: String, appearance: Appearance, colors: [String: RGBA]) {
1122 self.id = id
1223 self.name = name
@@ -29,6 +40,15 @@ extension ThemeSpec {
2940 "default-" + appearance.rawValue
3041 }
3142
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
3252 /// The default theme with each appearance's colors from the palette `light-theme` and
3353 /// `dark-theme` name; Default where one is unset or unknown, with a problem for unknown.
3454 public static func base(light: String?, dark: String?) -> (ThemeSpec, [String]) {
Sources/Orgstar/ContentView.swift +4 −2
@@ -460,7 +460,7 @@ struct ContentView: View {
460460 }
461461 .task(id: ReminderKey(
462462 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
464464 )) {
465465 await updateReminders()
466466 await updateWidgets()
@@ -905,7 +905,7 @@ struct ContentView: View {
905905 }
906906 }
907907
908 private struct ReminderKey: Hashable {
908 private struct ReminderKey: Equatable {
909909 var enabled: Bool
910910 var lead: Int
911911 var subfolders: Bool
@@ -913,6 +913,8 @@ struct ContentView: View {
913913 var changed: Int?
914914 var edits: Int
915915 var hour: Int
916 /// The widgets' colors.
917 var theme: ThemeSpec
916918 }
917919
918920 /// 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 {
2020 } header: {
2121 Text("Theme")
2222 } 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)
2424 .settingsFooter()
2525 }
2626 }
2727
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
2833 private func picker(_ title: LocalizedStringKey, _ appearance: Palette.Appearance, _ selection: Binding<String>) -> some View {
2934 Picker(title, selection: selection) {
3035 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)
3237 }
3338 if ThemeSpec.palette(selection.wrappedValue, appearance) == nil {
3439 Text(selection.wrappedValue).tag(selection.wrappedValue)
@@ -59,8 +64,11 @@ struct ThemePickerSection: View {
5964 message = String(localized: "my-theme.toml is already in the config folder; it was left as it is.")
6065 return
6166 }
67 let previous = themeFile
6268 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).")
6472 } catch {
6573 message = error.localizedDescription
6674 }
Sources/OrgstarMobile/AppIconScreen.swift +2 −1
@@ -5,7 +5,8 @@ import UIKit
55
66/// The app icons, as previews; tapping one makes it the home screen's icon.
77struct 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
910 @State private var failure: String?
1011
1112 var body: some View {
Sources/OrgstarMobile/MobileTheme.swift +20 −5
@@ -41,11 +41,26 @@ struct MobileTheme {
4141
4242 /// A color that follows the appearance, or nil when the theme has none for `key`.
4343 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.
45 let light = spec.light[key] ?? ThemeSpec.default.light[key] ?? spec.dark[key]
46 let dark = spec.dark[key] ?? ThemeSpec.default.dark[key] ?? spec.light[key]
47 guard let light, let dark else { return nil }
48 return Self.dynamic(light, dark)
44 // As on the Mac: a key the theme has for one appearance only takes the default for the
45 // other, except a key the system colors there.
46 let (light, dark) = (spec.editorColor(key, dark: false), spec.editorColor(key, dark: true))
47 if let light, let dark { 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 }
4964 }
5065
5166 static func dynamic(_ light: RGBA, _ dark: RGBA) -> UIColor {
Sources/OrgstarMobile/SettingsScreen.swift +7 −6
@@ -13,6 +13,7 @@ struct SettingsScreen: View {
1313 @State private var calendars: [CalendarChoice] = []
1414 @State private var reminderLists: [CalendarChoice] = []
1515 @State private var badges: Bool?
16 @State private var appIcon = AppIcons.id(alternateName: UIApplication.shared.alternateIconName)
1617 @Environment(\.openURL) private var openURL
1718 @Environment(\.scenePhase) private var scenePhase
1819
@@ -94,17 +95,17 @@ struct SettingsScreen: View {
9495 NavigationLink {
9596 ThemePickerScreen(model: model, appearance: .light)
9697 } label: {
97 LabeledContent("Light Theme", value: ThemePickerScreen.current(.light).name)
98 LabeledContent("Light Theme", value: ThemePickerScreen.current(.light).displayName)
9899 }
99100 NavigationLink {
100101 ThemePickerScreen(model: model, appearance: .dark)
101102 } label: {
102 LabeledContent("Dark Theme", value: ThemePickerScreen.current(.dark).name)
103 LabeledContent("Dark Theme", value: ThemePickerScreen.current(.dark).displayName)
103104 }
104105 NavigationLink {
105 AppIconScreen()
106 AppIconScreen(current: $appIcon)
106107 } label: {
107 LabeledContent("App Icon", value: AppIcons.name(AppIcons.id(alternateName: UIApplication.shared.alternateIconName)))
108 LabeledContent("App Icon", value: AppIcons.name(appIcon))
108109 }
109110 }
110111 calendarSection
@@ -127,14 +128,14 @@ struct SettingsScreen: View {
127128 }
128129 }
129130
130 /// `calendar-events` and `calendar-event-calendars`, written to config.toml.
131131 /// The two palettes' names, and the theme file's when there is one.
132132 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)"
134134 guard let file = UserDefaults.standard.string(forKey: "themeFile"), !file.isEmpty else { return names }
135135 return "\(names), \(file)"
136136 }
137137
138 /// `calendar-events` and `calendar-event-calendars`, written to config.toml.
138139 private var calendarSection: some View {
139140 let _ = model.settingsVersion
140141 let on = OrgPreferences.calendarEvents()
Sources/OrgstarMobile/ThemePickerScreen.swift +1 −1
@@ -17,7 +17,7 @@ struct ThemePickerScreen: View {
1717 } label: {
1818 HStack {
1919 VStack(alignment: .leading, spacing: 6) {
20 Text(palette.name).foregroundStyle(.primary)
20 Text(palette.displayName).foregroundStyle(.primary)
2121 Self.sample(palette)
2222 }
2323 Spacer()
Tests/OrgPresentationTests/PaletteTests.swift +14
@@ -109,4 +109,18 @@ struct PaletteTests {
109109 #expect(spec.color(key, dark: true) != nil, "\(key)")
110110 }
111111 }
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 }
112126}
l10n/Localizable.xcstrings +110
@@ -1424,6 +1424,16 @@
14241424 }
14251425 }
14261426 },
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 },
14271437 "Copied to my-theme.toml, now the theme file.": {
14281438 "localizations": {
14291439 "de": {
@@ -1654,6 +1664,16 @@
16541664 }
16551665 }
16561666 },
1667 "Default": {
1668 "localizations": {
1669 "de": {
1670 "stringUnit": {
1671 "state": "translated",
1672 "value": "Standard"
1673 }
1674 }
1675 }
1676 },
16571677 "Default TODO keywords": {
16581678 "localizations": {
16591679 "de": {
@@ -2309,6 +2329,16 @@
23092329 }
23102330 }
23112331 },
2332 "Forest": {
2333 "localizations": {
2334 "de": {
2335 "stringUnit": {
2336 "state": "translated",
2337 "value": "Wald"
2338 }
2339 }
2340 }
2341 },
23122342 "Forget Encryption Passphrase": {
23132343 "localizations": {
23142344 "de": {
@@ -2986,6 +3016,16 @@
29863016 }
29873017 }
29883018 },
3019 "Midnight": {
3020 "localizations": {
3021 "de": {
3022 "stringUnit": {
3023 "state": "translated",
3024 "value": "Mitternacht"
3025 }
3026 }
3027 }
3028 },
29893029 "Modal editing as in Doom Emacs, with SPC as the leader: SPC m t cycles TODO.": {
29903030 "localizations": {
29913031 "de": {
@@ -3809,6 +3849,16 @@
38093849 }
38103850 }
38113851 },
3852 "Paper": {
3853 "localizations": {
3854 "de": {
3855 "stringUnit": {
3856 "state": "translated",
3857 "value": "Papier"
3858 }
3859 }
3860 }
3861 },
38123862 "Passphrase": {
38133863 "localizations": {
38143864 "de": {
@@ -3999,6 +4049,16 @@
39994049 }
40004050 }
40014051 },
4052 "Rainbow": {
4053 "localizations": {
4054 "de": {
4055 "stringUnit": {
4056 "state": "translated",
4057 "value": "Regenbogen"
4058 }
4059 }
4060 }
4061 },
40024062 "Read-only: not UTF-8": {
40034063 "localizations": {
40044064 "de": {
@@ -5009,6 +5069,16 @@
50095069 }
50105070 }
50115071 },
5072 "Sunset": {
5073 "localizations": {
5074 "de": {
5075 "stringUnit": {
5076 "state": "translated",
5077 "value": "Sonnenuntergang"
5078 }
5079 }
5080 }
5081 },
50125082 "Switch to Buffer…": {
50135083 "localizations": {
50145084 "de": {
@@ -5343,6 +5413,16 @@
53435413 }
53445414 }
53455415 },
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 },
53465426 "The whole file is removed. Files in iCloud Drive go to Recently Deleted in the Files app.": {
53475427 "localizations": {
53485428 "de": {
@@ -5493,6 +5573,36 @@
54935573 }
54945574 }
54955575 },
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 },
54965606 "Unmark": {
54975607 "localizations": {
54985608 "de": {
scripts/build-app.sh +1 −1
@@ -57,7 +57,7 @@ fi
5757# The UI's translations, from l10n/Localizable.xcstrings.
5858scripts/localize.sh "$app/Contents/Resources"
5959
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.
6161work="$(mktemp -d)"
6262xcrun actool packaging/AppIcons.xcassets --compile "$app/Contents/Resources" --platform macosx \
6363 --minimum-deployment-target 26.0 --app-icon AppIcon --output-partial-info-plist "$work/icon.plist" > /dev/null