LiveActitiyAttributes.swift 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import ActivityKit
  2. import Foundation
  3. struct LiveActivityAttributes: ActivityAttributes {
  4. enum LiveActivityItem: String, Hashable, Codable, Equatable {
  5. case currentGlucose
  6. case iob
  7. case cob
  8. case updatedLabel
  9. case empty
  10. static let defaultItems: [Self] = [.currentGlucose, .iob, .cob, .updatedLabel]
  11. }
  12. struct ContentState: Codable, Hashable {
  13. let bg: String
  14. let direction: String?
  15. let change: String
  16. let date: Date?
  17. let highGlucose: Decimal
  18. let lowGlucose: Decimal
  19. let target: Decimal
  20. let glucoseColorScheme: String
  21. let detailedViewState: ContentAdditionalState?
  22. /// true for the first state that is set on the activity
  23. let isInitialState: Bool
  24. }
  25. struct ContentAdditionalState: Codable, Hashable {
  26. let chart: [Decimal]
  27. let chartDate: [Date?]
  28. let rotationDegrees: Double
  29. let cob: Decimal
  30. let iob: Decimal
  31. let unit: String
  32. let isOverrideActive: Bool
  33. let overrideName: String
  34. let overrideDate: Date
  35. let overrideDuration: Decimal
  36. let overrideTarget: Decimal
  37. let widgetItems: [LiveActivityItem]
  38. }
  39. let startDate: Date
  40. }