Forráskód Böngészése

Select view now opens in correct directory

Signed-off-by: Fredrik Rentsch <fredrik@rentsch.no>
Fredrik Rentsch 4 éve
szülő
commit
0092519802
1 módosított fájl, 30 hozzáadás és 12 törlés
  1. 30 12
      iOSClient/Main/Colleaction Common/NCCollectionCommon.swift

+ 30 - 12
iOSClient/Main/Colleaction Common/NCCollectionCommon.swift

@@ -105,23 +105,41 @@ class NCCollectionCommon: NSObject, NCSelectDelegate {
     func openSelectView(viewController: UIViewController, items: [Any]) {
         
         let navigationController = UIStoryboard.init(name: "NCSelect", bundle: nil).instantiateInitialViewController() as! UINavigationController
-        let vc = navigationController.topViewController as! NCSelect
+        var vc_list = [NCSelect]()
         var copyItems: [Any] = []
         for item in items {
             copyItems.append(item)
         }
         
-        vc.delegate = self
-        vc.hideButtonCreateFolder = false
-        vc.selectFile = false
-        vc.includeDirectoryE2EEncryption = false
-        vc.includeImages = false
-        vc.type = ""
-        vc.titleButtonDone = NSLocalizedString("_move_", comment: "")
-        vc.titleButtonDone1 = NSLocalizedString("_copy_",comment: "")
-        vc.isButtonDone1Hide = false
-        vc.isOverwriteHide = false
-        vc.items = copyItems
+        let appDelegate = UIApplication.shared.delegate as! AppDelegate
+        let homeUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
+        var serverUrl = (copyItems[0] as! Nextcloud.tableMetadata).serverUrl
+        
+        // Setup view controllers such that the current view is of the same directory the items to be copied are in
+        while true {
+            guard let vc = UIStoryboard(name: "NCSelect", bundle: nil).instantiateViewController(withIdentifier: "NCSelect.storyboard") as? NCSelect else { return }
+            vc.delegate = self
+            vc.hideButtonCreateFolder = false
+            vc.selectFile = false
+            vc.includeDirectoryE2EEncryption = false
+            vc.includeImages = false
+            vc.type = ""
+            vc.titleButtonDone = NSLocalizedString("_move_", comment: "")
+            vc.titleButtonDone1 = NSLocalizedString("_copy_",comment: "")
+            vc.isButtonDone1Hide = false
+            vc.isOverwriteHide = false
+            vc.items = copyItems
+            vc.serverUrl = serverUrl
+            vc_list.insert(vc, at: 0)
+            
+            if serverUrl != homeUrl {
+                serverUrl = CCUtility.deletingLastPathComponent(fromServerUrl: serverUrl)
+            } else {
+                break
+            }
+            
+        }
+        navigationController.setViewControllers(vc_list, animated: false)
         
         navigationController.modalPresentationStyle = .fullScreen
         viewController.present(navigationController, animated: true, completion: nil)