Adds animation

release
Laurent 3 years ago
parent ce8426dbf0
commit 21d21f8c81
  1. 6
      LeCountdown/Conductor.swift

@ -8,6 +8,7 @@
import Foundation import Foundation
import ActivityKit import ActivityKit
import BackgroundTasks import BackgroundTasks
import SwiftUI
enum Key: String { enum Key: String {
case countdowns case countdowns
@ -33,16 +34,20 @@ class Conductor: ObservableObject {
@Published var currentCountdowns: [String : DateInterval] = [:] { @Published var currentCountdowns: [String : DateInterval] = [:] {
didSet { didSet {
Conductor.savedCountdowns = currentCountdowns Conductor.savedCountdowns = currentCountdowns
withAnimation {
self._buildLiveTimers() self._buildLiveTimers()
} }
} }
}
@Published var currentStopwatches: [String : Date] = [:] { @Published var currentStopwatches: [String : Date] = [:] {
didSet { didSet {
Conductor.savedStopwatches = currentStopwatches Conductor.savedStopwatches = currentStopwatches
withAnimation {
self._buildLiveTimers() self._buildLiveTimers()
} }
} }
}
fileprivate var _cleanupTimers: [String : Timer] = [:] fileprivate var _cleanupTimers: [String : Timer] = [:]
@ -51,6 +56,7 @@ class Conductor: ObservableObject {
} }
fileprivate func _buildLiveTimers() { fileprivate func _buildLiveTimers() {
let liveCountdowns = self.currentCountdowns.map { let liveCountdowns = self.currentCountdowns.map {
return LiveTimer(id: $0, date: $1.end) return LiveTimer(id: $0, date: $1.end)
} }

Loading…
Cancel
Save