additions for accessibility.
This commit is contained in:
parent
f81b50d077
commit
b79ddf7346
@ -25,8 +25,14 @@ import UIKit
|
|||||||
if numberOfDigits > 0 {
|
if numberOfDigits > 0 {
|
||||||
var digitBoxes = [DigitBox]()
|
var digitBoxes = [DigitBox]()
|
||||||
|
|
||||||
for _ in 0..<numberOfDigits {
|
let ordinalFormatter = NumberFormatter()
|
||||||
digitBoxes.append(createDigitField())
|
ordinalFormatter.numberStyle = .ordinal
|
||||||
|
|
||||||
|
for i in 0..<numberOfDigits {
|
||||||
|
let newDigitBox = createDigitField()
|
||||||
|
let accessibileLabel = ordinalFormatter.string(from: NSNumber(value: i + 1)) ?? ""
|
||||||
|
newDigitBox.digitField.accessibilityLabel = "\(accessibileLabel) field of \(numberOfDigits) digit fields"
|
||||||
|
digitBoxes.append(newDigitBox)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.digitBoxes = digitBoxes
|
self.digitBoxes = digitBoxes
|
||||||
@ -218,7 +224,6 @@ import UIKit
|
|||||||
|
|
||||||
if !self.digitBoxes.isEmpty {
|
if !self.digitBoxes.isEmpty {
|
||||||
self.digitBoxes.forEach { $0.updateView(size) }
|
self.digitBoxes.forEach { $0.updateView(size) }
|
||||||
// self.layoutIfNeeded()
|
|
||||||
}
|
}
|
||||||
layoutIfNeeded()
|
layoutIfNeeded()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -117,12 +117,8 @@ import UIKit
|
|||||||
get { return feedbackLabel.text }
|
get { return feedbackLabel.text }
|
||||||
set (newFeedback) {
|
set (newFeedback) {
|
||||||
feedbackLabel.text = newFeedback
|
feedbackLabel.text = newFeedback
|
||||||
|
feedbackLabel.accessibilityElementsHidden = feedbackLabel.text?.isEmpty ?? true
|
||||||
DispatchQueue.main.async { [weak self] in
|
entryFieldContainer.refreshUI()
|
||||||
guard let self = self else { return }
|
|
||||||
|
|
||||||
self.entryFieldContainer.refreshUI()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -71,7 +71,13 @@ import UIKit
|
|||||||
public override var showError: Bool {
|
public override var showError: Bool {
|
||||||
get { return super.showError }
|
get { return super.showError }
|
||||||
set (error) {
|
set (error) {
|
||||||
textField.accessibilityValue = nil
|
|
||||||
|
if error {
|
||||||
|
textField.accessibilityValue = String(format: MVMCoreUIUtility.hardcodedString(withKey: "textfield_error_message") ?? "", textField.text ?? "", errorMessage ?? "")
|
||||||
|
} else {
|
||||||
|
textField.accessibilityValue = nil
|
||||||
|
}
|
||||||
|
|
||||||
super.showError = error
|
super.showError = error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,13 +99,7 @@ import UIKit
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public var validationBlock: ((_ value: String?) -> Bool)?
|
public var validationBlock: ((_ value: String?) -> Bool)?
|
||||||
|
|
||||||
public override var errorMessage: String? {
|
|
||||||
didSet {
|
|
||||||
textField.accessibilityValue = String(format: MVMCoreUIUtility.hardcodedString(withKey: "textfield_error_message") ?? "", textField.text ?? "", errorMessage ?? "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Delegate Properties
|
// MARK: - Delegate Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user