@Composable
fun LinearDeterminateIndicator() {
   
var currentProgress by remember { mutableStateOf(0f) }
   
var loading by remember { mutableStateOf(false) }
   
val scope = rememberCoroutineScope() // Create a coroutine scope

   
Column(
        verticalArrangement
= Arrangement.spacedBy(12.dp),
        horizontalAlignment
= Alignment.CenterHorizontally,
        modifier
= Modifier.fillMaxWidth()
   
) {
       
Button(onClick = {
            loading
= true
            scope
.launch {
                loadProgress
{ progress ->
                    currentProgress
= progress
               
}
                loading
= false // Reset loading when the coroutine finishes
           
}
       
}, enabled = !loading) {
           
Text("Start loading")
       
}

       
if (loading) {
           
LinearProgressIndicator(
                progress
= { currentProgress },
                modifier
= Modifier.fillMaxWidth(),
           
)
       
}
   
}
}

/** Iterate the progress value */
suspend fun loadProgress(updateProgress: (Float) -> Unit) {
   
for (i in 1..100) {
        updateProgress
(i.toFloat() / 100)
        delay
(100)
   
}
}