marinofaggiana 4 years ago
parent
commit
b25b98eb76

+ 1 - 5
iOSClient/FileViewInFolder/NCFileViewInFolder.swift

@@ -62,11 +62,7 @@ class NCFileViewInFolder: NCCollectionViewCommon  {
         self.navigationItem.leftBarButtonItem = nil
         self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_close_", comment: ""), style: .plain, target: self, action: #selector(tapClose(sender:)))       
     }
-    
-    public func presentationControllerDidDismiss( _ presentationController: UIPresentationController) {
-        appDelegate.activeFileViewInFolder = nil
-    }
-    
+
     // MARK: - TAP EVENT
 
     @objc func tapClose(sender: Any) {

+ 0 - 6
iOSClient/Files/NCFiles.swift

@@ -49,12 +49,6 @@ class NCFiles: NCCollectionViewCommon  {
         super.viewWillAppear(animated)
     }
     
-    public func presentationControllerDidDismiss( _ presentationController: UIPresentationController) {
-        if presentationController.presentedViewController is NCViewerRichWorkspaceWebView {
-            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_closeRichWorkspaceWebView, userInfo: nil)
-        }
-    }
-    
     // MARK: - NotificationCenter
     
     override func initializeMain() {

+ 13 - 2
iOSClient/Main/NCCollectionViewCommon.swift

@@ -136,7 +136,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: k_notificationCenter_changeTheming), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(reloadDataSource(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataSource), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(changeStatusFolderE2EE(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_changeStatusFolderE2EE), object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(closeRichWorkspaceWebView(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_closeRichWorkspaceWebView), object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(closeRichWorkspaceWebView), name: NSNotification.Name(rawValue: k_notificationCenter_closeRichWorkspaceWebView), object: nil)
 
         NotificationCenter.default.addObserver(self, selector: #selector(deleteFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_deleteFile), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(moveFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_moveFile), object: nil)
@@ -190,6 +190,17 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         reloadDataSourceNetwork()
     }
         
+    func presentationControllerDidDismiss( _ presentationController: UIPresentationController) {
+        let viewController = presentationController.presentedViewController
+        if viewController is NCViewerRichWorkspaceWebView {
+            closeRichWorkspaceWebView()
+        } else if viewController is UINavigationController {
+            if (viewController as! UINavigationController).topViewController is NCFileViewInFolder {
+                appDelegate.activeFileViewInFolder = nil
+            }
+        }
+    }
+    
     override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
         super.viewWillTransition(to: size, with: coordinator)
         
@@ -257,7 +268,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         reloadDataSource()
     }
     
-    @objc func closeRichWorkspaceWebView(_ notification: NSNotification) {
+    @objc func closeRichWorkspaceWebView() {
         if self.view?.window == nil { return }
         
         reloadDataSourceNetwork()