Skip to content

Instantly share code, notes, and snippets.

@Arunshaik2001
Created October 27, 2022 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arunshaik2001/cdfee6463ed48ed7a0cbe49e0aeb9b0d to your computer and use it in GitHub Desktop.
Save Arunshaik2001/cdfee6463ed48ed7a0cbe49e0aeb9b0d to your computer and use it in GitHub Desktop.
@Composable
fun DeviceScan(deviceScanViewState: DeviceScanViewState, onDeviceSelected: () -> Unit) {
when (deviceScanViewState) {
is DeviceScanViewState.ActiveScan -> {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize()
) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
CircularProgressIndicator()
Spacer(modifier = Modifier.height(15.dp))
Text(
text = "Scanning for devices",
fontSize = 15.sp,
fontWeight = FontWeight.Light
)
}
}
}
is DeviceScanViewState.ScanResults -> {
ShowDevices(scanResults = deviceScanViewState.scanResults, onClick = {
Log.i(TAG, "Device Selected ${it!!.name ?: ""}")
ChatServer.setCurrentChatConnection(device = it!!)
ChatServer.currentDevice = it
onDeviceSelected()
})
}
is DeviceScanViewState.Error -> {
Text(text = deviceScanViewState.message)
}
else -> {
Text(text = "Nothing")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment