Displaying Multiple Count-downs On Screen

Im currently working with a dictionary of items formatted like this

Key = name
values = timestamp, amount

I want to display on screen a list of timers (along with the other info) in ascending order of completion on the screen.

example:
Kale x10 1hr 5min 30 sec
Blueberry x5 2hr 10 min 55 sec

What component would you guys recomend?

Previously, i was just using a "list view" and displaying all of them. But this cannot be updated in the way i need it to be.
The values in a list view are static. How can i display the timers counting down in real time?

I would take the dictionary and process it into a three column table

  • name
  • time in seconds (numeric)
  • amount

Then i would run the table through an advanced sort block, by the second column as sort key

I would then reformat the sorted table into YAML Elements of a ListView
...
Name: Kale
amount: X5
Time: 1h2 5min 30sec
...

Had you stored the time in seconds originally, it would have avoided having to reformat it for the sort operation.

It is generally best to ice your cake after having baked it.

just to clarify. That is an example of how i want it to be formatted.

the timestamp is actually a milisecond (i think unix based) value. so it can easily be corrected.

Would doing it the way you suggest allow the timers to update in real time?

I looked at your "christmas countdown" example.
And i see how you did it there.
But in this case, we don't know how many "entries" there will be; so i was hoping to avoid having to create an label manually for everything that i want to show on screen.

The live countdown works beautifully on your app though.

Do you have a link for that?

So keep deadline milliseconds in your list, and keep it in time sorted order.

Use a Clock Timer to load a formatted copy into a ListView each second.

i do have the link.

you comment somewhere in there with the file for the example.

Ah. so we are just "wiping" and "reloading" all of them every second. gotcha.

1 Like

This seems to be the discussion about countdown for Christmas day

1 Like