updated more accessibilityLabels/Values
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
b919cfd92b
commit
18ab46b1f3
@ -75,6 +75,10 @@ open class SelectorBase: Control, SelectorControlable {
|
||||
|
||||
open override func setup() {
|
||||
super.setup()
|
||||
|
||||
isAccessibilityElement = true
|
||||
accessibilityTraits = .button
|
||||
|
||||
let layoutGuide = UILayoutGuide()
|
||||
addLayoutGuide(layoutGuide)
|
||||
|
||||
@ -107,4 +111,18 @@ open class SelectorBase: Control, SelectorControlable {
|
||||
layoutIfNeeded()
|
||||
}
|
||||
|
||||
open override func updateAccessibilityLabel() {
|
||||
accessibilityValue = isSelected ? "1" : "0"
|
||||
if !accessibilityTraits.contains(.selected) && isSelected {
|
||||
accessibilityTraits.insert(.selected)
|
||||
} else if accessibilityTraits.contains(.selected) && !isSelected{
|
||||
accessibilityTraits.remove(.selected)
|
||||
}
|
||||
|
||||
if !accessibilityTraits.contains(.notEnabled) && !isEnabled {
|
||||
accessibilityTraits.insert(.notEnabled)
|
||||
} else if accessibilityTraits.contains(.notEnabled) && !isEnabled {
|
||||
accessibilityTraits.remove(.notEnabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,6 +68,21 @@ open class SelectorGroupHandlerBase<HandlerType: Control>: Control, Changeable {
|
||||
super.reset()
|
||||
selectorViews.forEach{ $0.reset() }
|
||||
}
|
||||
|
||||
open override func updateAccessibilityLabel() {
|
||||
if !accessibilityTraits.contains(.selected) && isSelected {
|
||||
accessibilityTraits.insert(.selected)
|
||||
} else if accessibilityTraits.contains(.selected) && !isSelected{
|
||||
accessibilityTraits.remove(.selected)
|
||||
}
|
||||
|
||||
if !accessibilityTraits.contains(.notEnabled) && !isEnabled {
|
||||
accessibilityTraits.insert(.notEnabled)
|
||||
} else if accessibilityTraits.contains(.notEnabled) && !isEnabled {
|
||||
accessibilityTraits.remove(.notEnabled)
|
||||
}
|
||||
setAccessibilityLabel(for: selectorViews)
|
||||
}
|
||||
}
|
||||
|
||||
open class SelectorGroupSelectedHandlerBase<HandlerType: Control>: SelectorGroupHandlerBase<HandlerType>{
|
||||
@ -76,4 +91,13 @@ open class SelectorGroupSelectedHandlerBase<HandlerType: Control>: SelectorGroup
|
||||
public var selectedHandler: HandlerType? {
|
||||
return selectorViews.filter { $0.isSelected == true }.first
|
||||
}
|
||||
|
||||
open override func updateAccessibilityLabel() {
|
||||
super.updateAccessibilityLabel()
|
||||
if let selectedHandler, let value = selectedHandler.accessibilityValue, let label = selectedHandler.accessibilityLabel {
|
||||
accessibilityValue = "\(label) \(value)"
|
||||
} else {
|
||||
accessibilityValue = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,9 +270,16 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
||||
}
|
||||
|
||||
open override func updateAccessibilityLabel() {
|
||||
accessibilityValue = isSelected ? "1" : "0"
|
||||
if !accessibilityTraits.contains(.selected) && isSelected {
|
||||
accessibilityTraits.insert(.selected)
|
||||
} else if accessibilityTraits.contains(.selected) && !isSelected{
|
||||
accessibilityTraits.remove(.selected)
|
||||
}
|
||||
|
||||
if !accessibilityTraits.contains(.notEnabled) && !isEnabled {
|
||||
accessibilityTraits.insert(.notEnabled)
|
||||
} else {
|
||||
} else if accessibilityTraits.contains(.notEnabled) && !isEnabled {
|
||||
accessibilityTraits.remove(.notEnabled)
|
||||
}
|
||||
setAccessibilityLabel(for: [label, childLabel, errorLabel])
|
||||
|
||||
@ -161,7 +161,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
|
||||
open func updateAccessibilityLabel() {
|
||||
if !accessibilityTraits.contains(.notEnabled) && !isEnabled {
|
||||
accessibilityTraits.insert(.notEnabled)
|
||||
} else {
|
||||
} else if accessibilityTraits.contains(.notEnabled) && !isEnabled {
|
||||
accessibilityTraits.remove(.notEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ open class Checkbox: SelectorBase {
|
||||
|
||||
open override func setup() {
|
||||
super.setup()
|
||||
accessibilityLabel = "Checkbox"
|
||||
|
||||
backgroundColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .selected)
|
||||
backgroundColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: [.selected, .highlighted])
|
||||
|
||||
@ -55,6 +55,7 @@ open class CheckboxGroup: SelectorGroupHandlerBase<CheckboxItem> {
|
||||
}
|
||||
}
|
||||
}
|
||||
setNeedsUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase<RadioBoxItem> {
|
||||
for selector in selectorViews {
|
||||
selector.onClick = { [weak self] handler in
|
||||
self?.didSelect(handler)
|
||||
self?.setNeedsUpdate()
|
||||
}
|
||||
mainStackView.addArrangedSubview(selector)
|
||||
}
|
||||
@ -47,6 +48,7 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase<RadioBoxItem> {
|
||||
}
|
||||
}
|
||||
}
|
||||
setNeedsUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,8 +83,6 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase<RadioBoxItem> {
|
||||
|
||||
open override func setup() {
|
||||
super.setup()
|
||||
isAccessibilityElement = true
|
||||
accessibilityTraits = .button
|
||||
addSubview(mainStackView)
|
||||
ensureDevice()
|
||||
mainStackView.pinToSuperView()
|
||||
|
||||
@ -248,12 +248,21 @@ open class RadioBoxItem: Control, Changeable {
|
||||
}
|
||||
|
||||
open override func updateAccessibilityLabel() {
|
||||
accessibilityValue = isSelected ? "1" : "0"
|
||||
if !accessibilityTraits.contains(.selected) && isSelected {
|
||||
accessibilityTraits.insert(.selected)
|
||||
} else if accessibilityTraits.contains(.selected) && !isSelected{
|
||||
accessibilityTraits.remove(.selected)
|
||||
}
|
||||
|
||||
if !accessibilityTraits.contains(.notEnabled) && !isEnabled {
|
||||
accessibilityTraits.insert(.notEnabled)
|
||||
} else {
|
||||
} else if accessibilityTraits.contains(.notEnabled) && !isEnabled {
|
||||
accessibilityTraits.remove(.notEnabled)
|
||||
}
|
||||
setAccessibilityLabel(for: [textLabel, subTextLabel, subTextRightLabel])
|
||||
if accessibilityLabel == nil {
|
||||
setAccessibilityLabel(for: [textLabel, subTextLabel, subTextRightLabel])
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -23,6 +23,7 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase<RadioButtonItem> {
|
||||
for selector in selectorViews {
|
||||
selector.onClick = { [weak self] handler in
|
||||
self?.didSelect(handler)
|
||||
self?.setNeedsUpdate()
|
||||
}
|
||||
mainStackView.addArrangedSubview(selector)
|
||||
}
|
||||
@ -49,6 +50,7 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase<RadioButtonItem> {
|
||||
}
|
||||
}
|
||||
}
|
||||
setNeedsUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,8 +88,6 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase<RadioButtonItem> {
|
||||
open override func setup() {
|
||||
super.setup()
|
||||
|
||||
isAccessibilityElement = true
|
||||
accessibilityTraits = .button
|
||||
addSubview(mainStackView)
|
||||
|
||||
mainStackView.pinToSuperView()
|
||||
|
||||
@ -312,9 +312,16 @@ open class Toggle: Control, Changeable {
|
||||
}
|
||||
|
||||
open override func updateAccessibilityLabel() {
|
||||
accessibilityValue = isSelected ? "1" : "0"
|
||||
if !accessibilityTraits.contains(.selected) && isSelected {
|
||||
accessibilityTraits.insert(.selected)
|
||||
} else if accessibilityTraits.contains(.selected) && !isSelected{
|
||||
accessibilityTraits.remove(.selected)
|
||||
}
|
||||
|
||||
if !accessibilityTraits.contains(.notEnabled) && !isEnabled {
|
||||
accessibilityTraits.insert(.notEnabled)
|
||||
} else {
|
||||
} else if accessibilityTraits.contains(.notEnabled) && !isEnabled{
|
||||
accessibilityTraits.remove(.notEnabled)
|
||||
}
|
||||
setAccessibilityLabel(for: [label])
|
||||
|
||||
@ -168,7 +168,7 @@ open class Tooltip: Control, TooltipLaunchable {
|
||||
open override func updateAccessibilityLabel() {
|
||||
if !accessibilityTraits.contains(.notEnabled) && !isEnabled {
|
||||
accessibilityTraits.insert(.notEnabled)
|
||||
} else {
|
||||
} else if accessibilityTraits.contains(.notEnabled) && !isEnabled {
|
||||
accessibilityTraits.remove(.notEnabled)
|
||||
}
|
||||
var label = title
|
||||
|
||||
Loading…
Reference in New Issue
Block a user