Closed aSemy closed 5 months ago
I mentioned in #149 that I'm working on multiplatform support right now, but in the meantime you can animate it manually like this:
val progress = progressLayout {
progressBar()
}
val a = terminal.animation<Int> { progress.build(completed = it.toLong(), total = 10) }
repeat(10) {
a.update(it)
delay(500)
}
Though you'll have to keep track of completedPerSecond
yourself if you're showing it, and the framerates of all the cells will be the same. The new version I'm working on won't have those limitations.
Hi 👋
There's currently a note in the
progressAnimation {}
docs saying thatHowever, it's not clear how to achieve implement
progressAnimation
on non-JVM platforms... Looking at the existing JVM ProgressAnimation it's quite a complicated bit of code, and requires several internal functions which would have to be duplicated.Suggestions
Convert ProgressAnimation to Kotlin Multiplatform. This would probably require adding a dependency on Kotlinx Coroutines, for synchronizing (currently done using the
@Synchronized
annotation) and running background tasks (currently done using a Java Timer).I've had a stab at this, and it's possible. I've made a PR as a demonstration https://github.com/ajalt/mordant/pull/149. However, it might break GraalVM support... So an alternative would be to introduce a new ProgressAnimation that's compatible with coroutines - ProgressAnimationAsync (or something) - that is the same, but has
suspend fun
s.