refactored radioButton to new color states
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
b1cf47154e
commit
4ac73e3d38
@ -131,6 +131,16 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
|
||||
|
||||
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 inputId: String? { didSet { didChange() }}
|
||||
@ -178,7 +188,8 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
|
||||
isAccessibilityElement = true
|
||||
accessibilityTraits = .button
|
||||
addSubview(mainStackView)
|
||||
|
||||
mainStackView.isUserInteractionEnabled = false
|
||||
|
||||
mainStackView.addArrangedSubview(selectorStackView)
|
||||
mainStackView.addArrangedSubview(errorLabel)
|
||||
selectorStackView.addArrangedSubview(selectorView)
|
||||
@ -321,38 +332,33 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
|
||||
//--------------------------------------------------
|
||||
public let radioButtonSize = CGSize(width: 20, height: 20)
|
||||
public let radioButtonSelectedSize = CGSize(width: 10, height: 10)
|
||||
|
||||
private var radioButtonBackgroundColorConfiguration: ControlColorConfiguration = {
|
||||
var config = ControlColorConfiguration()
|
||||
config.setSurfaceColors(VDSColor.feedbackErrorBackgroundOnlight, VDSColor.feedbackErrorBackgroundOndark, forState: [.error])
|
||||
return config
|
||||
}()
|
||||
|
||||
private var radioButtonBorderColorConfiguration: ControlColorConfiguration = {
|
||||
var config = ControlColorConfiguration()
|
||||
config.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: [.selected])
|
||||
config.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: [.highlighted])
|
||||
config.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: [.error, .highlighted])
|
||||
config.setSurfaceColors(VDSFormControlsColor.borderOnlight, VDSFormControlsColor.borderOndark, forState: [.normal])
|
||||
config.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: [.selected, .disabled])
|
||||
config.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: [.normal, .disabled])
|
||||
config.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: [.error, .disabled])
|
||||
config.setSurfaceColors(VDSColor.feedbackErrorOnlight, VDSColor.feedbackErrorOndark, forState: [.error])
|
||||
return config
|
||||
}()
|
||||
|
||||
private var radioButtonBackgroundColorConfiguration = ErrorBinaryDisabledSurfaceColorConfiguration().with {
|
||||
//error doesn't care enabled/disable
|
||||
$0.error.forTrue.lightColor = VDSColor.elementsPrimaryOnlight
|
||||
$0.error.forTrue.darkColor = VDSColor.elementsPrimaryOndark
|
||||
$0.error.forFalse.lightColor = VDSColor.feedbackErrorBackgroundOnlight
|
||||
$0.error.forFalse.darkColor = VDSColor.feedbackErrorBackgroundOndark
|
||||
}
|
||||
|
||||
private var radioButtonBorderColorConfiguration = ErrorBinaryDisabledSurfaceColorConfiguration().with {
|
||||
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOnlight
|
||||
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark
|
||||
$0.forFalse.enabled.lightColor = VDSFormControlsColor.borderOnlight
|
||||
$0.forFalse.enabled.darkColor = VDSFormControlsColor.borderOndark
|
||||
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight
|
||||
$0.forTrue.disabled.darkColor = VDSColor.interactiveDisabledOndark
|
||||
$0.forFalse.disabled.lightColor = VDSColor.interactiveDisabledOnlight
|
||||
$0.forFalse.disabled.darkColor = VDSColor.interactiveDisabledOndark
|
||||
//error doesn't care enabled/disable
|
||||
$0.error.forTrue.lightColor = VDSColor.elementsPrimaryOnlight
|
||||
$0.error.forTrue.darkColor = VDSColor.elementsPrimaryOndark
|
||||
$0.error.forFalse.lightColor = VDSColor.feedbackErrorOnlight
|
||||
$0.error.forFalse.darkColor = VDSColor.feedbackErrorOndark
|
||||
}
|
||||
|
||||
private var radioButtonCheckColorConfiguration = BinaryDisabledSurfaceColorConfiguration().with {
|
||||
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOnlight
|
||||
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark
|
||||
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight
|
||||
$0.forTrue.disabled.darkColor = VDSColor.interactiveDisabledOndark
|
||||
}
|
||||
|
||||
private var radioButtonCheckColorConfiguration: ControlColorConfiguration = {
|
||||
var config = ControlColorConfiguration()
|
||||
config.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .selected)
|
||||
config.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: [.selected, .disabled])
|
||||
return config
|
||||
}()
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - RadioButton View
|
||||
//--------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user