added the logic for a attributedText
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
c150f1552b
commit
7f0da47036
@ -51,7 +51,7 @@ open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Er
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var shouldShowLabels: Bool {
|
private var shouldShowLabels: Bool {
|
||||||
guard labelText?.isEmpty == false || childText?.isEmpty == false else { return false }
|
guard labelText?.isEmpty == false || childText?.isEmpty == false || labelAttributedText?.string.isEmpty == false || childAttributedText?.string.isEmpty == false else { return false }
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,11 +105,27 @@ open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Er
|
|||||||
open var labelText: String? { didSet { didChange() }}
|
open var labelText: String? { didSet { didChange() }}
|
||||||
|
|
||||||
open var labelTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
open var labelTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
||||||
|
|
||||||
|
open var labelAttributedText: NSAttributedString? {
|
||||||
|
didSet {
|
||||||
|
primaryLabel.useAttributedText = !(labelAttributedText?.string.isEmpty ?? true)
|
||||||
|
primaryLabel.attributedText = labelAttributedText
|
||||||
|
didChange()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open var childText: String? { didSet { didChange() }}
|
open var childText: String? { didSet { didChange() }}
|
||||||
|
|
||||||
open var childTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
open var childTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
||||||
|
|
||||||
|
open var childAttributedText: NSAttributedString? {
|
||||||
|
didSet {
|
||||||
|
secondaryLabel.useAttributedText = !(childAttributedText?.string.isEmpty ?? true)
|
||||||
|
secondaryLabel.attributedText = childAttributedText
|
||||||
|
didChange()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open var showError: Bool = false { didSet { didChange() }}
|
open var showError: Bool = false { didSet { didChange() }}
|
||||||
|
|
||||||
open var errorText: String? { didSet { didChange() }}
|
open var errorText: String? { didSet { didChange() }}
|
||||||
@ -192,11 +208,14 @@ open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Er
|
|||||||
if let labelText {
|
if let labelText {
|
||||||
primaryLabel.textPosition = .left
|
primaryLabel.textPosition = .left
|
||||||
primaryLabel.typograpicalStyle = .BoldBodyLarge
|
primaryLabel.typograpicalStyle = .BoldBodyLarge
|
||||||
primaryLabel.text = labelText
|
|
||||||
primaryLabel.surface = surface
|
primaryLabel.surface = surface
|
||||||
primaryLabel.disabled = disabled
|
primaryLabel.disabled = disabled
|
||||||
primaryLabel.attributes = labelTextAttributes
|
primaryLabel.attributes = labelTextAttributes
|
||||||
|
primaryLabel.text = labelText
|
||||||
primaryLabel.isHidden = false
|
primaryLabel.isHidden = false
|
||||||
|
} else if labelAttributedText != nil {
|
||||||
|
primaryLabel.isHidden = false
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
primaryLabel.isHidden = true
|
primaryLabel.isHidden = true
|
||||||
}
|
}
|
||||||
@ -210,6 +229,10 @@ open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Er
|
|||||||
secondaryLabel.disabled = disabled
|
secondaryLabel.disabled = disabled
|
||||||
secondaryLabel.attributes = childTextAttributes
|
secondaryLabel.attributes = childTextAttributes
|
||||||
secondaryLabel.isHidden = false
|
secondaryLabel.isHidden = false
|
||||||
|
|
||||||
|
} else if childAttributedText != nil {
|
||||||
|
secondaryLabel.isHidden = false
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
secondaryLabel.isHidden = true
|
secondaryLabel.isHidden = true
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user