diff options
Diffstat (limited to 'Shared/SweepActivityAttributes.swift')
| -rw-r--r-- | Shared/SweepActivityAttributes.swift | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Shared/SweepActivityAttributes.swift b/Shared/SweepActivityAttributes.swift new file mode 100644 index 0000000..ee03c2d --- /dev/null +++ b/Shared/SweepActivityAttributes.swift @@ -0,0 +1,25 @@ +import ActivityKit +import Foundation + +/// Live Activity contract for an in-flight watchlist sweep or batch lookup. +/// +/// Lives in `Shared/` because the app starts/updates the activity and the +/// widget extension renders it. +struct SweepActivityAttributes: ActivityAttributes { + struct ContentState: Codable, Hashable { + var completed: Int + var total: Int + var currentDomain: String? + var changed: Int + var warnings: Int + + var fractionComplete: Double { + guard total > 0 else { return 0 } + return Double(completed) / Double(total) + } + } + + /// User-facing title for the run, e.g. "Watchlist Sweep" or "Batch Lookup". + var title: String + var startedAt: Date +} |
