浏览代码

copy personal invites to clipboard

B. Petersen 2 年之前
父节点
当前提交
583ac36bc3
共有 1 个文件被更改,包括 19 次插入0 次删除
  1. 19 0
      deltachat-ios/Controller/QrPageController.swift

+ 19 - 0
deltachat-ios/Controller/QrPageController.swift

@@ -63,6 +63,14 @@ class QrPageController: UIPageViewController {
             animated: true,
             completion: nil
         )
+
+        let image: UIImage?
+        if #available(iOS 13.0, *) {
+            image = UIImage(systemName: "ellipsis.circle")
+        } else {
+            image = UIImage(named: "ic_more")
+        }
+        self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: image, style: .plain, target: self, action: #selector(showMoreOptions))
     }
 
     override func viewWillAppear(_ animated: Bool) {
@@ -94,6 +102,17 @@ class QrPageController: UIPageViewController {
         }
     }
 
+    @objc private func showMoreOptions() {
+        let alert = UIAlertController(title: String.localized("qrshow_title"), message: nil, preferredStyle: .safeActionSheet)
+        alert.addAction(UIAlertAction(title: String.localized("menu_copy_to_clipboard"), style: .default, handler: copyToClipboard(_:)))
+        alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
+        self.present(alert, animated: true, completion: nil)
+    }
+
+    @objc func copyToClipboard(_ action: UIAlertAction) {
+        UIPasteboard.general.string = dcContext.getSecurejoinQr(chatId: 0)
+    }
+
     // MARK: - factory
     private func makeQRReader() -> QrCodeReaderController {
         let qrReader = QrCodeReaderController()