Animations in ASCII
BrewRatio now has some cool animations while brewing is happening!
I am a child of the BBS era, so I’m very fond of ascii art and animations. So I really wanted to add it bring something like that into my apps too. Now, the brew methods that use the timer have an animation while the brew is brewing!
They might not be final, and I might tweak them a bit still. But I think it is neat!
[dreamr.fi ~]$How it’s done? Just a loop of preformatted text:
animation = listOf( " ┌───┐ \n" + " │ ╞════O \n" + " ╰┰─┰╯ \n" + " \n" + " ", " ┌───┐ \n" + " │ ╞════O \n" + " ╰┰─┰╯ \n" + " ! ! \n" + " ", " ┌───┐ \n" + " │ ╞════O \n" + " ╰┰─┰╯ \n" + " \n" + " ! ! ",Refer it in the composable:
val animation by viewModel.currentAnimation.collectAsState()And implement the actual update in the ViewModel:
if (defaultAnimation != null && defaultAnimation.isNotEmpty() && (elapsedSeconds > 0 || _isTimerRunning.value)) { // Use modulus to loop through the animation list val index = elapsedSeconds % defaultAnimation.size _currentAnimation.value = defaultAnimation[index] } else { // If no animation is defined or timer is not running, clear the animation _currentAnimation.value = "" }