From 00f1418e693c2adf79e742e3b2e45abf732898d9 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 15 Nov 2022 10:10:04 -0600 Subject: [PATCH] updated controls for reset() Signed-off-by: Matt Bruce --- VDS/Classes/Control.swift | 4 +- VDS/Components/Badge/Badge.swift | 18 ++++++-- .../Buttons/TextLink/TextLink.swift | 4 +- .../Buttons/TextLinkCaret/TextLinkCaret.swift | 5 +++ VDS/Components/Checkbox/Checkbox.swift | 26 +++++++++++ VDS/Components/RadioBox/RadioBox.swift | 29 ++++++++++++ VDS/Components/RadioButton/RadioButton.swift | 42 ++++++++++++++---- VDS/Components/RadioSwatch/RadioSwatch.swift | 18 ++++++++ .../TextFields/EntryField/EntryField.swift | 44 ++++++++++++++++--- .../TextEntryField/TextEntryField.swift | 16 ++++++- VDS/Components/Toggle/Toggle.swift | 13 ++++++ 11 files changed, 196 insertions(+), 23 deletions(-) diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 0f7a2631..12e8fba4 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -86,7 +86,7 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable { open func reset() { backgroundColor = .clear surface = .light - disabled = false + disabled = false } // MARK: - ViewProtocol @@ -94,5 +94,5 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable { open func setup() { translatesAutoresizingMaskIntoConstraints = false insetsLayoutMarginsFromSafeArea = false - } + } } diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index f7da7374..94c4b8e0 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -21,9 +21,6 @@ public class Badge: View, Accessable { private var label = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.adjustsFontSizeToFitWidth = false - $0.lineBreakMode = .byTruncatingTail - $0.textPosition = .left - $0.typograpicalStyle = .BoldBodySmall } //-------------------------------------------------- @@ -83,6 +80,21 @@ public class Badge: View, Accessable { public override func reset() { super.reset() label.reset() + label.lineBreakMode = .byTruncatingTail + label.textPosition = .left + label.typograpicalStyle = .BoldBodySmall + + fillColor = .red + text = "" + maxWidth = nil + numberOfLines = 1 + accessibilityHintEnabled = nil + accessibilityHintDisabled = nil + accessibilityValueEnabled = nil + accessibilityValueDisabled = nil + accessibilityLabelEnabled = nil + accessibilityLabelDisabled = nil + setAccessibilityLabel() } diff --git a/VDS/Components/Buttons/TextLink/TextLink.swift b/VDS/Components/Buttons/TextLink/TextLink.swift index 2a8b9335..d1287c2e 100644 --- a/VDS/Components/Buttons/TextLink/TextLink.swift +++ b/VDS/Components/Buttons/TextLink/TextLink.swift @@ -83,8 +83,10 @@ open class TextLink: Control { open override func reset() { super.reset() - size = .large label.reset() + size = .large + text = nil + accessibilityCustomActions = [] accessibilityTraits = .staticText } diff --git a/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift b/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift index 6fa22280..83958072 100644 --- a/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift +++ b/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift @@ -97,6 +97,11 @@ open class TextLinkCaret: Control { open override func reset() { super.reset() label.reset() + + label.typograpicalStyle = TypographicalStyle.BoldBodyLarge + text = nil + iconPosition = .right + accessibilityCustomActions = [] accessibilityTraits = .staticText } diff --git a/VDS/Components/Checkbox/Checkbox.swift b/VDS/Components/Checkbox/Checkbox.swift index f2565c49..3a515eb4 100644 --- a/VDS/Components/Checkbox/Checkbox.swift +++ b/VDS/Components/Checkbox/Checkbox.swift @@ -258,6 +258,32 @@ open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Er label.reset() childLabel.reset() errorLabel.reset() + + label.typograpicalStyle = .BoldBodyLarge + childLabel.typograpicalStyle = .BodyLarge + errorLabel.typograpicalStyle = .BodyMedium + + labelText = nil + labelTextAttributes = nil + labelAttributedText = nil + childText = nil + childTextAttributes = nil + childAttributedText = nil + showError = false + errorText = nil + inputId = nil + value = nil + dataAnalyticsTrack = nil + dataClickStream = nil + dataTrack = nil + accessibilityHintEnabled = nil + accessibilityHintDisabled = nil + accessibilityValueEnabled = nil + accessibilityValueDisabled = nil + accessibilityLabelEnabled = nil + accessibilityLabelDisabled = nil + isSelected = false + updateSelector() setAccessibilityLabel() } diff --git a/VDS/Components/RadioBox/RadioBox.swift b/VDS/Components/RadioBox/RadioBox.swift index 6bc9b02a..d9245790 100644 --- a/VDS/Components/RadioBox/RadioBox.swift +++ b/VDS/Components/RadioBox/RadioBox.swift @@ -236,6 +236,35 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{ textLabel.reset() subTextLabel.reset() subTextRightLabel.reset() + + textLabel.typograpicalStyle = .BoldBodyLarge + subTextLabel.typograpicalStyle = .BodyLarge + subTextRightLabel.typograpicalStyle = .BodyLarge + + text = "Default Text" + textAttributes = nil + textAttributedText = nil + subText = nil + subTextAttributes = nil + subTextAttributedText = nil + subTextRight = nil + subTextRightAttributes = nil + subTextRightAttributedText = nil + strikethrough = false + inputId = nil + value = nil + dataAnalyticsTrack = nil + dataClickStream = nil + dataTrack = nil + accessibilityHintEnabled = nil + accessibilityHintDisabled = nil + accessibilityValueEnabled = nil + accessibilityValueDisabled = nil + accessibilityLabelEnabled = nil + accessibilityLabelDisabled = nil + + isSelected = false + updateSelector() setAccessibilityLabel() } diff --git a/VDS/Components/RadioButton/RadioButton.swift b/VDS/Components/RadioButton/RadioButton.swift index dae5f322..f52f2a09 100644 --- a/VDS/Components/RadioButton/RadioButton.swift +++ b/VDS/Components/RadioButton/RadioButton.swift @@ -82,14 +82,20 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable, private var label = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) + $0.textPosition = .left + $0.typograpicalStyle = .BoldBodyLarge } private var childLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) + $0.textPosition = .left + $0.typograpicalStyle = .BodyLarge } private var errorLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) + $0.textPosition = .left + $0.typograpicalStyle = .BodyMedium } //-------------------------------------------------- @@ -194,15 +200,6 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable, mainStackView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true mainStackView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true - //defaults - label.textPosition = .left - label.typograpicalStyle = .BoldBodyLarge - - childLabel.textPosition = .left - childLabel.typograpicalStyle = .BodyLarge - - errorLabel.textPosition = .left - errorLabel.typograpicalStyle = .BodyMedium } func updateLabels() { @@ -268,6 +265,33 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable, label.reset() childLabel.reset() errorLabel.reset() + + label.typograpicalStyle = .BoldBodyLarge + childLabel.typograpicalStyle = .BodyLarge + errorLabel.typograpicalStyle = .BodyMedium + + labelText = nil + labelTextAttributes = nil + labelAttributedText = nil + childText = nil + childTextAttributes = nil + childAttributedText = nil + showError = false + errorText = nil + inputId = nil + value = nil + dataAnalyticsTrack = nil + dataClickStream = nil + dataTrack = nil + accessibilityHintEnabled = nil + accessibilityHintDisabled = nil + accessibilityValueEnabled = nil + accessibilityValueDisabled = nil + accessibilityLabelEnabled = nil + accessibilityLabelDisabled = nil + + isSelected = false + updateSelector() setAccessibilityLabel() } diff --git a/VDS/Components/RadioSwatch/RadioSwatch.swift b/VDS/Components/RadioSwatch/RadioSwatch.swift index 758e5911..520262d1 100644 --- a/VDS/Components/RadioSwatch/RadioSwatch.swift +++ b/VDS/Components/RadioSwatch/RadioSwatch.swift @@ -122,6 +122,24 @@ open class RadioSwatchBase: Control, Accessable, DataTrackable, BinaryColorable public override func reset() { super.reset() + + fillImage = nil + text = "" + primaryColor = nil + secondaryColor = nil + strikethrough = false + inputId = nil + value = nil + dataAnalyticsTrack = nil + dataClickStream = nil + dataTrack = nil + accessibilityHintEnabled = nil + accessibilityHintDisabled = nil + accessibilityValueEnabled = nil + accessibilityValueDisabled = nil + accessibilityLabelEnabled = nil + accessibilityLabelDisabled = nil + setNeedsDisplay() setAccessibilityLabel() } diff --git a/VDS/Components/TextFields/EntryField/EntryField.swift b/VDS/Components/TextFields/EntryField/EntryField.swift index 65c1533f..3d8cfce0 100644 --- a/VDS/Components/TextFields/EntryField/EntryField.swift +++ b/VDS/Components/TextFields/EntryField/EntryField.swift @@ -46,14 +46,20 @@ open class EntryField: Control, Accessable { internal var titleLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.attributes = [] + $0.textPosition = .left + $0.typograpicalStyle = .BodySmall } internal var errorLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) + $0.textPosition = .left + $0.typograpicalStyle = .BodySmall } internal var helperLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) + $0.textPosition = .left + $0.typograpicalStyle = .BodySmall } internal var containerView: UIView = { @@ -256,6 +262,38 @@ open class EntryField: Control, Accessable { public override func reset() { super.reset() + titleLabel.reset() + errorLabel.reset() + helperLabel.reset() + + titleLabel.textPosition = .left + titleLabel.typograpicalStyle = .BodySmall + errorLabel.textPosition = .left + errorLabel.typograpicalStyle = .BodySmall + helperLabel.textPosition = .left + helperLabel.typograpicalStyle = .BodySmall + + labelText = nil + helperText = nil + showError = false + errorText = nil + tooltipTitle = nil + tooltipContent = nil + transparentBackground = false + width = nil + maxLength = nil + inputId = nil + value = nil + defaultValue = nil + required = false + readOnly = false + accessibilityHintEnabled = nil + accessibilityHintDisabled = nil + accessibilityValueEnabled = nil + accessibilityValueDisabled = nil + accessibilityLabelEnabled = nil + accessibilityLabelDisabled = nil + setAccessibilityLabel() } @@ -313,8 +351,6 @@ open class EntryField: Control, Accessable { } //set the titleLabel - titleLabel.textPosition = .left - titleLabel.typograpicalStyle = .BodySmall titleLabel.text = updatedLabelText titleLabel.attributes = attributes titleLabel.surface = surface @@ -324,8 +360,6 @@ open class EntryField: Control, Accessable { open func updateErrorLabel(){ if showError, let errorText { - errorLabel.textPosition = .left - errorLabel.typograpicalStyle = .BodySmall errorLabel.text = errorText errorLabel.surface = surface errorLabel.disabled = disabled @@ -338,8 +372,6 @@ open class EntryField: Control, Accessable { open func updateHelperLabel(){ //set the helper label position if let helperText { - helperLabel.textPosition = .left - helperLabel.typograpicalStyle = .BodySmall helperLabel.text = helperText helperLabel.surface = surface helperLabel.disabled = disabled diff --git a/VDS/Components/TextFields/TextEntryField/TextEntryField.swift b/VDS/Components/TextFields/TextEntryField/TextEntryField.swift index f64e27e9..c0eee646 100644 --- a/VDS/Components/TextFields/TextEntryField/TextEntryField.swift +++ b/VDS/Components/TextFields/TextEntryField/TextEntryField.swift @@ -60,6 +60,8 @@ open class TextEntryFieldBase: EntryField { private var successLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) + $0.textPosition = .left + $0.typograpicalStyle = .BodySmall } internal var minWidthConstraint: NSLayoutConstraint? @@ -80,6 +82,18 @@ open class TextEntryFieldBase: EntryField { } + public override func reset() { + super.reset() + successLabel.reset() + successLabel.textPosition = .left + successLabel.typograpicalStyle = .BodySmall + + type = .text + showSuccess = false + successText = nil + helperTextPlacement = .bottom + } + open override func getContainer() -> UIView { containerStackView.addArrangedSubview(containerView) return containerStackView @@ -126,8 +140,6 @@ open class TextEntryFieldBase: EntryField { successLabel.isHidden = true } else if showSuccess, let successText { - successLabel.textPosition = .left - successLabel.typograpicalStyle = .BodySmall successLabel.text = successText successLabel.surface = surface successLabel.disabled = disabled diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index b7782e1e..0694d0fb 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -295,6 +295,19 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { public override func reset() { super.reset() label.reset() + isSelected = false + isOn = false + + isAnimated = true + showText = false + onText = "On" + offText = "Off" + textSize = .small + textWeight = .regular + textPosition = .left + inputId = nil + value = nil + toggleView.backgroundColor = toggleColorConfiguration.getColor(self) knobView.backgroundColor = knobColorConfiguration.getColor(self) setAccessibilityLabel()