Add QR code outline

This commit is contained in:
Andrew 2024-03-01 17:24:03 +10:30
parent 505d839924
commit 2555b34d8e

View File

@ -11,10 +11,12 @@ import androidx.camera.core.Preview
import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.camera.view.PreviewView
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
@ -41,6 +43,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
@ -190,14 +193,25 @@ class LinkDeviceActivity : BaseActionBarActivity() {
@Composable
fun ScanQrCode(preview: Preview) {
AndroidView(
modifier = Modifier.fillMaxSize(),
factory = { context ->
PreviewView(context).apply {
preview.setSurfaceProvider(surfaceProvider)
Box {
AndroidView(
modifier = Modifier.fillMaxSize(),
factory = { context ->
PreviewView(context).apply {
preview.setSurfaceProvider(surfaceProvider)
}
}
}
)
)
Box(
Modifier
.aspectRatio(1f)
.padding(20.dp)
.clip(shape = RoundedCornerShape(20.dp))
.background(Color(0x33ffffff))
.align(Alignment.Center)
)
}
}
@Composable