Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera too dark when embed CodeScannerView to Jetpack Compose #173

Open
rizmaulana opened this issue Dec 22, 2022 · 0 comments
Open

Camera too dark when embed CodeScannerView to Jetpack Compose #173

rizmaulana opened this issue Dec 22, 2022 · 0 comments

Comments

@rizmaulana
Copy link

Hi @yuriy-budiyev
i start use this library to scan many kind of qr and barcode, but when it come to Jetpack Compose, I have a trouble : the camera is too dark.

I try to build from https://github.com/yuriy-budiyev/lib-demo-app everything looks good, so I assume is the problem is not related to the android device

From demo app From Jetpack Compose App
2022-12-22 15 12 09 2022-12-22 15 12 19

Here is my code :

@Composable
private fun CameraView(
    qrCodeReturn: (String) -> Unit
) {
    Box(Modifier.fillMaxSize()) {
        AndroidView(
            modifier = Modifier,
            factory = {
                CodeScannerView(it).apply {
                    val codeScanner = CodeScanner(it, this).apply {
                        isAutoFocusEnabled = true
                        isAutoFocusButtonVisible = false
                        scanMode = ScanMode.SINGLE
                        decodeCallback = DecodeCallback { result ->
                            qrCodeReturn.invoke(result.text)
                            releaseResources()
                        }
                        errorCallback = ErrorCallback {
                            releaseResources()
                        }
                    }
                    codeScanner.startPreview()
                }
            },
        )
    }
}

TIA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant