From 867dbf5b0c06dfb7056c9f473710736df25ba965 Mon Sep 17 00:00:00 2001 From: Markus Tamm Date: Wed, 3 Dec 2025 14:14:56 +0200 Subject: [PATCH 1/3] Fix accessibility issues on home view --- RIADigiDoc/UI/Component/HomeView.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/RIADigiDoc/UI/Component/HomeView.swift b/RIADigiDoc/UI/Component/HomeView.swift index 996b5043..b4116a7c 100644 --- a/RIADigiDoc/UI/Component/HomeView.swift +++ b/RIADigiDoc/UI/Component/HomeView.swift @@ -51,6 +51,8 @@ struct HomeView: View { @Binding private var externalFiles: [URL] + @AccessibilityFocusState private var isFilesButtonFocused: Bool + private var filesBottomSheetActions: [BottomSheetButton] { HomeViewBottomSheetActions.actions( onOpenFilesClick: { @@ -116,6 +118,7 @@ struct HomeView: View { viewModel: viewModel ) .bottomSheet(isPresented: $showFilesBottomSheet, actions: filesBottomSheetActions) + .accessibilityFocused($isFilesButtonFocused) SigningImportButton( title: languageSettings.localized("Signature"), @@ -174,6 +177,11 @@ struct HomeView: View { isNavigatingToEncryptView = false } }) + .onAppear { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { + isFilesButtonFocused = true + } + } } func getRecentDocumentsFolder(containerType: ContainerType) -> URL? { From 143025f8a3e31d40fb08d4c65a27c9df202f5ee9 Mon Sep 17 00:00:00 2001 From: Markus Tamm Date: Tue, 16 Dec 2025 18:16:01 +0200 Subject: [PATCH 2/3] Focus on files when bottom sheet is closed --- RIADigiDoc/UI/Component/HomeView.swift | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/RIADigiDoc/UI/Component/HomeView.swift b/RIADigiDoc/UI/Component/HomeView.swift index b4116a7c..1aa3ab46 100644 --- a/RIADigiDoc/UI/Component/HomeView.swift +++ b/RIADigiDoc/UI/Component/HomeView.swift @@ -89,6 +89,10 @@ struct HomeView: View { ) } + private var isBottomSheetPresented: Bool { + showFilesBottomSheet || showSignatureBottomSheet || showCryptoBottomSheet + } + init( fileOpeningViewModel: FileOpeningViewModel = Container.shared.fileOpeningViewModel(), cryptoFileOpeningViewModel: CryptoFileOpeningViewModel = Container.shared.cryptoFileOpeningViewModel(), @@ -177,12 +181,21 @@ struct HomeView: View { isNavigatingToEncryptView = false } }) + .onChange(of: isBottomSheetPresented) { oldValue, newValue in + if oldValue && !newValue { + focusFilesButtonWithDelay() + } + } .onAppear { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { + focusFilesButtonWithDelay() + } + } + + private func focusFilesButtonWithDelay() { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { isFilesButtonFocused = true } } - } func getRecentDocumentsFolder(containerType: ContainerType) -> URL? { switch containerType { From 9d7c76377988f7638a866a2324228c9033fefccc Mon Sep 17 00:00:00 2001 From: Markus Tamm Date: Mon, 29 Dec 2025 14:54:23 +0200 Subject: [PATCH 3/3] Move ContentView logic to HomeView --- RIADigiDoc/ContentView.swift | 85 +------- RIADigiDoc/DI/AppContainer.swift | 14 +- RIADigiDoc/UI/Component/HomeView.swift | 205 +++++++++++------- .../UI/Component/Shared/TopBar/TopBar.swift | 6 + .../Navigation/NavigationDestinations.swift | 2 +- RIADigiDoc/ViewModel/ContentViewModel.swift | 66 ------ RIADigiDoc/ViewModel/HomeViewModel.swift | 29 ++- .../Protocols/ContentViewModelProtocol.swift | 26 --- .../Protocols/HomeViewModelProtocol.swift | 1 + .../ViewModel/HomeViewModelTests.swift | 7 +- 10 files changed, 172 insertions(+), 269 deletions(-) delete mode 100644 RIADigiDoc/ViewModel/ContentViewModel.swift delete mode 100644 RIADigiDoc/ViewModel/Protocols/ContentViewModelProtocol.swift diff --git a/RIADigiDoc/ContentView.swift b/RIADigiDoc/ContentView.swift index ece1f916..89f7f646 100644 --- a/RIADigiDoc/ContentView.swift +++ b/RIADigiDoc/ContentView.swift @@ -19,93 +19,10 @@ import FactoryKit import SwiftUI -import OSLog -import UtilsLib struct ContentView: View { - @Environment(\.scenePhase) private var scenePhase - @AppTheme private var theme - @AppTypography private var typography - @Environment(LanguageSettings.self) private var languageSettings - - @Environment(NavigationPathManager.self) private var pathManager - - @State private var viewModel: ContentViewModel - - @State private var openedUrls: [URL] = [] - @State private var showHomeMenuBottomSheetFromButton = false - @State private var showSettingsBottomSheetFromButton = false - - @State private var navigateToAccessibility = false - @State private var navigateToInfo = false - @State private var navigateToDiagnostics = false - - @State private var sharedFilesLoadingTask: Task? - - private var homeMenuBottomSheetActions: [BottomSheetButton] { - HomeMenuBottomSheetActions.actions( - onInfoClick: { - pathManager.navigate(to: .infoView) - }, - onAccessibilityClick: { - pathManager.navigate(to: .accessibilityView) - }, - onDiagnosticsClick: { - pathManager.navigate(to: .diagnosticsView) - } - ) - } - - init() { - _viewModel = State(wrappedValue: Container.shared.contentViewModel()) - } - var body: some View { - TopBarContainer( - leftIcon: "ic_m3_menu_48pt_wght400", - leftIconAccessibility: "Menu", - onLeftClick: { - showHomeMenuBottomSheetFromButton = true - }, - content: { - ScrollView { - VStack { - HomeView(externalFiles: $openedUrls) - Spacer() - } - } - .background(theme.surface) - .onOpenURL { url in - openedUrls = [url] - } - .onAppear { - if scenePhase == .active { - sharedFilesLoadingTask = Task { - let sharedFiles = await viewModel.getSharedFiles() - if !sharedFiles.isEmpty { - openedUrls = sharedFiles - } - } - } - } - .onChange(of: scenePhase) { _, newPhase in - if newPhase == .active { - sharedFilesLoadingTask?.cancel() - - sharedFilesLoadingTask = Task { - let sharedFiles = await viewModel.getSharedFiles() - if !sharedFiles.isEmpty { - openedUrls = sharedFiles - } - } - } - } - .onDisappear { - sharedFilesLoadingTask?.cancel() - } - } - ) - .bottomSheet(isPresented: $showHomeMenuBottomSheetFromButton, actions: homeMenuBottomSheetActions) + HomeView() } } diff --git a/RIADigiDoc/DI/AppContainer.swift b/RIADigiDoc/DI/AppContainer.swift index e18873d0..4931ae05 100644 --- a/RIADigiDoc/DI/AppContainer.swift +++ b/RIADigiDoc/DI/AppContainer.swift @@ -86,7 +86,8 @@ extension Container { self { @MainActor in HomeViewModel( sharedContainerViewModel: self.sharedContainerViewModel(), - fileManager: self.fileManager() + fileManager: self.fileManager(), + fileUtil: self.fileUtil() ) } } @@ -205,17 +206,6 @@ extension Container { } } - @MainActor - var contentViewModel: Factory { - self { - @MainActor in - ContentViewModel( - fileUtil: self.fileUtil(), - fileManager: self.fileManager() - ) - } - } - @MainActor var recentDocumentsViewModel: Factory { self { diff --git a/RIADigiDoc/UI/Component/HomeView.swift b/RIADigiDoc/UI/Component/HomeView.swift index 1aa3ab46..27915584 100644 --- a/RIADigiDoc/UI/Component/HomeView.swift +++ b/RIADigiDoc/UI/Component/HomeView.swift @@ -25,8 +25,10 @@ import UtilsLib struct HomeView: View { @AppTheme private var theme - @Environment(LanguageSettings.self) private var languageSettings + @AppTypography private var typography + @Environment(\.scenePhase) private var scenePhase + @Environment(LanguageSettings.self) private var languageSettings @Environment(NavigationPathManager.self) private var pathManager @State private var viewModel: HomeViewModel @@ -45,12 +47,12 @@ struct HomeView: View { @State private var showFilesBottomSheet: Bool = false @State private var showSignatureBottomSheet: Bool = false @State private var showCryptoBottomSheet: Bool = false + @State private var showHomeMenuBottomSheet: Bool = false @State private var containerType: ContainerType = .asice @State private var recentDocumentsExtensions: [String] = Constants.Container.ContainerExtensions - @Binding private var externalFiles: [URL] - + @State private var sharedFilesLoadingTask: Task? @AccessibilityFocusState private var isFilesButtonFocused: Bool private var filesBottomSheetActions: [BottomSheetButton] { @@ -62,10 +64,10 @@ struct HomeView: View { containerType = .asice recentDocumentsExtensions = Constants.Container.ContainerExtensions pathManager.navigate(to: - .recentDocumentsView( - folderURL: getRecentDocumentsFolder(containerType: containerType), - extensions: recentDocumentsExtensions - ) + .recentDocumentsView( + folderURL: getRecentDocumentsFolder(containerType: containerType), + extensions: recentDocumentsExtensions + ) ) } ) @@ -80,93 +82,119 @@ struct HomeView: View { containerType = .cdoc recentDocumentsExtensions = Constants.Container.CryptoContainerExtensions pathManager.navigate(to: - .recentDocumentsView( - folderURL: getRecentDocumentsFolder(containerType: containerType), - extensions: recentDocumentsExtensions - ) + .recentDocumentsView( + folderURL: getRecentDocumentsFolder(containerType: containerType), + extensions: recentDocumentsExtensions + ) ) } ) } + private var homeMenuBottomSheetActions: [BottomSheetButton] { + HomeMenuBottomSheetActions.actions( + onInfoClick: { + pathManager.navigate(to: .infoView) + }, + onAccessibilityClick: { + pathManager.navigate(to: .accessibilityView) + }, + onDiagnosticsClick: { + pathManager.navigate(to: .diagnosticsView) + } + ) + } + private var isBottomSheetPresented: Bool { - showFilesBottomSheet || showSignatureBottomSheet || showCryptoBottomSheet + showFilesBottomSheet || showSignatureBottomSheet || showCryptoBottomSheet || showHomeMenuBottomSheet } init( fileOpeningViewModel: FileOpeningViewModel = Container.shared.fileOpeningViewModel(), cryptoFileOpeningViewModel: CryptoFileOpeningViewModel = Container.shared.cryptoFileOpeningViewModel(), - externalFiles: Binding<[URL]> ) { _viewModel = State(wrappedValue: Container.shared.homeViewModel()) _cryptoViewModel = State(wrappedValue: Container.shared.cryptoHomeViewModel()) self.fileOpeningViewModel = fileOpeningViewModel self.cryptoFileOpeningViewModel = cryptoFileOpeningViewModel - self._externalFiles = externalFiles } var body: some View { - VStack { - HomeHeader() - .padding(.bottom, Dimensions.Padding.LPadding) - - VStack(spacing: Dimensions.Padding.SPadding) { - SigningImportButton( - title: languageSettings.localized("Main home open document title"), - description: languageSettings.localized("Main home open document description"), - assetImageName: "ic_m3_attach_file_48pt_wght400", - isFileOpeningLoading: $isFileOpeningLoading, - isNavigatingToNextView: $isNavigatingToSigningView, - showBottomSheet: $showFilesBottomSheet, - isImporting: $isImporting, - viewModel: viewModel - ) - .bottomSheet(isPresented: $showFilesBottomSheet, actions: filesBottomSheetActions) - .accessibilityFocused($isFilesButtonFocused) - - SigningImportButton( - title: languageSettings.localized("Signature"), - description: languageSettings.localized("Main home signature description"), - assetImageName: "ic_m3_stylus_note_48pt_wght400", - isFileOpeningLoading: $isFileOpeningLoading, - isNavigatingToNextView: $isNavigatingToSigningView, - showBottomSheet: $showSignatureBottomSheet, - isImporting: $isImporting, - viewModel: viewModel - ) - .bottomSheet(isPresented: $showSignatureBottomSheet, actions: filesBottomSheetActions) - - CryptoImportButton( - title: languageSettings.localized("Main home crypto title"), - description: languageSettings.localized("Main home crypto description"), - assetImageName: "ic_m3_encrypted_48pt_wght400", - isFileOpeningLoading: $isCryptoFileOpeningLoading, - isNavigatingToNextView: $isNavigatingToEncryptView, - showBottomSheet: $showCryptoBottomSheet, - isImporting: $isCryptoImporting, - viewModel: cryptoViewModel - ) - .bottomSheet(isPresented: $showCryptoBottomSheet, actions: cryptoFilesBottomSheetActions) - - ActionButton( - title: languageSettings.localized("Main home my eid title"), - description: languageSettings.localized("Main home my eid description"), - assetImageName: "ic_m3_co_present_48pt_wght400", - action: { - pathManager.navigate(to: .myEidRootView) + TopBarContainer( + leftIcon: "ic_m3_menu_48pt_wght400", + leftIconAccessibility: "Menu", + onLeftClick: { + showHomeMenuBottomSheet = true + }, + onSettingsSheetDismiss: { + focusFilesButtonWithDelay() + }, + content: { + ScrollView { + HomeHeader() + .padding(.bottom, Dimensions.Padding.LPadding) + + VStack(spacing: Dimensions.Padding.SPadding) { + SigningImportButton( + title: languageSettings.localized("Main home open document title"), + description: languageSettings.localized("Main home open document description"), + assetImageName: "ic_m3_attach_file_48pt_wght400", + isFileOpeningLoading: $isFileOpeningLoading, + isNavigatingToNextView: $isNavigatingToSigningView, + showBottomSheet: $showFilesBottomSheet, + isImporting: $isImporting, + viewModel: viewModel + ) + .bottomSheet(isPresented: $showFilesBottomSheet, actions: filesBottomSheetActions) + .accessibilityFocused($isFilesButtonFocused) + + SigningImportButton( + title: languageSettings.localized("Signature"), + description: languageSettings.localized("Main home signature description"), + assetImageName: "ic_m3_stylus_note_48pt_wght400", + isFileOpeningLoading: $isFileOpeningLoading, + isNavigatingToNextView: $isNavigatingToSigningView, + showBottomSheet: $showSignatureBottomSheet, + isImporting: $isImporting, + viewModel: viewModel + ) + .bottomSheet(isPresented: $showSignatureBottomSheet, actions: filesBottomSheetActions) + + CryptoImportButton( + title: languageSettings.localized("Main home crypto title"), + description: languageSettings.localized("Main home crypto description"), + assetImageName: "ic_m3_encrypted_48pt_wght400", + isFileOpeningLoading: $isCryptoFileOpeningLoading, + isNavigatingToNextView: $isNavigatingToEncryptView, + showBottomSheet: $showCryptoBottomSheet, + isImporting: $isCryptoImporting, + viewModel: cryptoViewModel + ) + .bottomSheet(isPresented: $showCryptoBottomSheet, actions: cryptoFilesBottomSheetActions) + + ActionButton( + title: languageSettings.localized("Main home my eid title"), + description: languageSettings.localized("Main home my eid description"), + assetImageName: "ic_m3_co_present_48pt_wght400", + action: { + pathManager.navigate(to: .myEidRootView) + } + ) } - ) - } - .padding(Dimensions.Padding.SPadding) + .padding(Dimensions.Padding.SPadding) - Spacer() + Spacer() + } + } + ) + .bottomSheet(isPresented: $showHomeMenuBottomSheet, actions: homeMenuBottomSheetActions) + .onOpenURL { url in + handleFiles([url]) } - .onChange(of: externalFiles) { _, extFiles in - if !extFiles.isEmpty { - isFileOpeningLoading = true - viewModel.isImporting = false - self.viewModel.setChosenFiles(.success(extFiles)) - externalFiles = [] + .onAppear { + focusFilesButtonWithDelay() + if scenePhase == .active { + loadSharedFiles() } } .onChange(of: isNavigatingToSigningView, { _, newValue in @@ -186,16 +214,22 @@ struct HomeView: View { focusFilesButtonWithDelay() } } - .onAppear { - focusFilesButtonWithDelay() + .onChange(of: scenePhase) { _, newPhase in + if newPhase == .active { + sharedFilesLoadingTask?.cancel() + loadSharedFiles() + } + } + .onDisappear { + sharedFilesLoadingTask?.cancel() } } private func focusFilesButtonWithDelay() { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - isFilesButtonFocused = true - } + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { + isFilesButtonFocused = true } + } func getRecentDocumentsFolder(containerType: ContainerType) -> URL? { switch containerType { @@ -205,10 +239,25 @@ struct HomeView: View { return viewModel.getRecentDocumentsFolder() } } + + private func loadSharedFiles() { + sharedFilesLoadingTask = Task { + let sharedFiles = await viewModel.getSharedFiles() + handleFiles(sharedFiles) + } + } + + private func handleFiles(_ files: [URL]) { + if !files.isEmpty { + isFileOpeningLoading = true + viewModel.isImporting = false + viewModel.setChosenFiles(.success(files)) + } + } } #Preview { - HomeView(externalFiles: .constant([])) + HomeView() .environment(Container.shared.languageSettings()) .environment(Container.shared.themeSettings()) .environment(NavigationPathManager()) diff --git a/RIADigiDoc/UI/Component/Shared/TopBar/TopBar.swift b/RIADigiDoc/UI/Component/Shared/TopBar/TopBar.swift index 6e0b6f0f..3b8ff4a5 100644 --- a/RIADigiDoc/UI/Component/Shared/TopBar/TopBar.swift +++ b/RIADigiDoc/UI/Component/Shared/TopBar/TopBar.swift @@ -45,6 +45,7 @@ struct TopBarContainer: View { var rightSecondaryIconAccessibility: String = "Settings" var rightSecondaryIconAccessibilityInput: String? var onRightSecondaryClick: (() -> Void)? + var onSettingsSheetDismiss: (() -> Void)? var extraButtonIcon: String = "ic_m3_notifications_48pt_wght400" var extraButtonIconAccessibility: String = "Container notifications" @@ -106,6 +107,11 @@ struct TopBarContainer: View { content() } .bottomSheet(isPresented: $showSettingsSheet, actions: buildBottomSheetActions()) + .onChange(of: showSettingsSheet) { oldValue, newValue in + if oldValue && !newValue { + onSettingsSheetDismiss?() + } + } .navigationBarHidden(true) .navigationBarBackButtonHidden(true) .background(theme.surface) diff --git a/RIADigiDoc/UI/Navigation/NavigationDestinations.swift b/RIADigiDoc/UI/Navigation/NavigationDestinations.swift index eb8391c3..e89eed4e 100644 --- a/RIADigiDoc/UI/Navigation/NavigationDestinations.swift +++ b/RIADigiDoc/UI/Navigation/NavigationDestinations.swift @@ -105,7 +105,7 @@ struct NavigationDestinations: ViewModifier { ProxySettingsView() case .homeView: - HomeView(externalFiles: .constant([])) + HomeView() case .myEidRootView: MyEidRootView() } diff --git a/RIADigiDoc/ViewModel/ContentViewModel.swift b/RIADigiDoc/ViewModel/ContentViewModel.swift deleted file mode 100644 index e9c18bdd..00000000 --- a/RIADigiDoc/ViewModel/ContentViewModel.swift +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2017 - 2025 Riigi Infosüsteemi Amet - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -import Foundation -import OSLog -import FactoryKit -import UtilsLib -import CommonsLib - -@Observable -@MainActor -class ContentViewModel: ContentViewModelProtocol { - - private static let logger = Logger(subsystem: "ee.ria.digidoc.RIADigiDoc", category: "ContentViewModel") - - private let fileUtil: FileUtilProtocol - private let fileManager: FileManagerProtocol - - init( - fileUtil: FileUtilProtocol, - fileManager: FileManagerProtocol - ) { - self.fileUtil = fileUtil - self.fileManager = fileManager - } - - func getSharedFiles() async -> [URL] { - do { - ContentViewModel.logger.debug("Checking for shared files...") - let sharedFolderURL = try await Directories.getSharedFolder(fileManager: fileManager) - .validURL(fileUtil: fileUtil) - - let contents = try fileManager.contentsOfDirectory( - at: sharedFolderURL, - includingPropertiesForKeys: nil, - options: .skipsHiddenFiles) - - if contents.isEmpty { - ContentViewModel.logger.debug("Shared files folder is empty") - } else { - ContentViewModel.logger.debug("Found \(contents.count) shared files") - } - - return contents - } catch { - ContentViewModel.logger.error("Unable to get shared files: \(error.localizedDescription)") - return [] - } - } -} diff --git a/RIADigiDoc/ViewModel/HomeViewModel.swift b/RIADigiDoc/ViewModel/HomeViewModel.swift index 58eb9d2b..ae7569bc 100644 --- a/RIADigiDoc/ViewModel/HomeViewModel.swift +++ b/RIADigiDoc/ViewModel/HomeViewModel.swift @@ -37,13 +37,16 @@ class HomeViewModel: HomeViewModelProtocol { private let sharedContainerViewModel: SharedContainerViewModelProtocol private let fileManager: FileManagerProtocol + private let fileUtil: FileUtilProtocol init( sharedContainerViewModel: SharedContainerViewModelProtocol, - fileManager: FileManagerProtocol + fileManager: FileManagerProtocol, + fileUtil: FileUtilProtocol ) { self.sharedContainerViewModel = sharedContainerViewModel self.fileManager = fileManager + self.fileUtil = fileUtil } func didUserCancelFileOpening(isImportingValue: Bool, isFileOpeningLoading: Bool) -> Bool { @@ -68,4 +71,28 @@ class HomeViewModel: HomeViewModelProtocol { return nil } } + + func getSharedFiles() async -> [URL] { + do { + HomeViewModel.logger.debug("Checking for shared files...") + let sharedFolderURL = try await Directories.getSharedFolder(fileManager: fileManager) + .validURL(fileUtil: fileUtil) + + let contents = try fileManager.contentsOfDirectory( + at: sharedFolderURL, + includingPropertiesForKeys: nil, + options: .skipsHiddenFiles) + + if contents.isEmpty { + HomeViewModel.logger.debug("Shared files folder is empty") + } else { + HomeViewModel.logger.debug("Found \(contents.count) shared files") + } + + return contents + } catch { + HomeViewModel.logger.error("Unable to get shared files: \(error.localizedDescription)") + return [] + } + } } diff --git a/RIADigiDoc/ViewModel/Protocols/ContentViewModelProtocol.swift b/RIADigiDoc/ViewModel/Protocols/ContentViewModelProtocol.swift deleted file mode 100644 index 99000a47..00000000 --- a/RIADigiDoc/ViewModel/Protocols/ContentViewModelProtocol.swift +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2017 - 2025 Riigi Infosüsteemi Amet - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -import Foundation - -/// @mockable -@MainActor -public protocol ContentViewModelProtocol: Sendable { - func getSharedFiles() async -> [URL] -} diff --git a/RIADigiDoc/ViewModel/Protocols/HomeViewModelProtocol.swift b/RIADigiDoc/ViewModel/Protocols/HomeViewModelProtocol.swift index 3c8ccc5f..bd716e9a 100644 --- a/RIADigiDoc/ViewModel/Protocols/HomeViewModelProtocol.swift +++ b/RIADigiDoc/ViewModel/Protocols/HomeViewModelProtocol.swift @@ -26,4 +26,5 @@ public protocol HomeViewModelProtocol: Sendable { func didUserCancelFileOpening(isImportingValue: Bool, isFileOpeningLoading: Bool) -> Bool func setChosenFiles(_ chosenFiles: Result<[URL], Error>) func getRecentDocumentsFolder() -> URL? + func getSharedFiles() async -> [URL] } diff --git a/RIADigiDocTests/ViewModel/HomeViewModelTests.swift b/RIADigiDocTests/ViewModel/HomeViewModelTests.swift index 596c81dd..583ecab3 100644 --- a/RIADigiDocTests/ViewModel/HomeViewModelTests.swift +++ b/RIADigiDocTests/ViewModel/HomeViewModelTests.swift @@ -21,19 +21,24 @@ import Foundation import Testing import CommonsLib import CommonsLibMocks +import UtilsLib +import UtilsLibMocks @MainActor struct HomeViewModelTests { private let mockSharedContainerViewModel: SharedContainerViewModelProtocolMock private let mockFileManager: FileManagerProtocolMock + private let mockFileUtil: FileUtilProtocolMock private let viewModel: HomeViewModel init() async throws { mockSharedContainerViewModel = SharedContainerViewModelProtocolMock() mockFileManager = FileManagerProtocolMock() + mockFileUtil = FileUtilProtocolMock() viewModel = HomeViewModel( sharedContainerViewModel: mockSharedContainerViewModel, - fileManager: mockFileManager + fileManager: mockFileManager, + fileUtil: mockFileUtil ) }