Files
OSGKeyboard/OSGKeyboardShared/Models/AppearancePreference.swift
T
Rocky c598ba77e6 feat: iOS appearance, iPad logo fix, demo seed, and landing hero polish
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.
2026-07-12 16:24:59 +08:00

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
}
}