Digital ACT-191 ONEAPP-7135 story: color configurations as per states
This commit is contained in:
parent
e3b6b832e2
commit
e5d8b12bd6
@ -175,6 +175,12 @@ open class DropdownSelect: Control {
|
|||||||
$0.setSurfaceColors(VDSColor.elementsSecondaryOnlight, VDSColor.elementsSecondaryOndark, forDisabled: false)
|
$0.setSurfaceColors(VDSColor.elementsSecondaryOnlight, VDSColor.elementsSecondaryOndark, forDisabled: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal let iconColorConfig = 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 backgroundColorConfiguration = ControlColorConfiguration().with {
|
internal var backgroundColorConfiguration = ControlColorConfiguration().with {
|
||||||
$0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .normal)
|
$0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .normal)
|
||||||
$0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .disabled)
|
$0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .disabled)
|
||||||
@ -185,6 +191,16 @@ open class DropdownSelect: Control {
|
|||||||
$0.setSurfaceColors(VDSFormControlsColor.borderOnlight, VDSFormControlsColor.borderOnlight, forState: .normal)
|
$0.setSurfaceColors(VDSFormControlsColor.borderOnlight, VDSFormControlsColor.borderOnlight, forState: .normal)
|
||||||
$0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: .disabled)
|
$0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: .disabled)
|
||||||
$0.setSurfaceColors(VDSColor.feedbackErrorOnlight, VDSColor.feedbackErrorOndark, forState: .error)
|
$0.setSurfaceColors(VDSColor.feedbackErrorOnlight, VDSColor.feedbackErrorOndark, forState: .error)
|
||||||
|
$0.setSurfaceColors(VDSFormControlsColor.borderHoverOnlight, VDSFormControlsColor.borderHoverOndark, forState: .focused)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal var errorBorderColorConfiguration = ControlColorConfiguration().with {
|
||||||
|
$0.setSurfaceColors(VDSColor.feedbackErrorOnlight, VDSColor.feedbackErrorOndark, forState: .error)
|
||||||
|
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .focused)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal var readOnlyBorderColorConfiguration = ControlColorConfiguration().with {
|
||||||
|
$0.setSurfaceColors(VDSFormControlsColor.borderReadonlyOnlight, VDSFormControlsColor.borderReadonlyOndark, forState: .normal)
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -238,6 +254,8 @@ open class DropdownSelect: Control {
|
|||||||
errorLabel.textColorConfiguration = primaryColorConfig.eraseToAnyColorable()
|
errorLabel.textColorConfiguration = primaryColorConfig.eraseToAnyColorable()
|
||||||
helperLabel.textColorConfiguration = secondaryColorConfig.eraseToAnyColorable()
|
helperLabel.textColorConfiguration = secondaryColorConfig.eraseToAnyColorable()
|
||||||
inlineDisplayLabel.textColorConfiguration = primaryColorConfig.eraseToAnyColorable()
|
inlineDisplayLabel.textColorConfiguration = primaryColorConfig.eraseToAnyColorable()
|
||||||
|
selectedOptionLabel.textColorConfiguration = primaryColorConfig.eraseToAnyColorable()
|
||||||
|
icon.color = iconColorConfig.getColor(self)
|
||||||
|
|
||||||
optionsPicker.delegate = self
|
optionsPicker.delegate = self
|
||||||
optionsPicker.dataSource = self
|
optionsPicker.dataSource = self
|
||||||
@ -251,16 +269,20 @@ open class DropdownSelect: Control {
|
|||||||
|
|
||||||
/// Used to make changes to the View based off a change events or from local properties.
|
/// Used to make changes to the View based off a change events or from local properties.
|
||||||
open override func updateView() {
|
open override func updateView() {
|
||||||
|
|
||||||
container.backgroundColor = backgroundColorConfiguration.getColor(self)
|
container.backgroundColor = backgroundColorConfiguration.getColor(self)
|
||||||
container.layer.borderColor = containerBorderColorConfiguration.getColor(self).cgColor
|
|
||||||
container.layer.borderWidth = VDSFormControls.widthBorder
|
container.layer.borderWidth = VDSFormControls.widthBorder
|
||||||
container.layer.cornerRadius = VDSFormControls.borderradius
|
container.layer.cornerRadius = VDSFormControls.borderradius
|
||||||
|
container.layer.borderColor = readOnly ? readOnlyBorderColorConfiguration.getColor(self).cgColor : (showError ? errorBorderColorConfiguration.getColor(self).cgColor : containerBorderColorConfiguration.getColor(self).cgColor)
|
||||||
|
dropdownField.isUserInteractionEnabled = readOnly ? false : true
|
||||||
|
|
||||||
updateTitleLabel()
|
updateTitleLabel()
|
||||||
updateInlineLabel()
|
updateInlineLabel()
|
||||||
updateErrorLabel()
|
updateErrorLabel()
|
||||||
updateHelperLabel()
|
updateHelperLabel()
|
||||||
|
if readOnly {
|
||||||
|
icon.name = nil
|
||||||
|
}
|
||||||
selectedOptionLabel.surface = surface
|
selectedOptionLabel.surface = surface
|
||||||
backgroundColor = surface.color
|
backgroundColor = surface.color
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user