AppStateController.swift 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 overrideDisplayLocationChanged = 256
  24. case lowLineChanged = 512
  25. case highLineChanged = 1024
  26. case smallGraphHeight = 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. case useIFCCChange = 4096
  43. }
  44. class AppStateController {
  45. // add app states & methods here
  46. // General Settings States
  47. var generalSettingsChanged : Bool = false
  48. var generalSettingsChanges : Int = 0
  49. // Chart Settings State
  50. var chartSettingsChanged : Bool = false // settings change has ocurred
  51. var chartSettingsChanges: Int = 0 // what settings have changed
  52. // Info Data Settings State; no need for flags
  53. var infoDataSettingsChanged: Bool = false
  54. }