Эх сурвалжийг харах

Refactor how menu VC are displayed

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 3 жил өмнө
parent
commit
4f041f6405

+ 17 - 14
iOSClient/Menu/NCCollectionViewCommon+Menu.swift

@@ -28,9 +28,9 @@ import FloatingPanel
 import NCCommunication
 import Queuer
 
-extension NCCollectionViewCommon {
-
-    func toggleMenau(account: String, image: UIImage?) {
+extension UIViewController {
+    func showProfileMenu(account: String, image: UIImage?) {
+        
         let personHeader = NCMenuAction(
             title: account,
             icon: image ?? NCUtility.shared.loadImage(named: "person.crop.circle"),
@@ -50,7 +50,7 @@ extension NCCollectionViewCommon {
             icon: NCUtility.shared.loadImage(named: "envelope"),
             action: { menuAction in
                 //TODO: get mail
-                self.sendEmail(to: "\(account)")
+                self.sendEmail(to: account)
             }
         )
         
@@ -68,7 +68,7 @@ extension NCCollectionViewCommon {
                     // - roomType: 1
                     // - invite: <account.userId>
                     // let userToken = result.ocs.data.first(where: { $0.name == account.userId }).token
-//                     let userTalkUrl = URL(string: "\(urlBase)/call/\(token)")
+                    // let userTalkUrl = URL(string: "\(urlBase)/call/\(token)")
                     
                     // UIApplication.shared.open(userTalkUrl)
                 }
@@ -79,7 +79,7 @@ extension NCCollectionViewCommon {
         presentMenu(with: actions)
     }
     
-    fileprivate func sendEmail(to email: String) {
+    func sendEmail(to email: String) {
         if MFMailComposeViewController.canSendMail() {
             let mail = MFMailComposeViewController()
             mail.mailComposeDelegate = self
@@ -97,8 +97,7 @@ extension NCCollectionViewCommon {
     }
     
     fileprivate func presentMenu(with actions: [NCMenuAction]) {
-        let menuViewController = UIStoryboard.init(name: "NCMenu", bundle: nil).instantiateInitialViewController() as! NCMenu
-        menuViewController.actions = actions
+        let menuViewController = NCMenu.makeNCMenu(with: actions)
         
         let menuPanelController = NCMenuPanelController()
         menuPanelController.parentPresenter = self
@@ -108,6 +107,16 @@ extension NCCollectionViewCommon {
         
         present(menuPanelController, animated: true, completion: nil)
     }
+}
+
+extension UIViewController: MFMailComposeViewControllerDelegate {
+    public func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
+        controller.dismiss(animated: true)
+    }
+}
+
+
+extension NCCollectionViewCommon {
     
     func toggleMenu(metadata: tableMetadata, imageIcon: UIImage?) {
         
@@ -663,9 +672,3 @@ extension NCCollectionViewCommon {
         presentMenu(with: actions)
     }
 }
-
-extension NCCollectionViewCommon: MFMailComposeViewControllerDelegate {
-    func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
-        controller.dismiss(animated: true)
-    }
-}

+ 6 - 0
iOSClient/Menu/NCMenu.swift

@@ -30,6 +30,12 @@ class NCMenu: UITableViewController {
 
     var actions = [NCMenuAction]()
 
+    static func makeNCMenu(with actions: [NCMenuAction]) -> NCMenu {
+        let menuViewController = UIStoryboard.init(name: "NCMenu", bundle: nil).instantiateInitialViewController() as! NCMenu
+        menuViewController.actions = actions
+        return menuViewController
+    }
+    
     // MARK: - View Life Cycle
 
     override func viewDidLoad() {

+ 6 - 0
iOSClient/Share/NCShare.swift

@@ -99,6 +99,8 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
             //TODO: implement open profile dialoge
             sharedWithYouByLabel.text = NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata!.ownerDisplayName
             sharedWithYouByImage.image = UIImage(named: "avatar")?.imageColor(NCBrandColor.shared.label)
+            let shareAction = UITapGestureRecognizer(target: self, action: #selector(openShareProfile))
+            sharedWithYouByView.addGestureRecognizer(shareAction)
             
             if metadata?.note.count ?? 0 > 0 {
                 searchFieldTopConstraint.constant = 95
@@ -155,6 +157,10 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
     
     // MARK: - Notification Center
     
+    @objc func openShareProfile() {
+        print("Show share profile")
+    }
+    
     @objc func changeTheming() {
         tableView.reloadData()
     }