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