Browse Source

normalize

marinofaggiana 4 years ago
parent
commit
beecdf4ba2

+ 18 - 0
iOSClient/AppDelegate.swift

@@ -759,3 +759,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     }
 }
 
+// MARK: - NCAudioRecorder ViewController Delegate
+
+extension AppDelegate: NCAudioRecorderViewControllerDelegate {
+
+    func didFinishRecording(_ viewController: NCAudioRecorderViewController, fileName: String) {
+        
+        guard let navigationController = UIStoryboard(name: "NCCreateFormUploadVoiceNote", bundle: nil).instantiateInitialViewController() else { return }
+        navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
+        let appDelegate = UIApplication.shared.delegate as! AppDelegate
+        
+        let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadVoiceNote
+        viewController.setup(serverUrl: appDelegate.activeServerUrl, fileNamePath: NSTemporaryDirectory() + fileName, fileName: fileName)
+        appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+    }
+    
+    func didFinishWithoutRecording(_ viewController: NCAudioRecorderViewController, fileName: String) {
+    }
+}

+ 1 - 1
iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift

@@ -674,7 +674,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId) else { return }
 
         if namedButtonMore == NCGlobal.shared.buttonMoreMore {
-            toggleMenuMore(viewController: self, metadata: metadata, image: image)
+            toggleMenu(viewController: self, metadata: metadata, image: image)
         } else if namedButtonMore == NCGlobal.shared.buttonMoreStop {
             NCNetworking.shared.cancelTransferMetadata(metadata) { }
         }

+ 1 - 16
iOSClient/Menu/AppDelegate+Menu.swift

@@ -26,7 +26,7 @@
 import FloatingPanel
 import NCCommunication
 
-extension AppDelegate: NCAudioRecorderViewControllerDelegate {
+extension AppDelegate {
     
     func toggleMenu(viewController: UIViewController) {
         
@@ -315,19 +315,4 @@ extension AppDelegate: NCAudioRecorderViewControllerDelegate {
 
         viewController.present(menuPanelController, animated: true, completion: nil)
     }
-    
-    // MARK: - NCAudioRecorder ViewController Delegate
-
-    func didFinishRecording(_ viewController: NCAudioRecorderViewController, fileName: String) {
-        
-        guard let navigationController = UIStoryboard(name: "NCCreateFormUploadVoiceNote", bundle: nil).instantiateInitialViewController() else { return }
-        navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
-        let appDelegate = UIApplication.shared.delegate as! AppDelegate
-        
-        let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadVoiceNote
-        viewController.setup(serverUrl: appDelegate.activeServerUrl, fileNamePath: NSTemporaryDirectory() + fileName, fileName: fileName)
-        appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
-    }
-    
-    func didFinishWithoutRecording(_ viewController: NCAudioRecorderViewController, fileName: String) { }
 }

+ 1 - 1
iOSClient/Menu/NCCollectionViewCommon+Menu.swift

@@ -28,7 +28,7 @@ import NCCommunication
 
 extension NCCollectionViewCommon {
 
-    func toggleMenuMore(viewController: UIViewController, metadata: tableMetadata, image: UIImage?) {
+    func toggleMenu(viewController: UIViewController, metadata: tableMetadata, image: UIImage?) {
         
         let menuViewController = UIStoryboard.init(name: "NCMenu", bundle: nil).instantiateInitialViewController() as! NCMenu
         var actions = [NCMenuAction]()

+ 30 - 34
iOSClient/Menu/NCSortMenu.swift

@@ -48,39 +48,7 @@ class NCSortMenu: NSObject {
         
         (layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: key, serverUrl: serverUrl)
 
-        let mainMenuViewController = UIStoryboard.init(name: "NCMenu", bundle: nil).instantiateInitialViewController() as! NCMenu
-        mainMenuViewController.actions = self.initSortMenu()
-
-        let menuPanelController = NCMenuPanelController()
-        menuPanelController.parentPresenter = viewController
-        menuPanelController.delegate = mainMenuViewController
-        menuPanelController.set(contentViewController: mainMenuViewController)
-        menuPanelController.track(scrollView: mainMenuViewController.tableView)
-
-        viewController.present(menuPanelController, animated: true, completion: nil)
-    }
-    
-    func actionMenu() {
-                
-        switch sort {
-        case "fileName":
-            titleButton = ascending ? "_sorted_by_name_a_z_" : "_sorted_by_name_z_a_"
-        case "date":
-            titleButton = ascending ? "_sorted_by_date_less_recent_" : "_sorted_by_date_more_recent_"
-        case "size":
-            titleButton = ascending ? "_sorted_by_size_smallest_" : "_sorted_by_size_largest_"
-        default:
-            break
-        }
-        
-        self.sortButton?.setTitle(NSLocalizedString(titleButton, comment: ""), for: .normal)
-        
-        NCUtility.shared.setLayoutForView(key: key, serverUrl: serverUrl, layout: layout, sort: sort, ascending: ascending, groupBy: groupBy, directoryOnTop: directoryOnTop, titleButton: titleButton, itemForLine: itemForLine)
-        
-        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["serverUrl":self.serverUrl])
-    }
-
-    private func initSortMenu() -> [NCMenuAction] {
+        let menuViewController = UIStoryboard.init(name: "NCMenu", bundle: nil).instantiateInitialViewController() as! NCMenu
         var actions = [NCMenuAction]()
 
         actions.append(
@@ -155,6 +123,34 @@ class NCSortMenu: NSObject {
             )
         }
         
-        return actions
+        menuViewController.actions = actions
+
+        let menuPanelController = NCMenuPanelController()
+        menuPanelController.parentPresenter = viewController
+        menuPanelController.delegate = menuViewController
+        menuPanelController.set(contentViewController: menuViewController)
+        menuPanelController.track(scrollView: menuViewController.tableView)
+
+        viewController.present(menuPanelController, animated: true, completion: nil)
+    }
+    
+    func actionMenu() {
+                
+        switch sort {
+        case "fileName":
+            titleButton = ascending ? "_sorted_by_name_a_z_" : "_sorted_by_name_z_a_"
+        case "date":
+            titleButton = ascending ? "_sorted_by_date_less_recent_" : "_sorted_by_date_more_recent_"
+        case "size":
+            titleButton = ascending ? "_sorted_by_size_smallest_" : "_sorted_by_size_largest_"
+        default:
+            break
+        }
+        
+        self.sortButton?.setTitle(NSLocalizedString(titleButton, comment: ""), for: .normal)
+        
+        NCUtility.shared.setLayoutForView(key: key, serverUrl: serverUrl, layout: layout, sort: sort, ascending: ascending, groupBy: groupBy, directoryOnTop: directoryOnTop, titleButton: titleButton, itemForLine: itemForLine)
+        
+        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["serverUrl":self.serverUrl])
     }
 }

+ 1 - 1
iOSClient/Viewer/NCViewerImage/NCViewerImage.swift

@@ -129,7 +129,7 @@ class NCViewerImage: UIViewController {
     
     @objc func openMenuMore() {
         
-        NCViewer.shared.toggleMoreMenu(viewController: self, metadata: currentMetadata, webView: false)
+        NCViewer.shared.toggleMenu(viewController: self, metadata: currentMetadata, webView: false)
     }
     
     //MARK: - NotificationCenter

+ 1 - 1
iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift

@@ -132,7 +132,7 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
     //MARK: - Action
     
     @objc func openMenuMore() {
-        NCViewer.shared.toggleMoreMenu(viewController: self, metadata: metadata, webView: true)
+        NCViewer.shared.toggleMenu(viewController: self, metadata: metadata, webView: true)
     }
     
     //MARK: -