UnitSelectionStepView.swift 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import SwiftUI
  2. struct UnitSelectionStepView: View {
  3. @Bindable var state: Onboarding.StateModel
  4. var body: some View {
  5. VStack(alignment: .leading, spacing: 20) {
  6. Text("Please choose from the options below.")
  7. .font(.headline)
  8. .padding(.horizontal)
  9. HStack {
  10. Text("Glucose Units")
  11. Spacer()
  12. Picker("Glucose Units", selection: $state.units) {
  13. ForEach(GlucoseUnits.allCases, id: \.self) { unit in
  14. Text(unit.rawValue).tag(unit)
  15. }
  16. }
  17. }
  18. .padding()
  19. .background(Color.chart.opacity(0.65))
  20. .cornerRadius(10)
  21. HStack {
  22. Text("Pump Model")
  23. Spacer()
  24. Picker("Pump Model", selection: $state.pumpOptionForOnboardingUnits) {
  25. ForEach(PumpOptionForOnboardingUnits.allCases, id: \.self) { pumpModel in
  26. Text(pumpModel.displayName).tag(pumpModel)
  27. }
  28. }
  29. .onChange(of: state.pumpOptionForOnboardingUnits, { _, newValue in
  30. state.remapTherapyItemsForChangedPumpModel()
  31. // Conditionally set rewind setting, if pump model is Medtronic (.minimed) or Dana (i/RS)
  32. state.rewindResetsAutosens = (newValue == .minimed || newValue == .dana)
  33. })
  34. .onChange(of: state.units, { _, _ in
  35. state.remapTherapyItemsForChangedUnits()
  36. })
  37. }
  38. .padding()
  39. .background(Color.chart.opacity(0.65))
  40. .cornerRadius(10)
  41. Text(
  42. "Note: Choosing your pump model determines which increments for setting up your basal rates are available. You will pair your actual pump after finishing the onboarding process."
  43. )
  44. .padding(.horizontal)
  45. .font(.footnote)
  46. .foregroundStyle(Color.secondary)
  47. .multilineTextAlignment(.leading)
  48. }
  49. }
  50. }