@Composable
fun App() {
var progress by remember { mutableStateOf(0f) }
MaterialTheme {
Column {
Button(
modifier = Modifier.fillMaxWidth(),
onClick = {
flow {
for (i in 0..100) {
emit(i / 100f)
delay(50)
}
}
.onEach { progress = it }
.launchIn(CoroutineScope(Dispatchers.Default))
},
) {
Text(text = "Run")
}
LinearProgressIndicator(
progress = progress,
modifier = Modifier.fillMaxWidth()
)
CircularProgressIndicator(
progress = progress
)
}
}
}
fun main() = application {
Window(onCloseRequest = ::exitApplication) {
App()
}
}