capacitor-camera-module 0.0.52 → 0.0.54
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.
|
@@ -23,7 +23,8 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
|
|
|
23
23
|
CAPPluginMethod(name: "hasFlash", returnType: CAPPluginReturnPromise),
|
|
24
24
|
CAPPluginMethod(name: "takePhotoBase64", returnType: CAPPluginReturnPromise),
|
|
25
25
|
CAPPluginMethod(name: "startBarcodeScan", returnType: CAPPluginReturnPromise),
|
|
26
|
-
CAPPluginMethod(name: "stopBarcodeScan", returnType: CAPPluginReturnPromise)
|
|
26
|
+
CAPPluginMethod(name: "stopBarcodeScan", returnType: CAPPluginReturnPromise),
|
|
27
|
+
CAPPluginMethod(name: "getLastGalleryImage", returnType: CAPPluginReturnPromise)
|
|
27
28
|
|
|
28
29
|
]
|
|
29
30
|
|
|
@@ -168,19 +169,33 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
|
|
|
168
169
|
session.addOutput(self.photoOutput)
|
|
169
170
|
}
|
|
170
171
|
|
|
172
|
+
guard let container = self.bridge?.viewController?.view else {
|
|
173
|
+
call.reject("No container view")
|
|
174
|
+
return
|
|
175
|
+
}
|
|
171
176
|
|
|
172
|
-
|
|
173
|
-
let
|
|
177
|
+
// Preview view
|
|
178
|
+
let previewView = UIView()
|
|
179
|
+
previewView.translatesAutoresizingMaskIntoConstraints = false
|
|
180
|
+
previewView.backgroundColor = .black
|
|
181
|
+
container.addSubview(previewView)
|
|
182
|
+
|
|
183
|
+
NSLayoutConstraint.activate([
|
|
184
|
+
previewView.topAnchor.constraint(equalTo: container.topAnchor),
|
|
185
|
+
previewView.bottomAnchor.constraint(equalTo: container.bottomAnchor),
|
|
186
|
+
previewView.leadingAnchor.constraint(equalTo: container.leadingAnchor),
|
|
187
|
+
previewView.trailingAnchor.constraint(equalTo: container.trailingAnchor)
|
|
188
|
+
])
|
|
174
189
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
190
|
+
// Preview layer
|
|
191
|
+
let previewLayer = AVCaptureVideoPreviewLayer(session: session)
|
|
192
|
+
previewLayer.videoGravity = .resizeAspectFill
|
|
193
|
+
previewLayer.frame = container.bounds
|
|
178
194
|
|
|
179
|
-
|
|
180
|
-
self.bridge?.viewController?.view.insertSubview(view, at: 0)
|
|
195
|
+
previewView.layer.insertSublayer(previewLayer, at: 0)
|
|
181
196
|
|
|
182
|
-
self.previewView =
|
|
183
|
-
self.videoPreviewLayer =
|
|
197
|
+
self.previewView = previewView
|
|
198
|
+
self.videoPreviewLayer = previewLayer
|
|
184
199
|
self.captureSession = session
|
|
185
200
|
|
|
186
201
|
session.startRunning()
|
|
@@ -188,6 +203,7 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
|
|
|
188
203
|
}
|
|
189
204
|
}
|
|
190
205
|
|
|
206
|
+
|
|
191
207
|
@objc func stopPreview(_ call: CAPPluginCall) {
|
|
192
208
|
DispatchQueue.main.async {
|
|
193
209
|
self.captureSession?.stopRunning()
|