refactored radiobox/radiobutton to have attributedText override
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
7f0da47036
commit
92c8c1073f
@ -95,14 +95,38 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{
|
|||||||
|
|
||||||
open var textAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
open var textAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
||||||
|
|
||||||
|
open var textAttributedText: NSAttributedString? {
|
||||||
|
didSet {
|
||||||
|
textLabel.useAttributedText = !(textAttributedText?.string.isEmpty ?? true)
|
||||||
|
textLabel.attributedText = textAttributedText
|
||||||
|
didChange()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open var subText: String? { didSet { didChange() }}
|
open var subText: String? { didSet { didChange() }}
|
||||||
|
|
||||||
open var subTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
open var subTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
||||||
|
|
||||||
|
open var subTextAttributedText: NSAttributedString? {
|
||||||
|
didSet {
|
||||||
|
subTextLabel.useAttributedText = !(subTextAttributedText?.string.isEmpty ?? true)
|
||||||
|
subTextLabel.attributedText = subTextAttributedText
|
||||||
|
didChange()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open var subTextRight: String? { didSet { didChange() }}
|
open var subTextRight: String? { didSet { didChange() }}
|
||||||
|
|
||||||
open var subTextRightAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
open var subTextRightAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
||||||
|
|
||||||
|
open var subTextRightAttributedText: NSAttributedString? {
|
||||||
|
didSet {
|
||||||
|
subTextRightLabel.useAttributedText = !(subTextRightAttributedText?.string.isEmpty ?? true)
|
||||||
|
subTextRightLabel.attributedText = subTextRightAttributedText
|
||||||
|
didChange()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open var strikethrough: Bool = false { didSet { didChange() }}
|
open var strikethrough: Bool = false { didSet { didChange() }}
|
||||||
|
|
||||||
open var inputId: String? { didSet { didChange() }}
|
open var inputId: String? { didSet { didChange() }}
|
||||||
@ -191,6 +215,10 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{
|
|||||||
subTextLabel.disabled = disabled
|
subTextLabel.disabled = disabled
|
||||||
subTextLabel.attributes = subTextAttributes
|
subTextLabel.attributes = subTextAttributes
|
||||||
subTextLabel.isHidden = false
|
subTextLabel.isHidden = false
|
||||||
|
|
||||||
|
} else if subTextAttributedText != nil {
|
||||||
|
subTextLabel.isHidden = false
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
subTextLabel.isHidden = true
|
subTextLabel.isHidden = true
|
||||||
}
|
}
|
||||||
@ -204,6 +232,10 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{
|
|||||||
subTextRightLabel.disabled = disabled
|
subTextRightLabel.disabled = disabled
|
||||||
subTextRightLabel.attributes = subTextRightAttributes
|
subTextRightLabel.attributes = subTextRightAttributes
|
||||||
subTextRightLabel.isHidden = false
|
subTextRightLabel.isHidden = false
|
||||||
|
|
||||||
|
} else if subTextAttributedText != nil {
|
||||||
|
subTextRightLabel.isHidden = false
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
subTextRightLabel.isHidden = true
|
subTextRightLabel.isHidden = true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,7 +59,7 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,9 +111,25 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
|
|||||||
|
|
||||||
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() }}
|
||||||
|
|
||||||
@ -202,6 +218,10 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
|
|||||||
primaryLabel.disabled = disabled
|
primaryLabel.disabled = disabled
|
||||||
primaryLabel.attributes = labelTextAttributes
|
primaryLabel.attributes = labelTextAttributes
|
||||||
primaryLabel.isHidden = false
|
primaryLabel.isHidden = false
|
||||||
|
|
||||||
|
} else if labelAttributedText != nil {
|
||||||
|
primaryLabel.isHidden = false
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
primaryLabel.isHidden = true
|
primaryLabel.isHidden = true
|
||||||
}
|
}
|
||||||
@ -215,6 +235,10 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
|
|||||||
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