summaryrefslogtreecommitdiff
path: root/Shared/SweepActivityAttributes.swift
blob: ee03c2d81ddc2e803fd59b7374029fda87ddb671 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
}