Shared/SweepActivityAttributes.swift
25 lines · 746 bytes
1import ActivityKit
2import Foundation
3
4/// Live Activity contract for an in-flight watchlist sweep or batch lookup.
5///
6/// Lives in `Shared/` because the app starts/updates the activity and the
7/// widget extension renders it.
8struct SweepActivityAttributes: ActivityAttributes {
9 struct ContentState: Codable, Hashable {
10 var completed: Int
11 var total: Int
12 var currentDomain: String?
13 var changed: Int
14 var warnings: Int
15
16 var fractionComplete: Double {
17 guard total > 0 else { return 0 }
18 return Double(completed) / Double(total)
19 }
20 }
21
22 /// User-facing title for the run, e.g. "Watchlist Sweep" or "Batch Lookup".
23 var title: String
24 var startedAt: Date
25}