Skip to content

Instantly share code, notes, and snippets.

@akwasiio
Created March 26, 2022 21:17
Show Gist options
  • Save akwasiio/187ef5fa4d8139e9dfeb1d5ce4e00724 to your computer and use it in GitHub Desktop.
Save akwasiio/187ef5fa4d8139e9dfeb1d5ce4e00724 to your computer and use it in GitHub Desktop.
@Composable
fun MultipleProgressBar(steps: Int = 4, currentStep: Int) {
Row(
verticalAlignment = Alignment.CenterVertically, modifier = Modifier
.height(48.dp)
.fillMaxWidth()
.padding(24.dp, 0.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
for (index in 0 until steps) {
Box(
modifier = Modifier
.requiredHeight(4.dp)
.weight(if (index == currentStep) 1f else .5f)
.clip(RoundedCornerShape(50, 50, 50, 50))
.background(Color.Black)
) {
Box(
modifier = Modifier
.background(Color.White)
.fillMaxHeight()
.let {
when (index) {
in 0..currentStep -> it.fillMaxWidth()
else -> it
}
}
) {}
}
if (index != steps) {
Spacer(modifier = Modifier.width(4.dp))
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment