浏览代码

Improved applicationHandle

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 年之前
父节点
当前提交
9c131ff52f

+ 25 - 0
iOSClient/Brand/NCApplicationHandle.swift

@@ -22,10 +22,35 @@
 //
 
 import Foundation
+import NextcloudKit
 
 class NCApplicationHandle: NSObject {
 
+    let appDelegate = UIApplication.shared.delegate as? AppDelegate
+
+    // class: AppDelegate
+    // func: application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:])
     func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
         return false
     }
+
+    // class: NCFunctionCenter
+    // func: downloadedFile(_ notification: NSNotification)
+    func downloadedFile(selector: String, metadata: tableMetadata) {
+    }
+
+    // class: NCCollectionViewCommon (+Menu)
+    // func: toggleMenu(metadata: tableMetadata, imageIcon: UIImage?)
+    func addCollectionViewCommonMenu(metadata: tableMetadata, imageIcon: UIImage?, actions: [NCMenuAction]) {
+    }
+
+    // class: NCMore
+    // func: loadItems()
+    func loadItems(functionMenu: [NKExternalSite]) {
+    }
+
+    // class: NCMore
+    // func: tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
+    func didSelectItem(_ item: NKExternalSite, viewController: UIViewController) {
+    }
 }

+ 2 - 1
iOSClient/Main/NCFunctionCenter.swift

@@ -128,7 +128,8 @@ import Photos
             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterOpenMediaDetail, userInfo: ["ocId": metadata.ocId])
 
         default:
-            break
+            let applicationHandle = NCApplicationHandle()
+            applicationHandle.downloadedFile(selector: selector, metadata: metadata)
         }
     }
 

+ 3 - 0
iOSClient/Menu/NCCollectionViewCommon+Menu.swift

@@ -50,6 +50,7 @@ extension NCCollectionViewCommon {
 
         let editors = NCUtility.shared.isDirectEditing(account: metadata.account, contentType: metadata.contentType)
         let isRichDocument = NCUtility.shared.isRichDocument(metadata)
+        let applicationHandle = NCApplicationHandle()
 
         var iconHeader: UIImage!
 
@@ -359,6 +360,8 @@ extension NCCollectionViewCommon {
             )
         }
 
+        applicationHandle.addCollectionViewCommonMenu(metadata: metadata, imageIcon: imageIcon, actions: actions)
+
         presentMenu(with: actions)
     }
 }

+ 6 - 13
iOSClient/More/NCMore.swift

@@ -40,6 +40,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
 
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     let defaultCornerRadius: CGFloat = 10.0
+    let applicationHandle = NCApplicationHandle()
     
     var tabAccount: tableAccount?
 
@@ -166,17 +167,9 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         item.url = "segueSettings"
         settingsMenu.append(item)
 
-        // ITEM: Test API
-        /*
-        if NCUtility.shared.isSimulator() {
-            item = NKExternalSite()
-            item.name = "Test API"
-            item.icon = "swift"
-            item.url = "test"
-            settingsMenu.append(item)
-        }
-        */
-        
+        // ITEM : HANDLE
+        applicationHandle.loadItems(functionMenu: functionMenu)
+
         if quotaMenu.count > 0 {
             let item = quotaMenu[0]
             labelQuotaExternalSite.text = item.name
@@ -483,8 +476,8 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
             alertController.addAction(actionNo)
             self.present(alertController, animated: true, completion: nil)
 
-        } else if item.url == "test" {
-
+        } else {
+            applicationHandle.didSelectItem(item, viewController: self)
         }
     }
 }