first cut of accessibility update
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
0f27e82987
commit
9871324c8e
@ -100,16 +100,14 @@ open class DatePicker: EntryFieldBase, DatePickerViewControllerDelegate, UIPopov
|
|||||||
/// 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.
|
||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.setup()
|
super.setup()
|
||||||
|
|
||||||
fieldStackView.isAccessibilityElement = true
|
containerView.isAccessibilityElement = true
|
||||||
fieldStackView.accessibilityLabel = "Date Picker"
|
|
||||||
fieldStackView.accessibilityHint = "Double Tap to open"
|
|
||||||
|
|
||||||
// setting color config
|
// setting color config
|
||||||
selectedDateLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable()
|
selectedDateLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable()
|
||||||
|
|
||||||
// tap gesture
|
// tap gesture
|
||||||
fieldStackView
|
containerView
|
||||||
.publisher(for: UITapGestureRecognizer())
|
.publisher(for: UITapGestureRecognizer())
|
||||||
.sink { [weak self] _ in
|
.sink { [weak self] _ in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
@ -147,9 +145,31 @@ open class DatePicker: EntryFieldBase, DatePickerViewControllerDelegate, UIPopov
|
|||||||
|
|
||||||
open override func updateAccessibility() {
|
open override func updateAccessibility() {
|
||||||
super.updateAccessibility()
|
super.updateAccessibility()
|
||||||
fieldStackView.accessibilityLabel = "Date Picker, \(accessibilityLabelText)"
|
containerView.accessibilityLabel = "Date Picker, \(accessibilityLabelText)"
|
||||||
fieldStackView.accessibilityHint = isReadOnly || !isEnabled ? "" : "Double tap to open."
|
containerView.accessibilityHint = isReadOnly || !isEnabled ? "" : "Double tap to open."
|
||||||
fieldStackView.accessibilityValue = value
|
containerView.accessibilityValue = value
|
||||||
|
}
|
||||||
|
|
||||||
|
open override var accessibilityElements: [Any]? {
|
||||||
|
get {
|
||||||
|
var elements = [Any]()
|
||||||
|
elements.append(contentsOf: [titleLabel, containerView])
|
||||||
|
|
||||||
|
if showError {
|
||||||
|
elements.append(statusIcon)
|
||||||
|
if let errorText, !errorText.isEmpty {
|
||||||
|
elements.append(errorLabel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let helperText, !helperText.isEmpty {
|
||||||
|
elements.append(helperLabel)
|
||||||
|
}
|
||||||
|
|
||||||
|
return elements
|
||||||
|
}
|
||||||
|
|
||||||
|
set { super.accessibilityElements = newValue }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resets to default settings.
|
/// Resets to default settings.
|
||||||
@ -184,7 +204,7 @@ open class DatePicker: EntryFieldBase, DatePickerViewControllerDelegate, UIPopov
|
|||||||
controller.dismiss(animated: true) { [weak self] in
|
controller.dismiss(animated: true) { [weak self] in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
self.sendActions(for: .valueChanged)
|
self.sendActions(for: .valueChanged)
|
||||||
UIAccessibility.post(notification: .layoutChanged, argument: self.fieldStackView)
|
UIAccessibility.post(notification: .layoutChanged, argument: self.containerView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -131,7 +131,7 @@ open class DropdownSelect: EntryFieldBase {
|
|||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.setup()
|
super.setup()
|
||||||
|
|
||||||
fieldStackView.isAccessibilityElement = true
|
containerView.isAccessibilityElement = true
|
||||||
inlineDisplayLabel.isAccessibilityElement = true
|
inlineDisplayLabel.isAccessibilityElement = true
|
||||||
|
|
||||||
dropdownField.width(0)
|
dropdownField.width(0)
|
||||||
@ -278,15 +278,15 @@ open class DropdownSelect: EntryFieldBase {
|
|||||||
|
|
||||||
open override func updateAccessibility() {
|
open override func updateAccessibility() {
|
||||||
super.updateAccessibility()
|
super.updateAccessibility()
|
||||||
fieldStackView.accessibilityLabel = "Dropdown Select, \(accessibilityLabelText)"
|
containerView.accessibilityLabel = "Dropdown Select, \(accessibilityLabelText)"
|
||||||
fieldStackView.accessibilityHint = isReadOnly || !isEnabled ? "" : "has popup, Double tap to open."
|
containerView.accessibilityHint = isReadOnly || !isEnabled ? "" : "has popup, Double tap to open."
|
||||||
fieldStackView.accessibilityValue = value
|
containerView.accessibilityValue = value
|
||||||
}
|
}
|
||||||
|
|
||||||
open override var accessibilityElements: [Any]? {
|
open override var accessibilityElements: [Any]? {
|
||||||
get {
|
get {
|
||||||
var elements = [Any]()
|
var elements = [Any]()
|
||||||
elements.append(contentsOf: [titleLabel, fieldStackView])
|
elements.append(contentsOf: [titleLabel, containerView])
|
||||||
|
|
||||||
if showError {
|
if showError {
|
||||||
elements.append(statusIcon)
|
elements.append(statusIcon)
|
||||||
@ -310,7 +310,7 @@ open class DropdownSelect: EntryFieldBase {
|
|||||||
optionsPicker.isHidden = true
|
optionsPicker.isHidden = true
|
||||||
dropdownField.resignFirstResponder()
|
dropdownField.resignFirstResponder()
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
UIAccessibility.post(notification: .layoutChanged, argument: fieldStackView)
|
UIAccessibility.post(notification: .layoutChanged, argument: containerView)
|
||||||
}
|
}
|
||||||
|
|
||||||
open override var canBecomeFirstResponder: Bool {
|
open override var canBecomeFirstResponder: Bool {
|
||||||
@ -337,8 +337,8 @@ extension DropdownSelect: UIPickerViewDelegate, UIPickerViewDataSource {
|
|||||||
|
|
||||||
internal func launchPicker() {
|
internal func launchPicker() {
|
||||||
if optionsPicker.isHidden {
|
if optionsPicker.isHidden {
|
||||||
UIAccessibility.post(notification: .layoutChanged, argument: optionsPicker)
|
|
||||||
dropdownField.becomeFirstResponder()
|
dropdownField.becomeFirstResponder()
|
||||||
|
UIAccessibility.post(notification: .layoutChanged, argument: optionsPicker)
|
||||||
} else {
|
} else {
|
||||||
dropdownField.resignFirstResponder()
|
dropdownField.resignFirstResponder()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -181,6 +181,9 @@ open class InputField: EntryFieldBase {
|
|||||||
/// 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.
|
||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.setup()
|
super.setup()
|
||||||
|
containerView.isAccessibilityElement = true
|
||||||
|
textField.isAccessibilityElement = false
|
||||||
|
|
||||||
textField.heightAnchor.constraint(equalToConstant: 20).isActive = true
|
textField.heightAnchor.constraint(equalToConstant: 20).isActive = true
|
||||||
textField.delegate = self
|
textField.delegate = self
|
||||||
bottomContainerStackView.insertArrangedSubview(successLabel, at: 0)
|
bottomContainerStackView.insertArrangedSubview(successLabel, at: 0)
|
||||||
@ -230,8 +233,9 @@ open class InputField: EntryFieldBase {
|
|||||||
|
|
||||||
open override func updateAccessibility() {
|
open override func updateAccessibility() {
|
||||||
super.updateAccessibility()
|
super.updateAccessibility()
|
||||||
textField.accessibilityLabel = accessibilityLabelText
|
containerView.accessibilityLabel = "Input Field, \(accessibilityLabelText)"
|
||||||
textField.accessibilityHint = isReadOnly || !isEnabled ? "" : "Double tap to open."
|
containerView.accessibilityHint = isReadOnly || !isEnabled ? "" : "Double tap to edit."
|
||||||
|
containerView.accessibilityValue = value
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func updateErrorLabel() {
|
open override func updateErrorLabel() {
|
||||||
@ -264,7 +268,7 @@ open class InputField: EntryFieldBase {
|
|||||||
open override var accessibilityElements: [Any]? {
|
open override var accessibilityElements: [Any]? {
|
||||||
get {
|
get {
|
||||||
var elements = [Any]()
|
var elements = [Any]()
|
||||||
elements.append(contentsOf: [titleLabel, textField])
|
elements.append(contentsOf: [titleLabel, containerView])
|
||||||
if showError {
|
if showError {
|
||||||
elements.append(statusIcon)
|
elements.append(statusIcon)
|
||||||
if let errorText, !errorText.isEmpty {
|
if let errorText, !errorText.isEmpty {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user