additions for accessibility.
This commit is contained in:
parent
f81b50d077
commit
b79ddf7346
@ -25,8 +25,14 @@ import UIKit
|
||||
if numberOfDigits > 0 {
|
||||
var digitBoxes = [DigitBox]()
|
||||
|
||||
for _ in 0..<numberOfDigits {
|
||||
digitBoxes.append(createDigitField())
|
||||
let ordinalFormatter = NumberFormatter()
|
||||
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
|
||||
@ -218,7 +224,6 @@ import UIKit
|
||||
|
||||
if !self.digitBoxes.isEmpty {
|
||||
self.digitBoxes.forEach { $0.updateView(size) }
|
||||
// self.layoutIfNeeded()
|
||||
}
|
||||
layoutIfNeeded()
|
||||
}
|
||||
|
||||
@ -117,12 +117,8 @@ import UIKit
|
||||
get { return feedbackLabel.text }
|
||||
set (newFeedback) {
|
||||
feedbackLabel.text = newFeedback
|
||||
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self = self else { return }
|
||||
|
||||
self.entryFieldContainer.refreshUI()
|
||||
}
|
||||
feedbackLabel.accessibilityElementsHidden = feedbackLabel.text?.isEmpty ?? true
|
||||
entryFieldContainer.refreshUI()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -71,7 +71,13 @@ import UIKit
|
||||
public override var showError: Bool {
|
||||
get { return super.showError }
|
||||
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
|
||||
}
|
||||
}
|
||||
@ -93,13 +99,7 @@ import UIKit
|
||||
//--------------------------------------------------
|
||||
|
||||
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
|
||||
//--------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user