isEnabled workaround until I can figure something else out.
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
8e0287c8fd
commit
f8289788ee
@ -141,7 +141,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///AttributedText that will be used in the label.
|
///AttributedText that will be used in the label.
|
||||||
override open var attributedText: NSAttributedString? {
|
override open var attributedText: NSAttributedString? {
|
||||||
didSet {
|
didSet {
|
||||||
@ -169,7 +169,16 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the View is enabled or not.
|
/// Whether the View is enabled or not.
|
||||||
open override var isEnabled: Bool { didSet { setNeedsUpdate() } }
|
/// Since the UILabel itselfs draws a different color for the "disabled state", I have to track
|
||||||
|
/// local variable to deal with color and always enforce this UILabel is always enabled.
|
||||||
|
private var _fakeIsEnabled: Bool = true
|
||||||
|
open override var isEnabled: Bool {
|
||||||
|
get { true }
|
||||||
|
set {
|
||||||
|
_fakeIsEnabled = newValue
|
||||||
|
setNeedsUpdate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration Properties
|
// MARK: - Configuration Properties
|
||||||
@ -282,7 +291,21 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
styleAttributedText(attributedText)
|
styleAttributedText(attributedText)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private struct FakeEnabled: Enabling, Surfaceable {
|
||||||
|
var surface: Surface
|
||||||
|
var isEnabled: Bool
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Var to deal with the UILabel.isEnabled property causing issues with
|
||||||
|
/// textColor when it is false, I am now using a struct to draw and manage
|
||||||
|
/// colors instead of this class itself and this class will always be enabled
|
||||||
|
private var _textColor: UIColor {
|
||||||
|
let fake = FakeEnabled(surface: surface, isEnabled: _fakeIsEnabled)
|
||||||
|
return textColorConfiguration.getColor(fake)
|
||||||
|
}
|
||||||
|
|
||||||
private func styleText(_ newValue: String!) {
|
private func styleText(_ newValue: String!) {
|
||||||
defer { invalidateIntrinsicContentSize() }
|
defer { invalidateIntrinsicContentSize() }
|
||||||
guard let newValue, !newValue.isEmpty else {
|
guard let newValue, !newValue.isEmpty else {
|
||||||
@ -293,15 +316,13 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
accessibilityCustomActions = []
|
accessibilityCustomActions = []
|
||||||
|
|
||||||
//create the primary string
|
//create the primary string
|
||||||
let mutableText = NSMutableAttributedString.mutableText(for: newValue,
|
let mutableText = NSMutableAttributedString.mutableText(for: newValue,
|
||||||
textStyle: textStyle,
|
textStyle: textStyle,
|
||||||
useScaledFont: useScaledFont,
|
useScaledFont: useScaledFont,
|
||||||
textColor: textColorConfiguration.getColor(self),
|
textColor: _textColor,
|
||||||
alignment: textAlignment,
|
alignment: textAlignment,
|
||||||
lineBreakMode: lineBreakMode)
|
lineBreakMode: lineBreakMode)
|
||||||
|
|
||||||
applyAttributes(mutableText)
|
applyAttributes(mutableText)
|
||||||
|
|
||||||
// Set attributed text to match typography
|
// Set attributed text to match typography
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user