Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,12 @@ extension URL {
}
}
}

extension URL {
public var isPlainText: Bool {
guard let type = UTType(
filenameExtension: pathExtension.lowercased()
) else { return false }
return type.conforms(to: .text)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct CryptoDataFilesSection: View {
}
)
.background(fileSaverBackground)
.quickLookPreview($viewModel.previewFile)
.filePreview(item: $viewModel.previewFile)
}

private func openFile(_ dataFile: URL) {
Expand Down
3 changes: 1 addition & 2 deletions RIADigiDoc/UI/Component/Container/Crypto/EncryptView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

import SwiftUI
import QuickLook
import FactoryKit
import CryptoObjCWrapper
import CommonsLib
Expand Down Expand Up @@ -310,7 +309,7 @@ struct EncryptView: View {
isFileSaved: $isFileSaved
)
)
.quickLookPreview($viewModel.previewFile)
.filePreview(item: $viewModel.previewFile)
}
.padding(.vertical, Dimensions.Padding.MPadding)
} else {
Expand Down
2 changes: 1 addition & 1 deletion RIADigiDoc/UI/Component/Container/DataFilesSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct DataFilesSection: View {
)
.alert(sivaMessage, isPresented: $showSivaMessage, actions: alertActions)
.background(fileSaverBackground)
.quickLookPreview($viewModel.previewFile)
.filePreview(item: $viewModel.previewFile)
}

