-
-
Save StephenVinouze/d5a39a851fb124946d68689a8d0fb48a to your computer and use it in GitHub Desktop.
This file contains 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 SegmentedProgressBar( | |
segmentCount: Int, | |
modifier: Modifier = Modifier, | |
progress: Float = 0f, | |
spacing: Dp = 0.dp, | |
angle: Float = 0f, | |
segmentColor: SegmentColor = SegmentColor(), | |
progressColor: SegmentColor = SegmentColor(), | |
) { | |
// Init computer | |
Canvas( | |
modifier = modifier.fillMaxWidth(), | |
onDraw = { | |
// Draw segments | |
val progressCoordinates = computer.progressCoordinates( | |
progress = progress.coerceIn(0f, segmentCount.toFloat()), | |
segmentCount = segmentCount, | |
width = size.width, | |
height = size.height, | |
spacing = spacingPx, | |
angle = angle | |
) | |
drawSegment( | |
coordinates = progressCoordinates, | |
color = progressColor | |
) | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment