Skip to content

Commit 4a2d580

Browse files
committed
fix(*): reflect correct torch state
1 parent ce377e6 commit 4a2d580

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

android/src/main/java/com/michaelwolz/capacitorcameraview/CameraView.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class CameraView(plugin: Plugin) {
7979
// Store references for later use
8080
this.lifecycleOwner = lifecycleOwner
8181

82+
isTorchEnabled = false
83+
8284
mainHandler.post {
8385
try {
8486
initializeCamera(context, lifecycleOwner, config)
@@ -106,6 +108,8 @@ class CameraView(plugin: Plugin) {
106108
}
107109
}
108110

111+
isTorchEnabled = false
112+
109113
webView.setLayerType(WebView.LAYER_TYPE_NONE, null)
110114
webView.setBackgroundColor(android.graphics.Color.WHITE)
111115

ios/Sources/CameraViewPlugin/CameraViewManager.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
7373
self.preferredCameraDeviceTypes = convertToNativeCameraTypes(preferredCameraDeviceTypes)
7474
}
7575

76+
torchEnabled = false
77+
torchLevel = 1.0
78+
7679
DispatchQueue.global(qos: .userInitiated).async { [weak self] in
7780
guard let self = self else { return }
7881

@@ -111,6 +114,9 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
111114
public func stopSession() {
112115
guard captureSession.isRunning else { return }
113116

117+
torchEnabled = false
118+
torchLevel = 1.0
119+
114120
DispatchQueue.global(qos: .userInitiated).async { [weak self] in
115121
self?.captureSession.stopRunning()
116122
}

0 commit comments

Comments
 (0)