I have a screen with a countdown timer and therefore a clock component activated.
When I change screens I would like the countdown of the other screen to continue so when I return to this screen I see the time remaining.
But when I change screens, and I come back to my previous screen, I see that the countdown is reset to zero as if the clock component had deactivated when changing the screen.
How can I do when changing the screen so that my countdown does not reset and continue to run?
when timer starts, get the current time in milli and final millis
(e.g 5 min countdown timer mean, initial millis is current time milli, final timer will be initial milli + 300000 and save the final milli in tinydb, then start clock to run
for every second, add 1000 with current mill and find the difference between current milli and final mills and convert it into hh.mm,ss
if you go to any screen and come back mean, just check any final milli is in tinydb. if exists, again check the difference between current milli and tinydb milli and make clock to timer. once it timers, already you have designed block so it will take care untill timer goes to 0
I mis read your topic, I think… actually you want where you left… But my design is just it will goes on decreasing… little arrangement will solve, just save the remaining time in tinydb and start from that point when screen initialise
In the spirit, yes it is that of going from one screen to another and when we return to the 1st screen the countdown continues.
But I misspoke when I said that when I returned to the 1st screen, the countdown resumed where I was. I actually meant it continues to count down while I’m on screen 2.
I leave the 1st screen at 4m 30s
I’m going to the 2nd screen for a while
I return to the 1st screen afterwards with the countdown updated to for example 3m 30s if I spent a minute on screen 2.
Thank you @dora_paz , your solution is good but @Still-learning brought me the solution beyond my expectations with the stopwatch which continues even with the app closed.
It remains to be seen the aia he uses.