SettingsRootView.swift 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. Text("Statistics and Glucose").navigationLink(to: .statisticsConfig, from: self)
  33. }
  34. Section(header: Text("Configuration")) {
  35. Text("Preferences").navigationLink(to: .preferencesEditor, from: self)
  36. Text("Pump Settings").navigationLink(to: .pumpSettingsEditor, from: self)
  37. Text("Basal Profile").navigationLink(to: .basalProfileEditor, from: self)
  38. Text("Insulin Sensitivities").navigationLink(to: .isfEditor, from: self)
  39. Text("Carb Ratios").navigationLink(to: .crEditor, from: self)
  40. Text("Target Ranges").navigationLink(to: .targetsEditor, from: self)
  41. Text("Autotune").navigationLink(to: .autotuneConfig, from: self)
  42. }
  43. Section(header: Text("Developer")) {
  44. Toggle("Debug options", isOn: $state.debugOptions)
  45. if state.debugOptions {
  46. Group {
  47. Text("NS Upload Profile").onTapGesture {
  48. state.uploadProfile()
  49. }
  50. Text("NS Uploaded Profile")
  51. .navigationLink(to: .configEditor(file: OpenAPS.Nightscout.uploadedProfile), from: self)
  52. }
  53. Group {
  54. Text("Preferences")
  55. .navigationLink(to: .configEditor(file: OpenAPS.Settings.preferences), from: self)
  56. Text("Pump Settings")
  57. .navigationLink(to: .configEditor(file: OpenAPS.Settings.settings), from: self)
  58. Text("Autosense")
  59. .navigationLink(to: .configEditor(file: OpenAPS.Settings.autosense), from: self)
  60. Text("Pump History")
  61. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.pumpHistory), from: self)
  62. Text("Basal profile")
  63. .navigationLink(to: .configEditor(file: OpenAPS.Settings.basalProfile), from: self)
  64. Text("Targets ranges")
  65. .navigationLink(to: .configEditor(file: OpenAPS.Settings.bgTargets), from: self)
  66. Text("Temp targets")
  67. .navigationLink(to: .configEditor(file: OpenAPS.Settings.tempTargets), from: self)
  68. Text("Meal")
  69. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.meal), from: self)
  70. }
  71. Group {
  72. Text("Pump profile")
  73. .navigationLink(to: .configEditor(file: OpenAPS.Settings.pumpProfile), from: self)
  74. Text("Profile")
  75. .navigationLink(to: .configEditor(file: OpenAPS.Settings.profile), from: self)
  76. Text("Carbs")
  77. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.carbHistory), from: self)
  78. Text("Enacted")
  79. .navigationLink(to: .configEditor(file: OpenAPS.Enact.enacted), from: self)
  80. Text("Announcements")
  81. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.announcements), from: self)
  82. Text("Enacted announcements")
  83. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.announcementsEnacted), from: self)
  84. Text("Autotune")
  85. .navigationLink(to: .configEditor(file: OpenAPS.Settings.autotune), from: self)
  86. Text("Glucose")
  87. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.glucose), from: self)
  88. }
  89. Group {
  90. Text("Target presets")
  91. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.tempTargetsPresets), from: self)
  92. Text("Calibrations")
  93. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.calibrations), from: self)
  94. Text("Middleware")
  95. .navigationLink(to: .configEditor(file: OpenAPS.Middleware.determineBasal), from: self)
  96. Text("Statistics")
  97. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.statistics), from: self)
  98. Text("Edit settings json")
  99. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.settings), from: self)
  100. }
  101. }
  102. }
  103. Section {
  104. Toggle("Animated Background", isOn: $state.animatedBackground)
  105. }
  106. Section {
  107. Text("Share logs")
  108. .onTapGesture {
  109. showShareSheet = true
  110. }
  111. }
  112. }
  113. .sheet(isPresented: $showShareSheet) {
  114. ShareSheet(activityItems: state.logItems())
  115. }
  116. .onAppear(perform: configureView)
  117. .navigationTitle("Settings")
  118. .navigationBarItems(leading: Button("Close", action: state.hideSettingsModal))
  119. .navigationBarTitleDisplayMode(.automatic)
  120. }
  121. }
  122. }