From a6a0003c3b0d7f9954345b8b51589c24a3f2442e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 25 Aug 2023 15:46:00 -0500 Subject: [PATCH] refactored label to remove disabled. Signed-off-by: Matt Bruce --- VDS/Classes/SelectorItemBase.swift | 6 +++--- VDS/Components/Badge/Badge.swift | 2 +- VDS/Components/BadgeIndicator/BadgeIndicator.swift | 2 +- VDS/Components/Label/Label.swift | 12 +----------- VDS/Components/RadioBox/RadioBoxItem.swift | 6 +++--- VDS/Components/RadioSwatch/RadioSwatchGroup.swift | 2 +- .../TextFields/EntryField/EntryField.swift | 6 +++--- .../TextFields/InputField/InputField.swift | 2 +- VDS/Components/Toggle/Toggle.swift | 2 +- VDS/Components/Tooltip/TrailingTooltipLabel.swift | 2 +- 10 files changed, 16 insertions(+), 26 deletions(-) diff --git a/VDS/Classes/SelectorItemBase.swift b/VDS/Classes/SelectorItemBase.swift index b7c916b2..9d90507f 100644 --- a/VDS/Classes/SelectorItemBase.swift +++ b/VDS/Classes/SelectorItemBase.swift @@ -237,7 +237,7 @@ open class SelectorItemBase: Control, Errorable, //top label if let labelText { label.surface = surface - label.disabled = disabled + label.isEnabled = isEnabled label.attributes = labelTextAttributes label.text = labelText label.isHidden = false @@ -252,7 +252,7 @@ open class SelectorItemBase: Control, Errorable, if let childText { childLabel.text = childText childLabel.surface = surface - childLabel.disabled = disabled + childLabel.isEnabled = isEnabled childLabel.attributes = childTextAttributes childLabel.isHidden = false @@ -276,7 +276,7 @@ open class SelectorItemBase: Control, Errorable, if let errorText, shouldShowError { errorLabel.text = errorText errorLabel.surface = surface - errorLabel.disabled = disabled + errorLabel.isEnabled = isEnabled mainStackView.spacing = 8 errorLabel.isHidden = false } else { diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index ac8c0e94..ef7569fb 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -157,6 +157,6 @@ open class Badge: View { label.numberOfLines = numberOfLines label.text = text label.surface = surface - label.disabled = disabled + label.isEnabled = isEnabled } } diff --git a/VDS/Components/BadgeIndicator/BadgeIndicator.swift b/VDS/Components/BadgeIndicator/BadgeIndicator.swift index acf43519..c71b4f31 100644 --- a/VDS/Components/BadgeIndicator/BadgeIndicator.swift +++ b/VDS/Components/BadgeIndicator/BadgeIndicator.swift @@ -341,7 +341,7 @@ open class BadgeIndicator: View { label.textColorConfiguration = textColorConfiguration.eraseToAnyColorable() label.text = getText() label.surface = surface - label.disabled = disabled + label.isEnabled = isEnabled label.sizeToFit() setNeedsLayout() layoutIfNeeded() diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index 46b8bb39..437eea9d 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -55,16 +55,6 @@ open class Label: UILabel, ViewProtocol, UserInfoable { } } - /// Whether this object is disabled or not - open var disabled: Bool { - get { !isEnabled } - set { - if !isEnabled != newValue { - isEnabled = !newValue - } - } - } - /// Whether the View is enabled or not. open override var isEnabled: Bool { didSet { setNeedsUpdate(); isUserInteractionEnabled = isEnabled } } @@ -123,7 +113,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable { open func reset() { shouldUpdateView = false surface = .light - disabled = false + isEnabled = true attributes = nil textStyle = .defaultStyle textPosition = .left diff --git a/VDS/Components/RadioBox/RadioBoxItem.swift b/VDS/Components/RadioBox/RadioBoxItem.swift index e789785e..b9f16b5e 100644 --- a/VDS/Components/RadioBox/RadioBoxItem.swift +++ b/VDS/Components/RadioBox/RadioBoxItem.swift @@ -187,14 +187,14 @@ open class RadioBoxItem: Control, Changeable { //text label textLabel.text = text textLabel.surface = surface - textLabel.disabled = disabled + textLabel.isEnabled = isEnabled textLabel.attributes = textAttributes //subText label if let subText { subTextLabel.text = subText subTextLabel.surface = surface - subTextLabel.disabled = disabled + subTextLabel.isEnabled = isEnabled subTextLabel.attributes = subTextAttributes subTextLabel.isHidden = false @@ -209,7 +209,7 @@ open class RadioBoxItem: Control, Changeable { if let subTextRight { subTextRightLabel.text = subTextRight subTextRightLabel.surface = surface - subTextRightLabel.disabled = disabled + subTextRightLabel.isEnabled = isEnabled subTextRightLabel.attributes = subTextRightAttributes subTextRightLabel.isHidden = false diff --git a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift index 25827392..6ee3e4b9 100644 --- a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift +++ b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift @@ -132,7 +132,7 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase, UICo label.textStyle = .bodySmall label.text = selectedHandler?.text ?? " " label.surface = surface - label.disabled = disabled + label.isEnabled = isEnabled collectionView.reloadData() } diff --git a/VDS/Components/TextFields/EntryField/EntryField.swift b/VDS/Components/TextFields/EntryField/EntryField.swift index 819e805e..f581d54a 100644 --- a/VDS/Components/TextFields/EntryField/EntryField.swift +++ b/VDS/Components/TextFields/EntryField/EntryField.swift @@ -301,7 +301,7 @@ open class EntryField: Control, Changeable { titleLabel.text = updatedLabelText titleLabel.attributes = attributes titleLabel.surface = surface - titleLabel.disabled = disabled + titleLabel.isEnabled = isEnabled } @@ -309,7 +309,7 @@ open class EntryField: Control, Changeable { if showError, let errorText { errorLabel.text = errorText errorLabel.surface = surface - errorLabel.disabled = disabled + errorLabel.isEnabled = isEnabled errorLabel.isHidden = false icon.name = .error icon.color = VDSColor.paletteBlack @@ -326,7 +326,7 @@ open class EntryField: Control, Changeable { if let helperText { helperLabel.text = helperText helperLabel.surface = surface - helperLabel.disabled = disabled + helperLabel.isEnabled = isEnabled helperLabel.isHidden = false } else { helperLabel.isHidden = true diff --git a/VDS/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift index f6df3da8..1a3862ac 100644 --- a/VDS/Components/TextFields/InputField/InputField.swift +++ b/VDS/Components/TextFields/InputField/InputField.swift @@ -175,7 +175,7 @@ open class InputField: EntryField, UITextFieldDelegate { } else if showSuccess, let successText { successLabel.text = successText successLabel.surface = surface - successLabel.disabled = disabled + successLabel.isEnabled = isEnabled successLabel.isHidden = false errorLabel.isHidden = true icon.name = .checkmarkAlt diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index cfdef454..445a8732 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -234,7 +234,7 @@ open class Toggle: Control, Changeable { label.textStyle = textStyle label.text = statusText label.surface = surface - label.disabled = disabled + label.isEnabled = isEnabled switch textPosition { case .left: NSLayoutConstraint.deactivate(rightConstraints) diff --git a/VDS/Components/Tooltip/TrailingTooltipLabel.swift b/VDS/Components/Tooltip/TrailingTooltipLabel.swift index 4a1be607..32f255b1 100644 --- a/VDS/Components/Tooltip/TrailingTooltipLabel.swift +++ b/VDS/Components/Tooltip/TrailingTooltipLabel.swift @@ -71,7 +71,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable { label.textPosition = labelTextPosition label.attributes = labelAttributes label.surface = surface - label.disabled = disabled + label.isEnabled = isEnabled //add tooltip if let labelText, !labelText.isEmpty {