SettingsRootView.swift 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import SwiftUI
  2. import Swinject
  3. extension Settings {
  4. struct RootView: BaseView {
  5. let resolver: Resolver
  6. @StateObject var state = StateModel()
  7. @State private var showShareSheet = false
  8. var body: some View {
  9. Form {
  10. Section(header: Text("FreeAPS X v\(state.buildNumber)")) {
  11. Toggle("Closed loop", isOn: $state.closedLoop)
  12. }
  13. Section(header: Text("Devices")) {
  14. Text("Pump").navigationLink(to: .pumpConfig, from: self)
  15. }
  16. Section(header: Text("Services")) {
  17. Text("Nightscout").navigationLink(to: .nighscoutConfig, from: self)
  18. Text("CGM").navigationLink(to: .cgm, from: self)
  19. Text("Apple Health").navigationLink(to: .healthkit, from: self)
  20. Text("Notifications").navigationLink(to: .notificationsConfig, from: self)
  21. }
  22. Section(header: Text("Configuration")) {
  23. Text("Preferences").navigationLink(to: .preferencesEditor, from: self)
  24. Text("Pump Settings").navigationLink(to: .pumpSettingsEditor, from: self)
  25. Text("Basal Profile").navigationLink(to: .basalProfileEditor, from: self)
  26. Text("Insulin Sensitivities").navigationLink(to: .isfEditor, from: self)
  27. Text("Carb Ratios").navigationLink(to: .crEditor, from: self)
  28. Text("Target Ranges").navigationLink(to: .targetsEditor, from: self)
  29. Text("Autotune").navigationLink(to: .autotuneConfig, from: self)
  30. }
  31. Section(header: Text("Developer")) {
  32. Toggle("Debug options", isOn: $state.debugOptions)
  33. if state.debugOptions {
  34. Group {
  35. Text("Preferences")
  36. .navigationLink(to: .configEditor(file: OpenAPS.Settings.preferences), from: self)
  37. Text("Pump Settings")
  38. .navigationLink(to: .configEditor(file: OpenAPS.Settings.settings), from: self)
  39. Text("Autosense")
  40. .navigationLink(to: .configEditor(file: OpenAPS.Settings.autosense), from: self)
  41. Text("Pump History")
  42. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.pumpHistory), from: self)
  43. Text("Basal profile")
  44. .navigationLink(to: .configEditor(file: OpenAPS.Settings.basalProfile), from: self)
  45. Text("Targets ranges")
  46. .navigationLink(to: .configEditor(file: OpenAPS.Settings.bgTargets), from: self)
  47. Text("Carb ratios")
  48. .navigationLink(to: .configEditor(file: OpenAPS.Settings.carbRatios), from: self)
  49. Text("Insulin sensitivities")
  50. .navigationLink(to: .configEditor(file: OpenAPS.Settings.insulinSensitivities), from: self)
  51. Text("Temp targets")
  52. .navigationLink(to: .configEditor(file: OpenAPS.Settings.tempTargets), from: self)
  53. Text("Meal")
  54. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.meal), from: self)
  55. }
  56. Group {
  57. Text("IOB")
  58. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.iob), from: self)
  59. Text("Pump profile")
  60. .navigationLink(to: .configEditor(file: OpenAPS.Settings.pumpProfile), from: self)
  61. Text("Profile")
  62. .navigationLink(to: .configEditor(file: OpenAPS.Settings.profile), from: self)
  63. Text("Glucose")
  64. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.glucose), from: self)
  65. Text("Carbs")
  66. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.carbHistory), from: self)
  67. Text("Suggested")
  68. .navigationLink(to: .configEditor(file: OpenAPS.Enact.suggested), from: self)
  69. Text("Enacted")
  70. .navigationLink(to: .configEditor(file: OpenAPS.Enact.enacted), from: self)
  71. Text("Announcements")
  72. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.announcements), from: self)
  73. Text("Enacted announcements")
  74. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.announcementsEnacted), from: self)
  75. Text("Autotune")
  76. .navigationLink(to: .configEditor(file: OpenAPS.Settings.autotune), from: self)
  77. }
  78. Group {
  79. Text("HealthKit")
  80. .navigationLink(to: .configEditor(file: OpenAPS.HealthKit.downloadedGlucose), from: self)
  81. Text("Target presets")
  82. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.tempTargetsPresets), from: self)
  83. Text("Calibrations")
  84. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.calibrations), from: self)
  85. Text("Middleware")
  86. .navigationLink(to: .configEditor(file: OpenAPS.Middleware.determineBasal), from: self)
  87. Text("Edit settings json")
  88. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.settings), from: self)
  89. }
  90. }
  91. }
  92. Section {
  93. Text("Share logs")
  94. .onTapGesture {
  95. showShareSheet = true
  96. }
  97. }
  98. }
  99. .sheet(isPresented: $showShareSheet) {
  100. ShareSheet(activityItems: state.logItems())
  101. }
  102. .onAppear(perform: configureView)
  103. .navigationTitle("Settings")
  104. .navigationBarItems(leading: Button("Close", action: state.hideModal))
  105. .navigationBarTitleDisplayMode(.automatic)
  106. }
  107. }
  108. }