Add QR scanner support for macOS with camera selection
- Refactor QR scanner into separate Scanner module for iOS and macOS - Add camera selection menu for devices with multiple cameras - Use Vision framework for QR detection on macOS - Remove tvOS QR scanner support (continuity camera) - Add camera entitlement and usage description for macOS - Fix minor issues in Intents and ExtensionProvider
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import AVFoundation
|
||||
import SwiftUI
|
||||
|
||||
public enum QRScanError: Error, LocalizedError {
|
||||
case cameraUnavailable
|
||||
case permissionDenied
|
||||
case scanFailed(Error)
|
||||
case invalidCode
|
||||
|
||||
public var errorDescription: String? {
|
||||
switch self {
|
||||
case .cameraUnavailable:
|
||||
return String(localized: "Camera is not available")
|
||||
case .permissionDenied:
|
||||
return String(localized: "Camera access denied")
|
||||
case let .scanFailed(error):
|
||||
return error.localizedDescription
|
||||
case .invalidCode:
|
||||
return String(localized: "Invalid QR code")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct QRScanResult: Sendable {
|
||||
public let string: String
|
||||
public let type: AVMetadataObject.ObjectType
|
||||
|
||||
public init(string: String, type: AVMetadataObject.ObjectType) {
|
||||
self.string = string
|
||||
self.type = type
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user