updated controls for reset()

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-11-15 10:10:04 -06:00
parent 9b75fd4edc
commit 00f1418e69
11 changed files with 196 additions and 23 deletions

View File

@ -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
}
}
}

View File

@ -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()
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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()
}

View File

@ -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()
}

View File

@ -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()
}

View File

@ -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()
}

View File

@ -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

View File

@ -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

View File

@ -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()