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 {
var accessibilityLabels = [String]()
accessibilityLabels.append("\(Selector.self)")
if let text = labelText {
if let text = labelText, !text.isEmpty {
accessibilityLabels.append(text)
}
if let text = childText {
if let text = childText, !text.isEmpty {
accessibilityLabels.append(text)
}
@ -164,7 +163,7 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
accessibilityLabels.append("dimmed")
}
if let errorText, showError {
if let errorText, showError, !errorText.isEmpty {
accessibilityLabels.append("error, \(errorText)")
}
@ -177,9 +176,7 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
/// Executed on initialization for this View.
open override func 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.
@ -190,7 +187,6 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
selectorView.shouldUpdateAccessibility = false
isAccessibilityElement = false
accessibilityElements = [selectorView, label, childLabel, errorLabel]
addSubview(mainStackView)
mainStackView.isUserInteractionEnabled = false
@ -211,6 +207,7 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
open override func updateView() {
super.updateView()
updateLabels()
selectorView.isUserInteractionEnabled = true
selectorView.showError = showError
selectorView.isSelected = isSelected
selectorView.isHighlighted = isHighlighted
@ -224,7 +221,30 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
selectorView.accessibilityLabel = accessibilityLabelText
selectorView.accessibilityHint = !isEnabled ? "" : "Double tap to activate."
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.