Timo Drick
05/20/2021, 3:45 PMFilip Wiesner
05/20/2021, 3:56 PMAditya Thakar
05/20/2021, 4:53 PMZach Klippenstein (he/him) [MOD]
05/20/2021, 6:29 PMTimo Drick
05/21/2021, 7:26 AMTimo Drick
05/21/2021, 7:39 AMAditya Thakar
05/21/2021, 7:45 AMTimo Drick
05/21/2021, 7:49 AMTimo Drick
05/21/2021, 8:19 AMBox() {
content(myContent)
if (blockUI) Box(Modifier.matchParentSize().pointerInput(onDismissRequest) { detectTapGestures { } })
}
Timo Drick
05/21/2021, 8:59 AM/**
* Locks the UI behind and after 300 ms it overlays the screen with the defined color and show a progress indicator.
*/
@Composable
private fun ProgressScrim(
modifier: Modifier = Modifier,
color: Color = Color.Black,
onDismiss: () -> Unit = {}
) {
var showScrim by remember { mutableStateOf(false) }
LaunchedEffect(key1 = onDismiss) {
delay(300)
showScrim = true
}
val alpha by animateFloatAsState(
targetValue = if (showScrim) .8f else 0f,
animationSpec = TweenSpec()
)
Box(
modifier
.pointerInput(onDismiss) {
detectTapGestures { onDismiss() }
}
.semantics(mergeDescendants = true) {
contentDescription = "Progress overlay"
onClick { onDismiss(); true }
},
contentAlignment = Alignment.Center
) {
if (showScrim) {
Canvas(Modifier.fillMaxSize()) {
drawRect(color = color, alpha = alpha)
}
CircularProgressIndicator()
}
}
}