SettingsRootView.swift 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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("Notifications").navigationLink(to: .notificationsConfig, from: self)
  20. }
  21. Section(header: Text("Configuration")) {
  22. Text("Preferences").navigationLink(to: .preferencesEditor, from: self)
  23. Text("Pump Settings").navigationLink(to: .pumpSettingsEditor, from: self)
  24. Text("Basal Profile").navigationLink(to: .basalProfileEditor, from: self)
  25. Text("Insulin Sensitivities").navigationLink(to: .isfEditor, from: self)
  26. Text("Carb Ratios").navigationLink(to: .crEditor, from: self)
  27. Text("Target Ranges").navigationLink(to: .targetsEditor, from: self)
  28. Text("Autotune").navigationLink(to: .autotuneConfig, from: self)
  29. }
  30. if state.debugOptions {
  31. Section(header: Text("Config files")) {
  32. Group {
  33. Text("Preferences")
  34. .navigationLink(to: .configEditor(file: OpenAPS.Settings.preferences), from: self)
  35. Text("Pump Settings")
  36. .navigationLink(to: .configEditor(file: OpenAPS.Settings.settings), from: self)
  37. Text("Autosense")
  38. .navigationLink(to: .configEditor(file: OpenAPS.Settings.autosense), from: self)
  39. Text("Pump History")
  40. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.pumpHistory), from: self)
  41. Text("Basal profile")
  42. .navigationLink(to: .configEditor(file: OpenAPS.Settings.basalProfile), from: self)
  43. Text("Targets ranges")
  44. .navigationLink(to: .configEditor(file: OpenAPS.Settings.bgTargets), from: self)
  45. Text("Carb ratios")
  46. .navigationLink(to: .configEditor(file: OpenAPS.Settings.carbRatios), from: self)
  47. Text("Insulin sensitivities")
  48. .navigationLink(to: .configEditor(file: OpenAPS.Settings.insulinSensitivities), from: self)
  49. Text("Temp targets")
  50. .navigationLink(to: .configEditor(file: OpenAPS.Settings.tempTargets), from: self)
  51. Text("Meal")
  52. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.meal), from: self)
  53. }
  54. Group {
  55. Text("IOB")
  56. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.iob), from: self)
  57. Text("Pump profile")
  58. .navigationLink(to: .configEditor(file: OpenAPS.Settings.pumpProfile), from: self)
  59. Text("Profile")
  60. .navigationLink(to: .configEditor(file: OpenAPS.Settings.profile), from: self)
  61. Text("Glucose")
  62. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.glucose), from: self)
  63. Text("Carbs")
  64. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.carbHistory), from: self)
  65. Text("Suggested")
  66. .navigationLink(to: .configEditor(file: OpenAPS.Enact.suggested), from: self)
  67. Text("Enacted")
  68. .navigationLink(to: .configEditor(file: OpenAPS.Enact.enacted), from: self)
  69. Text("Announcements")
  70. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.announcements), from: self)
  71. Text("Enacted announcements")
  72. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.announcementsEnacted), from: self)
  73. Text("Autotune")
  74. .navigationLink(to: .configEditor(file: OpenAPS.Settings.autotune), from: self)
  75. }
  76. Group {
  77. Text("Target presets")
  78. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.tempTargetsPresets), from: self)
  79. Text("Calibrations")
  80. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.calibrations), from: self)
  81. Text("Middleware")
  82. .navigationLink(to: .configEditor(file: OpenAPS.Middleware.determineBasal), from: self)
  83. }
  84. }
  85. }
  86. Section {
  87. Text("Share logs")
  88. .onTapGesture {
  89. showShareSheet = true
  90. }
  91. }
  92. }
  93. .sheet(isPresented: $showShareSheet) {
  94. ShareSheet(activityItems: state.logItems())
  95. }
  96. .onAppear(perform: configureView)
  97. .navigationTitle("Settings")
  98. .navigationBarItems(leading: Button("Close", action: state.hideModal))
  99. .navigationBarTitleDisplayMode(.automatic)
  100. }
  101. }
  102. }