moved tap back into each control since not all controls should need this

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-08-31 13:21:13 -05:00
parent 1306c9e2a9
commit 6c67544c71
7 changed files with 30 additions and 12 deletions

View File

@ -27,7 +27,6 @@ open class Control<ModelType: Modelable>: UIControl, ModelHandlerable, ViewProto
//if set to true this will call the
//defaultAction() in the class
public var executeDefaultAction = true
public var isTappable = true
@Proxy(\.model.surface)
open var surface: Surface
@ -84,7 +83,6 @@ open class Control<ModelType: Modelable>: UIControl, ModelHandlerable, ViewProto
initialSetupPerformed = true
setupUpdateView()
setup()
if isTappable { addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(Self.tap))) }
}
}
@ -104,10 +102,6 @@ open class Control<ModelType: Modelable>: UIControl, ModelHandlerable, ViewProto
defaultAction()
}
}
@objc func tap() {
sendActions(for: .touchUpInside)
}
open func defaultAction() { }

View File

@ -127,7 +127,8 @@ open class CheckboxBase<ModelType: CheckboxModel>: Control<ModelType>, Changable
open override func setup() {
super.setup()
addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(Self.tap)))
isAccessibilityElement = true
accessibilityTraits = .button
addSubview(mainStackView)
@ -204,6 +205,10 @@ open class CheckboxBase<ModelType: CheckboxModel>: Control<ModelType>, Changable
onChange = nil
}
@objc func tap() {
sendActions(for: .touchUpInside)
}
/// This will checkbox the state of the Selector and execute the actionBlock if provided.
open override func defaultAction() {
//removed error

View File

@ -128,6 +128,7 @@ open class RadioBoxBase<ModelType: RadioBoxModel>: Control<ModelType>, Changable
open override func setup() {
super.setup()
addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(Self.tap)))
isAccessibilityElement = true
accessibilityTraits = .button
@ -202,6 +203,10 @@ open class RadioBoxBase<ModelType: RadioBoxModel>: Control<ModelType>, Changable
setAccessibilityLabel()
onChange = nil
}
@objc func tap() {
sendActions(for: .touchUpInside)
}
/// This will radioBox the state of the Selector and execute the actionBlock if provided.
open override func defaultAction() {

View File

@ -126,7 +126,8 @@ open class RadioButtonBase<ModelType: RadioButtonModel>: Control<ModelType>, Cha
open override func setup() {
super.setup()
addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(Self.tap)))
isAccessibilityElement = true
accessibilityTraits = .button
addSubview(mainStackView)
@ -203,6 +204,9 @@ open class RadioButtonBase<ModelType: RadioButtonModel>: Control<ModelType>, Cha
onChange = nil
}
@objc func tap() {
sendActions(for: .touchUpInside)
}
/// This will checkbox the state of the Selector and execute the actionBlock if provided.
open override func defaultAction() {

View File

@ -88,7 +88,8 @@ open class RadioSwatchBase<ModelType: RadioSwatchModel>: Control<ModelType>, Cha
open override func setup() {
super.setup()
addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(Self.tap)))
isAccessibilityElement = true
accessibilityTraits = .button
addSubview(selectorView)
@ -120,7 +121,11 @@ open class RadioSwatchBase<ModelType: RadioSwatchModel>: Control<ModelType>, Cha
setAccessibilityLabel()
onChange = nil
}
@objc func tap() {
sendActions(for: .touchUpInside)
}
open override func defaultAction() {
isSelected.toggle()
sendActions(for: .valueChanged)

View File

@ -96,7 +96,7 @@ public class RadioSwatchGroupBase<GroupModelType: RadioSwatchGroupModel, ModelHa
open override func setup() {
super.setup()
isTappable = false
isAccessibilityElement = true
accessibilityTraits = .button
addSubview(label)

View File

@ -254,6 +254,7 @@ open class ToggleBase<ModelType: ToggleModel>: Control<ModelType>, Changable {
//--------------------------------------------------
open override func setup() {
super.setup()
addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(Self.tap)))
isAccessibilityElement = true
accessibilityTraits = .button
@ -309,7 +310,11 @@ open class ToggleBase<ModelType: ToggleModel>: Control<ModelType>, Changable {
setAccessibilityLabel()
onChange = nil
}
@objc func tap() {
sendActions(for: .touchUpInside)
}
/// This will toggle the state of the Toggle and execute the actionBlock if provided.
open override func defaultAction() {
isOn.toggle()