SettingsRootView.swift 5.8 KB

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