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))) }
}
}
@ -105,10 +103,6 @@ open class Control<ModelType: Modelable>: UIControl, ModelHandlerable, ViewProto
}
}
@objc func tap() {
sendActions(for: .touchUpInside)
}
open func defaultAction() { }
//--------------------------------------------------

View File

@ -127,6 +127,7 @@ 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
@ -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
@ -203,6 +204,10 @@ open class RadioBoxBase<ModelType: RadioBoxModel>: Control<ModelType>, Changable
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() {
//removed error

View File

@ -126,6 +126,7 @@ 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
@ -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,6 +88,7 @@ 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
@ -121,6 +122,10 @@ open class RadioSwatchBase<ModelType: RadioSwatchModel>: Control<ModelType>, Cha
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
@ -310,6 +311,10 @@ open class ToggleBase<ModelType: ToggleModel>: Control<ModelType>, Changable {
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()