@capgo/camera-preview 7.4.0-alpha.24 → 7.4.0-alpha.25
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,23 +504,23 @@ extension CameraController {
|
|
|
504
504
|
dataOutput?.connections.forEach { $0.videoOrientation = videoOrientation }
|
|
505
505
|
photoOutput?.connections.forEach { $0.videoOrientation = videoOrientation }
|
|
506
506
|
}
|
|
507
|
-
|
|
507
|
+
|
|
508
508
|
private func setDefaultZoomAfterFlip() {
|
|
509
509
|
let device = (currentCameraPosition == .rear) ? rearCamera : frontCamera
|
|
510
510
|
guard let device = device else {
|
|
511
511
|
print("[CameraPreview] No device available for default zoom after flip")
|
|
512
512
|
return
|
|
513
513
|
}
|
|
514
|
-
|
|
514
|
+
|
|
515
515
|
// Set zoom to 1.0x in UI terms, accounting for display multiplier
|
|
516
516
|
let multiplier = self.getDisplayZoomMultiplier()
|
|
517
517
|
let targetUIZoom: Float = 1.0 // We want 1.0x in the UI
|
|
518
518
|
let nativeZoom = multiplier != 1.0 ? (targetUIZoom / multiplier) : targetUIZoom
|
|
519
|
-
|
|
519
|
+
|
|
520
520
|
let minZoom = device.minAvailableVideoZoomFactor
|
|
521
521
|
let maxZoom = min(device.maxAvailableVideoZoomFactor, saneMaxZoomFactor)
|
|
522
522
|
let clampedZoom = max(minZoom, min(CGFloat(nativeZoom), maxZoom))
|
|
523
|
-
|
|
523
|
+
|
|
524
524
|
do {
|
|
525
525
|
try device.lockForConfiguration()
|
|
526
526
|
device.videoZoomFactor = clampedZoom
|
|
@@ -621,7 +621,7 @@ extension CameraController {
|
|
|
621
621
|
|
|
622
622
|
// Update video orientation
|
|
623
623
|
self.updateVideoOrientation()
|
|
624
|
-
|
|
624
|
+
|
|
625
625
|
// Set default 1.0 zoom level after camera switch to prevent iOS 18+ zoom jumps
|
|
626
626
|
DispatchQueue.main.async { [weak self] in
|
|
627
627
|
self?.setDefaultZoomAfterFlip()
|
|
@@ -170,18 +170,62 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
var values: [Float] = []
|
|
173
|
-
if hasUltraWide {
|
|
173
|
+
if hasUltraWide {
|
|
174
|
+
values.append(0.5)
|
|
175
|
+
}
|
|
174
176
|
if hasWide {
|
|
175
177
|
values.append(1.0)
|
|
176
|
-
|
|
178
|
+
if self.isProModelSupportingOptical2x() {
|
|
179
|
+
values.append(2.0)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if hasTele {
|
|
183
|
+
// Use the virtual device's switch-over zoom factors when available
|
|
184
|
+
let displayMultiplier = self.cameraController.getDisplayZoomMultiplier()
|
|
185
|
+
var teleStep: Float
|
|
186
|
+
|
|
187
|
+
if #available(iOS 13.0, *) {
|
|
188
|
+
let switchFactors = device.virtualDeviceSwitchOverVideoZoomFactors
|
|
189
|
+
if !switchFactors.isEmpty {
|
|
190
|
+
// Choose the highest switch-over factor (typically the wide->tele threshold)
|
|
191
|
+
let maxSwitch = switchFactors.map { $0.floatValue }.max() ?? Float(device.maxAvailableVideoZoomFactor)
|
|
192
|
+
teleStep = maxSwitch * displayMultiplier
|
|
193
|
+
} else {
|
|
194
|
+
teleStep = Float(device.maxAvailableVideoZoomFactor) * displayMultiplier
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
teleStep = Float(device.maxAvailableVideoZoomFactor) * displayMultiplier
|
|
198
|
+
}
|
|
199
|
+
values.append(teleStep)
|
|
177
200
|
}
|
|
178
|
-
if hasTele { values.append(3.0) }
|
|
179
201
|
|
|
180
202
|
// Deduplicate and sort
|
|
181
203
|
let uniqueSorted = Array(Set(values)).sorted()
|
|
182
204
|
call.resolve(["values": uniqueSorted])
|
|
183
205
|
}
|
|
184
206
|
|
|
207
|
+
private func isProModelSupportingOptical2x() -> Bool {
|
|
208
|
+
// Detects iPhone 14 Pro/Pro Max, 15 Pro/Pro Max, and 16 Pro/Pro Max
|
|
209
|
+
var systemInfo = utsname()
|
|
210
|
+
uname(&systemInfo)
|
|
211
|
+
let mirror = Mirror(reflecting: systemInfo.machine)
|
|
212
|
+
let identifier = mirror.children.reduce("") { partialResult, element in
|
|
213
|
+
guard let value = element.value as? Int8, value != 0 else { return partialResult }
|
|
214
|
+
return partialResult + String(UnicodeScalar(UInt8(value)))
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Known identifiers: 14 Pro (iPhone15,2), 14 Pro Max (iPhone15,3),
|
|
218
|
+
// 15 Pro (iPhone16,1), 15 Pro Max (iPhone16,2),
|
|
219
|
+
// 16 Pro (iPhone17,1), 16 Pro Max (iPhone17,2),
|
|
220
|
+
// 17 Pro (iPhone18,1), 17 Pro Max (iPhone18,2)
|
|
221
|
+
let supportedIdentifiers: Set<String> = [
|
|
222
|
+
"iPhone15,2", "iPhone15,3", // 14 Pro / 14 Pro Max
|
|
223
|
+
"iPhone16,1", "iPhone16,2", // 15 Pro / 15 Pro Max
|
|
224
|
+
"iPhone17,1", "iPhone17,2" // 16 Pro / 16 Pro Max
|
|
225
|
+
]
|
|
226
|
+
return supportedIdentifiers.contains(identifier)
|
|
227
|
+
}
|
|
228
|
+
|
|
185
229
|
@objc func rotated() {
|
|
186
230
|
guard let previewView = self.previewView,
|
|
187
231
|
let posX = self.posX,
|