PumpSettingsEditorRootView.swift 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import SwiftUI
  2. extension PumpSettingsEditor {
  3. struct RootView: BaseView {
  4. @EnvironmentObject var viewModel: ViewModel<Provider>
  5. private var formatter: NumberFormatter {
  6. let formatter = NumberFormatter()
  7. formatter.numberStyle = .decimal
  8. return formatter
  9. }
  10. var body: some View {
  11. Form {
  12. Section(header: Text("Delivery limits")) {
  13. HStack {
  14. Text("Max Basal")
  15. DecimalTextField("hours", value: $viewModel.maxBasal, formatter: formatter)
  16. }
  17. HStack {
  18. Text("Max Bolus")
  19. DecimalTextField("U/hr", value: $viewModel.maxBolus, formatter: formatter)
  20. }
  21. }
  22. Section(header: Text("Duration of Insulin Action")) {
  23. HStack {
  24. Text("DIA")
  25. DecimalTextField("hours", value: $viewModel.dia, formatter: formatter)
  26. }
  27. }
  28. Section {
  29. HStack {
  30. if viewModel.syncInProgress {
  31. ProgressView().padding(.trailing, 10)
  32. }
  33. Button { viewModel.save() }
  34. label: {
  35. Text(viewModel.syncInProgress ? "Saving..." : "Save on Pump")
  36. }
  37. .disabled(viewModel.syncInProgress)
  38. }
  39. }
  40. }
  41. .navigationTitle("Pump Settings")
  42. .navigationBarTitleDisplayMode(.automatic)
  43. }
  44. }
  45. }