Last active
June 14, 2022 18:09
-
-
Save dilrajsingh1997/09f5d469922740499dee11dfdb69ab28 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
producerChannel.trySend( | |
List(10) { | |
getItemCircleLoader(width, height, (it * 100)) | |
} | |
) | |
fun getItemCircleLoader(width: Float, height: Float, initialDelay: Int = 0) = | |
ItemStateBuilder( | |
composeCanvasDrawItem = getTextCanvasObject(), | |
initialX = (width / 2 - 400f), | |
initialY = (height / 2 + 0f), | |
) | |
.animateX( | |
to = { | |
initialX | |
}, | |
animationSpec = { | |
repeatable( | |
iterations = 10, | |
animation = keyframes { | |
durationMillis = 8000 | |
(width / 2) - 400f at 0 with InverseCosineEasing | |
(width / 2) at 1000 with SineEasing | |
(width / 2) + 400f at 2000 with InverseCosineEasing | |
(width / 2) at 3000 with SineEasing | |
(width / 2) - 400f at 4000 with InverseCosineEasing | |
(width / 2) at 5000 with SineEasing | |
(width / 2) + 400f at 6000 with InverseCosineEasing | |
(width / 2) at 7000 with SineEasing | |
(width / 2) - 400f at 8000 with InverseCosineEasing | |
}, | |
initialStartOffset = StartOffset(initialDelay) | |
) | |
} | |
) | |
.animateY( | |
to = { | |
initialY | |
}, | |
animationSpec = { | |
repeatable( | |
iterations = 10, | |
animation = keyframes { | |
durationMillis = 8000 | |
(height / 2) at 0 with SineEasing | |
(height / 2) - 400f at 1000 with InverseCosineEasing | |
(height / 2) at 2000 with SineEasing | |
(height / 2) + 400f at 3000 with InverseCosineEasing | |
(height / 2) at 4000 with SineEasing | |
}, | |
initialStartOffset = StartOffset(initialDelay) | |
) | |
} | |
) | |
.animateAngle( | |
to = { | |
360f | |
}, | |
animationSpec = { | |
repeatable( | |
iterations = 10, | |
animation = keyframes { | |
durationMillis = 8000 | |
0f at 0 with LinearEasing | |
360f at 4000 with LinearEasing | |
}, | |
initialStartOffset = StartOffset(initialDelay) | |
) | |
} | |
) | |
.terminalCondition { _, _, _, _, _, _, elapsedTimeMillis -> | |
elapsedTimeMillis > 80000 + initialDelay | |
} | |
.animateColor( | |
to = { | |
Color.Green | |
}, | |
animationSpec = { | |
repeatable( | |
iterations = 10, | |
animation = keyframes { | |
durationMillis = 8000 | |
Color.Green at 2000 with LinearEasing | |
initialColor at 4000 with LinearEasing | |
Color.Red at 6000 with LinearEasing | |
initialColor at 8000 with LinearEasing | |
}, | |
initialStartOffset = StartOffset(initialDelay) | |
) | |
} | |
) | |
.build() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment