NightscoutFetchView.swift 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import SwiftUI
  2. struct NightscoutFetchView: View {
  3. @ObservedObject var state: NightscoutConfig.StateModel
  4. @Environment(\.colorScheme) var colorScheme
  5. var color: LinearGradient {
  6. colorScheme == .dark ? LinearGradient(
  7. gradient: Gradient(colors: [
  8. Color.bgDarkBlue,
  9. Color.bgDarkerDarkBlue
  10. ]),
  11. startPoint: .top,
  12. endPoint: .bottom
  13. )
  14. :
  15. LinearGradient(
  16. gradient: Gradient(colors: [Color.gray.opacity(0.1)]),
  17. startPoint: .top,
  18. endPoint: .bottom
  19. )
  20. }
  21. var body: some View {
  22. Form {
  23. Section {
  24. Toggle("Fetch Treatments", isOn: $state.isDownloadEnabled)
  25. .onChange(of: state.isDownloadEnabled) { newValue in
  26. if !newValue {
  27. state.allowAnnouncements = false
  28. }
  29. }
  30. } header: {
  31. Text("Allow Fetching from Nightscout")
  32. } footer: {
  33. Text(
  34. "The Fetch Treatments toggle enables fetching of carbs and temp targets entered in Careportal or by another uploading device than Trio."
  35. )
  36. }
  37. Section(
  38. header: Text("Allow Remote control of Trio"),
  39. footer: VStack(alignment: .leading, spacing: 2) {
  40. Text("Fetch Treatments needs to be allowed to be able to toggle on Remote Control.")
  41. Text("\nWhen enabled you allow these remote functions through announcements from Nightscout:")
  42. Text(" • ") + Text("Suspend/Resume Pump")
  43. Text(" • ") + Text("Opening/Closing Loop")
  44. Text(" • ") + Text("Set Temp Basal")
  45. Text(" • ") + Text("Enact Bolus")
  46. }
  47. )
  48. {
  49. Toggle("Remote Control", isOn: $state.allowAnnouncements)
  50. .disabled(!state.isDownloadEnabled)
  51. }
  52. }
  53. .navigationTitle("Fetch and Remote")
  54. .scrollContentBackground(.hidden).background(color)
  55. }
  56. }