Skip to content

Instantly share code, notes, and snippets.

@Arunshaik2001
Last active October 27, 2022 05:18
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/88804d81499b9dd655edcbd0cf0d0e2f to your computer and use it in GitHub Desktop.
Save Arunshaik2001/88804d81499b9dd655edcbd0cf0d0e2f to your computer and use it in GitHub Desktop.
Surface(
modifier = Modifier
.fillMaxSize()
.padding(10.dp),
color = MaterialTheme.colors.background
) {
val deviceScanningState by viewModel.viewState.observeAsState()
val deviceConnectionState by ChatServer.deviceConnection.observeAsState()
var isChatOpen by remember {
mutableStateOf(false)
}
Box(
contentAlignment = Alignment.TopCenter,
modifier = Modifier.fillMaxSize()
) {
if (deviceScanningState != null && !isChatOpen || deviceConnectionState == DeviceConnectionState.Disconnected) {
Column {
Text(
text = "Choose a device to chat with:",
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
Spacer(modifier = Modifier.height(10.dp))
DeviceScanCompose.DeviceScan(deviceScanViewState = deviceScanningState!!) {
isChatOpen = true
}
}
} else {
ChatCompose.Chats()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment