diff --git a/Sources/iOS/NavigationBar.swift b/Sources/iOS/NavigationBar.swift index f28f32a76..2bfc1c1cb 100644 --- a/Sources/iOS/NavigationBar.swift +++ b/Sources/iOS/NavigationBar.swift @@ -189,7 +189,6 @@ open class NavigationBar: UINavigationBar, Themeable { */ private func apply(theme: Theme, to item: UINavigationItem) { Theme.apply(theme: theme, to: item.toolbar) - item.toolbar.backgroundColor = .clear } } @@ -208,6 +207,7 @@ internal extension NavigationBar { } let toolbar = item.toolbar + toolbar.backgroundColor = .clear toolbar.interimSpace = interimSpace toolbar.contentEdgeInsets = contentEdgeInsets diff --git a/Sources/iOS/Theme.swift b/Sources/iOS/Theme.swift index 447152930..d161de2c8 100644 --- a/Sources/iOS/Theme.swift +++ b/Sources/iOS/Theme.swift @@ -74,6 +74,9 @@ public struct Theme: Hashable { /// Text and iconography color to be used on error color. public var onError = Color.white + /// A boolean indicating if theming is enabled globally. + public static var isEnabled = true + /// An initializer. public init() { } } @@ -172,10 +175,22 @@ public extension Theme { private var IsThemingEnabledKey: UInt8 = 0 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. var isThemingEnabled: Bool { get { - return AssociatedObject.get(base: self, key: &IsThemingEnabledKey) { + return type(of: self).isThemingEnabled && AssociatedObject.get(base: self, key: &IsThemingEnabledKey) { true } }