@capgo/camera-preview 7.4.0-beta.20 → 7.4.0-beta.22
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.
- package/README.md +30 -24
- package/android/.gradle/8.14.2/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/8.14.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.14.2/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.14.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.14.2/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +161 -55
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraXView.java +79 -38
- package/android/src/main/java/com/ahm/capacitor/camera/preview/GridOverlayView.java +8 -1
- package/dist/docs.json +43 -2
- package/dist/esm/definitions.d.ts +8 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.js +50 -7
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +50 -7
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +50 -7
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapgoCameraPreview/CameraController.swift +70 -59
- package/ios/Sources/CapgoCameraPreview/Plugin.swift +36 -17
- package/package.json +1 -1
|
@@ -89,6 +89,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
89
89
|
var currentLocation: CLLocation?
|
|
90
90
|
private var aspectRatio: String?
|
|
91
91
|
private var gridMode: String = "none"
|
|
92
|
+
private var positioning: String = "center"
|
|
92
93
|
private var permissionCallID: String?
|
|
93
94
|
private var waitingForLocation: Bool = false
|
|
94
95
|
|
|
@@ -435,6 +436,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
435
436
|
self.disableAudio = call.getBool("disableAudio") ?? true
|
|
436
437
|
self.aspectRatio = call.getString("aspectRatio")
|
|
437
438
|
self.gridMode = call.getString("gridMode") ?? "none"
|
|
439
|
+
self.positioning = call.getString("positioning") ?? "top"
|
|
438
440
|
let initialZoomLevel = call.getFloat("initialZoomLevel") ?? 1.0
|
|
439
441
|
if self.aspectRatio != nil && (call.getInt("width") != nil || call.getInt("height") != nil) {
|
|
440
442
|
call.reject("Cannot set both aspectRatio and size (width/height). Use setPreviewSize after start.")
|
|
@@ -472,6 +474,8 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
472
474
|
// Create and configure the preview view first
|
|
473
475
|
self.updateCameraFrame()
|
|
474
476
|
|
|
477
|
+
print("[CameraPreview] completeStartCamera - Preview frame after updateCameraFrame: \(self.previewView.frame)")
|
|
478
|
+
|
|
475
479
|
// Make webview transparent - comprehensive approach
|
|
476
480
|
self.makeWebViewTransparent()
|
|
477
481
|
|
|
@@ -505,7 +509,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
505
509
|
// Set up callback to wait for first frame before resolving
|
|
506
510
|
self.cameraController.firstFrameReadyCallback = { [weak self] in
|
|
507
511
|
guard let self = self else { return }
|
|
508
|
-
|
|
512
|
+
|
|
509
513
|
DispatchQueue.main.async {
|
|
510
514
|
var returnedObject = JSObject()
|
|
511
515
|
returnedObject["width"] = self.previewView.frame.width as any JSValue
|
|
@@ -515,7 +519,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
515
519
|
call.resolve(returnedObject)
|
|
516
520
|
}
|
|
517
521
|
}
|
|
518
|
-
|
|
522
|
+
|
|
519
523
|
// If already received first frame (unlikely but possible), resolve immediately
|
|
520
524
|
if self.cameraController.hasReceivedFirstFrame {
|
|
521
525
|
var returnedObject = JSObject()
|
|
@@ -601,6 +605,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
601
605
|
}
|
|
602
606
|
|
|
603
607
|
@objc func capture(_ call: CAPPluginCall) {
|
|
608
|
+
print("[CameraPreview] capture called with options: \(call.options)")
|
|
604
609
|
let withExifLocation = call.getBool("withExifLocation", false)
|
|
605
610
|
print("[CameraPreview] capture called, withExifLocation: \(withExifLocation)")
|
|
606
611
|
|
|
@@ -675,6 +680,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
675
680
|
|
|
676
681
|
private func performCapture(call: CAPPluginCall) {
|
|
677
682
|
print("[CameraPreview] performCapture called")
|
|
683
|
+
print("[CameraPreview] Call parameters: \(call.options)")
|
|
678
684
|
let quality = call.getFloat("quality", 85)
|
|
679
685
|
let saveToGallery = call.getBool("saveToGallery", false)
|
|
680
686
|
let withExifLocation = call.getBool("withExifLocation", false)
|
|
@@ -682,6 +688,8 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
682
688
|
let height = call.getInt("height")
|
|
683
689
|
let aspectRatio = call.getString("aspectRatio")
|
|
684
690
|
|
|
691
|
+
print("[CameraPreview] Raw parameter values - width: \(String(describing: width)), height: \(String(describing: height)), aspectRatio: \(String(describing: aspectRatio))")
|
|
692
|
+
|
|
685
693
|
// Check for conflicting parameters
|
|
686
694
|
if aspectRatio != nil && (width != nil || height != nil) {
|
|
687
695
|
print("[CameraPreview] Error: Cannot set both aspectRatio and size (width/height)")
|
|
@@ -689,16 +697,18 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
689
697
|
return
|
|
690
698
|
}
|
|
691
699
|
|
|
692
|
-
//
|
|
693
|
-
//
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
+
// When no dimensions are specified, we should capture exactly what's visible in the preview
|
|
701
|
+
// Don't pass aspectRatio in this case - let the capture method handle preview matching
|
|
702
|
+
print("[CameraPreview] Capture decision - width: \(width == nil), height: \(height == nil), aspectRatio param: \(aspectRatio == nil)")
|
|
703
|
+
print("[CameraPreview] Stored aspectRatio: \(self.aspectRatio ?? "nil")")
|
|
704
|
+
|
|
705
|
+
// Only pass aspectRatio if explicitly provided in the capture call
|
|
706
|
+
// Never use the stored aspectRatio when capturing without dimensions
|
|
707
|
+
let captureAspectRatio: String? = aspectRatio
|
|
708
|
+
|
|
700
709
|
print("[CameraPreview] Capture params - quality: \(quality), saveToGallery: \(saveToGallery), withExifLocation: \(withExifLocation), width: \(width ?? -1), height: \(height ?? -1), aspectRatio: \(aspectRatio ?? "nil"), using aspectRatio: \(captureAspectRatio ?? "nil")")
|
|
701
710
|
print("[CameraPreview] Current location: \(self.currentLocation?.description ?? "nil")")
|
|
711
|
+
print("[CameraPreview] Preview dimensions: \(self.previewView.frame.width)x\(self.previewView.frame.height)")
|
|
702
712
|
|
|
703
713
|
self.cameraController.captureImage(width: width, height: height, aspectRatio: captureAspectRatio, quality: quality, gpsLocation: self.currentLocation) { (image, error) in
|
|
704
714
|
print("[CameraPreview] captureImage callback received")
|
|
@@ -1344,9 +1354,9 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1344
1354
|
// Handle auto-centering when position is -1
|
|
1345
1355
|
if currentX == -1 || currentY == -1 {
|
|
1346
1356
|
// Only override dimensions if aspect ratio is provided and no explicit dimensions given
|
|
1347
|
-
if let ratio = currentAspectRatio,
|
|
1348
|
-
currentWidth == UIScreen.main.bounds.size.width &&
|
|
1349
|
-
|
|
1357
|
+
if let ratio = currentAspectRatio,
|
|
1358
|
+
currentWidth == UIScreen.main.bounds.size.width &&
|
|
1359
|
+
currentHeight == UIScreen.main.bounds.size.height {
|
|
1350
1360
|
finalWidth = webViewWidth
|
|
1351
1361
|
|
|
1352
1362
|
// Calculate height based on aspect ratio
|
|
@@ -1365,12 +1375,21 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1365
1375
|
finalX = currentX
|
|
1366
1376
|
}
|
|
1367
1377
|
|
|
1368
|
-
//
|
|
1378
|
+
// Position vertically if y is -1
|
|
1369
1379
|
if currentY == -1 {
|
|
1370
|
-
// Use full screen height for
|
|
1380
|
+
// Use full screen height for positioning
|
|
1371
1381
|
let screenHeight = UIScreen.main.bounds.size.height
|
|
1372
|
-
|
|
1373
|
-
|
|
1382
|
+
switch self.positioning {
|
|
1383
|
+
case "top":
|
|
1384
|
+
finalY = 0
|
|
1385
|
+
print("[CameraPreview] Positioning at top: finalY=0")
|
|
1386
|
+
case "bottom":
|
|
1387
|
+
finalY = screenHeight - finalHeight
|
|
1388
|
+
print("[CameraPreview] Positioning at bottom: screenHeight=\(screenHeight), finalHeight=\(finalHeight), finalY=\(finalY)")
|
|
1389
|
+
default: // "center"
|
|
1390
|
+
finalY = (screenHeight - finalHeight) / 2
|
|
1391
|
+
print("[CameraPreview] Centering vertically: screenHeight=\(screenHeight), finalHeight=\(finalHeight), finalY=\(finalY)")
|
|
1392
|
+
}
|
|
1374
1393
|
} else {
|
|
1375
1394
|
finalY = currentY
|
|
1376
1395
|
}
|