Skip to content

Commit 04d9fd6

Browse files
author
Garett Breen
authored
Merge pull request #1 from hyperoslo/master
Getting up to date
2 parents 3c821fa + 6fe5bb5 commit 04d9fd6

File tree

6 files changed

+39
-3
lines changed

6 files changed

+39
-3
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"SCAN_BARCODE_TITLE" = "Scan barcode";
2+
"BUTTON_CLOSE" = "Sluit";
3+
"BUTTON_SETTINGS" = "Instellingen";
4+
"INFO_DESCRIPTION_TEXT" = "Plaats de barcode in het venster om te scannen. Zoeken start automatisch.";
5+
"INFO_LOADING_TITLE" = "Product aan het zoeken...";
6+
"NO_PRODUCT_ERROR_TITLE" = "Geen product gevonden.";
7+
"ASK_FOR_PERMISSION_TEXT" = "Om een barcode te kunnen scannen hebben we toegang nodig tot de camera.";
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"SCAN_BARCODE_TITLE" = "Escaneie o código de barras";
2+
"BUTTON_CLOSE" = "Fechar";
3+
"BUTTON_SETTINGS" = "Configurações";
4+
"INFO_DESCRIPTION_TEXT" = "Posicione o código de barras dentro da janela. A busca iniciará automaticamente.";
5+
"INFO_LOADING_TITLE" = "Procurando pelo seu produto...";
6+
"NO_PRODUCT_ERROR_TITLE" = "Nenhum produto encontrado.";
7+
"ASK_FOR_PERMISSION_TEXT" = "Para escanear os códigos de barras você deve permitir acesso a câmera nas configurações.";
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"SCAN_BARCODE_TITLE" = "Сканер штрих-кода";
2+
"BUTTON_CLOSE" = "Закрыть";
3+
"BUTTON_SETTINGS" = "Настройки";
4+
"INFO_DESCRIPTION_TEXT" = "Расположите штрих-код в окне для сканирования. Поиск начнется автоматически.";
5+
"INFO_LOADING_TITLE" = "Ищем продукт...";
6+
"NO_PRODUCT_ERROR_TITLE" = "Продукт не найден";
7+
"ASK_FOR_PERMISSION_TEXT" = "Чтобы воспользоваться сканером, необходимо разрешить доступ к камере в настройках телефона";

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ let viewController = BarcodeScannerViewController()
185185
viewController.cameraViewController.barCodeFocusViewType = .animated
186186
// Show camera position button
187187
viewController.cameraViewController.showsCameraButton = true
188+
// Set the initial camera position
189+
viewController.cameraViewController.initialCameraPosition = .front // Default is .back
188190
// Set settings button text
189191
let title = NSAttributedString(
190192
string: "Settings",

Sources/Controllers/BarcodeScannerViewController.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public protocol BarcodeScannerDismissalDelegate: class {
3333
*/
3434
open class BarcodeScannerViewController: UIViewController {
3535
private static let footerHeight: CGFloat = 75
36+
public var hideFooterView = false
3637

3738
// MARK: - Public properties
3839

@@ -47,6 +48,10 @@ open class BarcodeScannerViewController: UIViewController {
4748
/// and waits for the next reset action.
4849
public var isOneTimeSearch = true
4950

51+
/// When the flag is set to `true` the screen is flashed on barcode scan.
52+
/// Defaults to true.
53+
public var shouldSimulateFlash = true
54+
5055
/// `AVCaptureMetadataOutput` metadata object types.
5156
public var metadata = AVMetadataObject.ObjectType.barcodeScannerMetadata {
5257
didSet {
@@ -197,6 +202,13 @@ open class BarcodeScannerViewController: UIViewController {
197202
- Parameter processing: Flag to set the current state to `.processing`.
198203
*/
199204
private func animateFlash(whenProcessing: Bool = false) {
205+
guard shouldSimulateFlash else {
206+
if whenProcessing {
207+
self.status = Status(state: .processing)
208+
}
209+
return
210+
}
211+
200212
let flashView = UIView(frame: view.bounds)
201213
flashView.backgroundColor = UIColor.white
202214
flashView.alpha = 1
@@ -235,7 +247,7 @@ private extension BarcodeScannerViewController {
235247
cameraView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
236248
cameraView.bottomAnchor.constraint(
237249
equalTo: view.bottomAnchor,
238-
constant: -BarcodeScannerViewController.footerHeight
250+
constant: hideFooterView ? 0 : -BarcodeScannerViewController.footerHeight
239251
)
240252
)
241253

@@ -272,7 +284,7 @@ private extension BarcodeScannerViewController {
272284
messageView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
273285
messageView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
274286
messageView.heightAnchor.constraint(
275-
equalToConstant: BarcodeScannerViewController.footerHeight
287+
equalToConstant: hideFooterView ? 0 : -BarcodeScannerViewController.footerHeight
276288
)
277289
]
278290
}

Sources/Controllers/CameraViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public final class CameraViewController: UIViewController {
1919

2020
/// Focus view type.
2121
public var barCodeFocusViewType: FocusViewType = .animated
22+
public var initialCameraPosition: AVCaptureDevice.Position = .back
2223
public var showsCameraButton: Bool = false {
2324
didSet {
2425
cameraButton.isHidden = showsCameraButton
@@ -213,7 +214,7 @@ public final class CameraViewController: UIViewController {
213214
}
214215

215216
if error == nil {
216-
strongSelf.setupSessionInput(for: .back)
217+
strongSelf.setupSessionInput(for: strongSelf.initialCameraPosition)
217218
strongSelf.setupSessionOutput()
218219
strongSelf.delegate?.cameraViewControllerDidSetupCaptureSession(strongSelf)
219220
} else {

0 commit comments

Comments
 (0)