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.
|
||||
open override func toggle() {
|
||||
guard isEnabled else { return }
|
||||
|
||||
//removed error
|
||||
if showError && isSelected == false {
|
||||
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.
|
||||
open override func toggle() {
|
||||
guard isEnabled else { return }
|
||||
|
||||
//removed error
|
||||
if showError && isSelected == false {
|
||||
showError.toggle()
|
||||
|
||||
@ -363,7 +363,12 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
||||
// creat the 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
|
||||
actions.append(labelAction)
|
||||
isUserInteractionEnabled = true
|
||||
@ -449,7 +454,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
||||
return element
|
||||
}
|
||||
|
||||
public override func accessibilityActivate() -> Bool {
|
||||
open override func accessibilityActivate() -> Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@ -198,7 +198,6 @@ open class RadioBoxItem: Control, Changeable, FormFieldable, Groupable {
|
||||
isAccessibilityElement = false
|
||||
selectorView.isAccessibilityElement = true
|
||||
selectorView.accessibilityTraits = .button
|
||||
|
||||
addSubview(selectorView)
|
||||
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.
|
||||
open func toggle() {
|
||||
guard isEnabled else { return }
|
||||
|
||||
//removed error
|
||||
isSelected.toggle()
|
||||
sendActions(for: .valueChanged)
|
||||
@ -268,14 +269,14 @@ open class RadioBoxItem: Control, Changeable, FormFieldable, Groupable {
|
||||
/// Used to update any Accessibility properties.
|
||||
open override func updateAccessibility() {
|
||||
super.updateAccessibility()
|
||||
accessibilityLabel = accessibilityLabelText
|
||||
selectorView.accessibilityLabel = accessibilityLabelText
|
||||
|
||||
if let accessibilityValueText {
|
||||
accessibilityValue = strikethrough
|
||||
selectorView.accessibilityValue = strikethrough
|
||||
? "\(strikethroughAccessibilityText), \(accessibilityValueText)"
|
||||
: accessibilityValueText
|
||||
} else {
|
||||
accessibilityValue = strikethrough
|
||||
selectorView.accessibilityValue = strikethrough
|
||||
? "\(strikethroughAccessibilityText)"
|
||||
: accessibilityValueText
|
||||
}
|
||||
@ -286,29 +287,41 @@ open class RadioBoxItem: Control, Changeable, FormFieldable, Groupable {
|
||||
var items = [Any]()
|
||||
items.append(selectorView)
|
||||
|
||||
let elements = gatherAccessibilityElements(from: selectorView)
|
||||
let views = elements.compactMap({ $0 as? UIView })
|
||||
|
||||
//update accessibilityLabel
|
||||
selectorView.setAccessibilityLabel(for: views)
|
||||
|
||||
//disabled
|
||||
if !isEnabled {
|
||||
if let label = selectorView.accessibilityLabel, !label.isEmpty {
|
||||
selectorView.accessibilityLabel = "\(label), dimmed"
|
||||
} else {
|
||||
selectorView.accessibilityLabel = "dimmed"
|
||||
}
|
||||
if let text = text, !text.isEmpty {
|
||||
items.append(textLabel)
|
||||
}
|
||||
|
||||
//append all children that are accessible
|
||||
items.append(contentsOf: elements)
|
||||
if let text = subText, !text.isEmpty {
|
||||
items.append(subTextLabel)
|
||||
}
|
||||
|
||||
if let text = subTextRight, !text.isEmpty {
|
||||
items.append(subTextRightLabel)
|
||||
}
|
||||
return items
|
||||
}
|
||||
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
|
||||
|
||||
@ -62,7 +62,7 @@ open class RadioButton: SelectorBase {
|
||||
|
||||
/// This will change the state of the Selector and execute the actionBlock if provided.
|
||||
open override func toggle() {
|
||||
guard !isSelected else { return }
|
||||
guard !isSelected, isEnabled else { return }
|
||||
|
||||
//removed error
|
||||
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.
|
||||
open override func toggle() {
|
||||
guard !isSelected else { return }
|
||||
guard !isSelected, isEnabled else { return }
|
||||
|
||||
//removed error
|
||||
if showError && isSelected == false {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user