Use QRCodeReaderViewControllerBuilder instead of QRCodeViewControllerBuilder

This commit is contained in:
Yannick Loriot 2016-09-08 12:33:27 +02:00
parent f41169c7ca
commit bd3103202a
5 changed files with 23 additions and 17 deletions

View File

@ -5,6 +5,8 @@ Released on 2016-06-15.
- Swift 3 supports - Swift 3 supports
- Use `QRCodeReaderViewControllerBuilder` instead of `QRCodeViewControllerBuilder`
`QRCodeReader`: `QRCodeReader`:
- Use `didFindCode` instead of `didFindCodeBlock` - Use `didFindCode` instead of `didFindCodeBlock`
- Use `isRunning` instead of `running` - Use `isRunning` instead of `running`
@ -12,6 +14,11 @@ Released on 2016-06-15.
- `hasFrontDevice` is a property - `hasFrontDevice` is a property
- `isTorchAvailable` is a property - `isTorchAvailable` is a property
## [Version 6.1.0](https://github.com/yannickl/QRCodeReader.swift/releases/tag/6.1.0)
Released on 2016-08-03.
- Hide/Display cancel button
## [Version 6.0.0](https://github.com/yannickl/QRCodeReader.swift/releases/tag/6.0.0) ## [Version 6.0.0](https://github.com/yannickl/QRCodeReader.swift/releases/tag/6.0.0)
Released on 2016-03-22. Released on 2016-03-22.

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<scenes> <scenes>
<!--View Controller--> <!--View Controller-->
@ -14,26 +15,24 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/> <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides> </layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/> <rect key="frame" x="0.0" y="0.0" width="1024" height="1366"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="P5n-CT-PTt"> <button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="P5n-CT-PTt">
<rect key="frame" x="222" y="225" width="155" height="150"/> <frame key="frameInset" minX="222" minY="225" width="155" height="150"/>
<animations/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="155" id="O9u-YB-D6M"/> <constraint firstAttribute="width" constant="155" id="O9u-YB-D6M"/>
<constraint firstAttribute="height" constant="150" id="h6v-qf-cpj"/> <constraint firstAttribute="height" constant="150" id="h6v-qf-cpj"/>
</constraints> </constraints>
<state key="normal" title="Scan"> <state key="normal" title="Scan">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> <color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state> </state>
<connections> <connections>
<action selector="scanAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Tum-8Y-xC0"/> <action selector="scanAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Tum-8Y-xC0"/>
</connections> </connections>
</button> </button>
</subviews> </subviews>
<animations/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints> <constraints>
<constraint firstAttribute="centerX" secondItem="P5n-CT-PTt" secondAttribute="centerX" constant="0.5" id="CeZ-ED-sHl"/> <constraint firstAttribute="centerX" secondItem="P5n-CT-PTt" secondAttribute="centerX" constant="0.5" id="CeZ-ED-sHl"/>
<constraint firstAttribute="centerY" secondItem="P5n-CT-PTt" secondAttribute="centerY" id="fM5-Fa-KlF"/> <constraint firstAttribute="centerY" secondItem="P5n-CT-PTt" secondAttribute="centerY" id="fM5-Fa-KlF"/>

View File

@ -29,7 +29,7 @@ import AVFoundation
class ViewController: UIViewController, QRCodeReaderViewControllerDelegate { class ViewController: UIViewController, QRCodeReaderViewControllerDelegate {
lazy var reader: QRCodeReaderViewController = { lazy var reader: QRCodeReaderViewController = {
let builder = QRCodeViewControllerBuilder { builder in let builder = QRCodeReaderViewControllerBuilder { builder in
builder.reader = QRCodeReader(metadataObjectTypes: [AVMetadataObjectTypeQRCode]) builder.reader = QRCodeReader(metadataObjectTypes: [AVMetadataObjectTypeQRCode])
builder.showTorchButton = true builder.showTorchButton = true
} }

View File

@ -106,7 +106,7 @@ public class QRCodeReaderViewController: UIViewController {
- parameter showTorchButton: Flag to display the toggle torch button. If the value is true and there is no torch the button will not be displayed. - parameter showTorchButton: Flag to display the toggle torch button. If the value is true and there is no torch the button will not be displayed.
*/ */
public convenience init(cancelButtonTitle: String, codeReader reader: QRCodeReader, startScanningAtLoad startScan: Bool = true, showSwitchCameraButton showSwitch: Bool = true, showTorchButton showTorch: Bool = false) { public convenience init(cancelButtonTitle: String, codeReader reader: QRCodeReader, startScanningAtLoad startScan: Bool = true, showSwitchCameraButton showSwitch: Bool = true, showTorchButton showTorch: Bool = false) {
self.init(builder: QRCodeViewControllerBuilder { builder in self.init(builder: QRCodeReaderViewControllerBuilder { builder in
builder.cancelButtonTitle = cancelButtonTitle builder.cancelButtonTitle = cancelButtonTitle
builder.reader = reader builder.reader = reader
builder.startScanningAtLoad = startScan builder.startScanningAtLoad = startScan
@ -120,7 +120,7 @@ public class QRCodeReaderViewController: UIViewController {
- parameter builder: A QRCodeViewController builder object. - parameter builder: A QRCodeViewController builder object.
*/ */
required public init(builder: QRCodeViewControllerBuilder) { required public init(builder: QRCodeReaderViewControllerBuilder) {
startScanningAtLoad = builder.startScanningAtLoad startScanningAtLoad = builder.startScanningAtLoad
codeReader = builder.reader codeReader = builder.reader
showSwitchCameraButton = builder.showSwitchCameraButton showSwitchCameraButton = builder.showSwitchCameraButton

View File

@ -30,14 +30,14 @@ import Foundation
The QRCodeViewControllerBuilder aims to create a simple configuration object for The QRCodeViewControllerBuilder aims to create a simple configuration object for
the QRCode view controller. the QRCode view controller.
*/ */
public final class QRCodeViewControllerBuilder { public final class QRCodeReaderViewControllerBuilder {
// MARK: - Configuring the QRCodeViewController Objects // MARK: - Configuring the QRCodeViewController Objects
/** /**
The builder block. The builder block.
The block gives a reference of builder you can configure. The block gives a reference of builder you can configure.
*/ */
public typealias QRCodeViewControllerBuilderBlock = (QRCodeViewControllerBuilder) -> Void public typealias QRCodeReaderViewControllerBuilderBlock = (QRCodeReaderViewControllerBuilder) -> Void
/** /**
The title to use for the cancel button. The title to use for the cancel button.
@ -72,11 +72,11 @@ public final class QRCodeViewControllerBuilder {
public init() {} public init() {}
/** /**
Initialize a QRCodeViewController builder with default values. Initialize a QRCodeReaderViewController builder with default values.
- parameter buildBlock: A QRCodeViewController builder block to configure itself. - parameter buildBlock: A QRCodeReaderViewController builder block to configure itself.
*/ */
public init(buildBlock: QRCodeViewControllerBuilderBlock) { public init(buildBlock: QRCodeReaderViewControllerBuilderBlock) {
buildBlock(self) buildBlock(self)
} }
} }