Created
March 29, 2022 12:05
-
-
Save cp-hardik-p/45e751260539f48a18ddd223ae55af75 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 ArcRotationAnimation(infiniteTransition: InfiniteTransition) { | |
val circleColor = Color(0xFF008080) | |
val arcAngle1 by infiniteTransition.animateFloat( | |
initialValue = 0F, | |
targetValue = 180F, | |
animationSpec = infiniteRepeatable( | |
animation = tween(1000, easing = LinearEasing), | |
repeatMode = RepeatMode.Restart | |
) | |
) | |
val arcAngle2 by infiniteTransition.animateFloat( | |
initialValue = 180F, | |
targetValue = 360F, | |
animationSpec = infiniteRepeatable( | |
animation = tween(1000, easing = LinearEasing), | |
repeatMode = RepeatMode.Restart | |
) | |
) | |
val greenCircleAnimation by infiniteTransition.animateFloat( | |
initialValue = 50f, | |
targetValue = 80f, | |
animationSpec = infiniteRepeatable( | |
animation = tween(1000, delayMillis = 100, easing = FastOutLinearInEasing), | |
repeatMode = RepeatMode.Reverse | |
) | |
) | |
Canvas( | |
modifier = Modifier | |
.padding(12.dp) | |
.size(100.dp) | |
) { | |
drawArc( | |
color = circleColor, | |
startAngle = arcAngle1, | |
sweepAngle = 90f, | |
useCenter = false, | |
style = Stroke(width = 10f, cap = StrokeCap.Round), | |
) | |
drawArc( | |
color = circleColor, | |
startAngle = arcAngle2, | |
sweepAngle = 90f, | |
useCenter = false, | |
style = Stroke(width = 10f, cap = StrokeCap.Round), | |
) | |
drawCircle( | |
color = Color.LightGray, | |
radius = 120f, | |
) | |
drawCircle( | |
color = circleColor, | |
radius = greenCircleAnimation, | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment