Adam Brown
12/04/2024, 1:28 AMAJ Alt
12/10/2024, 8:37 PMval pbl = progressBarLayout { progressBar() }
val anim = terminal.animation<MyAnimState> {
table {
body { row(pbl.build(it.total, it.completed, it.time)) }
}
}
and then update
the animation yourself in a loop.Adam Brown
12/10/2024, 8:39 PMAJ Alt
12/14/2024, 4:54 PMAdam Brown
12/17/2024, 4:31 AMinline fun Animation<Unit>.animateInCoroutine(
fps: Int = 30,
crossinline finished: () -> Boolean = { false },
): CoroutineAnimator {
return asRefreshable(fps, finished).animateInCoroutine(terminal)
}
Be: inline fun Animation<T>.animateInCoroutine
? Currently if I want to pass a state in, I don't see an animateInCoroutine
style extension.Adam Brown
12/17/2024, 4:59 AMAJ Alt
12/17/2024, 4:32 PManimateIn
extensions, you would need to store the state externally, since you can't feed state into the `Animator`:
val pbl = progressBarLayout { progressBar() }
var state = MyState()
val anim = terminal.animation<Unit> {
table {
body { row(pbl.build(it.total, it.completed, it.time)) }
}
}.animateInCoroutine()
launch { anim.execute() }
while(true) {
state = MyState.copy(completed = state.completed + 1)
delay(100)
}
I should probably add some docs about thatAdam Brown
12/17/2024, 5:32 PMstate
would be captured by the lambda and then just ignore any subsequent changes.
Docs would be great! Also I would love an interface similar to how the progress bar animator works, so I can just call execute()
to start it going, and update()
and pass in my new state. That felt quite ergonomic.
Docs on this use case of combining an animated progressbar inside of a larger animated UI would be great, also if I have a table, how I can do something like a column span for one row would be nice.AJ Alt
12/23/2024, 5:53 PMcell { columnSpan = 2 }