I just created a timer app for me and my friends with multiple timers. To navigate between these timers i created a list for each timer in an array of timerObjects
instanzes.
struct ContentView: View {
private let timers = [TimerObject(name: "Kuchen", duration: 15), TimerObject(name: "Atem anhalten", duration: 30), TimerObject(name: "Abflug", duration: 7200)]
var body: some View {
NavigationView {
List(timers, id: \.id) { timer in
NavigationLink {
TimerView(timerObject: timer)
} label: {
Text(timer.name)
}
}
}
}
}
The TimerView()
is just the view that handels and present the whole thing behind the timer.
My Problem now is now: if i start a timer in the TimerView()
and than go back to the list and than go back to the started timer, i get a new instanz of my timer and the TimerView()
don´t show me the started timer. My goal is to go back to the started timer!
To clarify my problem, I also recorded my problem once and uploaded it to youtube so that you can see it too: https://youtu.be/bdh-122-Jx0
I would be very happy about help. Best regards!