Move usage of LocalInspectionMode.current into the deeper block.
This commit is contained in:
parent
6100d4944f
commit
06c20e3abf
1 changed files with 67 additions and 67 deletions
|
|
@ -48,15 +48,6 @@ fun QrCodeCameraView(
|
|||
isScanning: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
if (LocalInspectionMode.current) {
|
||||
Box(
|
||||
modifier = modifier
|
||||
.background(color = ElementTheme.colors.bgSubtlePrimary),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Text("CameraView")
|
||||
}
|
||||
} else {
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
val localContext = LocalContext.current
|
||||
val lifecycleOwner = LocalLifecycleOwner.current
|
||||
|
|
@ -90,7 +81,7 @@ fun QrCodeCameraView(
|
|||
lifecycleOwner,
|
||||
cameraSelector,
|
||||
previewUseCase,
|
||||
imageAnalysis
|
||||
imageAnalysis,
|
||||
)
|
||||
lastFrame = null
|
||||
} catch (e: Exception) {
|
||||
|
|
@ -120,6 +111,15 @@ fun QrCodeCameraView(
|
|||
}
|
||||
|
||||
Box(modifier.clipToBounds()) {
|
||||
if (LocalInspectionMode.current) {
|
||||
Box(
|
||||
modifier = modifier
|
||||
.background(color = ElementTheme.colors.bgSubtlePrimary),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Text("CameraView")
|
||||
}
|
||||
} else {
|
||||
AndroidView(
|
||||
factory = { context ->
|
||||
val previewView = PreviewView(context)
|
||||
|
|
@ -145,12 +145,12 @@ fun QrCodeCameraView(
|
|||
cameraProvider = null
|
||||
},
|
||||
)
|
||||
}
|
||||
lastFrame?.let {
|
||||
Image(bitmap = it.asImageBitmap(), contentDescription = null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun Context.getCameraProvider(): ProcessCameraProvider =
|
||||
suspendCoroutine { continuation ->
|
||||
|
|
@ -159,7 +159,7 @@ private suspend fun Context.getCameraProvider(): ProcessCameraProvider =
|
|||
{
|
||||
continuation.resume(cameraProvider.get())
|
||||
},
|
||||
ContextCompat.getMainExecutor(this)
|
||||
ContextCompat.getMainExecutor(this),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue