Add LND test wallet
This commit is contained in:
19
Pods/QR-Code-Scanner-iOS/LICENSE
generated
Normal file
19
Pods/QR-Code-Scanner-iOS/LICENSE
generated
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2020 Applied Recognition, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
160
Pods/QR-Code-Scanner-iOS/QR Code Scanner/Base.lproj/QRCode.storyboard
generated
Normal file
160
Pods/QR-Code-Scanner-iOS/QR Code Scanner/Base.lproj/QRCode.storyboard
generated
Normal file
@ -0,0 +1,160 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="y2r-2W-Kfy">
|
||||
<device id="retina4_0" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Scan Code-->
|
||||
<scene sceneID="I2H-Ea-9of">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="scanCode" id="y2r-2W-Kfy" customClass="QRCodeScanViewController" customModule="QR_Code_Scanner" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="7Dr-tT-ym7">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dHG-WP-6So">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="284"/>
|
||||
<color key="backgroundColor" white="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Please scan the QR code on your computer's screen." textAlignment="center" lineBreakMode="wordWrap" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aFZ-zX-6H0">
|
||||
<rect key="frame" x="24" y="444" width="272" height="100"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="100" id="dau-SG-XQW"/>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="256" id="m0W-NA-pcB"/>
|
||||
<constraint firstAttribute="height" constant="100" id="sUP-Zr-vJJ"/>
|
||||
<constraint firstAttribute="width" constant="272" id="wss-GD-Qsm"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="1000" image="qr_code" translatesAutoresizingMaskIntoConstraints="NO" id="idD-yC-9NX">
|
||||
<rect key="frame" x="96" y="316" width="128" height="128"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="128" id="3zz-o7-Irj"/>
|
||||
<constraint firstAttribute="width" constant="128" id="inb-Nw-PSU"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<constraints>
|
||||
<constraint firstItem="HcW-ma-4Y9" firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="aFZ-zX-6H0" secondAttribute="bottom" constant="24" id="3Gx-Mz-RjT"/>
|
||||
<constraint firstItem="aFZ-zX-6H0" firstAttribute="top" secondItem="idD-yC-9NX" secondAttribute="bottom" id="4d2-CW-bq6"/>
|
||||
<constraint firstItem="dHG-WP-6So" firstAttribute="height" secondItem="7Dr-tT-ym7" secondAttribute="height" multiplier="0.5" id="6D2-cL-pfV"/>
|
||||
<constraint firstItem="aFZ-zX-6H0" firstAttribute="centerY" secondItem="HcW-ma-4Y9" secondAttribute="centerY" priority="999" constant="200" id="7vv-ud-cQ4"/>
|
||||
<constraint firstItem="dHG-WP-6So" firstAttribute="leading" secondItem="HcW-ma-4Y9" secondAttribute="leading" id="Cgk-Md-0az"/>
|
||||
<constraint firstItem="idD-yC-9NX" firstAttribute="centerX" secondItem="7Dr-tT-ym7" secondAttribute="centerX" id="KHv-xR-1AC"/>
|
||||
<constraint firstItem="dHG-WP-6So" firstAttribute="top" secondItem="7Dr-tT-ym7" secondAttribute="top" id="ZH3-TS-kWK"/>
|
||||
<constraint firstItem="dHG-WP-6So" firstAttribute="trailing" secondItem="HcW-ma-4Y9" secondAttribute="trailing" id="cy7-ek-IRs"/>
|
||||
<constraint firstItem="aFZ-zX-6H0" firstAttribute="centerX" secondItem="7Dr-tT-ym7" secondAttribute="centerX" id="dDa-0M-NuA"/>
|
||||
</constraints>
|
||||
<viewLayoutGuide key="safeArea" id="HcW-ma-4Y9"/>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" title="Scan Code" id="d0Z-d3-Eu5"/>
|
||||
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
|
||||
<connections>
|
||||
<outlet property="cameraView" destination="dHG-WP-6So" id="UUo-WY-Ziq"/>
|
||||
<outlet property="promptLabel" destination="aFZ-zX-6H0" id="Wp8-wK-c3f"/>
|
||||
<segue destination="ksr-ra-by9" kind="show" identifier="denied" id="hci-Jh-Lpx"/>
|
||||
<segue destination="JmV-9f-Gyt" kind="show" identifier="restricted" id="N0x-0E-lxh"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="lxj-g1-dsq" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="886.875" y="27.464788732394368"/>
|
||||
</scene>
|
||||
<!--Camera Access Denied View Controller-->
|
||||
<scene sceneID="gyq-DK-avj">
|
||||
<objects>
|
||||
<viewController id="ksr-ra-by9" customClass="CameraAccessDeniedViewController" customModule="QR_Code_Scanner" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="anx-7h-CQ8">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Camera access denied. Please go to settings and enable camera." textAlignment="center" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ivo-nD-I5y">
|
||||
<rect key="frame" x="24" y="444" width="272" height="100"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="272" id="R3x-dE-PeA"/>
|
||||
<constraint firstAttribute="height" constant="100" id="koy-m2-Odt"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="RIk-vx-R8e">
|
||||
<rect key="frame" x="81.5" y="276" width="157" height="60"/>
|
||||
<color key="backgroundColor" red="0.21176470589999999" green="0.68627450980000004" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="60" id="UgE-k4-NXY"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="24"/>
|
||||
<inset key="contentEdgeInsets" minX="20" minY="0.0" maxX="20" maxY="0.0"/>
|
||||
<state key="normal" title="SETTINGS">
|
||||
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</state>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
|
||||
<integer key="value" value="20"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<action selector="openSettings" destination="ksr-ra-by9" eventType="touchUpInside" id="b3c-NX-isc"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<constraints>
|
||||
<constraint firstItem="RIk-vx-R8e" firstAttribute="centerY" secondItem="Nn2-2b-I7a" secondAttribute="centerY" id="6xx-R6-0l2"/>
|
||||
<constraint firstItem="ivo-nD-I5y" firstAttribute="centerX" secondItem="anx-7h-CQ8" secondAttribute="centerX" id="91s-0E-NIN"/>
|
||||
<constraint firstItem="ivo-nD-I5y" firstAttribute="centerY" secondItem="Nn2-2b-I7a" secondAttribute="centerY" priority="999" constant="200" id="JCs-2s-LNF"/>
|
||||
<constraint firstItem="RIk-vx-R8e" firstAttribute="centerX" secondItem="Nn2-2b-I7a" secondAttribute="centerX" id="JJQ-e4-tMz"/>
|
||||
<constraint firstItem="Nn2-2b-I7a" firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="ivo-nD-I5y" secondAttribute="bottom" constant="24" id="QdZ-8V-aTQ"/>
|
||||
</constraints>
|
||||
<viewLayoutGuide key="safeArea" id="Nn2-2b-I7a"/>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="label" destination="ivo-nD-I5y" id="oS7-BJ-FpM"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="DcX-Tj-tVf" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1748" y="-128"/>
|
||||
</scene>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="2JM-NP-OiX">
|
||||
<objects>
|
||||
<viewController id="JmV-9f-Gyt" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="LIk-Xe-Kkl">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Camera access on your device is restricted. Please contact the system administrator." textAlignment="center" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NV9-3Y-dJa">
|
||||
<rect key="frame" x="16" y="253.5" width="288" height="61"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<constraints>
|
||||
<constraint firstItem="NV9-3Y-dJa" firstAttribute="centerY" secondItem="LIk-Xe-Kkl" secondAttribute="centerY" id="9MO-I6-xou"/>
|
||||
<constraint firstItem="NV9-3Y-dJa" firstAttribute="trailing" secondItem="LIk-Xe-Kkl" secondAttribute="trailingMargin" id="MeX-Ws-kZV"/>
|
||||
<constraint firstItem="NV9-3Y-dJa" firstAttribute="leading" secondItem="LIk-Xe-Kkl" secondAttribute="leadingMargin" id="gQu-7O-TO6"/>
|
||||
</constraints>
|
||||
<viewLayoutGuide key="safeArea" id="jdU-SE-06w"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="LYY-O2-PHk" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1748" y="598"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="qr_code" width="272" height="272"/>
|
||||
</resources>
|
||||
</document>
|
27
Pods/QR-Code-Scanner-iOS/QR Code Scanner/CameraAccessDeniedViewController.swift
generated
Normal file
27
Pods/QR-Code-Scanner-iOS/QR Code Scanner/CameraAccessDeniedViewController.swift
generated
Normal file
@ -0,0 +1,27 @@
|
||||
//
|
||||
// CameraAccessDeniedViewController.swift
|
||||
//
|
||||
// Created by Jakub Dolejs on 28/03/2018.
|
||||
// Copyright © 2018 Applied Recognition Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class CameraAccessDeniedViewController: UIViewController {
|
||||
|
||||
@IBOutlet var label: UILabel!
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
if let appName = Bundle.main.infoDictionary?[kCFBundleNameKey as String] as? String {
|
||||
label.text = String(format: "Camera access denied. Please go to settings and enable camera for %@.", appName)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func openSettings() {
|
||||
if let settingsURL = URL(string: UIApplication.openSettingsURLString) {
|
||||
UIApplication.shared.open(settingsURL, options: [:], completionHandler: nil)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
6
Pods/QR-Code-Scanner-iOS/QR Code Scanner/Media.xcassets/Contents.json
generated
Normal file
6
Pods/QR-Code-Scanner-iOS/QR Code Scanner/Media.xcassets/Contents.json
generated
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
23
Pods/QR-Code-Scanner-iOS/QR Code Scanner/Media.xcassets/qr_code.imageset/Contents.json
generated
vendored
Normal file
23
Pods/QR-Code-Scanner-iOS/QR Code Scanner/Media.xcassets/qr_code.imageset/Contents.json
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "qr_code.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "qr_code@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "qr_code@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
Pods/QR-Code-Scanner-iOS/QR Code Scanner/Media.xcassets/qr_code.imageset/qr_code.png
generated
vendored
Normal file
BIN
Pods/QR-Code-Scanner-iOS/QR Code Scanner/Media.xcassets/qr_code.imageset/qr_code.png
generated
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
BIN
Pods/QR-Code-Scanner-iOS/QR Code Scanner/Media.xcassets/qr_code.imageset/qr_code@2x.png
generated
vendored
Normal file
BIN
Pods/QR-Code-Scanner-iOS/QR Code Scanner/Media.xcassets/qr_code.imageset/qr_code@2x.png
generated
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 126 KiB |
BIN
Pods/QR-Code-Scanner-iOS/QR Code Scanner/Media.xcassets/qr_code.imageset/qr_code@3x.png
generated
vendored
Normal file
BIN
Pods/QR-Code-Scanner-iOS/QR Code Scanner/Media.xcassets/qr_code.imageset/qr_code@3x.png
generated
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 196 KiB |
186
Pods/QR-Code-Scanner-iOS/QR Code Scanner/QRCodeScanViewController.swift
generated
Normal file
186
Pods/QR-Code-Scanner-iOS/QR Code Scanner/QRCodeScanViewController.swift
generated
Normal file
@ -0,0 +1,186 @@
|
||||
//
|
||||
// QRCodeScanViewController.swift
|
||||
// BFL Authenticator
|
||||
//
|
||||
// Created by Jakub Dolejs on 28/03/2018.
|
||||
// Copyright © 2018 Applied Recognition Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import AVFoundation
|
||||
|
||||
public class QRCodeScanViewController: UIViewController, AVCaptureMetadataOutputObjectsDelegate {
|
||||
|
||||
public weak var delegate: QRCodeScanViewControllerDelegate?
|
||||
public var prompt: String?
|
||||
|
||||
public static func create() -> QRCodeScanViewController {
|
||||
let storyboard = UIStoryboard(name: "QRCode", bundle: Bundle(for: QRCodeScanViewController.self))
|
||||
return storyboard.instantiateInitialViewController() as! QRCodeScanViewController
|
||||
}
|
||||
|
||||
private override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
}
|
||||
|
||||
@IBOutlet var cameraView: UIView!
|
||||
@IBOutlet var promptLabel: UILabel!
|
||||
var captureSession: AVCaptureSession!
|
||||
lazy var barcodeScanQueue: DispatchQueue = {
|
||||
let queue = DispatchQueue.init(label: "com.appliedrec.qrcodescan")
|
||||
return queue
|
||||
}()
|
||||
var avCaptureVideoOrientation: AVCaptureVideoOrientation {
|
||||
switch UIApplication.shared.statusBarOrientation {
|
||||
case .portraitUpsideDown:
|
||||
return AVCaptureVideoOrientation.portraitUpsideDown
|
||||
case .landscapeRight:
|
||||
return AVCaptureVideoOrientation.landscapeRight
|
||||
case .landscapeLeft:
|
||||
return AVCaptureVideoOrientation.landscapeLeft
|
||||
default:
|
||||
return AVCaptureVideoOrientation.portrait
|
||||
}
|
||||
}
|
||||
|
||||
public override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
if let prompt = self.prompt {
|
||||
self.promptLabel.text = prompt
|
||||
}
|
||||
}
|
||||
|
||||
public override func didReceiveMemoryWarning() {
|
||||
super.didReceiveMemoryWarning()
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
public override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
startCamera()
|
||||
}
|
||||
|
||||
func startCamera() {
|
||||
let status = AVCaptureDevice.authorizationStatus(for: .video)
|
||||
switch status {
|
||||
case .authorized:
|
||||
self.startScan()
|
||||
case .notDetermined:
|
||||
AVCaptureDevice.requestAccess(for: .video) { granted in
|
||||
if granted {
|
||||
self.startScan()
|
||||
} else {
|
||||
self.showCameraAccessDenied()
|
||||
}
|
||||
}
|
||||
case .denied:
|
||||
self.showCameraAccessDenied()
|
||||
case .restricted:
|
||||
self.showCameraAccessRestricted()
|
||||
@unknown default:
|
||||
fatalError()
|
||||
}
|
||||
}
|
||||
|
||||
public override func viewWillDisappear(_ animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
self.stopCamera()
|
||||
}
|
||||
|
||||
@IBAction func restartQRCodeScan(_ segue: UIStoryboardSegue) {
|
||||
|
||||
}
|
||||
|
||||
func showCameraAccessDenied() {
|
||||
DispatchQueue.main.async {
|
||||
self.performSegue(withIdentifier: "denied", sender: nil)
|
||||
}
|
||||
}
|
||||
|
||||
func showCameraAccessRestricted() {
|
||||
DispatchQueue.main.async {
|
||||
self.performSegue(withIdentifier: "restricted", sender: nil)
|
||||
}
|
||||
}
|
||||
|
||||
private func startScan() {
|
||||
self.barcodeScanQueue.async {
|
||||
self.captureSession = AVCaptureSession()
|
||||
guard let camera = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back) else {
|
||||
return
|
||||
}
|
||||
guard let videoInput = try? AVCaptureDeviceInput(device: camera) else {
|
||||
return
|
||||
}
|
||||
do {
|
||||
try camera.lockForConfiguration()
|
||||
if camera.isAutoFocusRangeRestrictionSupported {
|
||||
camera.autoFocusRangeRestriction = .near
|
||||
}
|
||||
if camera.isFocusModeSupported(AVCaptureDevice.FocusMode.continuousAutoFocus) {
|
||||
camera.focusMode = .continuousAutoFocus
|
||||
} else if camera.isFocusModeSupported(AVCaptureDevice.FocusMode.autoFocus) {
|
||||
camera.focusMode = .autoFocus
|
||||
}
|
||||
if camera.isFocusPointOfInterestSupported {
|
||||
camera.focusPointOfInterest = CGPoint(x: 0.5, y: 0.5)
|
||||
}
|
||||
camera.unlockForConfiguration()
|
||||
} catch {
|
||||
|
||||
}
|
||||
if self.captureSession.canAddInput(videoInput) {
|
||||
self.captureSession.addInput(videoInput)
|
||||
}
|
||||
let barcodeOutput = AVCaptureMetadataOutput()
|
||||
barcodeOutput.setMetadataObjectsDelegate(self, queue: self.barcodeScanQueue)
|
||||
if self.captureSession.canAddOutput(barcodeOutput) {
|
||||
self.captureSession.addOutput(barcodeOutput)
|
||||
if barcodeOutput.availableMetadataObjectTypes.contains(where: { (val) -> Bool in return val == AVMetadataObject.ObjectType.qr }) {
|
||||
barcodeOutput.metadataObjectTypes = [.qr]
|
||||
}
|
||||
}
|
||||
self.captureSession.startRunning()
|
||||
DispatchQueue.main.async {
|
||||
let previewLayer = AVCaptureVideoPreviewLayer(session: self.captureSession)
|
||||
previewLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill
|
||||
previewLayer.frame = self.cameraView.bounds
|
||||
if previewLayer.connection != nil && previewLayer.connection!.isVideoOrientationSupported {
|
||||
previewLayer.connection!.videoOrientation = self.avCaptureVideoOrientation
|
||||
}
|
||||
self.cameraView.layer.masksToBounds = true
|
||||
while let sub = self.cameraView.layer.sublayers?.first {
|
||||
sub.removeFromSuperlayer()
|
||||
}
|
||||
self.cameraView.layer.addSublayer(previewLayer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func stopCamera() {
|
||||
self.barcodeScanQueue.async {
|
||||
if self.captureSession != nil {
|
||||
self.captureSession.stopRunning()
|
||||
self.captureSession = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection) {
|
||||
if let codeValue = (metadataObjects.first(where: { $0 is AVMetadataMachineReadableCodeObject && $0.type == AVMetadataObject.ObjectType.qr }) as? AVMetadataMachineReadableCodeObject)?.stringValue {
|
||||
self.stopCamera()
|
||||
DispatchQueue.main.async {
|
||||
self.delegate?.qrCodeScanViewController(self, didScanQRCode: codeValue)
|
||||
self.delegate = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public protocol QRCodeScanViewControllerDelegate: class {
|
||||
func qrCodeScanViewController(_ viewController: QRCodeScanViewController, didScanQRCode value: String)
|
||||
}
|
54
Pods/QR-Code-Scanner-iOS/README.md
generated
Normal file
54
Pods/QR-Code-Scanner-iOS/README.md
generated
Normal file
@ -0,0 +1,54 @@
|
||||
# QR Code Scanner for iOS
|
||||
|
||||
Scans QR codes using the device's camera and returns a string value.
|
||||
|
||||
## Installation
|
||||
|
||||
1. Install [CocoaPods](https://cocoapods.org).
|
||||
2. Add the following dependency in your **Podspec** file:
|
||||
|
||||
~~~ruby
|
||||
pod 'QR-Code-Scanner-iOS', '~> 1.0'
|
||||
~~~
|
||||
3. Run `pod install`.
|
||||
|
||||
## Usage
|
||||
|
||||
~~~swift
|
||||
import UIKit
|
||||
import QRCodeScanner
|
||||
|
||||
class MyViewController: UIViewController, QRCodeScanViewControllerDelegate {
|
||||
|
||||
/// Start the QR code scan
|
||||
func scanQRCode() {
|
||||
|
||||
// Create an instance of QRCodeScanViewController
|
||||
let viewController = QRCodeScanViewController.create()
|
||||
|
||||
// Set itself as delegate
|
||||
viewController.delegate = self
|
||||
|
||||
// Present the view controller
|
||||
self.present(viewController, animated: true)
|
||||
}
|
||||
|
||||
// MARK: QRCodeScanViewControllerDelegate
|
||||
|
||||
/// Called when the camera scans a QR code
|
||||
/// - Parameters:
|
||||
/// - viewController: View controller that scanned the QR code
|
||||
/// - value: String encoded in the QR code
|
||||
func qrCodeScanViewController(_ viewController: QRCodeScanViewController, didScanQRCode value: String) {
|
||||
|
||||
// Dismiss the view controller
|
||||
viewController.dismiss(animated: true) {
|
||||
|
||||
// Show an alert with the scanned value
|
||||
let alert = UIAlertController(title: "Scanned value", message: value, preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
||||
self.present(alert, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
~~~
|
Reference in New Issue
Block a user