private func openFile(_ dataFile: DataFileWrapper) {
Expand Down
18 changes: 18 additions & 0 deletions RIADigiDoc/UI/Component/Container/Signing/ControlCodeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ struct ControlCodeView: View {
@Binding var controlCode: String
@Binding var infoMessage: String

@AccessibilityFocusState private var isControlCodeFocused: Bool

private var isControlCodeValid: Bool {
!controlCode.isEmpty && controlCode.allSatisfy { $0.isNumber }
}

var body: some View {
VStack(alignment: .center) {
Image(icon)
Expand All @@ -46,18 +52,30 @@ struct ControlCodeView: View {
Text(verbatim: languageSettings.localized("Control code"))
.font(typography.bodyLarge)
.foregroundStyle(theme.onSurface)
.accessibilityHidden(!isControlCodeValid)

Text(verbatim: controlCode)
.speechSpellsOutCharacters(true)
.font(typography.displayMedium)
.foregroundStyle(theme.onSurface)
.scaleEffect(x: Dimensions.Scaling.WideScaling, y: Dimensions.Scaling.DefaultScaling)
.accessibilityIdentifier("controlCode")
.accessibilityHidden(!isControlCodeValid)

Text(verbatim: languageSettings.localized(infoMessage))
.font(typography.bodyLarge)
.foregroundStyle(theme.onSurface)
.accessibilityIdentifier("infoMessage")
}
.onChange(of: controlCode) { _, newValue in
if (!newValue.isEmpty && newValue.allSatisfy { $0.isNumber }) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
isControlCodeFocused = true
}
}
}
.accessibilityFocused($isControlCodeFocused)
.accessibilityElement(children: .combine)
}
.onDisappear {
controlCode = "- - - -"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import IdCardLib
import CommonsLib

struct IdCardView: View {
@Environment(\.accessibilityVoiceOverEnabled) private var voiceOverEnabled
@Environment(\.openURL) private var openURL
@Environment(\.dismiss) private var dismiss
@Environment(LanguageSettings.self) private var languageSettings
Expand Down Expand Up @@ -116,6 +117,10 @@ struct IdCardView: View {
viewModel.idCardAlertMessageKey?.isEmpty == false
}

private var signatureAddedMessage: String {
languageSettings.localized("Signature added")
}

init(
actionType: ActionType,
actionMethods: [ActionMethod],
Expand Down Expand Up @@ -487,10 +492,10 @@ struct IdCardView: View {
isShowingPinView = false
isShowingLoadingView = false

Toast.show(
languageSettings.localized("Signature added"),
type: .success
)
Toast.show(signatureAddedMessage, type: .success)
if voiceOverEnabled {
AccessibilityUtil.announceMessage(signatureAddedMessage)
}

onSuccess(container)
dismiss()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import LibdigidocLibSwift
import CommonsLib

struct MobileIdView: View {
@Environment(\.accessibilityVoiceOverEnabled) private var voiceOverEnabled
@Environment(\.openURL) private var openURL
@Environment(\.dismiss) private var dismiss
@Environment(LanguageSettings.self) private var languageSettings
Expand Down Expand Up @@ -138,9 +139,13 @@ struct MobileIdView: View {
if let messageKey = newValue,
!messageKey.isEmpty {
let extraArguments = viewModel.mobileIdAlertMessageExtraArguments
Toast.show(
languageSettings.localized(messageKey, extraArguments)
)
let message = languageSettings.localized(messageKey, extraArguments)

Toast.show(message)
if voiceOverEnabled {
AccessibilityUtil.announceMessage(message)
}

viewModel.mobileIdErrorMessageKey = nil
viewModel.mobileIdAlertMessageExtraArguments = []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct ConfirmModalView: View {
.opacity(Dimensions.Shadow.LOpacity)
.ignoresSafeArea()
.accessibilityHidden(true)
.allowsHitTesting(true)

TextModal(
title: title,
Expand All @@ -54,5 +55,6 @@ struct ConfirmModalView: View {
.accessibilityAddTraits(.isModal)
.accessibilityElement(children: .contain)
}
.accessibilityAddTraits(.isModal)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ struct NFCInputView: View {
text: $canNumber,
isError: !(canNumberError?.isEmpty ?? true),
errorText: canNumberError ?? "",
keyboardType: .numberPad
keyboardType: .numberPad,
sortPriority: 0
)
.onChange(of: canNumber) {
onInputChange()
Expand All @@ -96,10 +97,12 @@ struct NFCInputView: View {
Text(verbatim: canNumberLocationLabel)
.font(typography.labelMedium)
.foregroundStyle(theme.onSecondaryContainer)
.padding(.vertical, Dimensions.Padding.XXSPadding)
.padding(.top, Dimensions.Padding.XXSPadding)
.accessibilitySortPriority(1)
}
.accessibilityElement(children: .contain)
}
.padding(.vertical, Dimensions.Padding.ZeroPadding)
.padding(.bottom, Dimensions.Padding.MPadding)

if showPinField {
VStack(alignment: .leading, spacing: Dimensions.Padding.ZeroPadding) {
Expand Down
8 changes: 8 additions & 0 deletions RIADigiDoc/UI/Component/Container/Signing/NFC/NFCView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import CryptoSwift
import IdCardLib
import LibdigidocLibSwift
import CommonsLib

struct NFCView: View {
@Environment(\.accessibilityVoiceOverEnabled) private var voiceOverEnabled
@Environment(\.dismiss) private var dismiss
@Environment(\.openURL) private var openURL
@Environment(LanguageSettings.self) private var languageSettings
Expand Down Expand Up @@ -95,6 +97,10 @@ struct NFCView: View {
languageSettings.localized(key, args)
}
}

private var signatureAddedMessage: String {
languageSettings.localized("Signature added")
}

let signedContainer: SignedContainerProtocol?
let cryptoContainer: CryptoContainerProtocol?
Expand Down Expand Up @@ -358,6 +364,8 @@ struct NFCView: View {
guard let container = updatedContainer else {
return
}

Toast.show(signatureAddedMessage, type: .success)

onSuccess(container)
dismiss()
Expand Down
3 changes: 1 addition & 2 deletions RIADigiDoc/UI/Component/Container/Signing/SigningView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

import SwiftUI
import QuickLook
import FactoryKit
import LibdigidocLibSwift
import CommonsLib
Expand Down Expand Up @@ -317,7 +316,7 @@ struct SigningView: View {
isFileSaved: $isFileSaved
)
)
.quickLookPreview($viewModel.previewFile)
.filePreview(item: $viewModel.previewFile)
}
.padding(.vertical, Dimensions.Padding.MPadding)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import CommonsLib

struct SmartIdView: View {
@Environment(\.scenePhase) private var scenePhase
@Environment(\.accessibilityVoiceOverEnabled) private var voiceOverEnabled
@Environment(\.openURL) private var openURL
@Environment(\.dismiss) private var dismiss
@Environment(LanguageSettings.self) private var languageSettings
Expand Down Expand Up @@ -149,9 +150,12 @@ struct SmartIdView: View {
.onChange(of: viewModel.smartIdErrorMessageKey, { _, newValue in
if let messageKey = newValue, !messageKey.isEmpty {
let extraArguments = viewModel.smartIdAlertMessageExtraArguments
Toast.show(
languageSettings.localized(messageKey, extraArguments)
)
let message = languageSettings.localized(messageKey, extraArguments)
Toast.show(message)
if voiceOverEnabled {
AccessibilityUtil.announceMessage(message)
}

viewModel.smartIdErrorMessageKey = nil
viewModel.smartIdAlertMessageExtraArguments = []
}
Expand Down
2 changes: 2 additions & 0 deletions RIADigiDoc/UI/Component/Container/UnsignedBottomBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct UnsignedBottomBarView: View {
Text(languageSettings.localized(leftButtonLabel))
.foregroundStyle(theme.primary)
.font(typography.titleMedium)
.minimumScaleFactor(0.5)
.accessibilityLabel(leftButtonAccessibilityLabel)
})
.foregroundStyle(theme.surfaceContainer)
Expand All @@ -72,6 +73,7 @@ struct UnsignedBottomBarView: View {
Text(languageSettings.localized(rightButtonLabel))
.foregroundStyle(theme.primary)
.font(typography.titleMedium)
.minimumScaleFactor(0.5)
.accessibilityLabel(rightButtonAccessibilityLabel)
}
.padding(.horizontal, Dimensions.Padding.MPadding)
Expand Down
1 change: 1 addition & 0 deletions RIADigiDoc/UI/Component/My eID/MyEidPinChangeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ struct MyEidPinChangeView: View {
.frame(maxWidth: .infinity, alignment: .leading)
.accessibilitySortPriority(1)
}
.accessibilityElement(children: .contain)
}
}

Expand Down
24 changes: 24 additions & 0 deletions RIADigiDoc/UI/Component/Shared/Extension/ViewExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,27 @@ extension View {
}
}
}

extension View {
func filePreview(item: Binding<FileItem?>) -> some View {
self.sheet(item: item) { file in
FilePreviewSheet(url: file.url, isPresented: Binding(
get: { item.wrappedValue != nil },
set: { if !$0 { item.wrappedValue = nil } }
))
}
}
}

private struct FilePreviewSheet: View {
let url: URL
@Binding var isPresented: Bool

var body: some View {
if url.isPlainText {
TextFilePreview(url: url, isPresented: $isPresented)
} else {
PreviewController(url: url, isPresented: $isPresented)
}
}
}
Loading
Loading