-
-
Save StephenVinouze/37ad7f77f6fefb7f54f7a2573cb7a08d 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, | |
spacing: Dp = 0.dp, | |
angle: Float = 0f, | |
segmentColor: SegmentColor = SegmentColor(), | |
) { | |
val computer = remember { SegmentCoordinatesComputer() } | |
val spacingPx = LocalDensity.current.run { spacing.toPx() } | |
Canvas( | |
modifier = modifier.fillMaxWidth(), | |
onDraw = { | |
(0 until segmentCount).forEach { position -> | |
val segmentCoordinates = computer.segmentCoordinates( | |
position = position, | |
segmentCount = segmentCount, | |
width = size.width, | |
height = size.height, | |
spacing = spacingPx, | |
angle = angle | |
) | |
drawSegment( | |
coordinates = segmentCoordinates, | |
color = segmentColor | |
) | |
} | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment