UnitSelectionStepView.swift 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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, { _, _ in
  30. // Reset basal profile and related values when pump model changes
  31. state.basalProfileItems = []
  32. })
  33. }
  34. .padding()
  35. .background(Color.chart.opacity(0.65))
  36. .cornerRadius(10)
  37. Text(
  38. "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."
  39. )
  40. .padding(.horizontal)
  41. .font(.footnote)
  42. .foregroundStyle(Color.secondary)
  43. .multilineTextAlignment(.leading)
  44. }
  45. }
  46. }