feat: add torch plugin for iOS and Android (#3551)

* feat(barcode-scanner): add torch toggle

* feat: torch plugin

* fix

---------

Co-authored-by: Lucas Nogueira <lucas@tauri.app>
This commit is contained in:
0xbizkandLucas Nogueira authored and GitHub committed 2026-10-13 05:37:04 -03:00
1 parent c91a9e6af5
commit d80b1be257
48 files changed
+1861 -4

No files matched your search

@@ -75,6 +75,10 @@ class BarcodeScannerPlugin(private val activity: Activity) : Plugin(activity),
private var cameraProvider: ProcessCameraProvider? = null
private var graphicOverlay: GraphicOverlay? = null
private var camera: Camera? = null
set(value) {
field = value
activeCamera = value
}
private var vibrator: Vibrator? = null
private var scannerOptions: BarcodeScannerOptions? = null
@@ -416,4 +420,19 @@ class BarcodeScannerPlugin(private val activity: Activity) : Plugin(activity),
private fun openSettingsResult(invoke: Invoke, result: ActivityResult) {
invoke.resolve()
}
companion object {
@Volatile
private var activeCamera: Camera? = null
/**
* The camera bound by an active scan, or `null` when no scan is running.
*
* Looked up through reflection by the torch plugin (`app.tauri.torch`): while a scan holds the
* camera, Android rejects `CameraManager.setTorchMode`, so the flash must be driven through
* this camera's `CameraControl` instead. Keep the name and signature stable.
*/
@JvmStatic
fun getActiveCamera(): Camera? = activeCamera
}
}