Bläddra i källkod

add title and cancel button to webxdc selector

cyberta 2 år sedan
förälder
incheckning
95e032d87a

+ 9 - 2
deltachat-ios/Chat/ChatViewController.swift

@@ -1488,13 +1488,20 @@ class ChatViewController: UITableViewController {
         let msgIds = dcContext.getChatMedia(chatId: 0, messageType: DC_MSG_WEBXDC, messageType2: 0, messageType3: 0)
         let webxdcSelector = WebxdcSelector(context: dcContext, mediaMessageIds: msgIds.reversed())
         webxdcSelector.delegate = self
+        let webxdcSelectorNavigationController = UINavigationController(rootViewController: webxdcSelector)
         if #available(iOS 15.0, *) {
-            if let sheet = webxdcSelector.sheetPresentationController {
+            if let sheet = webxdcSelectorNavigationController.sheetPresentationController {
                 sheet.detents = [.medium()]
                 sheet.preferredCornerRadius = 20
             }
         }
-        navigationController?.present(webxdcSelector, animated: true)
+        let leftBarBtn = UIBarButtonItem.init(barButtonSystemItem: UIBarButtonItem.SystemItem.cancel,
+                                                            target: webxdcSelector,
+                                              action: #selector(webxdcSelector.cancelAction))
+        webxdcSelectorNavigationController.navigationBar.topItem?.setLeftBarButton(leftBarBtn, animated: false)
+
+        self.present(webxdcSelectorNavigationController, animated: true)
+        //navigationController?.present(webxdcSelector, animated: true)
     }
 
     private func showDocumentLibrary() {

+ 5 - 0
deltachat-ios/Controller/WebxdcSelector.swift

@@ -117,6 +117,11 @@ class WebxdcSelector: UIViewController {
             }
         }
     }
+    
+    @objc func cancelAction() {
+        logger.debug("cancel Action")
+        dismiss(animated: true, completion: nil)
+    }
 }
 
 extension WebxdcSelector: UICollectionViewDataSourcePrefetching {