@capgo/camera-preview 8.0.2 → 8.0.3
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.
|
@@ -34,7 +34,7 @@ extension UIWindow {
|
|
|
34
34
|
*/
|
|
35
35
|
@objc(CameraPreview)
|
|
36
36
|
public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelegate {
|
|
37
|
-
private let pluginVersion: String = "8.0.
|
|
37
|
+
private let pluginVersion: String = "8.0.3"
|
|
38
38
|
public let identifier = "CameraPreviewPlugin"
|
|
39
39
|
public let jsName = "CameraPreview"
|
|
40
40
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -1636,7 +1636,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1636
1636
|
// First, convert from UI/display zoom to native zoom using the iOS 18 multiplier
|
|
1637
1637
|
let displayMultiplier = self.cameraController.getDisplayZoomMultiplier()
|
|
1638
1638
|
if displayMultiplier != 1.0 {
|
|
1639
|
-
level
|
|
1639
|
+
level /= displayMultiplier
|
|
1640
1640
|
}
|
|
1641
1641
|
|
|
1642
1642
|
let ramp = call.getBool("ramp") ?? true
|
|
@@ -2017,11 +2017,11 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
2017
2017
|
|
|
2018
2018
|
if currentRatio > ratio {
|
|
2019
2019
|
let newWidth = frame.height * ratio
|
|
2020
|
-
frame.origin.x
|
|
2020
|
+
frame.origin.x += (frame.width - newWidth) / 2
|
|
2021
2021
|
frame.size.width = newWidth
|
|
2022
2022
|
} else {
|
|
2023
2023
|
let newHeight = frame.width / ratio
|
|
2024
|
-
frame.origin.y
|
|
2024
|
+
frame.origin.y += (frame.height - newHeight) / 2
|
|
2025
2025
|
frame.size.height = newHeight
|
|
2026
2026
|
}
|
|
2027
2027
|
}
|
|
@@ -2074,14 +2074,14 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
2074
2074
|
}
|
|
2075
2075
|
|
|
2076
2076
|
// Always set to -1 for auto-centering if not explicitly provided
|
|
2077
|
-
if let
|
|
2078
|
-
self.posX = CGFloat(
|
|
2077
|
+
if let xValue = call.getInt("x") {
|
|
2078
|
+
self.posX = CGFloat(xValue)
|
|
2079
2079
|
} else {
|
|
2080
2080
|
self.posX = -1 // Auto-center if X not provided
|
|
2081
2081
|
}
|
|
2082
2082
|
|
|
2083
|
-
if let
|
|
2084
|
-
self.posY = CGFloat(
|
|
2083
|
+
if let yValue = call.getInt("y") {
|
|
2084
|
+
self.posY = CGFloat(yValue)
|
|
2085
2085
|
} else {
|
|
2086
2086
|
self.posY = -1 // Auto-center if Y not provided
|
|
2087
2087
|
}
|
|
@@ -2110,13 +2110,13 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
2110
2110
|
return
|
|
2111
2111
|
}
|
|
2112
2112
|
|
|
2113
|
-
guard let
|
|
2113
|
+
guard let xCoord = call.getFloat("x"), let yCoord = call.getFloat("y") else {
|
|
2114
2114
|
call.reject("x and y parameters are required")
|
|
2115
2115
|
return
|
|
2116
2116
|
}
|
|
2117
2117
|
|
|
2118
2118
|
// Reject if values are outside 0-1 range
|
|
2119
|
-
if
|
|
2119
|
+
if xCoord < 0 || xCoord > 1 || yCoord < 0 || yCoord > 1 {
|
|
2120
2120
|
call.reject("Focus coordinates must be between 0 and 1")
|
|
2121
2121
|
return
|
|
2122
2122
|
}
|
|
@@ -2124,8 +2124,8 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
2124
2124
|
DispatchQueue.main.async {
|
|
2125
2125
|
do {
|
|
2126
2126
|
// Convert normalized coordinates to view coordinates
|
|
2127
|
-
let viewX = CGFloat(
|
|
2128
|
-
let viewY = CGFloat(
|
|
2127
|
+
let viewX = CGFloat(xCoord) * self.previewView.bounds.width
|
|
2128
|
+
let viewY = CGFloat(yCoord) * self.previewView.bounds.height
|
|
2129
2129
|
let focusPoint = CGPoint(x: viewX, y: viewY)
|
|
2130
2130
|
|
|
2131
2131
|
// Convert view coordinates to device coordinates
|
|
@@ -2235,13 +2235,13 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
2235
2235
|
// Snap to valid range and step
|
|
2236
2236
|
var range = try self.cameraController.getExposureCompensationRange()
|
|
2237
2237
|
if range.step <= 0 { range.step = 0.1 }
|
|
2238
|
-
let
|
|
2239
|
-
let
|
|
2240
|
-
// Clamp to [
|
|
2241
|
-
value = max(
|
|
2238
|
+
let minValue = min(range.min, range.max)
|
|
2239
|
+
let maxValue = max(range.min, range.max)
|
|
2240
|
+
// Clamp to [minValue, maxValue]
|
|
2241
|
+
value = max(minValue, min(maxValue, value))
|
|
2242
2242
|
// Snap to nearest step
|
|
2243
|
-
let steps = round((value -
|
|
2244
|
-
let snapped =
|
|
2243
|
+
let steps = round((value - minValue) / range.step)
|
|
2244
|
+
let snapped = minValue + steps * range.step
|
|
2245
2245
|
|
|
2246
2246
|
try self.cameraController.setExposureCompensation(snapped)
|
|
2247
2247
|
call.resolve()
|