Commit 16d1f535 by Orkhan Alikhanov

Disallow setting Theme.current directly

parent 848d5a3a
...@@ -70,15 +70,7 @@ public struct Theme { ...@@ -70,15 +70,7 @@ public struct Theme {
public extension Theme { public extension Theme {
/// Current theme for Material. /// Current theme for Material.
static var current = Theme.light { static private(set) var current = Theme.light
didSet {
guard let v = Application.rootViewController else {
return
}
apply(theme: .current, to: v)
}
}
/// A light theme. /// A light theme.
static var light = Theme() static var light = Theme()
...@@ -92,6 +84,21 @@ public extension Theme { ...@@ -92,6 +84,21 @@ public extension Theme {
t.onBackground = .white t.onBackground = .white
return t return t
}() }()
}
public extension Theme {
/**
Applies theme to the entire app.
- Parameter theme: A Theme.
*/
static func apply(theme: Theme) {
guard let v = Application.rootViewController else {
return
}
current = theme
apply(theme: theme, to: v)
}
/** /**
Applies theme to the hierarchy of given view. Applies theme to the hierarchy of given view.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment