Created
March 26, 2022 21:17
-
-
Save akwasiio/187ef5fa4d8139e9dfeb1d5ce4e00724 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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