Commit d9dfb66c by Daniel Jonathan Committed by GitHub

Merge pull request #1174 from OrkhanAlikhanov/theme-global-disable

Added disabling theming globally and per-class
parents e26faf0c a7dba80a
...@@ -189,7 +189,6 @@ open class NavigationBar: UINavigationBar, Themeable { ...@@ -189,7 +189,6 @@ open class NavigationBar: UINavigationBar, Themeable {
*/ */
private func apply(theme: Theme, to item: UINavigationItem) { private func apply(theme: Theme, to item: UINavigationItem) {
Theme.apply(theme: theme, to: item.toolbar) Theme.apply(theme: theme, to: item.toolbar)
item.toolbar.backgroundColor = .clear
} }
} }
...@@ -208,6 +207,7 @@ internal extension NavigationBar { ...@@ -208,6 +207,7 @@ internal extension NavigationBar {
} }
let toolbar = item.toolbar let toolbar = item.toolbar
toolbar.backgroundColor = .clear
toolbar.interimSpace = interimSpace toolbar.interimSpace = interimSpace
toolbar.contentEdgeInsets = contentEdgeInsets toolbar.contentEdgeInsets = contentEdgeInsets
......
...@@ -74,6 +74,9 @@ public struct Theme: Hashable { ...@@ -74,6 +74,9 @@ public struct Theme: Hashable {
/// Text and iconography color to be used on error color. /// Text and iconography color to be used on error color.
public var onError = Color.white public var onError = Color.white
/// A boolean indicating if theming is enabled globally.
public static var isEnabled = true
/// An initializer. /// An initializer.
public init() { } public init() { }
} }
...@@ -172,10 +175,22 @@ public extension Theme { ...@@ -172,10 +175,22 @@ public extension Theme {
private var IsThemingEnabledKey: UInt8 = 0 private var IsThemingEnabledKey: UInt8 = 0
public extension Themeable where Self: NSObject { public extension Themeable where Self: NSObject {
/// A class-wide boolean indicating if theming is enabled.
static var isThemingEnabled: Bool {
get {
return Theme.isEnabled && AssociatedObject.get(base: self, key: &IsThemingEnabledKey) {
true
}
}
set(value) {
AssociatedObject.set(base: self, key: &IsThemingEnabledKey, value: value)
}
}
/// A boolean indicating if theming is enabled. /// A boolean indicating if theming is enabled.
var isThemingEnabled: Bool { var isThemingEnabled: Bool {
get { get {
return AssociatedObject.get(base: self, key: &IsThemingEnabledKey) { return type(of: self).isThemingEnabled && AssociatedObject.get(base: self, key: &IsThemingEnabledKey) {
true true
} }
} }
......
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