Skip to content

Commit

Permalink
Merge pull request #130 from qalandarov/main
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Fallet authored Feb 23, 2024
2 parents 0af227c + 6124b72 commit 9302aa1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
14 changes: 13 additions & 1 deletion Sources/CodeScanner/CodeScanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,20 @@ public enum ScanMode {
/// Keep scanning all codes until dismissed.
case continuous

/// Keep scanning all codes - except the ones from the ignored list - until dismissed.
case continuousExcept(ignoredList: Set<String>)

/// Scan only when capture button is tapped.
case manual

var isManual: Bool {
switch self {
case .manual:
return true
case .once, .oncePerCode, .continuous, .continuousExcept:
return false
}
}
}

/// A SwiftUI view that is able to scan barcodes, QR codes, and more, and send back what was found.
Expand Down Expand Up @@ -114,7 +126,7 @@ public struct CodeScannerView: UIViewControllerRepresentable {
uiViewController.updateViewController(
isTorchOn: isTorchOn,
isGalleryPresented: isGalleryPresented.wrappedValue,
isManualCapture: scanMode == .manual,
isManualCapture: scanMode.isManual,
isManualSelect: manualSelect
)
}
Expand Down
7 changes: 6 additions & 1 deletion Sources/CodeScanner/ScannerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ extension CodeScannerView {
}

public func readyManualCapture() {
guard parentView.scanMode == .manual else { return }
guard parentView.scanMode.isManual else { return }
self.reset()
lastTime = Date()
}
Expand Down Expand Up @@ -465,6 +465,11 @@ extension CodeScannerView.ScannerViewController: AVCaptureMetadataOutputObjectsD
if isPastScanInterval() {
found(result)
}

case .continuousExcept(let ignoredList):
if isPastScanInterval() && !ignoredList.contains(stringValue) {
found(result)
}
}
}

Expand Down

0 comments on commit 9302aa1

Please sign in to comment.