split up accessibility
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
a043bd33f2
commit
b3f810500b
@ -124,6 +124,7 @@ open class SelectorBase: Control, SelectorControlable {
|
||||
open override func updateAccessibility() {
|
||||
super.updateAccessibility()
|
||||
accessibilityLabel = "\(Self.self)\(showError ? ", error" : "")"
|
||||
accessibilityHint = !isEnabled ? "" : "Double tap to open."
|
||||
}
|
||||
|
||||
/// This will change the state of the Selector and execute the actionBlock if provided.
|
||||
|
||||
@ -147,6 +147,30 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
||||
|
||||
open var accessibilityValueText: String?
|
||||
|
||||
open var accessibilityLabelText: String {
|
||||
var accessibilityLabels = [String]()
|
||||
|
||||
accessibilityLabels.append("\(Selector.self)")
|
||||
|
||||
if let text = labelText {
|
||||
accessibilityLabels.append(text)
|
||||
}
|
||||
|
||||
if let text = childText {
|
||||
accessibilityLabels.append(text)
|
||||
}
|
||||
|
||||
if !isEnabled {
|
||||
accessibilityLabels.append("dimmed")
|
||||
}
|
||||
|
||||
if let errorText, showError {
|
||||
accessibilityLabels.append("error, \(errorText)")
|
||||
}
|
||||
|
||||
return accessibilityLabels.joined(separator: ", ")
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Overrides
|
||||
//--------------------------------------------------
|
||||
@ -162,9 +186,11 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
||||
open override func setup() {
|
||||
super.setup()
|
||||
|
||||
selectorView.isAccessibilityElement = false
|
||||
isAccessibilityElement = true
|
||||
accessibilityTraits = .button
|
||||
selectorView.isAccessibilityElement = true
|
||||
selectorView.shouldUpdateAccessibility = false
|
||||
|
||||
isAccessibilityElement = false
|
||||
accessibilityElements = [selectorView, label, childLabel, errorLabel]
|
||||
addSubview(mainStackView)
|
||||
mainStackView.isUserInteractionEnabled = false
|
||||
|
||||
@ -195,8 +221,10 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
||||
/// Used to update any Accessibility properties.
|
||||
open override func updateAccessibility() {
|
||||
super.updateAccessibility()
|
||||
setAccessibilityLabel(for: [selectorView, label, childLabel, errorLabel])
|
||||
selectorView.accessibilityLabel = accessibilityLabelText
|
||||
selectorView.accessibilityHint = !isEnabled ? "" : "Double tap to activate."
|
||||
accessibilityValue = accessibilityValueText
|
||||
|
||||
}
|
||||
|
||||
/// Resets to default settings.
|
||||
|
||||
@ -51,6 +51,8 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable {
|
||||
/// Key of whether or not updateView() is called in setNeedsUpdate()
|
||||
open var shouldUpdateView: Bool = true
|
||||
|
||||
open var shouldUpdateAccessibility: Bool = true
|
||||
|
||||
open var surface: Surface = .light { didSet { setNeedsUpdate() } }
|
||||
|
||||
/// Text that will be used in the titleLabel.
|
||||
|
||||
@ -102,8 +102,6 @@ open class DatePicker: EntryFieldBase, DatePickerViewControllerDelegate, UIPopov
|
||||
super.setup()
|
||||
|
||||
fieldStackView.isAccessibilityElement = true
|
||||
fieldStackView.accessibilityLabel = "Date Picker"
|
||||
fieldStackView.accessibilityHint = "Double Tap to open"
|
||||
|
||||
// setting color config
|
||||
selectedDateLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable()
|
||||
|
||||
@ -133,6 +133,30 @@ open class RadioBoxItem: Control, Changeable, FormFieldable, Groupable {
|
||||
|
||||
open var accessibilityValueText: String?
|
||||
|
||||
open var accessibilityLabelText: String {
|
||||
var accessibilityLabels = [String]()
|
||||
|
||||
accessibilityLabels.append("Radiobox")
|
||||
|
||||
if let text {
|
||||
accessibilityLabels.append(text)
|
||||
}
|
||||
|
||||
if let text = subText {
|
||||
accessibilityLabels.append(text)
|
||||
}
|
||||
|
||||
if let text = subTextRight {
|
||||
accessibilityLabels.append(text)
|
||||
}
|
||||
|
||||
if !isEnabled {
|
||||
accessibilityLabels.append("dimmed")
|
||||
}
|
||||
|
||||
return accessibilityLabels.joined(separator: ", ")
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Configuration Properties
|
||||
//--------------------------------------------------
|
||||
@ -171,8 +195,10 @@ open class RadioBoxItem: Control, Changeable, FormFieldable, Groupable {
|
||||
open override func setup() {
|
||||
super.setup()
|
||||
|
||||
isAccessibilityElement = true
|
||||
accessibilityTraits = .button
|
||||
isAccessibilityElement = false
|
||||
selectorView.isAccessibilityElement = true
|
||||
selectorView.accessibilityTraits = .button
|
||||
|
||||
addSubview(selectorView)
|
||||
selectorView.isUserInteractionEnabled = false
|
||||
|
||||
@ -242,12 +268,8 @@ open class RadioBoxItem: Control, Changeable, FormFieldable, Groupable {
|
||||
/// Used to update any Accessibility properties.
|
||||
open override func updateAccessibility() {
|
||||
super.updateAccessibility()
|
||||
setAccessibilityLabel(for: [textLabel, subTextLabel, subTextRightLabel])
|
||||
if let currentAccessibilityLabel = accessibilityLabel {
|
||||
accessibilityLabel = "Radiobox, \(currentAccessibilityLabel)"
|
||||
} else {
|
||||
accessibilityLabel = "Radiobox"
|
||||
}
|
||||
accessibilityLabel = accessibilityLabelText
|
||||
|
||||
if let accessibilityValueText {
|
||||
accessibilityValue = strikethrough
|
||||
? "\(strikethroughAccessibilityText), \(accessibilityValueText)"
|
||||
@ -259,6 +281,35 @@ open class RadioBoxItem: Control, Changeable, FormFieldable, Groupable {
|
||||
}
|
||||
}
|
||||
|
||||
open override var accessibilityElements: [Any]? {
|
||||
get {
|
||||
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"
|
||||
}
|
||||
}
|
||||
|
||||
//append all children that are accessible
|
||||
items.append(contentsOf: elements)
|
||||
|
||||
return items
|
||||
}
|
||||
set {}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Private Methods
|
||||
//--------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user