@capgo/camera-preview 7.4.0-alpha.22 → 7.4.0-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -504,6 +504,33 @@ extension CameraController {
|
|
|
504
504
|
dataOutput?.connections.forEach { $0.videoOrientation = videoOrientation }
|
|
505
505
|
photoOutput?.connections.forEach { $0.videoOrientation = videoOrientation }
|
|
506
506
|
}
|
|
507
|
+
|
|
508
|
+
private func setDefaultZoomAfterFlip() {
|
|
509
|
+
let device = (currentCameraPosition == .rear) ? rearCamera : frontCamera
|
|
510
|
+
guard let device = device else {
|
|
511
|
+
print("[CameraPreview] No device available for default zoom after flip")
|
|
512
|
+
return
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// Set zoom to 1.0x in UI terms, accounting for display multiplier
|
|
516
|
+
let multiplier = self.getDisplayZoomMultiplier()
|
|
517
|
+
let targetUIZoom: Float = 1.0 // We want 1.0x in the UI
|
|
518
|
+
let nativeZoom = multiplier != 1.0 ? (targetUIZoom / multiplier) : targetUIZoom
|
|
519
|
+
|
|
520
|
+
let minZoom = device.minAvailableVideoZoomFactor
|
|
521
|
+
let maxZoom = min(device.maxAvailableVideoZoomFactor, saneMaxZoomFactor)
|
|
522
|
+
let clampedZoom = max(minZoom, min(CGFloat(nativeZoom), maxZoom))
|
|
523
|
+
|
|
524
|
+
do {
|
|
525
|
+
try device.lockForConfiguration()
|
|
526
|
+
device.videoZoomFactor = clampedZoom
|
|
527
|
+
device.unlockForConfiguration()
|
|
528
|
+
self.zoomFactor = clampedZoom
|
|
529
|
+
print("[CameraPreview] Set default zoom after flip: UI=\(targetUIZoom)x, native=\(clampedZoom), multiplier=\(multiplier)")
|
|
530
|
+
} catch {
|
|
531
|
+
print("[CameraPreview] Failed to set default zoom after flip: \(error)")
|
|
532
|
+
}
|
|
533
|
+
}
|
|
507
534
|
|
|
508
535
|
func switchCameras() throws {
|
|
509
536
|
guard let currentCameraPosition = currentCameraPosition,
|
|
@@ -594,6 +621,11 @@ extension CameraController {
|
|
|
594
621
|
|
|
595
622
|
// Update video orientation
|
|
596
623
|
self.updateVideoOrientation()
|
|
624
|
+
|
|
625
|
+
// Set default 1.0 zoom level after camera switch to prevent iOS 18+ zoom jumps
|
|
626
|
+
DispatchQueue.main.async { [weak self] in
|
|
627
|
+
self?.setDefaultZoomAfterFlip()
|
|
628
|
+
}
|
|
597
629
|
}
|
|
598
630
|
|
|
599
631
|
func captureImage(width: Int?, height: Int?, aspectRatio: String?, quality: Float, gpsLocation: CLLocation?, completion: @escaping (UIImage?, Data?, [AnyHashable: Any]?, Error?) -> Void) {
|