Browse Source

improvements

marinofaggiana 4 years ago
parent
commit
8fb835123a

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

@@ -107,8 +107,8 @@ class NCCollectionCommon: NSObject, NCSelectDelegate {
     func openSelectView(items: [Any]) {
         
         let navigationController = UIStoryboard.init(name: "NCSelect", bundle: nil).instantiateInitialViewController() as! UINavigationController
-        let top_vc = navigationController.topViewController as! NCSelect
-        var vc_list = [NCSelect]()
+        let topViewController = navigationController.topViewController as! NCSelect
+        var listViewController = [NCSelect]()
         
         var copyItems: [Any] = []
         for item in items {
@@ -130,7 +130,7 @@ class NCCollectionCommon: NSObject, NCSelectDelegate {
                 }
                 viewController!.titleCurrentFolder = CCUtility.getLastPath(fromServerUrl: serverUrl, urlBase: appDelegate.urlBase)
             } else {
-                viewController = top_vc
+                viewController = topViewController
             }
             guard let vc = viewController else { return }
 
@@ -148,7 +148,7 @@ class NCCollectionCommon: NSObject, NCSelectDelegate {
             vc.serverUrl = serverUrl
             
             vc.navigationItem.backButtonTitle = vc.titleCurrentFolder
-            vc_list.insert(vc, at: 0)
+            listViewController.insert(vc, at: 0)
             
             if serverUrl != homeUrl {
                 serverUrl = CCUtility.deletingLastPathComponent(fromServerUrl: serverUrl)
@@ -157,8 +157,8 @@ class NCCollectionCommon: NSObject, NCSelectDelegate {
             }
         }
         
-        navigationController.setViewControllers(vc_list, animated: false)
-        navigationController.modalPresentationStyle = .fullScreen
+        navigationController.setViewControllers(listViewController, animated: false)
+        navigationController.modalPresentationStyle = .formSheet
         
         appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
     }
@@ -168,8 +168,8 @@ class NCCollectionCommon: NSObject, NCSelectDelegate {
         let viewController = UIStoryboard(name: "NCFileViewInFolder", bundle: nil).instantiateInitialViewController() as! NCFileViewInFolder
         let navigationController = UINavigationController.init(rootViewController: viewController)
 
-        let top_vc = viewController
-        var vc_list = [NCFileViewInFolder]()
+        let topViewController = viewController
+        var listViewController = [NCFileViewInFolder]()
         var serverUrl = serverUrl
         let homeUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
         
@@ -183,7 +183,7 @@ class NCCollectionCommon: NSObject, NCSelectDelegate {
                 }
                 viewController!.titleCurrentFolder = CCUtility.getLastPath(fromServerUrl: serverUrl, urlBase: appDelegate.urlBase)
             } else {
-                viewController = top_vc
+                viewController = topViewController
             }
             guard let vc = viewController else { return }
             
@@ -191,7 +191,7 @@ class NCCollectionCommon: NSObject, NCSelectDelegate {
             vc.fileName = fileName
             
             vc.navigationItem.backButtonTitle = vc.titleCurrentFolder
-            vc_list.insert(vc, at: 0)
+            listViewController.insert(vc, at: 0)
             
             if serverUrl != homeUrl {
                 serverUrl = CCUtility.deletingLastPathComponent(fromServerUrl: serverUrl)
@@ -200,8 +200,8 @@ class NCCollectionCommon: NSObject, NCSelectDelegate {
             }
         }
         
-        navigationController.setViewControllers(vc_list, animated: false)
-        navigationController.modalPresentationStyle = .fullScreen
+        navigationController.setViewControllers(listViewController, animated: false)
+        navigationController.modalPresentationStyle = .formSheet
         
         appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
     }

+ 2 - 0
iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift

@@ -86,6 +86,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     override func viewDidLoad() {
         super.viewDidLoad()
         
+        self.navigationController?.presentationController?.delegate = self
+        
         if enableSearchBar {
             searchController = UISearchController(searchResultsController: nil)
             searchController?.searchResultsUpdater = self

+ 6 - 1
iOSClient/Select/NCSelect.swift

@@ -28,7 +28,7 @@ import NCCommunication
     @objc func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], buttonType: String, overwrite: Bool)
 }
 
-class NCSelect: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, NCEmptyDataSetDelegate {
+class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresentationControllerDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, NCEmptyDataSetDelegate {
     
     @IBOutlet fileprivate weak var collectionView: UICollectionView!
     @IBOutlet fileprivate weak var toolbar: UIView!
@@ -105,6 +105,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegat
         super.viewDidLoad()
         
         self.navigationController?.navigationBar.prefersLargeTitles = true
+        self.navigationController?.presentationController?.delegate = self
         
         // Cell
         collectionView.register(UINib.init(nibName: "NCListCell", bundle: nil), forCellWithReuseIdentifier: "listCell")
@@ -217,6 +218,10 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegat
         //toolbar.tintColor = .gray
     }
     
+    func presentationControllerDidDismiss( _ presentationController: UIPresentationController) {
+        delegate?.dismissSelect(serverUrl: nil, metadata: nil, type: type, items: items, buttonType: "cancel", overwrite: overwrite)
+    }
+    
     // MARK: - Empty
     
     func emptyDataSetView(_ view: NCEmptyView) {