SettingsRootView.swift 5.9 KB

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