Pārlūkot izejas kodu

implement basic mock profile

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 3 gadi atpakaļ
vecāks
revīzija
1e6ea28a3a

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

@@ -41,7 +41,7 @@ extension NCCollectionViewCommon {
             title: NSLocalizedString("_profile_", comment: ""),
             icon: NCUtility.shared.loadImage(named: "globe"),
             action: { menuAction in
-                
+                //TODO: Wait for https://github.com/nextcloud/server/pull/28751
             }
         )
         
@@ -49,16 +49,29 @@ extension NCCollectionViewCommon {
             title: NSLocalizedString("_mail_", comment: ""),
             icon: NCUtility.shared.loadImage(named: "envelope"),
             action: { menuAction in
-                
+                //TODO: get mail
+                self.sendEmail(to: "\(account)")
             }
         )
         
-        let talkAction =
-        NCMenuAction(
+        let talkAction = NCMenuAction(
             title: NSLocalizedString("_talk_", comment: ""),
+            // TODO: Needs talk icon
             icon: NCUtility.shared.loadImage(named: "talk-icon"),
             action: { menuAction in
-                
+                //TODO:
+                if let userTalkUrl = URL(string: "nextcloudtalk://login?server=https://nextcloud.server.tld&username=theirname"),
+                   UIApplication.shared.canOpenURL(userTalkUrl) {
+                    UIApplication.shared.open(userTalkUrl)
+                } else {
+                    // TODO: POST /ocs/v2.php/apps/spreed/api/v4/room
+                    // - roomType: 1
+                    // - invite: <account.userId>
+                    // let userToken = result.ocs.data.first(where: { $0.name == account.userId }).token
+//                     let userTalkUrl = URL(string: "\(urlBase)/call/\(token)")
+                    
+                    // UIApplication.shared.open(userTalkUrl)
+                }
             }
         )
         
@@ -66,6 +79,23 @@ extension NCCollectionViewCommon {
         presentMenu(with: actions)
     }
     
+    fileprivate func sendEmail(to email: String) {
+        if MFMailComposeViewController.canSendMail() {
+            let mail = MFMailComposeViewController()
+            mail.mailComposeDelegate = self
+            mail.setToRecipients([email])
+
+            present(mail, animated: true)
+        } else {
+            NCContentPresenter.shared.messageNotification(
+                "_error_", description: "_error_send_mail_",
+                delay: NCGlobal.shared.dismissAfterSecond,
+                type: NCContentPresenter.messageType.error,
+                errorCode: NCGlobal.shared.errorGeneric,
+                forced: true)
+        }
+    }
+    
     fileprivate func presentMenu(with actions: [NCMenuAction]) {
         let menuViewController = UIStoryboard.init(name: "NCMenu", bundle: nil).instantiateInitialViewController() as! NCMenu
         menuViewController.actions = actions
@@ -630,15 +660,12 @@ extension NCCollectionViewCommon {
             )
         )
         
-        menuViewController.actions = actions
-
-        let menuPanelController = NCMenuPanelController()
-        menuPanelController.parentPresenter = self
-        menuPanelController.delegate = menuViewController
-        menuPanelController.set(contentViewController: menuViewController)
-        menuPanelController.track(scrollView: menuViewController.tableView)
-
-        present(menuPanelController, animated: true, completion: nil)
+        presentMenu(with: actions)
     }
 }
 
+extension NCCollectionViewCommon: MFMailComposeViewControllerDelegate {
+    func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
+        controller.dismiss(animated: true)
+    }
+}

+ 2 - 1
iOSClient/Share/NCShare.swift

@@ -96,6 +96,7 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
             
             searchFieldTopConstraint.constant = 65
             sharedWithYouByView.isHidden = false
+            //TODO: implement open profile dialoge
             sharedWithYouByLabel.text = NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata!.ownerDisplayName
             sharedWithYouByImage.image = UIImage(named: "avatar")?.imageColor(NCBrandColor.shared.label)
             
@@ -136,7 +137,7 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
                     }
                 }
             }
-        } 
+        }
         
         reloadData()