Unified progress bar code
This commit is contained in:
parent
19f6772c30
commit
eb2a6a3264
|
@ -133,24 +133,23 @@ class MainView : View() {
|
||||||
AudioFileStatus.NotAnimated -> Text("Not animated").apply {
|
AudioFileStatus.NotAnimated -> Text("Not animated").apply {
|
||||||
fill = Color.GRAY
|
fill = Color.GRAY
|
||||||
}
|
}
|
||||||
AudioFileStatus.Pending -> ProgressBar().apply {
|
AudioFileStatus.Pending,
|
||||||
progress = -1.0 // Indeterminate
|
|
||||||
maxWidth = Double.MAX_VALUE
|
|
||||||
}
|
|
||||||
AudioFileStatus.Animating -> HBox().apply {
|
AudioFileStatus.Animating -> HBox().apply {
|
||||||
val progress = state.progress ?: 0.0
|
val progress: Double? = state.progress
|
||||||
val bar = progressbar(progress) {
|
val indeterminate = -1.0
|
||||||
|
val bar = progressbar(progress ?: indeterminate) {
|
||||||
maxWidth = Double.MAX_VALUE
|
maxWidth = Double.MAX_VALUE
|
||||||
}
|
}
|
||||||
HBox.setHgrow(bar, Priority.ALWAYS)
|
HBox.setHgrow(bar, Priority.ALWAYS)
|
||||||
val progressString = "${(progress * 100).toInt()}%"
|
|
||||||
hbox {
|
hbox {
|
||||||
minWidth = 30.0
|
minWidth = 30.0
|
||||||
text(progressString) {
|
if (progress != null) {
|
||||||
|
text("${(progress * 100).toInt()}%") {
|
||||||
alignment = Pos.BASELINE_RIGHT
|
alignment = Pos.BASELINE_RIGHT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
AudioFileStatus.Canceling -> Text("Canceling")
|
AudioFileStatus.Canceling -> Text("Canceling")
|
||||||
AudioFileStatus.Done -> Text("Done").apply {
|
AudioFileStatus.Done -> Text("Done").apply {
|
||||||
font = Font.font(font.family, FontWeight.BOLD, font.size)
|
font = Font.font(font.family, FontWeight.BOLD, font.size)
|
||||||
|
|
Loading…
Reference in New Issue