BasalProfileEditorDataFlow.swift 858 B

123456789101112131415161718192021222324252627282930313233
  1. import Combine
  2. import Foundation
  3. enum BasalProfileEditor {
  4. enum Config {}
  5. class Item: Identifiable, Hashable, Equatable {
  6. let id = UUID()
  7. var rateIndex: Int
  8. var timeIndex: Int
  9. init(rateIndex: Int, timeIndex: Int) {
  10. self.rateIndex = rateIndex
  11. self.timeIndex = timeIndex
  12. }
  13. static func == (lhs: Item, rhs: Item) -> Bool {
  14. lhs.rateIndex == rhs.rateIndex && lhs.timeIndex == rhs.timeIndex
  15. }
  16. func hash(into hasher: inout Hasher) {
  17. hasher.combine(rateIndex)
  18. hasher.combine(timeIndex)
  19. }
  20. }
  21. }
  22. protocol BasalProfileEditorProvider: Provider {
  23. var profile: [BasalProfileEntry] { get }
  24. var supportedBasalRates: [Decimal]? { get }
  25. func saveProfile(_ profile: [BasalProfileEntry]) -> AnyPublisher<Void, Error>
  26. }