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,
|
isScanning: Boolean,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
if (LocalInspectionMode.current) {
|
|
||||||
Box(
|
|
||||||
modifier = modifier
|
|
||||||
.background(color = ElementTheme.colors.bgSubtlePrimary),
|
|
||||||
contentAlignment = Alignment.Center,
|
|
||||||
) {
|
|
||||||
Text("CameraView")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
val localContext = LocalContext.current
|
val localContext = LocalContext.current
|
||||||
val lifecycleOwner = LocalLifecycleOwner.current
|
val lifecycleOwner = LocalLifecycleOwner.current
|
||||||
|
|
@ -90,7 +81,7 @@ fun QrCodeCameraView(
|
||||||
lifecycleOwner,
|
lifecycleOwner,
|
||||||
cameraSelector,
|
cameraSelector,
|
||||||
previewUseCase,
|
previewUseCase,
|
||||||
imageAnalysis
|
imageAnalysis,
|
||||||
)
|
)
|
||||||
lastFrame = null
|
lastFrame = null
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|
@ -120,6 +111,15 @@ fun QrCodeCameraView(
|
||||||
}
|
}
|
||||||
|
|
||||||
Box(modifier.clipToBounds()) {
|
Box(modifier.clipToBounds()) {
|
||||||
|
if (LocalInspectionMode.current) {
|
||||||
|
Box(
|
||||||
|
modifier = modifier
|
||||||
|
.background(color = ElementTheme.colors.bgSubtlePrimary),
|
||||||
|
contentAlignment = Alignment.Center,
|
||||||
|
) {
|
||||||
|
Text("CameraView")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
AndroidView(
|
AndroidView(
|
||||||
factory = { context ->
|
factory = { context ->
|
||||||
val previewView = PreviewView(context)
|
val previewView = PreviewView(context)
|
||||||
|
|
@ -145,12 +145,12 @@ fun QrCodeCameraView(
|
||||||
cameraProvider = null
|
cameraProvider = null
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
}
|
||||||
lastFrame?.let {
|
lastFrame?.let {
|
||||||
Image(bitmap = it.asImageBitmap(), contentDescription = null)
|
Image(bitmap = it.asImageBitmap(), contentDescription = null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private suspend fun Context.getCameraProvider(): ProcessCameraProvider =
|
private suspend fun Context.getCameraProvider(): ProcessCameraProvider =
|
||||||
suspendCoroutine { continuation ->
|
suspendCoroutine { continuation ->
|
||||||
|
|
@ -159,7 +159,7 @@ private suspend fun Context.getCameraProvider(): ProcessCameraProvider =
|
||||||
{
|
{
|
||||||
continuation.resume(cameraProvider.get())
|
continuation.resume(cameraProvider.get())
|
||||||
},
|
},
|
||||||
ContextCompat.getMainExecutor(this)
|
ContextCompat.getMainExecutor(this),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue