Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix camera orientation for Mac Catalyst #705

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ios/ReactNativeCameraKit/RealCamera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
private var maxPhotoQualityPrioritization: MaxPhotoQualityPrioritization?
private var resetFocus: (() -> Void)?
private var focusFinished: (() -> Void)?
private var onBarcodeRead: ((_ barcode: String,_ codeFormat : CodeFormat) -> Void)?

Check warning on line 39 in ios/ReactNativeCameraKit/RealCamera.swift

View workflow job for this annotation

GitHub Actions / Lint iOS

Colons should be next to the identifier when specifying a type and next to the key in dictionary literals (colon)

Check warning on line 39 in ios/ReactNativeCameraKit/RealCamera.swift

View workflow job for this annotation

GitHub Actions / Lint iOS

There should be no space before and one after any comma (comma)
private var scannerFrameSize: CGRect? = nil

Check warning on line 40 in ios/ReactNativeCameraKit/RealCamera.swift

View workflow job for this annotation

GitHub Actions / Lint iOS

Initializing an optional variable with nil is redundant (redundant_optional_initialization)
private var onOrientationChange: RCTDirectEventBlock?
private var onZoomCallback: RCTDirectEventBlock?
private var lastOnZoom: Double?
Expand All @@ -54,7 +54,7 @@
private var inProgressPhotoCaptureDelegates = [Int64: PhotoCaptureDelegate]()

// MARK: - Lifecycle

Check warning on line 57 in ios/ReactNativeCameraKit/RealCamera.swift

View workflow job for this annotation

GitHub Actions / Lint iOS

Lines should not have trailing whitespace (trailing_whitespace)
#if !targetEnvironment(macCatalyst)
override init() {
super.init()
Expand All @@ -75,7 +75,7 @@
// Mac Catalyst doesn't support device orientation notifications
}
#endif

Check warning on line 78 in ios/ReactNativeCameraKit/RealCamera.swift

View workflow job for this annotation

GitHub Actions / Lint iOS

Lines should not have trailing whitespace (trailing_whitespace)
@available(*, unavailable)
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
Expand Down Expand Up @@ -268,7 +268,7 @@
func update(flashMode: FlashMode) {
self.flashMode = flashMode
}

Check warning on line 271 in ios/ReactNativeCameraKit/RealCamera.swift

View workflow job for this annotation

GitHub Actions / Lint iOS

Lines should not have trailing whitespace (trailing_whitespace)
func update(maxPhotoQualityPrioritization: MaxPhotoQualityPrioritization?) {
guard maxPhotoQualityPrioritization != self.maxPhotoQualityPrioritization else { return }
if #available(iOS 13.0, *) {
Expand Down Expand Up @@ -375,7 +375,7 @@

func isBarcodeScannerEnabled(_ isEnabled: Bool,
supportedBarcodeTypes supportedBarcodeType: [CodeFormat],
onBarcodeRead: ((_ barcode: String,_ codeFormat:CodeFormat) -> Void)?) {

Check warning on line 378 in ios/ReactNativeCameraKit/RealCamera.swift

View workflow job for this annotation

GitHub Actions / Lint iOS

Colons should be next to the identifier when specifying a type and next to the key in dictionary literals (colon)

Check warning on line 378 in ios/ReactNativeCameraKit/RealCamera.swift

View workflow job for this annotation

GitHub Actions / Lint iOS

There should be no space before and one after any comma (comma)
sessionQueue.async {
self.onBarcodeRead = onBarcodeRead
let newTypes: [AVMetadataObject.ObjectType]
Expand Down Expand Up @@ -434,7 +434,7 @@
// Determine the barcode type and convert it to CodeFormat
let barcodeType = CodeFormat.fromAVMetadataObjectType(machineReadableCodeObject.type)

onBarcodeRead?(codeStringValue,barcodeType)

Check warning on line 437 in ios/ReactNativeCameraKit/RealCamera.swift

View workflow job for this annotation

GitHub Actions / Lint iOS

There should be no space before and one after any comma (comma)
}

// MARK: - Private
Expand Down Expand Up @@ -604,7 +604,7 @@
motionManager = CMMotionManager()
motionManager?.accelerometerUpdateInterval = 0.2
motionManager?.gyroUpdateInterval = 0.2
motionManager?.startAccelerometerUpdates(to: OperationQueue(), withHandler: { (accelerometerData, error) -> Void in

Check warning on line 607 in ios/ReactNativeCameraKit/RealCamera.swift

View workflow job for this annotation

GitHub Actions / Lint iOS

Returning Void in a function declaration is redundant (redundant_void_return)
guard error == nil else {
print("\(error!)")
return
Expand Down Expand Up @@ -698,8 +698,8 @@
}
self.cameraPreview.previewLayer.connection?.videoOrientation = self.videoOrientation(from: interfaceOrientation)
#else
// Mac Catalyst always uses landscape orientation
self.cameraPreview.previewLayer.connection?.videoOrientation = .landscapeRight
// Mac Catalyst always uses portrait orientation
self.cameraPreview.previewLayer.connection?.videoOrientation = .portrait
#endif
}

Expand Down
Loading