| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- import SwiftUI
- import Swinject
- extension PumpConfig {
- struct RootView: BaseView {
- let resolver: Resolver
- let displayClose: Bool
- let bluetoothManager: BluetoothStateManager
- @StateObject var state = StateModel()
- @State private var shouldDisplayHint: Bool = false
- @State var hintDetent = PresentationDetent.large
- @State var selectedVerboseHint: AnyView?
- @State var hintLabel: String?
- @State private var decimalPlaceholder: Decimal = 0.0
- @State private var booleanPlaceholder: Bool = false
- @State var showPumpSelection: Bool = false
- @Environment(\.colorScheme) var colorScheme
- @Environment(AppState.self) var appState
- var body: some View {
- NavigationView {
- Form {
- Section(
- header: Text("Pump Integration to Trio"),
- content: {
- if bluetoothManager.bluetoothAuthorization != .authorized {
- HStack {
- Spacer()
- BluetoothRequiredView()
- Spacer()
- }
- } else if let pumpState = state.pumpState {
- Button {
- state.setupPump = true
- } label: {
- HStack {
- Image(uiImage: pumpState.image ?? UIImage())
- .resizable()
- .scaledToFit()
- .frame(maxWidth: 100)
- Text(pumpState.name)
- }
- .frame(maxWidth: .infinity, minHeight: 50, alignment: .center)
- .font(.title2)
- }.padding()
- if state.hasUnacknowledgedAlert {
- Spacer()
- Button("Acknowledge all alerts") { state.ack() }
- }
- } else {
- VStack {
- Button {
- showPumpSelection.toggle()
- } label: {
- Text("Add Pump")
- .font(.title3) }
- .frame(maxWidth: .infinity, alignment: .center)
- .buttonStyle(.bordered)
- HStack(alignment: .center) {
- Text(
- "Pair your insulin pump with Trio. See hint for compatible devices."
- )
- .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)
- }
- .scrollContentBackground(.hidden).background(appState.trioBackgroundColor(for: colorScheme))
- .onAppear(perform: configureView)
- .navigationTitle("Insulin Pump")
- .navigationBarTitleDisplayMode(.automatic)
- .navigationBarItems(leading: displayClose ? Button("Close", action: state.hideModal) : nil)
- .sheet(isPresented: $state.setupPump) {
- if let pumpManager = state.provider.apsManager.pumpManager {
- PumpSettingsView(
- pumpManager: pumpManager,
- bluetoothManager: state.provider.apsManager.bluetoothManager!,
- completionDelegate: state,
- setupDelegate: state
- )
- } else {
- PumpSetupView(
- pumpType: state.setupPumpType,
- pumpInitialSettings: state.initialSettings,
- bluetoothManager: state.provider.apsManager.bluetoothManager!,
- completionDelegate: state,
- setupDelegate: state
- )
- }
- }
- .sheet(isPresented: $shouldDisplayHint) {
- SettingInputHintView(
- hintDetent: $hintDetent,
- shouldDisplayHint: $shouldDisplayHint,
- hintLabel: "Pump Pairing to Trio",
- hintText: AnyView(
- VStack(alignment: .leading, spacing: 10) {
- Text(
- "Current Pump Models Supported:"
- )
- VStack(alignment: .leading) {
- Text("• Medtronic")
- Text("• All Omnipod Types")
- Text("• Omnipod Eros")
- Text("• Omnipod DASH")
- Text("• Dana (RS/-i)")
- Text("• Medtrum Nano (200u/300u)")
- Text("• Pump Simulator")
- }
- Text(
- "Note: If using a pump simulator, you will not have continuous readings from the CGM in Trio. Using a pump simulator is only advisable for becoming familiar with the app user interface. It will not give you insight on how the algorithm will respond."
- )
- }
- ),
- sheetTitle: String(localized: "Help", comment: "Help sheet title")
- )
- }
- .confirmationDialog("Pump Model", isPresented: $showPumpSelection) {
- Button("Medtronic") { state.addPump(.minimed) }
- Button("All Omnipod Types") { state.addPump(.omni) }
- Button("Omnipod Eros") { state.addPump(.omnipod) }
- Button("Omnipod DASH") { state.addPump(.omnipodBLE) }
- Button("Dana(RS/-i)") { state.addPump(.dana) }
- Button("Medtrum Nano") { state.addPump(.medtrum) }
- Button("Pump Simulator") { state.addPump(.simulator) }
- } message: { Text("Select Pump Model") }
- }
- }
- }
- }
|