PumpSettingsEditorRootView.swift 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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/hour", 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. Button { viewModel.save() }
  30. label: {
  31. Text(viewModel.syncInProgress ? "Saving..." : "Save on Pump")
  32. }
  33. .disabled(viewModel.syncInProgress)
  34. }
  35. }
  36. .navigationTitle("Pump Settings")
  37. .navigationBarTitleDisplayMode(.automatic)
  38. .navigationBarItems(leading: Button("Close", action: viewModel.hideModal))
  39. }
  40. }
  41. }