rename example

This commit is contained in:
2026-06-01 03:09:19 +02:00
parent 7f3d14a764
commit b5473bfafc
59 changed files with 261 additions and 182 deletions
@@ -0,0 +1,42 @@
package com.bitcointxoko.gudariwallet.ui
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import com.journeyapps.barcodescanner.ScanContract
import com.journeyapps.barcodescanner.ScanOptions
/**
* Launches the zxing-android-embedded scanner activity and calls [onScanned]
* with the raw result string, or [onDismiss] if the user cancels.
*
* Camera permission is handled internally by the scanner activity — no
* Accompanist boilerplate needed here.
*/
@Composable
fun QrScannerScreen(
onScanned: (String) -> Unit,
onDismiss: () -> Unit
) {
val launcher = rememberLauncherForActivityResult(ScanContract()) { result ->
val content = result.contents
if (content != null) {
onScanned(content)
} else {
onDismiss()
}
}
// Launch the scanner as soon as this composable enters the composition.
// The scanner activity takes over the screen; when it finishes the result
// callback above fires and we navigate away.
LaunchedEffect(Unit) {
val options = ScanOptions().apply {
setDesiredBarcodeFormats(ScanOptions.QR_CODE)
setPrompt("") // no bottom prompt text
setBeepEnabled(false) // wallet apps are usually silent
setOrientationLocked(true)
}
launcher.launch(options)
}
}