SettingsRootView.swift 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import HealthKit
  2. import SwiftUI
  3. import Swinject
  4. extension Settings {
  5. struct RootView: BaseView {
  6. let resolver: Resolver
  7. @StateObject var state = StateModel()
  8. @State private var showShareSheet = false
  9. var body: some View {
  10. Form {
  11. Section(
  12. header: Text(
  13. "iAPS v\(state.versionNumber) - \(state.buildNumber) \nBranch: \(state.branch) \(state.copyrightNotice) "
  14. ).textCase(nil)
  15. ) {
  16. Toggle("Closed loop", isOn: $state.closedLoop)
  17. }
  18. Section(header: Text("Devices")) {
  19. Text("Pump").navigationLink(to: .pumpConfig, from: self)
  20. Text("CGM").navigationLink(to: .cgm, from: self)
  21. Text("Watch Devices").navigationLink(to: .watch, from: self)
  22. }
  23. Section(header: Text("Services")) {
  24. Text("Nightscout").navigationLink(to: .nighscoutConfig, from: self)
  25. if HKHealthStore.isHealthDataAvailable() {
  26. Text("Apple Health").navigationLink(to: .healthkit, from: self)
  27. }
  28. Text("Notifications").navigationLink(to: .notificationsConfig, from: self)
  29. Text("Fat And Protein Conversion").navigationLink(to: .fpuConfig, from: self)
  30. Text("Profile Override").navigationLink(to: .overrideProfilesConfig, from: self)
  31. Text("App Icons").navigationLink(to: .iconConfig, from: self)
  32. }
  33. Section(header: Text("Configuration")) {
  34. Text("Preferences").navigationLink(to: .preferencesEditor, from: self)
  35. Text("Pump Settings").navigationLink(to: .pumpSettingsEditor, from: self)
  36. Text("Basal Profile").navigationLink(to: .basalProfileEditor, from: self)
  37. Text("Insulin Sensitivities").navigationLink(to: .isfEditor, from: self)
  38. Text("Carb Ratios").navigationLink(to: .crEditor, from: self)
  39. Text("Target Ranges").navigationLink(to: .targetsEditor, from: self)
  40. Text("Autotune").navigationLink(to: .autotuneConfig, from: self)
  41. }
  42. Section(header: Text("Developer")) {
  43. Toggle("Debug options", isOn: $state.debugOptions)
  44. if state.debugOptions {
  45. Group {
  46. Text("NS Upload Profile").onTapGesture {
  47. state.uploadProfile()
  48. }
  49. Text("NS Uploaded Profile")
  50. .navigationLink(to: .configEditor(file: OpenAPS.Nightscout.uploadedProfile), from: self)
  51. }
  52. Group {
  53. Text("Preferences")
  54. .navigationLink(to: .configEditor(file: OpenAPS.Settings.preferences), from: self)
  55. Text("Pump Settings")
  56. .navigationLink(to: .configEditor(file: OpenAPS.Settings.settings), from: self)
  57. Text("Autosense")
  58. .navigationLink(to: .configEditor(file: OpenAPS.Settings.autosense), from: self)
  59. Text("Pump History")
  60. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.pumpHistory), from: self)
  61. Text("Basal profile")
  62. .navigationLink(to: .configEditor(file: OpenAPS.Settings.basalProfile), from: self)
  63. Text("Targets ranges")
  64. .navigationLink(to: .configEditor(file: OpenAPS.Settings.bgTargets), from: self)
  65. Text("Temp targets")
  66. .navigationLink(to: .configEditor(file: OpenAPS.Settings.tempTargets), from: self)
  67. Text("Meal")
  68. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.meal), from: self)
  69. }
  70. Group {
  71. Text("Pump profile")
  72. .navigationLink(to: .configEditor(file: OpenAPS.Settings.pumpProfile), from: self)
  73. Text("Profile")
  74. .navigationLink(to: .configEditor(file: OpenAPS.Settings.profile), from: self)
  75. Text("Carbs")
  76. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.carbHistory), from: self)
  77. Text("Enacted")
  78. .navigationLink(to: .configEditor(file: OpenAPS.Enact.enacted), from: self)
  79. Text("Announcements")
  80. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.announcements), from: self)
  81. Text("Enacted announcements")
  82. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.announcementsEnacted), from: self)
  83. Text("Autotune")
  84. .navigationLink(to: .configEditor(file: OpenAPS.Settings.autotune), from: self)
  85. Text("Glucose")
  86. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.glucose), from: self)
  87. }
  88. Group {
  89. Text("Target presets")
  90. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.tempTargetsPresets), from: self)
  91. Text("Calibrations")
  92. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.calibrations), from: self)
  93. Text("Middleware")
  94. .navigationLink(to: .configEditor(file: OpenAPS.Middleware.determineBasal), from: self)
  95. Text("Statistics")
  96. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.statistics), from: self)
  97. Text("Edit settings json")
  98. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.settings), from: self)
  99. }
  100. }
  101. }
  102. Section {
  103. Toggle("Animated Background", isOn: $state.animatedBackground)
  104. }
  105. Section {
  106. Text("Share logs")
  107. .onTapGesture {
  108. showShareSheet = true
  109. }
  110. }
  111. }
  112. .sheet(isPresented: $showShareSheet) {
  113. ShareSheet(activityItems: state.logItems())
  114. }
  115. .onAppear(perform: configureView)
  116. .navigationTitle("Settings")
  117. .navigationBarItems(leading: Button("Close", action: state.hideSettingsModal))
  118. .navigationBarTitleDisplayMode(.automatic)
  119. }
  120. }
  121. }