6a2a69825d
Replaces custom accent-only themes with the seven themes from org-social-ios-lib (Default, Emacs, Dracula, One Dark, Monokai, Material, Thankful Eyes). Swatches now show background/secondaryBackground/accent. Selecting a theme applies tint and preferredColorScheme app-wide immediately.
21 lines
528 B
Swift
21 lines
528 B
Swift
import Foundation
|
|
import Observation
|
|
|
|
@Observable @MainActor
|
|
final class ThemeManager {
|
|
static let shared = ThemeManager()
|
|
|
|
private(set) var current: AppTheme = .default
|
|
private static let key = "appThemeID"
|
|
|
|
private init() {
|
|
let saved = UserDefaults.standard.string(forKey: Self.key) ?? "default"
|
|
current = AppTheme.all.first { $0.id == saved } ?? .default
|
|
}
|
|
|
|
func select(_ theme: AppTheme) {
|
|
current = theme
|
|
UserDefaults.standard.set(theme.id, forKey: Self.key)
|
|
}
|
|
}
|