Jetpack Compose Show Budy Dialog

December 16, 2021
@Composable
fun test() {
    var showBusy by remember { mutableStateOf(false) }

    Button(onClick = { showBusy = true }) {
      Text("Show Busy")
    }

    if (showBusy) {
        BusyDialog("I am Busy")
    }
}
fun BusyDialog(title: String? = null) {
    Dialog(
        onDismissRequest = { },
        DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false)
        ) {
        Box(
            contentAlignment = Alignment.Center,
            modifier = Modifier
                .size(100.dp)
                .background(MaterialTheme.colors.surface.copy(alpha = 0.7f), shape = RoundedCornerShape(8.dp))
        ) {
            CircularProgressIndicator()
        }
    }
}
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.