Skip to content

Commit 0f22eac

Browse files
committed
Add accessibility improvements to My eID
1 parent a37a486 commit 0f22eac

24 files changed

+411
-113
lines changed

Modules/UtilsLib/Sources/UtilsLib/Extensions/URLExtensions.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,12 @@ extension URL {
398398
}
399399
}
400400
}
401+
402+
extension URL {
403+
public var isPlainText: Bool {
404+
guard let type = UTType(
405+
filenameExtension: pathExtension.lowercased()
406+
) else { return false }
407+
return type.conforms(to: .text)
408+
}
409+
}

RIADigiDoc/UI/Component/Container/Crypto/CryptoDataFilesSection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ struct CryptoDataFilesSection: View {
8383
}
8484
)
8585
.background(fileSaverBackground)
86-
.quickLookPreview($viewModel.previewFile)
86+
.filePreview(item: $viewModel.previewFile)
8787
}
8888

8989
private func openFile(_ dataFile: URL) {

RIADigiDoc/UI/Component/Container/Crypto/EncryptView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919

2020
import SwiftUI
21-
import QuickLook
2221
import FactoryKit
2322
import CryptoObjCWrapper
2423
import CommonsLib
@@ -310,7 +309,7 @@ struct EncryptView: View {
310309
isFileSaved: $isFileSaved
311310
)
312311
)
313-
.quickLookPreview($viewModel.previewFile)
312+
.filePreview(item: $viewModel.previewFile)
314313
}
315314
.padding(.vertical, Dimensions.Padding.MPadding)
316315
} else {

RIADigiDoc/UI/Component/Container/DataFilesSection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct DataFilesSection: View {
7676
)
7777
.alert(sivaMessage, isPresented: $showSivaMessage, actions: alertActions)
7878
.background(fileSaverBackground)
79-
.quickLookPreview($viewModel.previewFile)
79+
.filePreview(item: $viewModel.previewFile)
8080
}
8181

8282
private func openFile(_ dataFile: DataFileWrapper) {

RIADigiDoc/UI/Component/Container/Signing/ControlCodeView.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ struct ControlCodeView: View {
3131
@Binding var controlCode: String
3232
@Binding var infoMessage: String
3333

34+
@AccessibilityFocusState private var isControlCodeFocused: Bool
35+
36+
private var isControlCodeValid: Bool {
37+
!controlCode.isEmpty && controlCode.allSatisfy { $0.isNumber }
38+
}
39+
3440
var body: some View {
3541
VStack(alignment: .center) {
3642
Image(icon)
@@ -46,18 +52,30 @@ struct ControlCodeView: View {
4652
Text(verbatim: languageSettings.localized("Control code"))
4753
.font(typography.bodyLarge)
4854
.foregroundStyle(theme.onSurface)
55+
.accessibilityHidden(!isControlCodeValid)
4956

5057
Text(verbatim: controlCode)
58+
.speechSpellsOutCharacters(true)
5159
.font(typography.displayMedium)
5260
.foregroundStyle(theme.onSurface)
5361
.scaleEffect(x: Dimensions.Scaling.WideScaling, y: Dimensions.Scaling.DefaultScaling)
5462
.accessibilityIdentifier("controlCode")
63+
.accessibilityHidden(!isControlCodeValid)
5564

5665
Text(verbatim: languageSettings.localized(infoMessage))
5766
.font(typography.bodyLarge)
5867
.foregroundStyle(theme.onSurface)
5968
.accessibilityIdentifier("infoMessage")
6069
}
70+
.onChange(of: controlCode) { _, newValue in
71+
if (!newValue.isEmpty && newValue.allSatisfy { $0.isNumber }) {
72+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
73+
isControlCodeFocused = true
74+
}
75+
}
76+
}
77+
.accessibilityFocused($isControlCodeFocused)
78+
.accessibilityElement(children: .combine)
6179
}
6280
.onDisappear {
6381
controlCode = "- - - -"

RIADigiDoc/UI/Component/Container/Signing/IdCard/IdCardView.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import IdCardLib
2525
import CommonsLib
2626

2727
struct IdCardView: View {
28+
@Environment(\.accessibilityVoiceOverEnabled) private var voiceOverEnabled
2829
@Environment(\.openURL) private var openURL
2930
@Environment(\.dismiss) private var dismiss
3031
@Environment(LanguageSettings.self) private var languageSettings
@@ -116,6 +117,10 @@ struct IdCardView: View {
116117
viewModel.idCardAlertMessageKey?.isEmpty == false
117118
}
118119

120+
private var signatureAddedMessage: String {
121+
languageSettings.localized("Signature added")
122+
}
123+
119124
init(
120125
actionType: ActionType,
121126
actionMethods: [ActionMethod],
@@ -487,10 +492,10 @@ struct IdCardView: View {
487492
isShowingPinView = false
488493
isShowingLoadingView = false
489494

490-
Toast.show(
491-
languageSettings.localized("Signature added"),
492-
type: .success
493-
)
495+
Toast.show(signatureAddedMessage, type: .success)
496+
if voiceOverEnabled {
497+
AccessibilityUtil.announceMessage(signatureAddedMessage)
498+
}
494499

495500
onSuccess(container)
496501
dismiss()

RIADigiDoc/UI/Component/Container/Signing/MobileId/MobileIdView.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import LibdigidocLibSwift
2323
import CommonsLib
2424

2525
struct MobileIdView: View {
26+
@Environment(\.accessibilityVoiceOverEnabled) private var voiceOverEnabled
2627
@Environment(\.openURL) private var openURL
2728
@Environment(\.dismiss) private var dismiss
2829
@Environment(LanguageSettings.self) private var languageSettings
@@ -138,9 +139,13 @@ struct MobileIdView: View {
138139
if let messageKey = newValue,
139140
!messageKey.isEmpty {
140141
let extraArguments = viewModel.mobileIdAlertMessageExtraArguments
141-
Toast.show(
142-
languageSettings.localized(messageKey, extraArguments)
143-
)
142+
let message = languageSettings.localized(messageKey, extraArguments)
143+
144+
Toast.show(message)
145+
if voiceOverEnabled {
146+
AccessibilityUtil.announceMessage(message)
147+
}
148+
144149
viewModel.mobileIdErrorMessageKey = nil
145150
viewModel.mobileIdAlertMessageExtraArguments = []
146151
}

RIADigiDoc/UI/Component/Container/Signing/Modal/ConfirmModalView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct ConfirmModalView: View {
3838
.opacity(Dimensions.Shadow.LOpacity)
3939
.ignoresSafeArea()
4040
.accessibilityHidden(true)
41+
.allowsHitTesting(true)
4142

4243
TextModal(
4344
title: title,
@@ -54,5 +55,6 @@ struct ConfirmModalView: View {
5455
.accessibilityAddTraits(.isModal)
5556
.accessibilityElement(children: .contain)
5657
}
58+
.accessibilityAddTraits(.isModal)
5759
}
5860
}

RIADigiDoc/UI/Component/Container/Signing/NFC/NFCInputView.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ struct NFCInputView: View {
8787
text: $canNumber,
8888
isError: !(canNumberError?.isEmpty ?? true),
8989
errorText: canNumberError ?? "",
90-
keyboardType: .numberPad
90+
keyboardType: .numberPad,
91+
sortPriority: 0
9192
)
9293
.onChange(of: canNumber) {
9394
onInputChange()
@@ -96,10 +97,12 @@ struct NFCInputView: View {
9697
Text(verbatim: canNumberLocationLabel)
9798
.font(typography.labelMedium)
9899
.foregroundStyle(theme.onSecondaryContainer)
99-
.padding(.vertical, Dimensions.Padding.XXSPadding)
100+
.padding(.top, Dimensions.Padding.XXSPadding)
101+
.accessibilitySortPriority(1)
100102
}
103+
.accessibilityElement(children: .contain)
101104
}
102-
.padding(.vertical, Dimensions.Padding.ZeroPadding)
105+
.padding(.bottom, Dimensions.Padding.MPadding)
103106

104107
if showPinField {
105108
VStack(alignment: .leading, spacing: Dimensions.Padding.ZeroPadding) {

RIADigiDoc/UI/Component/Container/Signing/NFC/NFCView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ import CryptoSwift
2323
import IdCardLib
2424
import LibdigidocLibSwift
2525
import CommonsLib
26+
2627
struct NFCView: View {
28+
@Environment(\.accessibilityVoiceOverEnabled) private var voiceOverEnabled
2729
@Environment(\.dismiss) private var dismiss
2830
@Environment(\.openURL) private var openURL
2931
@Environment(LanguageSettings.self) private var languageSettings
@@ -359,6 +361,10 @@ struct NFCView: View {
359361
return
360362
}
361363

364+
if voiceOverEnabled {
365+
AccessibilityUtil.announceMessage(languageSettings.localized("Signature added"))
366+
}
367+
362368
onSuccess(container)
363369
dismiss()
364370
}

0 commit comments

Comments
 (0)