AdvancedSettingsViewModel.swift 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // LoopFollow
  2. // AdvancedSettingsViewModel.swift
  3. import Foundation
  4. class AdvancedSettingsViewModel: ObservableObject {
  5. @Published var downloadTreatments: Bool {
  6. didSet {
  7. Storage.shared.downloadTreatments.value = downloadTreatments
  8. }
  9. }
  10. @Published var downloadPrediction: Bool {
  11. didSet {
  12. Storage.shared.downloadPrediction.value = downloadPrediction
  13. }
  14. }
  15. @Published var graphBasal: Bool {
  16. didSet {
  17. Storage.shared.graphBasal.value = graphBasal
  18. }
  19. }
  20. @Published var graphBolus: Bool {
  21. didSet {
  22. Storage.shared.graphBolus.value = graphBolus
  23. }
  24. }
  25. @Published var graphCarbs: Bool {
  26. didSet {
  27. Storage.shared.graphCarbs.value = graphCarbs
  28. }
  29. }
  30. @Published var graphOtherTreatments: Bool {
  31. didSet {
  32. Storage.shared.graphOtherTreatments.value = graphOtherTreatments
  33. }
  34. }
  35. @Published var bgUpdateDelay: Int {
  36. didSet {
  37. Storage.shared.bgUpdateDelay.value = bgUpdateDelay
  38. }
  39. }
  40. @Published var debugLogLevel: Bool {
  41. didSet {
  42. Storage.shared.debugLogLevel.value = debugLogLevel
  43. }
  44. }
  45. init() {
  46. downloadTreatments = Storage.shared.downloadTreatments.value
  47. downloadPrediction = Storage.shared.downloadPrediction.value
  48. graphBasal = Storage.shared.graphBasal.value
  49. graphBolus = Storage.shared.graphBolus.value
  50. graphCarbs = Storage.shared.graphCarbs.value
  51. graphOtherTreatments = Storage.shared.graphOtherTreatments.value
  52. bgUpdateDelay = Storage.shared.bgUpdateDelay.value
  53. debugLogLevel = Storage.shared.debugLogLevel.value
  54. }
  55. }