mirror of
https://github.com/selfxyz/self.git
synced 2026-01-10 15:18:18 -05:00
* Clean up root license wording * Simplify SPDX header * simplify license and rename BSL to BUSL * fix merge issues * fix missing method --------- Co-authored-by: Justin Hernandez <transphorm@gmail.com>
48 lines
1.4 KiB
Swift
48 lines
1.4 KiB
Swift
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11
|
|
|
|
//
|
|
// QRScannerViewController.swift
|
|
// OpenPassport
|
|
//
|
|
// Created by Rémi Colin on 23/07/2024.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
import SwiftQRScanner
|
|
|
|
class QRScannerViewController: UIViewController, QRScannerCodeDelegate {
|
|
var completionHandler: ((String) -> Void)?
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
var configuration = QRScannerConfiguration()
|
|
configuration.cameraImage = UIImage(named: "camera")
|
|
configuration.flashOnImage = UIImage(named: "flash-on")
|
|
configuration.galleryImage = UIImage(named: "photos")
|
|
|
|
let scanner = QRCodeScannerController(qrScannerConfiguration: configuration)
|
|
scanner.delegate = self
|
|
|
|
addChild(scanner)
|
|
view.addSubview(scanner.view)
|
|
scanner.view.frame = view.bounds
|
|
scanner.didMove(toParent: self)
|
|
}
|
|
|
|
func qrScanner(_ controller: UIViewController, didScanQRCodeWithResult result: String) {
|
|
completionHandler?(result)
|
|
dismiss(animated: true, completion: nil)
|
|
}
|
|
|
|
func qrScanner(_ controller: UIViewController, didFailWithError error: QRCodeError) {
|
|
print("QR Scanner Error: \(error.localizedDescription)")
|
|
dismiss(animated: true, completion: nil)
|
|
}
|
|
|
|
func qrScannerDidCancel(_ controller: UIViewController) {
|
|
dismiss(animated: true, completion: nil)
|
|
}
|
|
}
|