BasalProfileEditorDataFlow.swift 846 B

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