Skip to content

Commit

Permalink
- NSObject+ThemeApplication: fix wrong label colors for ThemeCSSLabel…
Browse files Browse the repository at this point in the history
…s that are also subject to NSObject.applyThemeCollection() calls
  • Loading branch information
felix-schwarz committed Aug 28, 2023
1 parent b56d60e commit 069feb8
Showing 1 changed file with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
}
}

Expand Down

0 comments on commit 069feb8

Please sign in to comment.