I am trying to do custom progress bar like this in jetpack compose.
When I slide the user button to the right and left, it will increase and decrease with values of 0.25. The first value will be 0.25 and the last value will be 1, that is, it will consist of 4 stages.
here is what i did
@Composable
fun CustomProgressBar() {
var progress by remember { mutableStateOf(0.25f) }
Column(
modifier = Modifier.padding(16.dp)
) {
Row(
verticalAlignment = Alignment.CenterVertically
) {
Box(
modifier = Modifier
.weight(1f)
.height(16.dp)
.background(Color.LightGray)
) {
Box(
modifier = Modifier
.fillMaxWidth(progress)
.height(16.dp)
.background(DefaultDYTColor)
)
}
Button(
onClick = {
if (progress < 1f) {
progress += 0.25f
}
}
) {
Text("increase")
}
}
Text(
text = "$progress",
modifier = Modifier.align(Alignment.CenterHorizontally)
)
}
}
this is wrong but I want to share my code to explain what I did at least.
hear is my code result