dimanche 3 janvier 2021

How to make the View update instant in SwiftUI?

I have a Text that acts as a timer whith different values of my array. And it displays with timerIntervalSinceNow. The problem is when it reaches zero it should show zero to but that does not happen before clicking again on the screen. If I do not click on it it keeps going up since it is timeIntervalSincNow, but when I click it switches to the Text with 0 sec. Any way on telling swiftUI to do this by itself without clicking ?

if(exerciseTime[value].timeIntervalSinceNow > 0){
    Text(exerciseTime[value], style:.relative).foregroundColor(.white).font(.largeTitle).padding(.top, 30)                                   
  } else {
    Text("0 sec").foregroundColor(.white).font(.largeTitle).padding(.top, 30)
}

Aucun commentaire:

Enregistrer un commentaire