BarcodeScanner

BarcodeScanner

제품 정보

즐겨찾기

프로그래밍 언어

공개 채팅

지원 계획

현재 사용할 수 있는 OSS 플랜이 없습니다.

저장소의 제공자 또는 기여자인 경우 OSS 플랜 추가를 시작할 수 있습니다.

OSS 플랜 추가
여기에서 자세히 알아보세요

이 오픈소스에 대한 플랜을 찾고 있다면 저희에게 문의해 주세요.

전문 공급자와 연락하실 수 있도록 도와드리겠습니다.

제품 세부 정보

:mag_right: A simple and beautiful barcode scanner.

BarcodeScanner

CI Status Version Swift Carthage Compatible License Platform

Description

BarcodeScanner is a simple and beautiful wrapper around the camera with barcode capturing functionality and a great user experience.

  • [x] Barcode scanning.
  • [x] State modes: scanning, processing, unauthorized, not found.
  • [x] Handling of camera authorization status.
  • [x] Animated focus view and custom loading indicator.
  • [x] Torch mode switch.
  • [x] Customizable colors, informational and error messages.
  • [x] No external dependencies.
  • [x] Demo project.

Table of Contents

BarcodeScanner Icon

Usage

Controller

To start capturing just instantiate BarcodeScannerViewController, set needed delegates and present it:

let viewController = BarcodeScannerViewController()
viewController.codeDelegate = self
viewController.errorDelegate = self
viewController.dismissalDelegate = self

present(viewController, animated: true, completion: nil)
BarcodeScanner scanning

You can also push `BarcodeScannerViewController` to your navigation stack: ```swift let viewController = BarcodeScannerViewController() viewController.codeDelegate = self navigationController?.pushViewController(viewController, animated: true) ``` ### Delegates **Code delegate** Use `BarcodeScannerCodeDelegate` when you want to get the captured code back. ```swift extension ViewController: BarcodeScannerCodeDelegate { func scanner(_ controller: BarcodeScannerViewController, didCaptureCode code: String, type: String) { print(code) controller.reset() } } ``` **Error delegate** Use `BarcodeScannerErrorDelegate` when you want to handle session errors. ```swift extension ViewController: BarcodeScannerErrorDelegate { func scanner(_ controller: BarcodeScannerViewController, didReceiveError error: Error) { print(error) } } ``` **Dismissal delegate** Use `BarcodeScannerDismissalDelegate` to handle "Close button" tap. **Please note** that `BarcodeScannerViewController` doesn't dismiss itself if it was presented initially. ```swift extension ViewController: BarcodeScannerDismissalDelegate { func scannerDidDismiss(_ controller: BarcodeScannerViewController) { controller.dismiss(animated: true, completion: nil) } } ``` ### Actions When the code is captured `BarcodeScannerViewController` switches to the processing mode:
BarcodeScanner loading

While the user sees a nice loading animation you can perform some background task, for example make a network request to fetch product info based on the code. When the task is done you have 3 options to proceed: 1. Dismiss `BarcodeScannerViewController` and show your results. ```swift func scanner(_ controller: BarcodeScannerViewController, didCaptureCode code: String, type: String) { // Code processing controller.dismiss(animated: true, completion: nil) } ``` 2. Show an error message and switch back to the scanning mode (for example, when there is no product found with a given barcode in your database):
BarcodeScanner error

```swift func scanner(_ controller: BarcodeScannerViewController, didCaptureCode code: String, type: String) { // Code processing controller.resetWithError(message: "Error message") // If message is not provided the default message will be used instead. } ``` 3. Reset the controller to the scanning mode (with or without animation): ```swift func scanner(_ controller: BarcodeScannerViewController, didCaptureCode code: String, type: String) { // Code processing controller.reset(animated: true) } ``` If you want to do continuous barcode scanning just set the `isOneTimeSearch` property on your `BarcodeScannerViewController` instance to `false`. ### Customization We styled **BarcodeScanner** to make it look nice, but you can always use public properties or inheritance to customize its appearance. **Header** ```swift let viewController = BarcodeScannerViewController() viewController.headerViewController.titleLabel.text = "Scan barcode" viewController.headerViewController.closeButton.tintColor = .red ``` **Please note** that `HeaderViewController` is visible only when `BarcodeScannerViewController` is being presented. **Footer and messages** ```swift let viewController = BarcodeScannerViewController() viewController.messageViewController.regularTintColor = .black viewController.messageViewController.errorTintColor = .red viewController.messageViewController.textLabel.textColor = .black ``` **Camera** ```swift let viewController = BarcodeScannerViewController() // Change focus view style viewController.cameraViewController.barCodeFocusViewType = .animated // Show camera position button viewController.cameraViewController.showsCameraButton = true // Set the initial camera position viewController.cameraViewController.initialCameraPosition = .front // Default is .back // Set settings button text let title = NSAttributedString( string: "Settings", attributes: [.font: UIFont.boldSystemFont(ofSize: 17), .foregroundColor : UIColor.white] ) viewController.cameraViewController.settingButton.setAttributedTitle(title, for: UIControlState()) ``` **Metadata** ```swift // Add extra metadata object type let viewController = BarcodeScannerViewController() viewController.metadata.append(AVMetadataObject.ObjectType.qr) ``` ## Installation **BarcodeScanner** is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your Podfile: ```ruby pod 'BarcodeScanner' ``` Don't forget to set a `Privacy - Camera Usage Description` in your Info.plist file, else the app will crash with a SIGBART. In order to quickly try the demo project of a **BarcodeScanner** just run `pod try BarcodeScanner` in your terminal. **BarcodeScanner** is also available through [Carthage](https://github.com/Carthage/Carthage). To install just write into your Cartfile: ```ruby github "hyperoslo/BarcodeScanner" ``` To install **BarcodeScanner** manually just download and drop `Sources` and `Images` folders in your project. ## Author Hyper Interaktiv AS, ios@hyper.no ## Contributing We would love you to contribute to **BarcodeScanner**, check the [CONTRIBUTING](https://github.com/hyperoslo/BarcodeScanner/blob/master/CONTRIBUTING.md) file for more info. ## License **BarcodeScanner** is available under the MIT license. See the [LICENSE](https://github.com/hyperoslo/BarcodeScanner/blob/master/LICENSE.md) file for more info.

문의하기

  • 비즈니스 개발자를 위한 최신 정보를 원하십니까? 소스 코드 프로젝트에 대한 PieceX 커뮤니티의 요구사항을 알아보세요. PieceX의 최신 무료 커뮤니티 코드를 빠르게 알려드립니다.
PieceX Logo