TidepoolStartView.swift 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import SwiftUI
  2. struct TidepoolStartView: View {
  3. @ObservedObject var state: Settings.StateModel
  4. var body: some View {
  5. Form {
  6. Section(
  7. header: Text("Connect to Tidepool"),
  8. footer: VStack(alignment: .leading, spacing: 2) {
  9. Text(
  10. "When connected, uploading of carbs, bolus, basal and glucose from Trio to your Tidepool account is enabled."
  11. )
  12. Text(
  13. "\nUse your Tidepool credentials to login. If you dont already have a Tidepool account, you can sign up for one on the login page."
  14. )
  15. }
  16. )
  17. {
  18. Button("Connect to Tidepool") { state.setupTidepool = true }
  19. }
  20. .navigationTitle("Tidepool")
  21. }
  22. .sheet(isPresented: $state.setupTidepool) {
  23. if let serviceUIType = state.serviceUIType,
  24. let pluginHost = state.provider.tidepoolManager.getTidepoolPluginHost()
  25. {
  26. if let serviceUI = state.provider.tidepoolManager.getTidepoolServiceUI() {
  27. TidepoolSettingsView(
  28. serviceUI: serviceUI,
  29. serviceOnBoardDelegate: self.state,
  30. serviceDelegate: self.state
  31. )
  32. } else {
  33. TidepoolSetupView(
  34. serviceUIType: serviceUIType,
  35. pluginHost: pluginHost,
  36. serviceOnBoardDelegate: self.state,
  37. serviceDelegate: self.state
  38. )
  39. }
  40. }
  41. }
  42. }
  43. }