SettingsRootView.swift 6.3 KB

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