c598ba77e6
Add System/Light/Dark preference for iPhone and iPad, restore the iPad sidebar brand mark, ship a DEBUG seed-demo URL for rich placeholder data, and refresh GitHub Pages with the device composite, full-bleed pale-green hero wash, and transparent Mac screenshot chrome.
42 lines
1.3 KiB
Swift
42 lines
1.3 KiB
Swift
// AppearancePreference.swift
|
|
// OSGKeyboard · Shared
|
|
//
|
|
// In-app light / dark preference for the iOS main app (iPhone + iPad).
|
|
// Mirrors macOS `MacAppearancePreference` but uses iOS Settings copy keys.
|
|
// Stored in standard UserDefaults (app-local); not synced via iCloud.
|
|
|
|
import SwiftUI
|
|
|
|
/// How the iOS host app resolves its colour scheme.
|
|
public enum AppearancePreference: String, CaseIterable, Identifiable, Sendable, Codable {
|
|
case system
|
|
case light
|
|
case dark
|
|
|
|
public var id: String { rawValue }
|
|
|
|
/// `nil` means follow the system — SwiftUI's `preferredColorScheme(nil)`.
|
|
public var colorScheme: ColorScheme? {
|
|
switch self {
|
|
case .system: return nil
|
|
case .light: return .light
|
|
case .dark: return .dark
|
|
}
|
|
}
|
|
|
|
public var labelKey: String {
|
|
switch self {
|
|
case .system: return "settings.appearance.system"
|
|
case .light: return "settings.appearance.light"
|
|
case .dark: return "settings.appearance.dark"
|
|
}
|
|
}
|
|
|
|
public static let storageKey = "config.appearancePreference"
|
|
|
|
public static func fromStored(_ raw: String?) -> AppearancePreference {
|
|
guard let raw, let value = AppearancePreference(rawValue: raw) else { return .system }
|
|
return value
|
|
}
|
|
}
|