diff --git a/AgileWorks/AgileWorks/Login/View/LoginViewController.swift b/AgileWorks/AgileWorks/Login/View/LoginViewController.swift index ffb1dd3395d95f7cbc7dbad72c8945b7c813deba..74cca099a497908b0b85fa9f9149c37b0289b781 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 e66c8539443bd3fecb8a4ec979c52f333bd186c6..972ab8e5225b7addb4d8c366f8010b22c8528045 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 {