capacitor-camera-module 0.0.61 → 0.0.63

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.
@@ -157,7 +157,6 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
157
157
  }
158
158
 
159
159
  let session = AVCaptureSession()
160
- session.sessionPreset = .photo
161
160
 
162
161
  guard let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back),
163
162
  let input = try? AVCaptureDeviceInput(device: device) else {
@@ -178,61 +177,68 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
178
177
  return
179
178
  }
180
179
 
181
- // Preview view
180
+ // 1. Cambia isUserInteractionEnabled a true
182
181
  let previewView = UIView()
183
-
184
- // 🔑 MUY IMPORTANTE
185
- previewView.isUserInteractionEnabled = false
186
182
  previewView.translatesAutoresizingMaskIntoConstraints = false
187
183
  previewView.backgroundColor = .black
184
+ previewView.isUserInteractionEnabled = true // CAMBIO IMPORTANTE
185
+
186
+
187
+ previewView.backgroundColor = .red // Para ver si la vista se muestra
188
+
189
+
190
+ // Agrega esto después de crear la vista
191
+ print("PreviewView frame: \(previewView.frame)")
192
+ print("Superview: \(previewView.superview)")
188
193
 
189
194
  guard let webView = self.bridge?.webView else {
190
195
  call.reject("No webView")
191
196
  return
192
197
  }
193
198
 
194
- container.insertSubview(previewView, at: 0)
195
- webView.layer.zPosition = 1
196
- previewView.layer.zPosition = 0
197
-
198
-
199
-
199
+ // 2. Inserta la previewView sobre el webView temporalmente para debug
200
+ container.addSubview(previewView)
200
201
 
202
+ // 3. Configura constraints
201
203
  let safeArea = container.safeAreaLayoutGuide
202
-
203
204
  NSLayoutConstraint.activate([
204
- previewView.topAnchor.constraint(equalTo: container.topAnchor),
205
+ previewView.topAnchor.constraint(equalTo: safeArea.topAnchor), // NO container.topAnchor
205
206
  previewView.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor, constant: -180),
206
207
  previewView.leadingAnchor.constraint(equalTo: container.leadingAnchor),
207
208
  previewView.trailingAnchor.constraint(equalTo: container.trailingAnchor)
208
209
  ])
209
210
 
211
+ // 4. FORZA el layout inmediatamente
212
+ container.layoutIfNeeded()
210
213
 
211
- // Preview layer
214
+ // 5. Crea el previewLayer después de tener el tamaño correcto
212
215
  let previewLayer = AVCaptureVideoPreviewLayer(session: session)
213
216
  previewLayer.videoGravity = .resizeAspectFill
214
-
215
- previewView.layoutIfNeeded()
216
217
  previewLayer.frame = previewView.bounds
217
218
  previewLayer.masksToBounds = true
218
219
 
219
-
220
220
  previewView.layer.insertSublayer(previewLayer, at: 0)
221
221
 
222
-
223
-
222
+ // 6. Guarda referencias
224
223
  self.previewView = previewView
225
224
  self.videoPreviewLayer = previewLayer
226
225
  self.captureSession = session
227
226
 
228
- session.beginConfiguration()
227
+ // 7. Configura la sesión ANTES de iniciarla
229
228
  session.sessionPreset = .photo
230
- session.commitConfiguration()
231
229
 
230
+ // 8. Inicia la sesión en background
232
231
  DispatchQueue.global(qos: .userInitiated).async {
233
-
234
232
  session.startRunning()
233
+
234
+ // 9. Vuelve al main thread para verificar que se esté mostrando
235
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
236
+ print("Preview frame: \(previewView.frame)")
237
+ print("Preview layer frame: \(previewLayer.frame)")
238
+ print("Preview visible: \(previewView.window != nil)")
239
+ }
235
240
  }
241
+
236
242
  call.resolve()
237
243
  }
238
244
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-camera-module",
3
- "version": "0.0.61",
3
+ "version": "0.0.63",
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",