Created
September 30, 2021 03:05
-
-
Save sproctor/b811263ecd293a39202e966d782008ac to your computer and use it in GitHub Desktop.
Pairing dialog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun PairDialog(sdkHandler: SDKHandler, hideDialog: () -> Unit) { | |
AlertDialog( | |
onDismissRequest = hideDialog, | |
confirmButton = { | |
Button(onClick = hideDialog) { | |
Text("CANCEL") | |
} | |
}, | |
text = { | |
BoxWithConstraints(modifier = Modifier.fillMaxWidth().padding(32.dp)) { | |
val density = LocalDensity.current | |
val width = maxWidth | |
val height = min(maxWidth / 3, maxHeight) | |
AndroidView( | |
modifier = Modifier | |
.size(width = width, height = height) | |
.align(Alignment.Center), | |
factory = { | |
sdkHandler.dcssdkGetPairingBarcode( | |
DCSSDKDefs.DCSSDK_BT_PROTOCOL.SSI_BT_LE, | |
DCSSDKDefs.DCSSDK_BT_SCANNER_CONFIG.KEEP_CURRENT | |
) | |
.also { | |
with(density) { it.setSize(width.toPx().toInt(), height.toPx().toInt()) } | |
} | |
} | |
) | |
} | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment