updated icon to statusIcon and iconColorConfiguration

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-04-19 14:55:29 -05:00
parent 3497807d1c
commit 37890e0c88
3 changed files with 26 additions and 34 deletions

View File

@ -89,12 +89,6 @@ open class DropdownSelect: EntryFieldBase {
// MARK: - Configuration Properties // MARK: - Configuration Properties
//-------------------------------------------------- //--------------------------------------------------
internal override var containerSize: CGSize { CGSize(width: showInlineLabel ? minWidthInlineLabel : width ?? minWidthDefault, height: 44) } internal override var containerSize: CGSize { CGSize(width: showInlineLabel ? minWidthInlineLabel : width ?? minWidthDefault, height: 44) }
internal let iconColorConfiguration = ControlColorConfiguration().with {
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .normal)
$0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: .disabled)
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .error)
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Overrides // MARK: - Overrides
@ -240,11 +234,11 @@ open class DropdownSelect: EntryFieldBase {
open override func updateErrorLabel() { open override func updateErrorLabel() {
super.updateErrorLabel() super.updateErrorLabel()
if !showError && !hasInternalError { if !showError && !hasInternalError {
icon.name = .downCaret statusIcon.name = .downCaret
} }
icon.surface = surface statusIcon.surface = surface
icon.isHidden = readOnly ? true : false statusIcon.isHidden = readOnly ? true : false
icon.color = iconColorConfiguration.getColor(self) statusIcon.color = iconColorConfiguration.getColor(self)
} }
@objc open func pickerDoneClicked() { @objc open func pickerDoneClicked() {

View File

@ -112,6 +112,12 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
$0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: [.disabled,.error]) $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: [.disabled,.error])
} }
internal let iconColorConfiguration = ControlColorConfiguration().with {
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .normal)
$0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: .disabled)
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .error)
}
internal var readOnlyBorderColorConfiguration = ControlColorConfiguration().with { internal var readOnlyBorderColorConfiguration = ControlColorConfiguration().with {
$0.setSurfaceColors(VDSFormControlsColor.borderReadonlyOnlight, VDSFormControlsColor.borderReadonlyOndark, forState: .normal) $0.setSurfaceColors(VDSFormControlsColor.borderReadonlyOnlight, VDSFormControlsColor.borderReadonlyOndark, forState: .normal)
} }
@ -142,7 +148,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
$0.textStyle = .bodySmall $0.textStyle = .bodySmall
} }
open var icon: Icon = Icon().with { open var statusIcon: Icon = Icon().with {
$0.size = .medium $0.size = .medium
} }
@ -248,7 +254,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
//add the view to add input fields //add the view to add input fields
containerStackView.addArrangedSubview(controlContainerView) containerStackView.addArrangedSubview(controlContainerView)
containerStackView.addArrangedSubview(icon) containerStackView.addArrangedSubview(statusIcon)
containerStackView.setCustomSpacing(VDSLayout.space3X, after: controlContainerView) containerStackView.setCustomSpacing(VDSLayout.space3X, after: controlContainerView)
//get the container this is what show helper text, error text //get the container this is what show helper text, error text
@ -379,32 +385,30 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
errorLabel.surface = surface errorLabel.surface = surface
errorLabel.isEnabled = isEnabled errorLabel.isEnabled = isEnabled
errorLabel.isHidden = false errorLabel.isHidden = false
icon.name = .error statusIcon.name = .error
icon.color = VDSColor.paletteBlack statusIcon.surface = surface
icon.surface = surface statusIcon.isHidden = !isEnabled
icon.isHidden = !isEnabled
} else if showError, let errorText { } else if showError, let errorText {
errorLabel.text = errorText errorLabel.text = errorText
errorLabel.surface = surface errorLabel.surface = surface
errorLabel.isEnabled = isEnabled errorLabel.isEnabled = isEnabled
errorLabel.isHidden = false errorLabel.isHidden = false
icon.name = .error statusIcon.name = .error
icon.color = VDSColor.paletteBlack statusIcon.surface = surface
icon.surface = surface statusIcon.isHidden = !isEnabled
icon.isHidden = !isEnabled
} else if hasInternalError, let internalErrorText { } else if hasInternalError, let internalErrorText {
errorLabel.text = internalErrorText errorLabel.text = internalErrorText
errorLabel.surface = surface errorLabel.surface = surface
errorLabel.isEnabled = isEnabled errorLabel.isEnabled = isEnabled
errorLabel.isHidden = false errorLabel.isHidden = false
icon.name = .error statusIcon.name = .error
icon.color = VDSColor.paletteBlack statusIcon.surface = surface
icon.surface = surface statusIcon.isHidden = !isEnabled
icon.isHidden = !isEnabled
} else { } else {
icon.isHidden = true statusIcon.isHidden = true
errorLabel.isHidden = true errorLabel.isHidden = true
} }
statusIcon.color = iconColorConfiguration.getColor(self)
} }
open func updateHelperLabel(){ open func updateHelperLabel(){

View File

@ -138,12 +138,7 @@ open class TextArea: EntryFieldBase {
setNeedsUpdate() setNeedsUpdate()
} }
} }
/// Color configuration for error icon.
internal var iconColorConfiguration = ControlColorConfiguration().with {
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .normal)
}
/// Color configuration for character counter's highlight background color /// Color configuration for character counter's highlight background color
internal var highlightBackgroundColor = ControlColorConfiguration().with { internal var highlightBackgroundColor = ControlColorConfiguration().with {
$0.setSurfaceColors(VDSColor.backgroundPrimaryDark, VDSColor.backgroundPrimaryLight, forState: .normal) $0.setSurfaceColors(VDSColor.backgroundPrimaryDark, VDSColor.backgroundPrimaryLight, forState: .normal)
@ -219,8 +214,7 @@ open class TextArea: EntryFieldBase {
characterCounterLabel.text = getCharacterCounterText() characterCounterLabel.text = getCharacterCounterText()
icon.size = .medium statusIcon.color = iconColorConfiguration.getColor(self)
icon.color = iconColorConfiguration.getColor(self)
containerView.layer.borderColor = readOnly ? readOnlyBorderColorConfiguration.getColor(self).cgColor : borderColorConfiguration.getColor(self).cgColor containerView.layer.borderColor = readOnly ? readOnlyBorderColorConfiguration.getColor(self).cgColor : borderColorConfiguration.getColor(self).cgColor
textView.isEditable = readOnly ? false : true textView.isEditable = readOnly ? false : true
textView.backgroundColor = backgroundColorConfiguration.getColor(self) textView.backgroundColor = backgroundColorConfiguration.getColor(self)
@ -240,7 +234,7 @@ open class TextArea: EntryFieldBase {
open override func updateAccessibility() { open override func updateAccessibility() {
super.updateAccessibility() super.updateAccessibility()
if showError { if showError {
accessibilityElements = [titleLabel, textView, icon, errorLabel, helperLabel] accessibilityElements = [titleLabel, textView, statusIcon, errorLabel, helperLabel]
} else { } else {
accessibilityElements = [titleLabel, textView, helperLabel] accessibilityElements = [titleLabel, textView, helperLabel]
} }