From 5528e402f6b6d50181260fa42ada6d70f6b5bab0 Mon Sep 17 00:00:00 2001 From: Jameson Lapp Date: Fri, 6 Feb 2026 10:28:39 -0500 Subject: [PATCH] Fixed the initial state for flashMode and torchMode --- android/src/main/java/com/rncamerakit/CKCamera.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/android/src/main/java/com/rncamerakit/CKCamera.kt b/android/src/main/java/com/rncamerakit/CKCamera.kt index 928c5e361..fb62e6ea2 100644 --- a/android/src/main/java/com/rncamerakit/CKCamera.kt +++ b/android/src/main/java/com/rncamerakit/CKCamera.kt @@ -103,6 +103,8 @@ class CKCamera(context: ThemedReactContext) : FrameLayout(context), LifecycleObs private var maxZoom: Double? = null private var zoomStartedAt = 1.0f private var pinchGestureStartedAt = 0.0f + private var flashMode: String = "auto" + private var torchMode: String = "off" // Barcode Props private var scanBarcode: Boolean = false @@ -405,6 +407,10 @@ class CKCamera(context: ThemedReactContext) : FrameLayout(context), LifecycleObs resetZoom(newCamera) + // Apply initial flash mode and torch mode settings after camera initialization + setFlashMode(flashMode) + setTorchMode(torchMode) + // Attach the viewfinder's surface provider to preview use case preview?.setSurfaceProvider(viewFinder.surfaceProvider) } catch (exc: Exception) { @@ -588,6 +594,7 @@ class CKCamera(context: ThemedReactContext) : FrameLayout(context), LifecycleObs fun setFlashMode(mode: String?) { + flashMode = mode ?: "auto" val imageCapture = imageCapture ?: return val camera = camera ?: return when (mode) { @@ -607,6 +614,7 @@ class CKCamera(context: ThemedReactContext) : FrameLayout(context), LifecycleObs } fun setTorchMode(mode: String?) { + torchMode = mode ?: "off" val camera = camera ?: return when (mode) { "on" -> {