ソースを参照

add 'paste from clipboard' to qr-scan-menu

B. Petersen 2 年 前
コミット
3dd92d409c
1 ファイル変更10 行追加2 行削除
  1. 10 2
      deltachat-ios/Controller/QrPageController.swift

+ 10 - 2
deltachat-ios/Controller/QrPageController.swift

@@ -106,8 +106,12 @@ 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(_:)))
+        let alert = UIAlertController(title: String.localized("qr_code"), message: nil, preferredStyle: .safeActionSheet)
+        if qrSegmentControl.selectedSegmentIndex == 0 {
+            alert.addAction(UIAlertAction(title: String.localized("menu_copy_to_clipboard"), style: .default, handler: copyToClipboard(_:)))
+        } else {
+            alert.addAction(UIAlertAction(title: String.localized("paste_from_clipboard"), style: .default, handler: pasteFromClipboard(_:)))
+        }
         alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
         self.present(alert, animated: true, completion: nil)
     }
@@ -116,6 +120,10 @@ class QrPageController: UIPageViewController {
         UIPasteboard.general.string = dcContext.getSecurejoinQr(chatId: 0)
     }
 
+    @objc func pasteFromClipboard(_ action: UIAlertAction) {
+        handleQrCode(UIPasteboard.general.string ?? "")
+    }
+
     // MARK: - factory
     private func makeQRReader() -> QrCodeReaderController {
         let qrReader = QrCodeReaderController(title: String.localized("qrscan_title"))