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
AnimatedCircularProgressIndicator( | |
currentValue = 17, | |
maxValue = 20, | |
progressBackgroundColor = Purple80, | |
progressIndicatorColor = PurpleGrey40, | |
completedColor = Purple40 | |
) |
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 | |
private fun ProgressStatus( | |
currentValue: Int, | |
maxValue: Int, | |
progressBackgroundColor: Color, | |
progressIndicatorColor: Color, | |
completedColor: Color, modifier: Modifier = Modifier | |
) { | |
Text(modifier = modifier, text = buildAnnotatedString { | |
val emphasisSpan = |
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
private fun DrawScope.drawCircularProgressIndicator( | |
startAngle: Float, | |
sweep: Float, | |
color: Color, | |
stroke: Stroke | |
) { | |
// To draw this circle we need a rect with edges that line up with the midpoint of the stroke. | |
// To do this we need to remove half the stroke width from the total diameter for both sides. | |
val diameterOffset = stroke.width / 2 | |
val arcDimen = size.width - 2 * diameterOffset |
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
Canvas( | |
Modifier | |
.progressSemantics(currentValue / maxValue.toFloat()) | |
.size(CircularIndicatorDiameter) | |
) { | |
// Start at 12 O'clock | |
val startAngle = 270f | |
val sweep: Float = animateFloat.value * 360f | |
val diameterOffset = stroke.width / 2 |
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
val animateFloat = remember { Animatable(0f) } | |
LaunchedEffect(animateFloat) { | |
animateFloat.animateTo( | |
targetValue = currentValue / maxValue.toFloat(), | |
animationSpec = tween(durationMillis = 2000, easing = FastOutSlowInEasing) | |
) | |
} |
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
import androidx.compose.animation.core.Animatable | |
import androidx.compose.animation.core.FastOutSlowInEasing | |
import androidx.compose.animation.core.tween | |
import androidx.compose.foundation.Canvas | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.size | |
import androidx.compose.foundation.progressSemantics | |
import androidx.compose.material3.Text | |
import androidx.compose.runtime.Composable | |
import androidx.compose.runtime.LaunchedEffect |