ThemeManager
public final class ThemeManager : ObservableObject, Identifiable
Implements ObservableObject, Identifiable protocols. Manages available theme and current active one.
Singleton class, call ThemeManager.shared to retrieve it.
You can set the active theme by calling ThemeManager.shared.setCurrentTheme(CAITheme)
-
Returns the current active CAITheme
Declaration
Swift
public private(set) var theme: CAITheme { get } -
Singleton instance
Declaration
Swift
public static let shared: ThemeManager -
Set active theme. Triggers UI Binding.
Declaration
Swift
public func setCurrentTheme(_ theme: CAITheme)Parameters
themeCAITheme
-
Binds this method in your SwiftUI Views to get the color for the current theme
Declaration
Swift
public func color(for key: Theme.Color.Key) -> ColorParameters
keyTheme.Key
Return Value
Color
-
Binds this method in your SwiftUI Views to get the value for the current theme
Declaration
Swift
public func value(for key: Theme.Key) -> Any?Parameters
keyTheme.Key
Return Value
Any. Nil if key is not found
-
Binds this method in your SwiftUI Views to get the value for the current theme
Declaration
Swift
public func value<T>(for key: Theme.Key, type: T.Type, defaultValue: T) -> TParameters
keyTheme.Key
TypeExpected Type T that this value should be
defaultValueDefault value to return if key does not exist OR is of wrong type
Return Value
Value of type T
-
Binds this method in your SwiftUI Views to get the value for the current theme
Declaration
Swift
public func value<T>(for key: Theme.Key, type: T.Type) -> T?Parameters
keyTheme.Key
TypeExpected Type T that this value should be
Return Value
Value of type T?