commit 3b87b9e0ac121946043c10896f594ccf12ee536c
parent 73753bb5032e1137f3fcd461cc41ad03d6fbb9d0
Author: Marc Stibane <marc@taler.net>
Date: Fri, 13 Dec 2024 12:25:03 +0100
A11y fixes
Diffstat:
6 files changed, 33 insertions(+), 27 deletions(-)
diff --git a/TalerWallet1/Views/HelperViews/Buttons.swift b/TalerWallet1/Views/HelperViews/Buttons.swift
@@ -71,40 +71,30 @@ struct QRButton : View {
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)
}
}
- let closingAnnouncement = AttributedString(localized: "Closing Camera")
- private var dismissAlertButton: some View {
- Button("Cancel", role: .cancel) {
- if #available(iOS 17.0, *) {
- AccessibilityNotification.Announcement(closingAnnouncement).post()
- }
- showCameraAlert = false
- }
- }
- var defaultPriorityAnnouncement = AttributedString(localized: "Opening Camera")
- var lowPriorityAnnouncement: AttributedString {
- var lowPriorityString = AttributedString ("Camera Loading")
- if #available(iOS 17.0, *) {
- lowPriorityString.accessibilitySpeechAnnouncementPriority = .low
- }
- return lowPriorityString
- }
+ let closingAnnouncement = String(localized: "Closing Camera", comment: "VoiceOver")
+
+ var defaultPriorityAnnouncement = String(localized: "Opening Camera", comment: "VoiceOver")
+
var highPriorityAnnouncement: AttributedString {
- var highPriorityString = AttributedString("Camera Active")
+ var highPriorityString = AttributedString(localized: "Camera Active", comment: "VoiceOver")
if #available(iOS 17.0, *) {
highPriorityString.accessibilitySpeechAnnouncementPriority = .high
}
return highPriorityString
}
+ @MainActor
private func checkCameraAvailable() -> Void {
// Open Camera when QR-Button was tapped
- if #available(iOS 17.0, *) {
- AccessibilityNotification.Announcement(defaultPriorityAnnouncement).post()
- }
+ announce(defaultPriorityAnnouncement)
+
AVCaptureDevice.requestAccess(for: .video, completionHandler: { (granted: Bool) -> Void in
if granted {
action()
if #available(iOS 17.0, *) {
AccessibilityNotification.Announcement(highPriorityAnnouncement).post()
+ } else {
+ let cameraActive = String(localized: "Camera Active", comment: "VoiceOver")
+ announce(cameraActive)
}
} else {
showCameraAlert = true
@@ -113,6 +103,10 @@ struct QRButton : View {
}
var body: some View {
+ let dismissAlertButton = Button("Cancel", role: .cancel) {
+ announce(closingAnnouncement)
+ showCameraAlert = false
+ }
let scanText = String(localized: "Scan QR code", comment: "Button title, a11y")
let qr = "qrcode.viewfinder"
let qrImage = Text("\(Image(systemName: qr))", comment: "QR Image")
diff --git a/TalerWallet1/Views/HelperViews/LoadingView.swift b/TalerWallet1/Views/HelperViews/LoadingView.swift
@@ -18,10 +18,9 @@ struct LoadingView: View {
var body: some View {
VStack(alignment: .center) {
Spacer()
- RotatingTaler(size: 100, progress: true,
- rotationEnabled: $rotationEnabled)
-// .accessibilityLabel("Progress indicator")
- .onTapGesture(count: 2) {
+ RotatingTaler(size: 100, progress: true, // VoiceOver "In progress"
+ rotationEnabled: $rotationEnabled)
+ .onTapGesture(count: 1) {
rotationEnabled.toggle()
}
Spacer()
diff --git a/TalerWallet1/Views/HelperViews/View+fitsSideBySide.swift b/TalerWallet1/Views/HelperViews/View+fitsSideBySide.swift
@@ -12,6 +12,12 @@ extension View {
UIAccessibility.post(notification: .announcement, argument: this)
}
}
+ @MainActor
+ public func setVoice(to this: (any View)?) {
+ if UIAccessibility.isVoiceOverRunning {
+ UIAccessibility.post(notification: .layoutChanged, argument: this)
+ }
+ }
}
extension View {
diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
@@ -253,14 +253,15 @@ struct PaymentView: View, Sendable {
}
}.monospacedDigit()
Text("seconds")
- }
+ }.accessibilityElement(children: .combine)
}
let destination = PaymentDone(stack: stack.push(),
// scope: firstScope, // TODO: let user choose which currency
transactionId: preparePayResult.transactionId)
NavigationLink(destination: destination) {
let formatted = raw.formatted(currencyInfo, isNegative: false)
- Text("Pay \(formatted) now")
+ Text("Pay \(formatted.0) now")
+ .accessibilityLabel("Pay \(formatted.1) now")
}
.buttonStyle(TalerButtonStyle(type: .prominent))
.padding(.horizontal)
diff --git a/TalerWallet1/Views/Sheets/QRSheet.swift b/TalerWallet1/Views/Sheets/QRSheet.swift
@@ -46,14 +46,18 @@ struct QRSheet: View {
}
} else {
CodeScannerView(codeTypes: [AVMetadataObject.ObjectType.qr], showViewfinder: true) { response in
+ let closingAnnouncement: String
switch response {
case .success(let result):
symLog.log("Found code: \(result.string)")
scannedCode = result.string
+ closingAnnouncement = String(localized: "QR code recognized", comment: "VoiceOver")
case .failure(let error):
// TODO: errorAlert
ErrorView(errortext: error.localizedDescription)
+ closingAnnouncement = String(localized: "Error while scanning QR code", comment: "VoiceOver")
}
+ announce(closingAnnouncement)
}
}
}
diff --git a/TalerWallet1/Views/Transactions/ThreeAmountsSection.swift b/TalerWallet1/Views/Transactions/ThreeAmountsSection.swift
@@ -147,6 +147,7 @@ struct ThreeAmountsSection: View {
image.resizable()
.scaledToFill()
.frame(width: 64, height: 64)
+ .accessibilityHidden(true)
Text(productImage.description)
// if let product_id = product.product_id {
// Text(product_id)
@@ -156,6 +157,7 @@ struct ThreeAmountsSection: View {
AmountV(scope, price, isNegative: nil)
}
}.talerFont(.body)
+ .accessibilityElement(children: .combine)
}
}
}