refactored radioButton to new color states

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-12-08 12:48:24 -06:00
parent b1cf47154e
commit 4ac73e3d38

View File

@ -131,6 +131,16 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
open var showError: Bool = false { didSet { didChange() }} open var showError: Bool = false { didSet { didChange() }}
open override var state: UIControl.State {
get {
var state = super.state
if showError {
state.insert(.error)
}
return state
}
}
open var errorText: String? { didSet { didChange() }} open var errorText: String? { didSet { didChange() }}
open var inputId: String? { didSet { didChange() }} open var inputId: String? { didSet { didChange() }}
@ -178,6 +188,7 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
isAccessibilityElement = true isAccessibilityElement = true
accessibilityTraits = .button accessibilityTraits = .button
addSubview(mainStackView) addSubview(mainStackView)
mainStackView.isUserInteractionEnabled = false
mainStackView.addArrangedSubview(selectorStackView) mainStackView.addArrangedSubview(selectorStackView)
mainStackView.addArrangedSubview(errorLabel) mainStackView.addArrangedSubview(errorLabel)
@ -322,36 +333,31 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
public let radioButtonSize = CGSize(width: 20, height: 20) public let radioButtonSize = CGSize(width: 20, height: 20)
public let radioButtonSelectedSize = CGSize(width: 10, height: 10) public let radioButtonSelectedSize = CGSize(width: 10, height: 10)
private var radioButtonBackgroundColorConfiguration = ErrorBinaryDisabledSurfaceColorConfiguration().with { private var radioButtonBackgroundColorConfiguration: ControlColorConfiguration = {
//error doesn't care enabled/disable var config = ControlColorConfiguration()
$0.error.forTrue.lightColor = VDSColor.elementsPrimaryOnlight config.setSurfaceColors(VDSColor.feedbackErrorBackgroundOnlight, VDSColor.feedbackErrorBackgroundOndark, forState: [.error])
$0.error.forTrue.darkColor = VDSColor.elementsPrimaryOndark return config
$0.error.forFalse.lightColor = VDSColor.feedbackErrorBackgroundOnlight }()
$0.error.forFalse.darkColor = VDSColor.feedbackErrorBackgroundOndark
}
private var radioButtonBorderColorConfiguration = ErrorBinaryDisabledSurfaceColorConfiguration().with { private var radioButtonBorderColorConfiguration: ControlColorConfiguration = {
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOnlight var config = ControlColorConfiguration()
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark config.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: [.selected])
$0.forFalse.enabled.lightColor = VDSFormControlsColor.borderOnlight config.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: [.highlighted])
$0.forFalse.enabled.darkColor = VDSFormControlsColor.borderOndark config.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: [.error, .highlighted])
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight config.setSurfaceColors(VDSFormControlsColor.borderOnlight, VDSFormControlsColor.borderOndark, forState: [.normal])
$0.forTrue.disabled.darkColor = VDSColor.interactiveDisabledOndark config.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: [.selected, .disabled])
$0.forFalse.disabled.lightColor = VDSColor.interactiveDisabledOnlight config.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: [.normal, .disabled])
$0.forFalse.disabled.darkColor = VDSColor.interactiveDisabledOndark config.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: [.error, .disabled])
//error doesn't care enabled/disable config.setSurfaceColors(VDSColor.feedbackErrorOnlight, VDSColor.feedbackErrorOndark, forState: [.error])
$0.error.forTrue.lightColor = VDSColor.elementsPrimaryOnlight return config
$0.error.forTrue.darkColor = VDSColor.elementsPrimaryOndark }()
$0.error.forFalse.lightColor = VDSColor.feedbackErrorOnlight
$0.error.forFalse.darkColor = VDSColor.feedbackErrorOndark
}
private var radioButtonCheckColorConfiguration = BinaryDisabledSurfaceColorConfiguration().with { private var radioButtonCheckColorConfiguration: ControlColorConfiguration = {
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOnlight var config = ControlColorConfiguration()
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark config.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .selected)
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight config.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: [.selected, .disabled])
$0.forTrue.disabled.darkColor = VDSColor.interactiveDisabledOndark return config
} }()
//-------------------------------------------------- //--------------------------------------------------
// MARK: - RadioButton View // MARK: - RadioButton View