Sources/OrgPresentation/AppIcons.swift

ed75375eb5b1fd99336b7369fc806c4c9f911dca
orgstar/Sources/OrgPresentation/AppIcons.swift

29 lines · 1269 bytes

 1/// The app icons `scripts/make-icon.swift` draws, by id, in its order.
 2public enum AppIcons {
 3    public static let ids = [
 4        "default", "midnight", "paper", "org", "sunset", "forest", "mono", "rainbow", "outline", "terminal",
 5        "unicorn", "unicorn-night", "unicorn-pastel",
 6    ]
 7
 8    private static func words(_ id: String) -> [String] { id.split(separator: "-").map { $0.prefix(1).uppercased() + $0.dropFirst() } }
 9
10    public static func name(_ id: String) -> String { words(id).joined(separator: " ") }
11
12    /// The iOS alternate icon's name; nil for the primary icon.
13    public static func alternateName(_ id: String) -> String? {
14        id == "default" ? nil : "AppIcon-" + words(id).joined()
15    }
16
17    public static func id(alternateName: String?) -> String {
18        ids.first { self.alternateName($0) == alternateName && alternateName != nil } ?? "default"
19    }
20}
21
22extension AppIcons {
23    /// The Mac's Dock icon file for `id` in an appearance, in `Contents/Resources/IconPreviews`;
24    /// nil for the default, which is the bundle's own icon.
25    public static func dockFile(_ id: String, dark: Bool) -> String? {
26        guard id != "default", ids.contains(id) else { return nil }
27        return "\(id)-\(dark ? "dark" : "light")"
28    }
29}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form