only toggle when enabled
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
ec8d4ba1d6
commit
f25aee83de
@ -63,6 +63,8 @@ open class Checkbox: SelectorBase {
|
|||||||
|
|
||||||
/// This will change the state of the Selector and execute the actionBlock if provided.
|
/// This will change the state of the Selector and execute the actionBlock if provided.
|
||||||
open override func toggle() {
|
open override func toggle() {
|
||||||
|
guard isEnabled else { return }
|
||||||
|
|
||||||
//removed error
|
//removed error
|
||||||
if showError && isSelected == false {
|
if showError && isSelected == false {
|
||||||
showError.toggle()
|
showError.toggle()
|
||||||
|
|||||||
@ -38,6 +38,8 @@ open class CheckboxItem: SelectorItemBase<Checkbox> {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
/// This will change the state of the Selector and execute the actionBlock if provided.
|
/// This will change the state of the Selector and execute the actionBlock if provided.
|
||||||
open override func toggle() {
|
open override func toggle() {
|
||||||
|
guard isEnabled else { return }
|
||||||
|
|
||||||
//removed error
|
//removed error
|
||||||
if showError && isSelected == false {
|
if showError && isSelected == false {
|
||||||
showError.toggle()
|
showError.toggle()
|
||||||
|
|||||||
@ -363,7 +363,12 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
// creat the action
|
// creat the action
|
||||||
let labelAction = LabelAction(range: actionable.range, action: actionable.action)
|
let labelAction = LabelAction(range: actionable.range, action: actionable.action)
|
||||||
|
|
||||||
customAccessibilityAction?.action = labelAction.performAction
|
// set the action of the accessibilityElement
|
||||||
|
customAccessibilityAction?.action = { [weak self] in
|
||||||
|
guard let self, isEnabled else { return }
|
||||||
|
labelAction.performAction()
|
||||||
|
}
|
||||||
|
|
||||||
//create a wrapper for the attributes range, block and
|
//create a wrapper for the attributes range, block and
|
||||||
actions.append(labelAction)
|
actions.append(labelAction)
|
||||||
isUserInteractionEnabled = true
|
isUserInteractionEnabled = true
|
||||||
@ -449,7 +454,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
return element
|
return element
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func accessibilityActivate() -> Bool {
|
open override func accessibilityActivate() -> Bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -198,7 +198,6 @@ open class RadioBoxItem: Control, Changeable, FormFieldable, Groupable {
|
|||||||
isAccessibilityElement = false
|
isAccessibilityElement = false
|
||||||
selectorView.isAccessibilityElement = true
|
selectorView.isAccessibilityElement = true
|
||||||
selectorView.accessibilityTraits = .button
|
selectorView.accessibilityTraits = .button
|
||||||
|
|
||||||
addSubview(selectorView)
|
addSubview(selectorView)
|
||||||
selectorView.isUserInteractionEnabled = false
|
selectorView.isUserInteractionEnabled = false
|
||||||
|
|
||||||
@ -252,6 +251,8 @@ open class RadioBoxItem: Control, Changeable, FormFieldable, Groupable {
|
|||||||
|
|
||||||
/// This will change the state of the Selector and execute the actionBlock if provided.
|
/// This will change the state of the Selector and execute the actionBlock if provided.
|
||||||
open func toggle() {
|
open func toggle() {
|
||||||
|
guard isEnabled else { return }
|
||||||
|
|
||||||
//removed error
|
//removed error
|
||||||
isSelected.toggle()
|
isSelected.toggle()
|
||||||
sendActions(for: .valueChanged)
|
sendActions(for: .valueChanged)
|
||||||
@ -268,14 +269,14 @@ open class RadioBoxItem: Control, Changeable, FormFieldable, Groupable {
|
|||||||
/// Used to update any Accessibility properties.
|
/// Used to update any Accessibility properties.
|
||||||
open override func updateAccessibility() {
|
open override func updateAccessibility() {
|
||||||
super.updateAccessibility()
|
super.updateAccessibility()
|
||||||
accessibilityLabel = accessibilityLabelText
|
selectorView.accessibilityLabel = accessibilityLabelText
|
||||||
|
|
||||||
if let accessibilityValueText {
|
if let accessibilityValueText {
|
||||||
accessibilityValue = strikethrough
|
selectorView.accessibilityValue = strikethrough
|
||||||
? "\(strikethroughAccessibilityText), \(accessibilityValueText)"
|
? "\(strikethroughAccessibilityText), \(accessibilityValueText)"
|
||||||
: accessibilityValueText
|
: accessibilityValueText
|
||||||
} else {
|
} else {
|
||||||
accessibilityValue = strikethrough
|
selectorView.accessibilityValue = strikethrough
|
||||||
? "\(strikethroughAccessibilityText)"
|
? "\(strikethroughAccessibilityText)"
|
||||||
: accessibilityValueText
|
: accessibilityValueText
|
||||||
}
|
}
|
||||||
@ -286,29 +287,41 @@ open class RadioBoxItem: Control, Changeable, FormFieldable, Groupable {
|
|||||||
var items = [Any]()
|
var items = [Any]()
|
||||||
items.append(selectorView)
|
items.append(selectorView)
|
||||||
|
|
||||||
let elements = gatherAccessibilityElements(from: selectorView)
|
if let text = text, !text.isEmpty {
|
||||||
let views = elements.compactMap({ $0 as? UIView })
|
items.append(textLabel)
|
||||||
|
}
|
||||||
//update accessibilityLabel
|
|
||||||
selectorView.setAccessibilityLabel(for: views)
|
if let text = subText, !text.isEmpty {
|
||||||
|
items.append(subTextLabel)
|
||||||
//disabled
|
}
|
||||||
if !isEnabled {
|
|
||||||
if let label = selectorView.accessibilityLabel, !label.isEmpty {
|
if let text = subTextRight, !text.isEmpty {
|
||||||
selectorView.accessibilityLabel = "\(label), dimmed"
|
items.append(subTextRightLabel)
|
||||||
} else {
|
|
||||||
selectorView.accessibilityLabel = "dimmed"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//append all children that are accessible
|
|
||||||
items.append(contentsOf: elements)
|
|
||||||
|
|
||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
set {}
|
set {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Overriden to take the hit if there is an onClickSubscriber and the view is not a UIControl
|
||||||
|
open override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||||
|
guard isEnabled else { return super.hitTest(point, with: event) }
|
||||||
|
|
||||||
|
let textPoint = convert(point, to: textLabel)
|
||||||
|
let subTextPoint = convert(point, to: subTextLabel)
|
||||||
|
let subTextRightPoint = convert(point, to: subTextRightLabel)
|
||||||
|
|
||||||
|
if textLabel.isAction(for: textPoint) {
|
||||||
|
return textLabel
|
||||||
|
} else if subTextLabel.isAction(for: subTextPoint) {
|
||||||
|
return subTextLabel
|
||||||
|
} else if subTextRightLabel.isAction(for: subTextRightPoint) {
|
||||||
|
return subTextRightLabel
|
||||||
|
} else {
|
||||||
|
guard !UIAccessibility.isVoiceOverRunning else { return nil }
|
||||||
|
return super.hitTest(point, with: event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Methods
|
// MARK: - Private Methods
|
||||||
|
|||||||
@ -62,7 +62,7 @@ open class RadioButton: SelectorBase {
|
|||||||
|
|
||||||
/// This will change the state of the Selector and execute the actionBlock if provided.
|
/// This will change the state of the Selector and execute the actionBlock if provided.
|
||||||
open override func toggle() {
|
open override func toggle() {
|
||||||
guard !isSelected else { return }
|
guard !isSelected, isEnabled else { return }
|
||||||
|
|
||||||
//removed error
|
//removed error
|
||||||
if showError && isSelected == false {
|
if showError && isSelected == false {
|
||||||
|
|||||||
@ -34,7 +34,7 @@ open class RadioButtonItem: SelectorItemBase<RadioButton> {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
/// This will change the state of the Selector and execute the actionBlock if provided.
|
/// This will change the state of the Selector and execute the actionBlock if provided.
|
||||||
open override func toggle() {
|
open override func toggle() {
|
||||||
guard !isSelected else { return }
|
guard !isSelected, isEnabled else { return }
|
||||||
|
|
||||||
//removed error
|
//removed error
|
||||||
if showError && isSelected == false {
|
if showError && isSelected == false {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user