Se7eN
10/11/2020, 12:32 PMLinearProgressIndicator
over time. Like I want it to go from 0 to 100 in 3 seconds. How do I approach this?Louis Pullen-Freilich [G]
10/11/2020, 2:38 PMval animatedFloat = animatedFloat(initVal = 0f)
LinearProgressIndicator(progress = animatedFloat.value)
And then in an onClick
lambda or whenever you want to animate you can do:
animatedFloat.animateTo(1f, ProgressIndicatorConstants.DefaultProgressAnimationSpec)
(the default recommended animation)
Or for 3 seconds you could do:
animatedFloat.animateTo(1f, tween(durationMillis = 3000))
Se7eN
10/11/2020, 2:48 PMstop()
caelum19
10/12/2020, 6:55 PMfor (i in 0 .. 100) {
Thread.sleep(1000)
LinearProgressIndicator(progress = i.toFloat())
}
Benefits:
• No need to complicate your codebase with cancelling animations or allowing pesky users to break things while you're working
• Long artificial waiting time gives the illusion that more is being done than really is
• Crashing entire interface until done prevents user from switching to competing apps
(🧌 )Se7eN
10/14/2020, 11:02 AM