SettingsRootView.swift 6.6 KB

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