CGMRootView.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import SwiftUI
  2. extension CGM {
  3. struct RootView: BaseView {
  4. @EnvironmentObject var viewModel: ViewModel<Provider>
  5. var body: some View {
  6. Form {
  7. Section {
  8. Picker("Type", selection: $viewModel.cgm) {
  9. ForEach(CGMType.allCases) {
  10. Text($0.displayName).tag($0)
  11. }
  12. }
  13. }
  14. if [.dexcomG5, .dexcomG6].contains(viewModel.cgm) {
  15. Section(header: Text("Transmitter ID")) {
  16. TextField("XXXXXX", text: $viewModel.transmitterID, onCommit: {
  17. UIApplication.shared.endEditing()
  18. viewModel.onChangeID()
  19. })
  20. .disableAutocorrection(true)
  21. .autocapitalization(.allCharacters)
  22. .keyboardType(.asciiCapable)
  23. }
  24. }
  25. Section(header: Text("Other")) {
  26. Toggle("Upload glucose to Nightscout", isOn: $viewModel.uploadGlucose)
  27. }
  28. }
  29. .navigationTitle("CGM")
  30. .navigationBarTitleDisplayMode(.automatic)
  31. }
  32. }
  33. }