From 069feb8ab683300dfc39e48074b797f966a14bf6 Mon Sep 17 00:00:00 2001 From: Felix Schwarz Date: Mon, 28 Aug 2023 16:12:59 +0200 Subject: [PATCH] - NSObject+ThemeApplication: fix wrong label colors for ThemeCSSLabels that are also subject to NSObject.applyThemeCollection() calls --- .../Theme/NSObject+ThemeApplication.swift | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/ownCloudAppShared/User Interface/Theme/NSObject+ThemeApplication.swift b/ownCloudAppShared/User Interface/Theme/NSObject+ThemeApplication.swift index e30e26bec..8f6a959ff 100644 --- a/ownCloudAppShared/User Interface/Theme/NSObject+ThemeApplication.swift +++ b/ownCloudAppShared/User Interface/Theme/NSObject+ThemeApplication.swift @@ -140,25 +140,7 @@ public extension NSObject { } if let label = self as? UILabel { - var normalColor : UIColor // = collection.tableRowColors.labelColor - var highlightColor : UIColor // = collection.tableRowHighlightColors.labelColor - let disabledColor : UIColor = css.getColor(.stroke, selectors: [.secondary], for: label) ?? .secondaryLabel // = collection.tableRowColors.secondaryLabelColor - - switch itemStyle { - case .message, .bigMessage, .systemSecondary(textStyle: _, weight: _): - normalColor = css.getColor(.stroke, selectors: [.secondary], for: label) ?? .secondaryLabel - highlightColor = css.getColor(.stroke, selectors: [.secondary], state: [.highlighted], for: label) ?? .tertiaryLabel - // normalColor = collection.tableRowColors.secondaryLabelColor - // highlightColor = collection.tableRowHighlightColors.secondaryLabelColor - - default: - // case .title, .bigTitle, .system(textStyle: _, weight: _): - normalColor = css.getColor(.stroke, selectors: [.primary], for: label) ?? .label - highlightColor = css.getColor(.stroke, selectors: [.primary], state: [.highlighted], for: label) ?? .label - // normalColor = collection.tableRowColors.labelColor - // highlightColor = collection.tableRowHighlightColors.labelColor - } - + // Change font for any type of label switch itemStyle { case .bigTitle: label.font = UIFont.boldSystemFont(ofSize: 34) @@ -184,15 +166,33 @@ public extension NSObject { break } - switch itemState { - case .normal: - label.textColor = normalColor + // Adapt color only for non-ThemeCSSLabel + let cssLabel = self as? ThemeCSSLabel + if cssLabel == nil { + var normalColor : UIColor + var highlightColor : UIColor + let disabledColor : UIColor = css.getColor(.stroke, selectors: [.secondary], for: label) ?? .secondaryLabel + + switch itemStyle { + case .message, .bigMessage, .systemSecondary(textStyle: _, weight: _): + normalColor = css.getColor(.stroke, selectors: [.secondary], for: label) ?? .secondaryLabel + highlightColor = css.getColor(.stroke, selectors: [.secondary], state: [.highlighted], for: label) ?? .tertiaryLabel + + default: + normalColor = css.getColor(.stroke, selectors: [.primary], for: label) ?? .label + highlightColor = css.getColor(.stroke, selectors: [.primary], state: [.highlighted], for: label) ?? .label + } + + switch itemState { + case .normal: + label.textColor = normalColor - case .highlighted: - label.textColor = highlightColor + case .highlighted: + label.textColor = highlightColor - case .disabled: - label.textColor = disabledColor + case .disabled: + label.textColor = disabledColor + } } }