diff options
author | marinofaggiana <ios@nextcloud.com> | 2022-08-02 12:28:11 +0300 |
---|---|---|
committer | marinofaggiana <ios@nextcloud.com> | 2022-08-02 12:28:11 +0300 |
commit | 9cf7562fba9e1aa8d5372197fbac6ff09525e20b (patch) | |
tree | dedfd21f095d9aba4ac9c10535156228409c58c9 /iOSClient | |
parent | efb1fb5fe3b3e8435efc7787ec6494d166ebc73c (diff) |
new openFileViewInFolder
Signed-off-by: marinofaggiana <ios@nextcloud.com>
Diffstat (limited to 'iOSClient')
-rw-r--r-- | iOSClient/AppDelegate.swift | 2 | ||||
-rw-r--r-- | iOSClient/Main/Collection Common/NCCollectionViewCommon.swift | 2 | ||||
-rw-r--r-- | iOSClient/Main/NCFunctionCenter.swift | 34 | ||||
-rw-r--r-- | iOSClient/Menu/NCViewer+Menu.swift | 2 |
4 files changed, 36 insertions, 4 deletions
diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index e051af989..67256ae35 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -868,7 +868,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD } DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - NCFunctionCenter.shared.openFileViewInFolder(serverUrl: serverUrl, fileName: fileName) + NCFunctionCenter.shared.openFileViewInFolder(viewController: self.activeViewController, serverUrl: serverUrl, fileName: fileName) } } else { diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index f5adadb27..91a75882b 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -1282,7 +1282,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate { pushMetadata(metadata) - } else if !(self is NCFileViewInFolder) { + } else { //if !(self is NCFileViewInFolder) { let imageIcon = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) diff --git a/iOSClient/Main/NCFunctionCenter.swift b/iOSClient/Main/NCFunctionCenter.swift index bf67cdda1..49524b768 100644 --- a/iOSClient/Main/NCFunctionCenter.swift +++ b/iOSClient/Main/NCFunctionCenter.swift @@ -454,6 +454,7 @@ import Photos // MARK: - + /* func openFileViewInFolder(serverUrl: String, fileName: String) { let viewController = UIStoryboard(name: "NCFileViewInFolder", bundle: nil).instantiateInitialViewController() as! NCFileViewInFolder @@ -496,6 +497,37 @@ import Photos appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil) } + */ + + func openFileViewInFolder(viewController: UIViewController?, serverUrl: String, fileName: String) { + + var topNavigationController: UINavigationController? + var pushServerUrl = NCUtilityFileSystem.shared.getHomeServer(account: appDelegate.account) + + viewController?.navigationController?.popToRootViewController(animated: false) + if let tabBarController = appDelegate.window?.rootViewController as? UITabBarController { + tabBarController.selectedIndex = 0 + if let navigationController = tabBarController.viewControllers?.first as? UINavigationController { + navigationController.popToRootViewController(animated: false) + topNavigationController = navigationController + } + } + guard let topNavigationController = topNavigationController else { return} + + while pushServerUrl != serverUrl { + + guard let viewController = UIStoryboard(name: "NCFiles", bundle: nil).instantiateInitialViewController() as? NCFiles else { return } + pushServerUrl = pushServerUrl + "/" + fileName + viewController.isRoot = false + viewController.serverUrl = pushServerUrl + viewController.titleCurrentFolder = fileName + appDelegate.listFilesVC[serverUrl] = viewController + + viewController.navigationItem.backButtonTitle = viewController.titleCurrentFolder + topNavigationController.pushViewController(viewController, animated: false) + } + } + // MARK: - NCSelect + Delegate @@ -633,7 +665,7 @@ import Photos } let viewInFolder = UIAction(title: NSLocalizedString("_view_in_folder_", comment: ""), image: UIImage(systemName: "arrow.forward.square")) { _ in - self.openFileViewInFolder(serverUrl: metadata.serverUrl, fileName: metadata.fileName) + self.openFileViewInFolder(viewController: viewController, serverUrl: metadata.serverUrl, fileName: metadata.fileName) } let openIn = UIAction(title: NSLocalizedString("_open_in_", comment: ""), image: UIImage(systemName: "square.and.arrow.up") ) { _ in diff --git a/iOSClient/Menu/NCViewer+Menu.swift b/iOSClient/Menu/NCViewer+Menu.swift index 5b18d6a6f..d345185d2 100644 --- a/iOSClient/Menu/NCViewer+Menu.swift +++ b/iOSClient/Menu/NCViewer+Menu.swift @@ -192,7 +192,7 @@ extension NCViewer { title: NSLocalizedString("_view_in_folder_", comment: ""), icon: NCUtility.shared.loadImage(named: "arrow.forward.square"), action: { menuAction in - NCFunctionCenter.shared.openFileViewInFolder(serverUrl: metadata.serverUrl, fileName: metadata.fileName) + NCFunctionCenter.shared.openFileViewInFolder(viewController: viewController, serverUrl: metadata.serverUrl, fileName: metadata.fileName) } ) ) |