commit 7cd1cdb11d9272db9fcd5b73442152a4a1c4df18
parent 9d5526f246f406a446fd80af53a198da7cc0ea77
Author: Marc Stibane <marc@taler.net>
Date: Mon, 23 Nov 2026 08:14:42 +0100
Error view, A11y
Diffstat:
1 file changed, 48 insertions(+), 34 deletions(-)
diff --git a/TalerWallet1/Views/Main/ErrorView.swift b/TalerWallet1/Views/Main/ErrorView.swift
@@ -104,6 +104,7 @@ enum ErrorData {
struct ErrorView: View {
let stack: CallStack?
var title: String
+ var titleA11y: String?
var exclam: Bool
var message: String? = nil
var requestUrl: String? = nil
@@ -111,11 +112,15 @@ struct ErrorView: View {
var onDismiss: (() -> Void)?
- init(_ stack: CallStack?, title: String, exclam: Bool = true, message: String? = nil,
- requestUrl: String? = nil, copyable: Bool = false, onDismiss: (() -> Void)? = nil) {
+ init(_ stack: CallStack?, title: String, titleA11y: String? = nil,
+ exclam: Bool = true, message: String? = nil,
+ requestUrl: String? = nil, copyable: Bool = false,
+ onDismiss: (() -> Void)? = nil
+ ) {
self.stack = stack
self.title = title
self.exclam = exclam
+ self.titleA11y = titleA11y
self.message = message
self.requestUrl = requestUrl
self.copyable = copyable
@@ -269,44 +274,53 @@ struct ErrorView: View {
}
}
+// @ScaledMetric // relative to fontSize
+ var frameSize: CGFloat = 50
+
+ @ViewBuilder
+ func content() -> some View {
+ if let message {
+ if copyable {
+ if #available(iOS 16.4, *) {
+ Text(message).monospaced()
+ } else {
+ Text(message).font(.system(.body, design: .monospaced))
+ }
+
+ CopyButton(message, vertical: false)
+ .accessibilityLabel(Text("Copy the error JSON", comment: "a11y"))
+ .padding()
+ } else {
+ if let requestUrl {
+ Text(requestUrl)
+ .multilineTextAlignment(.center)
+ .padding()
+ }
+ Text(message)
+ .multilineTextAlignment(.center)
+ .padding()
+ }
+ }
+ }
+
var body: some View {
ScrollView {
VStack {
- if exclam {
- Image(systemName: EXCLAMATION)
- .resizable()
- .frame(width: 50, height: 50)
- .aspectRatio(contentMode: .fit)
- .foregroundStyle(WalletColors().attention)
- .padding()
- }
+ Image(systemName: EXCLAMATION)
+ .resizable()
+ .frame(width: frameSize, height: frameSize)
+ .aspectRatio(contentMode: .fit)
+ .foregroundStyle(exclam ? WalletColors().attention : WalletColors().gray1)
+ .padding()
+ .accessibilityHidden(true)
Text(title)
.talerFont(.title)
.padding(.bottom)
-
- if let message {
- if copyable {
- if #available(iOS 16.4, *) {
- Text(message).monospaced()
- } else {
- Text(message).font(.system(.body, design: .monospaced))
- }
-
- CopyButton(message, vertical: false)
- .accessibilityLabel(Text("Copy the error JSON", comment: "a11y"))
- .padding()
- } else {
- if let requestUrl {
- Text(requestUrl)
- .multilineTextAlignment(.center)
- .padding()
- }
- Text(message)
- .multilineTextAlignment(.center)
- .padding()
- }
- }
- }
+ .accessibilityLabel(Text(titleA11y ?? title))
+ } .accessibilityAddTraits(.isHeader)
+ .accessibilitySortPriority(2)
+ content()
+ .accessibilitySortPriority(1)
}
.padding()
.safeAreaInset(edge: .bottom) {