refactored to use color configuartion and remove tap gesture
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
1791718c75
commit
081e60ddba
@ -160,14 +160,10 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{
|
|||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.setup()
|
super.setup()
|
||||||
|
|
||||||
//add tapGesture to self
|
|
||||||
publisher(for: UITapGestureRecognizer()).sink { [weak self] _ in
|
|
||||||
self?.sendActions(for: .touchUpInside)
|
|
||||||
}.store(in: &subscribers)
|
|
||||||
|
|
||||||
isAccessibilityElement = true
|
isAccessibilityElement = true
|
||||||
accessibilityTraits = .button
|
accessibilityTraits = .button
|
||||||
addSubview(selectorView)
|
addSubview(selectorView)
|
||||||
|
selectorView.isUserInteractionEnabled = false
|
||||||
|
|
||||||
selectorView.addSubview(mainStackView)
|
selectorView.addSubview(mainStackView)
|
||||||
|
|
||||||
@ -289,29 +285,21 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{
|
|||||||
private var selectorCornerRadius: CGFloat = 4.0
|
private var selectorCornerRadius: CGFloat = 4.0
|
||||||
private var selectorBorderWidthSelected: CGFloat = 2.0
|
private var selectorBorderWidthSelected: CGFloat = 2.0
|
||||||
private var selectorBorderWidth: CGFloat = 1.0
|
private var selectorBorderWidth: CGFloat = 1.0
|
||||||
|
|
||||||
private var radioBoxBackgroundColorConfiguration = BinaryDisabledSurfaceColorConfiguration().with {
|
private var backgroundColorConfiguration = ControlColorConfiguration().with {
|
||||||
$0.forFalse.enabled.lightColor = VDSFormControlsColor.backgroundOnlight
|
$0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .normal)
|
||||||
$0.forFalse.enabled.darkColor = VDSFormControlsColor.backgroundOndark
|
$0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .disabled)
|
||||||
$0.forFalse.disabled.lightColor = VDSFormControlsColor.backgroundOnlight
|
$0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .selected)
|
||||||
$0.forFalse.disabled.darkColor = VDSFormControlsColor.backgroundOndark
|
$0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: [.selected, .disabled])
|
||||||
|
$0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .highlighted)
|
||||||
$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 radioBoxBorderColorConfiguration = BinaryDisabledSurfaceColorConfiguration().with {
|
private var borderColorConfiguration = ControlColorConfiguration().with {
|
||||||
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOnlight
|
$0.setSurfaceColors(VDSFormControlsColor.borderOnlight, VDSFormControlsColor.borderOndark, forState: .normal)
|
||||||
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark
|
$0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: .disabled)
|
||||||
$0.forFalse.enabled.lightColor = VDSFormControlsColor.borderOnlight
|
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .selected)
|
||||||
$0.forFalse.enabled.darkColor = VDSFormControlsColor.borderOndark
|
$0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: [.selected, .disabled])
|
||||||
|
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .highlighted)
|
||||||
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight
|
|
||||||
$0.forTrue.disabled.darkColor = VDSColor.interactiveDisabledOndark
|
|
||||||
$0.forFalse.disabled.lightColor = VDSColor.interactiveDisabledOnlight
|
|
||||||
$0.forFalse.disabled.darkColor = VDSColor.interactiveDisabledOndark
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -323,8 +311,8 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{
|
|||||||
|
|
||||||
open func updateSelector() {
|
open func updateSelector() {
|
||||||
//get the colors
|
//get the colors
|
||||||
let backgroundColor = radioBoxBackgroundColorConfiguration.getColor(self)
|
let backgroundColor = backgroundColorConfiguration.getColor(self)
|
||||||
let borderColor = radioBoxBorderColorConfiguration.getColor(self)
|
let borderColor = borderColorConfiguration.getColor(self)
|
||||||
let borderWidth = isSelected ? selectorBorderWidthSelected : selectorBorderWidth
|
let borderWidth = isSelected ? selectorBorderWidthSelected : selectorBorderWidth
|
||||||
|
|
||||||
selectorView.backgroundColor = backgroundColor
|
selectorView.backgroundColor = backgroundColor
|
||||||
@ -343,7 +331,7 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{
|
|||||||
|
|
||||||
open override func draw(_ layer: CALayer, in ctx: CGContext) {
|
open override func draw(_ layer: CALayer, in ctx: CGContext) {
|
||||||
|
|
||||||
let borderColor = radioBoxBorderColorConfiguration.getColor(self)
|
let borderColor = borderColorConfiguration.getColor(self)
|
||||||
|
|
||||||
shapeLayer?.removeFromSuperlayer()
|
shapeLayer?.removeFromSuperlayer()
|
||||||
shapeLayer = nil
|
shapeLayer = nil
|
||||||
|
|||||||
@ -180,11 +180,6 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
|
|||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.setup()
|
super.setup()
|
||||||
|
|
||||||
//add tapGesture to self
|
|
||||||
publisher(for: UITapGestureRecognizer()).sink { [weak self] _ in
|
|
||||||
self?.sendActions(for: .touchUpInside)
|
|
||||||
}.store(in: &subscribers)
|
|
||||||
|
|
||||||
isAccessibilityElement = true
|
isAccessibilityElement = true
|
||||||
accessibilityTraits = .button
|
accessibilityTraits = .button
|
||||||
addSubview(mainStackView)
|
addSubview(mainStackView)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user