Introduces a SwiftUI companion app for the Fail Well PWA: menu bar status item, popover with task list / record / history views, command palette, and a Dynamic Island-style notch overlay that shows the active step and timer beside the hardware notch and expands on hover to reveal pause/next controls.
26 lines
541 B
Swift
26 lines
541 B
Swift
import Foundation
|
|
import Observation
|
|
|
|
@MainActor
|
|
@Observable
|
|
final class Clock {
|
|
var now: Date = Date()
|
|
|
|
@ObservationIgnored private var tickTask: Task<Void, Never>?
|
|
|
|
init(tickInterval: Duration = .milliseconds(500)) {
|
|
tickTask = Task { [weak self] in
|
|
while !Task.isCancelled {
|
|
await MainActor.run {
|
|
self?.now = Date()
|
|
}
|
|
try? await Task.sleep(for: tickInterval)
|
|
}
|
|
}
|
|
}
|
|
|
|
deinit {
|
|
tickTask?.cancel()
|
|
}
|
|
}
|