1
0
mirror of https://github.com/mastodon/mastodon-ios.git synced 2024-12-15 10:24:32 +01:00
mastodon-app-ufficiale-ipho.../MastodonSDK/Sources/MastodonUI/Service/ThemeService/ThemeService.swift

37 lines
825 B
Swift
Raw Normal View History

2021-07-05 10:07:17 +02:00
//
// ThemeService.swift
// Mastodon
//
// Created by MainasuK Cirno on 2021-7-5.
//
import UIKit
import Combine
import MastodonCommon
2021-07-05 10:07:17 +02:00
// ref: https://zamzam.io/protocol-oriented-themes-for-ios-apps/
public final class ThemeService {
2021-10-29 08:58:09 +02:00
public static let tintColor: UIColor = .label
2021-07-05 10:07:17 +02:00
// MARK: - Singleton
public static let shared = ThemeService()
public let currentTheme: CurrentValueSubject<Theme, Never>
2021-07-05 10:07:17 +02:00
private init() {
let theme = ThemeName(rawValue: UserDefaults.shared.currentThemeNameRawValue)?.theme ?? ThemeName.mastodon.theme
currentTheme = CurrentValueSubject(theme)
}
}
extension ThemeName {
public var theme: Theme {
switch self {
case .system: return SystemTheme()
case .mastodon: return MastodonTheme()
}
}
}