ONEAPP-6239 - Loader Voice Over Fixes

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-12-15 14:04:27 -06:00
parent 94a505d20e
commit 8b69c3eb15
2 changed files with 28 additions and 7 deletions

View File

@ -35,7 +35,8 @@ open class Loader: View {
private var icon = Icon().with { $0.name = .loader }
private var opacity: CGFloat = 0.8
private var iconColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark)
private var loadingTimer: Timer?
//--------------------------------------------------
// MARK: - Public Properties
//--------------------------------------------------
@ -59,8 +60,9 @@ open class Loader: View {
/// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations.
open override func setup() {
super.setup()
addSubview(icon)
addSubview(icon)
isAccessibilityElement = true
icon.isAccessibilityElement = false
icon
.pinTopGreaterThanOrEqualTo()
.pinLeadingGreaterThanOrEqualTo()
@ -85,22 +87,37 @@ open class Loader: View {
}
}
open override func updateAccessibility() {
}
//--------------------------------------------------
// MARK: - Private Methods
//--------------------------------------------------
private let rotationLayerName = "rotationAnimation"
private func startAnimating() {
accessibilityLabel = "Loading"
icon.layer.remove(layerName: rotationLayerName)
let rotation : CABasicAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
rotation.toValue = NSNumber(value: Double.pi * 2)
rotation.duration = 0.5 // the speed of the rotation
rotation.isCumulative = true
rotation.repeatCount = Float.greatestFiniteMagnitude
rotation.fromValue = 0
rotation.toValue = Double.pi * 2
rotation.duration = 0.5
rotation.repeatCount = .infinity
icon.layer.add(rotation, forKey: rotationLayerName)
// Focus VoiceOver on this view
UIAccessibility.post(notification: .layoutChanged, argument: self)
loadingTimer = Timer.scheduledTimer(withTimeInterval: 20, repeats: true) { [weak self] _ in
self?.accessibilityLabel = "Still Loading"
UIAccessibility.post(notification: .announcement, argument: "Still Loading")
}
}
private func stopAnimating() {
icon.layer.removeAnimation(forKey: rotationLayerName)
loadingTimer?.invalidate()
loadingTimer = nil
}
}

View File

@ -1,3 +1,7 @@
1.0.49
----------------
- ONEAPP-6239 - Loader Voice Over Fixes
1.0.48
----------------
- ONEAPP-4683 - Accessibility - Tabs (Voice Over)