diff --git a/VDS/Components/Checkbox/Checkbox.swift b/VDS/Components/Checkbox/Checkbox.swift index 64a4fdc3..a0426c09 100644 --- a/VDS/Components/Checkbox/Checkbox.swift +++ b/VDS/Components/Checkbox/Checkbox.swift @@ -51,7 +51,7 @@ open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Er } 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 } @@ -105,11 +105,27 @@ open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Er open var labelText: String? { 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 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 errorText: String? { didSet { didChange() }} @@ -192,11 +208,14 @@ open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Er if let labelText { primaryLabel.textPosition = .left primaryLabel.typograpicalStyle = .BoldBodyLarge - primaryLabel.text = labelText primaryLabel.surface = surface primaryLabel.disabled = disabled primaryLabel.attributes = labelTextAttributes + primaryLabel.text = labelText primaryLabel.isHidden = false + } else if labelAttributedText != nil { + primaryLabel.isHidden = false + } else { primaryLabel.isHidden = true } @@ -210,6 +229,10 @@ open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Er secondaryLabel.disabled = disabled secondaryLabel.attributes = childTextAttributes secondaryLabel.isHidden = false + + } else if childAttributedText != nil { + secondaryLabel.isHidden = false + } else { secondaryLabel.isHidden = true }