AppStateController.swift 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // AppStateController.swift
  3. // LoopFollow
  4. //
  5. // Created by Jose Paredes on 7/17/20.
  6. // Copyright © 2020 Jon Fawcett. All rights reserved.
  7. //
  8. import Foundation
  9. // App Sate used used to changes to the app view controllers (Settings, for example)
  10. // Recommended way of utilizing is when viewVillAppear(..) is called,
  11. // look in the app state to see if further action must be t
  12. // Setup App States to comminicate between views
  13. // Graph Setup Flags
  14. enum ChartSettingsChangeEnum: Int {
  15. case chartScaleXChanged = 1
  16. case showDotsChanged = 2
  17. case showLinesChanged = 4
  18. case offsetCarbsBolusChanged = 8
  19. case hoursToLoadChanged = 16
  20. case predictionToLoadChanged = 32
  21. case minBasalScaleChanged = 64
  22. case minBGScaleChanged = 128
  23. case minBGValueChanged = 256
  24. case overrideDisplayLocationChanged = 512
  25. case lowLineChanged = 1024
  26. case highLineChanged = 2048
  27. }
  28. // General Settings Flags
  29. enum GeneralSettingsChangeEnum: Int {
  30. case colorBGTextChange = 1
  31. case speakBGChange = 2
  32. case backgroundRefreshFrequencyChange = 4
  33. case backgroundRefreshChange = 8
  34. case appBadgeChange = 16
  35. case dimScreenWhenIdleChange = 32
  36. case forceDarkModeChang = 64
  37. case persistentNotificationChange = 128
  38. case persistentNotificationLastBGTimeChange = 256
  39. case screenlockSwitchStateChange = 512
  40. case showStatsChange = 1024
  41. case showSmallGraphChange = 2048
  42. }
  43. class AppStateController {
  44. // add app states & methods here
  45. // General Settings States
  46. var generalSettingsChanged : Bool = false
  47. var generalSettingsChanges : Int = 0
  48. // Chart Settings State
  49. var chartSettingsChanged : Bool = false // settings change has ocurred
  50. var chartSettingsChanges: Int = 0 // what settings have changed
  51. // Info Data Settings State; no need for flags
  52. var infoDataSettingsChanged: Bool = false
  53. }