AdvancedSettingsViewModel.swift 1.8 KB

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