SettingsRootView.swift 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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").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("App Icons").navigationLink(to: .iconConfig, from: self)
  31. Text("Statistics and Home View").navigationLink(to: .statisticsConfig, 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 Glucose").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 and Settings").onTapGesture {
  47. state.uploadProfileAndSettings()
  48. }
  49. }
  50. Group {
  51. Text("Preferences")
  52. .navigationLink(to: .configEditor(file: OpenAPS.Settings.preferences), from: self)
  53. Text("Pump Settings")
  54. .navigationLink(to: .configEditor(file: OpenAPS.Settings.settings), from: self)
  55. Text("Autosense")
  56. .navigationLink(to: .configEditor(file: OpenAPS.Settings.autosense), from: self)
  57. Text("Pump History")
  58. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.pumpHistory), from: self)
  59. Text("Basal profile")
  60. .navigationLink(to: .configEditor(file: OpenAPS.Settings.basalProfile), from: self)
  61. Text("Targets ranges")
  62. .navigationLink(to: .configEditor(file: OpenAPS.Settings.bgTargets), from: self)
  63. Text("Temp targets")
  64. .navigationLink(to: .configEditor(file: OpenAPS.Settings.tempTargets), from: self)
  65. Text("Meal")
  66. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.meal), from: self)
  67. }
  68. Group {
  69. Text("Pump profile")
  70. .navigationLink(to: .configEditor(file: OpenAPS.Settings.pumpProfile), from: self)
  71. Text("Profile")
  72. .navigationLink(to: .configEditor(file: OpenAPS.Settings.profile), from: self)
  73. Text("Carbs")
  74. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.carbHistory), from: self)
  75. Text("Enacted")
  76. .navigationLink(to: .configEditor(file: OpenAPS.Enact.enacted), from: self)
  77. Text("Announcements")
  78. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.announcements), from: self)
  79. Text("Enacted announcements")
  80. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.announcementsEnacted), from: self)
  81. Text("Autotune")
  82. .navigationLink(to: .configEditor(file: OpenAPS.Settings.autotune), from: self)
  83. Text("Glucose")
  84. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.glucose), from: self)
  85. }
  86. Group {
  87. Text("Target presets")
  88. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.tempTargetsPresets), from: self)
  89. Text("Calibrations")
  90. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.calibrations), from: self)
  91. Text("Middleware")
  92. .navigationLink(to: .configEditor(file: OpenAPS.Middleware.determineBasal), from: self)
  93. Text("Statistics")
  94. .navigationLink(to: .configEditor(file: OpenAPS.Monitor.statistics), from: self)
  95. Text("Edit settings json")
  96. .navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.settings), from: self)
  97. }
  98. }
  99. }
  100. Section {
  101. Toggle("Animated Background", isOn: $state.animatedBackground)
  102. }
  103. Section {
  104. Text("Share logs")
  105. .onTapGesture {
  106. showShareSheet = true
  107. }
  108. }
  109. }
  110. .sheet(isPresented: $showShareSheet) {
  111. ShareSheet(activityItems: state.logItems())
  112. }
  113. .onAppear(perform: configureView)
  114. .navigationTitle("Settings")
  115. .navigationBarItems(leading: Button("Close", action: state.hideSettingsModal))
  116. .navigationBarTitleDisplayMode(.automatic)
  117. }
  118. }
  119. }