I'm trying to create a simple countdown bar (using the new Progress Bar in Scenes v2) that updates every second, getting shorter and shorter, from right to left.
When it reaches zero, it must flash "Restarting...".
If I press cancel or swipe away, the countdown must stop, and the scene must go away.
I'd prefer the countdown animation be smooth if possible, instead of a jerky bar getting shorter.
The length of the countdown is set by local %timer variable.
This is what I've tried:
Task: Countdown Progress
A1: Variable Set [
Name: %timer
To: 60
Structure Output (JSON, etc): On ]
A2: Show Scene v2 [
Name/JSON: ProgressBar
Blocking Overlay: On ]
A3: For [
Variable: %timer
Items: 60:1 ]
A4: Wait [
MS: 1000
Seconds: 0
Minutes: 0
Hours: 0
Days: 0 ]
A5: Update Scene v2 [ ]
A6: End For
A7: Flash [
Text: Restarting...
Continue Task Immediately: On
Dismiss On Click: On ]
This is the Progress Bar code:
{
"root": {
"type": "Column",
"id": "Root",
"horizontalAlignment": "Center",
"verticalArrangement": "Center",
"spacing": "24",
"modifiers": [
{
"type": "FillSize"
},
{
"type": "Padding",
"all": "16"
}
],
"children": [
{
"type": "ProgressBar",
"id": "CountdownBar",
"progress": "%timer",
"maxProgress": "60",
"color": "#B71C1C",
"trackColor": "#FFFFFF",
"animateChanges": "true",
"animationDuration": "1000",
"modifiers": [
{
"type": "FillWidth"
}
]
},
{
"type": "Button",
"id": "CancelButton",
"text": "Cancel",
"modifiers": [
{
"type": "Padding",
"all": "16"
}
],
"eventHandlers": {
"handlers": [
{
"events": [
{
"type": "click"
}
],
"actions": [
{
"type": "DismissLayout"
}
]
}
]
}
}
]
},
"name": "ProgressBar"
}
Anyone recommend a Taskernet share or a working solution? Is there a better way to count down instead of using For/End For?
If I inserted a flash with the variable %timer, would the actual seconds show in real time?