Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions android/src/main/java/com/rncamerakit/CKCamera.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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" -> {
Expand Down
Loading