import SwiftUI /// The member's Appearance, from `/api/v1/me` (Settings on the web): it /// overrides the system's, as `data-theme` on the web's `` does. public enum BaseAppearance: String, Sendable, Codable, CaseIterable { case system, light, dark /// What to pass `preferredColorScheme`: nil follows the system. public var colorScheme: ColorScheme? { switch self { case .system: nil case .light: .light case .dark: .dark } } /// Anything else the server says (a value from a newer Base) is System. public init(server value: String?) { self = value.flatMap(BaseAppearance.init(rawValue:)) ?? .system } } public extension View { /// The member's Appearance over the system's. func baseAppearance(_ appearance: BaseAppearance) -> some View { preferredColorScheme(appearance.colorScheme) } }