Skip to content

Instantly share code, notes, and snippets.

@StephenVinouze
Last active January 14, 2022 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StephenVinouze/d5a39a851fb124946d68689a8d0fb48a to your computer and use it in GitHub Desktop.
Save StephenVinouze/d5a39a851fb124946d68689a8d0fb48a to your computer and use it in GitHub Desktop.
@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