| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- import SwiftUI
- import Swinject
- struct TidepoolStartView: BaseView {
- let resolver: Resolver
- @ObservedObject var state: Settings.StateModel
- @State private var shouldDisplayHint: Bool = false
- @State var hintDetent = PresentationDetent.large
- @State private var decimalPlaceholder: Decimal = 0.0
- @State private var booleanPlaceholder: Bool = false
- @Environment(\.colorScheme) var colorScheme
- @Environment(AppState.self) var appState
- var body: some View {
- Form {
- Section(
- header: Text("Tidepool Integration"),
- content:
- {
- VStack {
- if let serviceUIType = state.serviceUIType,
- let pluginHost = state.provider.tidepoolManager.getTidepoolPluginHost()
- {
- if let serviceUI = state.provider.tidepoolManager.getTidepoolServiceUI()
- {
- Button {
- state.setupTidepool.toggle()
- }
- label: {
- HStack {
- Text("Connected to Tidepool").font(.title3)
- ZStack {
- Image(systemName: "network")
- Image(systemName: "checkmark.circle.fill")
- .foregroundColor(.green).font(.caption2)
- .offset(x: 9, y: 6)
- }
- }
- }
- .frame(maxWidth: .infinity, alignment: .center)
- .buttonStyle(.bordered)
- } else {
- Button {
- state.setupTidepool.toggle()
- }
- label: { Text("Connect to Tidepool").font(.title3) }
- .frame(maxWidth: .infinity, alignment: .center)
- .buttonStyle(.bordered)
- }
- }
- HStack(alignment: .center) {
- Text("You can connect Trio to seamlessly upload and manage your diabetes data on Tidepool.")
- .font(.footnote)
- .foregroundColor(.secondary)
- .lineLimit(nil)
- Spacer()
- Button(
- action: {
- shouldDisplayHint.toggle()
- },
- label: {
- HStack {
- Image(systemName: "questionmark.circle")
- }
- }
- ).buttonStyle(BorderlessButtonStyle())
- }.padding(.top)
- }.padding(.vertical)
- }
- ).listRowBackground(Color.chart)
- }
- .sheet(isPresented: $state.setupTidepool) {
- if let serviceUIType = state.serviceUIType,
- let pluginHost = state.provider.tidepoolManager.getTidepoolPluginHost()
- {
- if let serviceUI = state.provider.tidepoolManager.getTidepoolServiceUI() {
- TidepoolSettingsView(
- serviceUI: serviceUI,
- serviceOnBoardDelegate: self.state,
- serviceDelegate: self.state
- )
- } else {
- TidepoolSetupView(
- serviceUIType: serviceUIType,
- pluginHost: pluginHost,
- serviceOnBoardDelegate: self.state,
- serviceDelegate: self.state
- )
- }
- }
- }
- .sheet(isPresented: $shouldDisplayHint) {
- SettingInputHintView(
- hintDetent: $hintDetent,
- shouldDisplayHint: $shouldDisplayHint,
- hintLabel: "Connect to Tidepool",
- hintText: Text(
- "Use your Tidepool credentials to log in. If you don't have a Tidepool account, you can sign up on the login page.\n\nWhen connected, Trio uploads your glucose, carb entries, insulin (bolus and basal), pump settings, and therapy settings to Tidepool.\n\nTherapy settings include basal schedules, carb ratios, insulin sensitivities, and glucose targets."
- ),
- sheetTitle: String(localized: "Help", comment: "Help sheet title")
- )
- }
- .scrollContentBackground(.hidden).background(appState.trioBackgroundColor(for: colorScheme))
- .navigationTitle("Tidepool")
- .navigationBarTitleDisplayMode(.automatic)
- .onAppear(perform: configureView)
- }
- }
|