updated accessibility elements

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-06-19 09:36:11 -05:00
parent 225c44a84a
commit 6d42ec599c

View File

@ -149,14 +149,13 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
open var accessibilityLabelText: String { open var accessibilityLabelText: String {
var accessibilityLabels = [String]() var accessibilityLabels = [String]()
accessibilityLabels.append("\(Selector.self)") accessibilityLabels.append("\(Selector.self)")
if let text = labelText { if let text = labelText, !text.isEmpty {
accessibilityLabels.append(text) accessibilityLabels.append(text)
} }
if let text = childText { if let text = childText, !text.isEmpty {
accessibilityLabels.append(text) accessibilityLabels.append(text)
} }
@ -164,7 +163,7 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
accessibilityLabels.append("dimmed") accessibilityLabels.append("dimmed")
} }
if let errorText, showError { if let errorText, showError, !errorText.isEmpty {
accessibilityLabels.append("error, \(errorText)") accessibilityLabels.append("error, \(errorText)")
} }
@ -177,9 +176,7 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
/// Executed on initialization for this View. /// Executed on initialization for this View.
open override func initialSetup() { open override func initialSetup() {
super.initialSetup() super.initialSetup()
onClick = { control in
control.toggle()
}
} }
/// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations.
@ -190,7 +187,6 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
selectorView.shouldUpdateAccessibility = false selectorView.shouldUpdateAccessibility = false
isAccessibilityElement = false isAccessibilityElement = false
accessibilityElements = [selectorView, label, childLabel, errorLabel]
addSubview(mainStackView) addSubview(mainStackView)
mainStackView.isUserInteractionEnabled = false mainStackView.isUserInteractionEnabled = false
@ -211,6 +207,7 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
open override func updateView() { open override func updateView() {
super.updateView() super.updateView()
updateLabels() updateLabels()
selectorView.isUserInteractionEnabled = true
selectorView.showError = showError selectorView.showError = showError
selectorView.isSelected = isSelected selectorView.isSelected = isSelected
selectorView.isHighlighted = isHighlighted selectorView.isHighlighted = isHighlighted
@ -224,7 +221,30 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
selectorView.accessibilityLabel = accessibilityLabelText selectorView.accessibilityLabel = accessibilityLabelText
selectorView.accessibilityHint = !isEnabled ? "" : "Double tap to activate." selectorView.accessibilityHint = !isEnabled ? "" : "Double tap to activate."
accessibilityValue = accessibilityValueText accessibilityValue = accessibilityValueText
}
open override var accessibilityElements: [Any]? {
get {
var elements = [Any]()
elements.append(selectorView)
if let text = labelText, !text.isEmpty {
elements.append(label)
}
if let text = childText, !text.isEmpty {
elements.append(childLabel)
}
if let errorText, showError, !errorText.isEmpty {
elements.append(errorLabel)
}
return elements
}
set {
super.accessibilityElements = newValue
}
} }
/// Resets to default settings. /// Resets to default settings.