From efaa70f52ddd41147f6266e5624368c5bdeff893 Mon Sep 17 00:00:00 2001 From: tsagano Date: Tue, 27 May 2025 10:16:42 +0900 Subject: [PATCH] =?UTF-8?q?QR=E3=82=B3=E3=83=BC=E3=83=89=E3=83=9C=E3=82=BF?= =?UTF-8?q?=E3=83=B3=E8=AA=AD=E8=BE=BC=E3=83=9C=E3=82=BF=E3=83=B3=E3=82=92?= =?UTF-8?q?=E6=8A=BC=E3=81=97=E3=81=9F=E3=81=A8=E3=81=8D=E4=BB=96=E3=81=AE?= =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E3=82=92=E8=A7=A6=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=82=82=E5=8F=8D=E5=BF=9C=E3=81=97=E3=81=AA=E3=81=84=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AgileWorks/AgileWorks/Login/View/LoginViewController.swift | 7 +++++++ AgileWorks/Common/QRCodeReader.swift | 3 +++ 2 files changed, 10 insertions(+) diff --git a/AgileWorks/AgileWorks/Login/View/LoginViewController.swift b/AgileWorks/AgileWorks/Login/View/LoginViewController.swift index ffb1dd3..74cca09 100644 --- a/AgileWorks/AgileWorks/Login/View/LoginViewController.swift +++ b/AgileWorks/AgileWorks/Login/View/LoginViewController.swift @@ -304,8 +304,13 @@ class LoginViewController: UIViewController { // QRコードリードボタンタップ処理 @IBAction private func qrCodeStartupTapped() { self.view.endEditing(true) + + disableLogin() // カメラ起動 qrCodeReader.delegate = self + qrCodeReader.onCancel = { [weak self] in + self?.enableLogin() + } if qrCodeReader.setupCamera(view: self.view) { // 読み込めるカメラ範囲設定 qrCodeReader.readRange() @@ -313,6 +318,7 @@ class LoginViewController: UIViewController { qrCodeReader.setCameraGuide(guide: getLocalizableStrings(key: "QRCodeReadGuidance", comment: "")) } else { qrCodeReader.delegate = nil + enableLogin() // カメラ起動失敗 let message = getLocalizableStrings(key: "CameraStartupErrorMessage", comment: "") let defaultAction = UIAlertAction(title: getLocalizableStrings(key: "OK", comment: ""), style: .default) { _ in } @@ -508,6 +514,7 @@ extension LoginViewController: AVCaptureMetadataOutputObjectsDelegate { loginButton.isEnabled = isTextFieldValue() // カメラ停止 qrCodeReader.stopRunning() + enableLogin() } catch { log.error(error) print(error) diff --git a/AgileWorks/Common/QRCodeReader.swift b/AgileWorks/Common/QRCodeReader.swift index e66c853..972ab8e 100644 --- a/AgileWorks/Common/QRCodeReader.swift +++ b/AgileWorks/Common/QRCodeReader.swift @@ -37,6 +37,8 @@ public class QRCodeReader { // カメラガイダンスラベル var cameraGuideLbl: UILabel! + public var onCancel: (() -> Void)? + // カメラセットアップ func setupCamera(view: UIView, borderWidth: Int = 1, borderColor: CGColor = UIColor.red.cgColor) -> Bool { self.preview = view @@ -195,6 +197,7 @@ public class QRCodeReader { @objc func cancelBtnTaped(_ sender: UIButton) { self.stopRunning() + self.onCancel?() } private func appOrientation() -> UIInterfaceOrientation { -- GitLab