diff --git a/VDS/Components/RadioBox/RadioBox.swift b/VDS/Components/RadioBox/RadioBox.swift index ee53b936..2ffab628 100644 --- a/VDS/Components/RadioBox/RadioBox.swift +++ b/VDS/Components/RadioBox/RadioBox.swift @@ -160,14 +160,10 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{ open override func setup() { super.setup() - //add tapGesture to self - publisher(for: UITapGestureRecognizer()).sink { [weak self] _ in - self?.sendActions(for: .touchUpInside) - }.store(in: &subscribers) - isAccessibilityElement = true accessibilityTraits = .button addSubview(selectorView) + selectorView.isUserInteractionEnabled = false selectorView.addSubview(mainStackView) @@ -289,29 +285,21 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{ private var selectorCornerRadius: CGFloat = 4.0 private var selectorBorderWidthSelected: CGFloat = 2.0 private var selectorBorderWidth: CGFloat = 1.0 - - private var radioBoxBackgroundColorConfiguration = BinaryDisabledSurfaceColorConfiguration().with { - $0.forFalse.enabled.lightColor = VDSFormControlsColor.backgroundOnlight - $0.forFalse.enabled.darkColor = VDSFormControlsColor.backgroundOndark - $0.forFalse.disabled.lightColor = VDSFormControlsColor.backgroundOnlight - $0.forFalse.disabled.darkColor = VDSFormControlsColor.backgroundOndark - - $0.forTrue.enabled.lightColor = VDSFormControlsColor.backgroundOnlight - $0.forTrue.enabled.darkColor = VDSFormControlsColor.backgroundOndark - $0.forTrue.disabled.lightColor = VDSFormControlsColor.backgroundOnlight - $0.forTrue.disabled.darkColor = VDSFormControlsColor.backgroundOndark + + private var backgroundColorConfiguration = ControlColorConfiguration().with { + $0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .normal) + $0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .disabled) + $0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .selected) + $0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: [.selected, .disabled]) + $0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .highlighted) } - - private var radioBoxBorderColorConfiguration = BinaryDisabledSurfaceColorConfiguration().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 + + private var borderColorConfiguration = ControlColorConfiguration().with { + $0.setSurfaceColors(VDSFormControlsColor.borderOnlight, VDSFormControlsColor.borderOndark, forState: .normal) + $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: .disabled) + $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .selected) + $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: [.selected, .disabled]) + $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .highlighted) } //-------------------------------------------------- @@ -323,8 +311,8 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{ open func updateSelector() { //get the colors - let backgroundColor = radioBoxBackgroundColorConfiguration.getColor(self) - let borderColor = radioBoxBorderColorConfiguration.getColor(self) + let backgroundColor = backgroundColorConfiguration.getColor(self) + let borderColor = borderColorConfiguration.getColor(self) let borderWidth = isSelected ? selectorBorderWidthSelected : selectorBorderWidth selectorView.backgroundColor = backgroundColor @@ -343,7 +331,7 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{ open override func draw(_ layer: CALayer, in ctx: CGContext) { - let borderColor = radioBoxBorderColorConfiguration.getColor(self) + let borderColor = borderColorConfiguration.getColor(self) shapeLayer?.removeFromSuperlayer() shapeLayer = nil diff --git a/VDS/Components/RadioButton/RadioButton.swift b/VDS/Components/RadioButton/RadioButton.swift index 49cc28d9..fe367b27 100644 --- a/VDS/Components/RadioButton/RadioButton.swift +++ b/VDS/Components/RadioButton/RadioButton.swift @@ -180,11 +180,6 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable, open override func setup() { super.setup() - //add tapGesture to self - publisher(for: UITapGestureRecognizer()).sink { [weak self] _ in - self?.sendActions(for: .touchUpInside) - }.store(in: &subscribers) - isAccessibilityElement = true accessibilityTraits = .button addSubview(mainStackView)