From 21d21f8c81b94b308ee6791f26e4f16efb889ba4 Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 6 Feb 2023 15:57:01 +0100 Subject: [PATCH] Adds animation --- LeCountdown/Conductor.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/LeCountdown/Conductor.swift b/LeCountdown/Conductor.swift index d1614bd..c2446da 100644 --- a/LeCountdown/Conductor.swift +++ b/LeCountdown/Conductor.swift @@ -8,6 +8,7 @@ import Foundation import ActivityKit import BackgroundTasks +import SwiftUI enum Key: String { case countdowns @@ -33,14 +34,18 @@ class Conductor: ObservableObject { @Published var currentCountdowns: [String : DateInterval] = [:] { didSet { Conductor.savedCountdowns = currentCountdowns - self._buildLiveTimers() + withAnimation { + self._buildLiveTimers() + } } } @Published var currentStopwatches: [String : Date] = [:] { didSet { Conductor.savedStopwatches = currentStopwatches - self._buildLiveTimers() + withAnimation { + self._buildLiveTimers() + } } } @@ -51,6 +56,7 @@ class Conductor: ObservableObject { } fileprivate func _buildLiveTimers() { + let liveCountdowns = self.currentCountdowns.map { return LiveTimer(id: $0, date: $1.end) }