capacitor-camera-module 0.0.53 → 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.
@@ -169,19 +169,33 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
169
169
  session.addOutput(self.photoOutput)
170
170
  }
171
171
 
172
+ guard let container = self.bridge?.viewController?.view else {
173
+ call.reject("No container view")
174
+ return
175
+ }
172
176
 
173
- let container = self.bridge?.viewController?.view
174
- let view = UIView(frame: container?.bounds ?? .zero)
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
+ ])
175
189
 
176
- let layer = AVCaptureVideoPreviewLayer(session: session)
177
- layer.videoGravity = .resizeAspectFill
178
- layer.frame = view.bounds
190
+ // Preview layer
191
+ let previewLayer = AVCaptureVideoPreviewLayer(session: session)
192
+ previewLayer.videoGravity = .resizeAspectFill
193
+ previewLayer.frame = container.bounds
179
194
 
180
- view.layer.addSublayer(layer)
181
- self.bridge?.viewController?.view.insertSubview(view, at: 0)
195
+ previewView.layer.insertSublayer(previewLayer, at: 0)
182
196
 
183
- self.previewView = view
184
- self.videoPreviewLayer = layer
197
+ self.previewView = previewView
198
+ self.videoPreviewLayer = previewLayer
185
199
  self.captureSession = session
186
200
 
187
201
  session.startRunning()
@@ -189,6 +203,7 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
189
203
  }
190
204
  }
191
205
 
206
+
192
207
  @objc func stopPreview(_ call: CAPPluginCall) {
193
208
  DispatchQueue.main.async {
194
209
  self.captureSession?.stopRunning()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-camera-module",
3
- "version": "0.0.53",
3
+ "version": "0.0.54",
4
4
  "description": "Plugin to request permissiones view camera take phots",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",