TrioRemoteControlView.swift 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // LoopFollow
  2. // TrioRemoteControlView.swift
  3. import SwiftUI
  4. struct TrioRemoteControlView: View {
  5. @ObservedObject var viewModel: TrioRemoteControlViewModel
  6. @Environment(\.presentationMode) var presentationMode
  7. var body: some View {
  8. NavigationView {
  9. VStack {
  10. let columns = [
  11. GridItem(.flexible(), spacing: 16),
  12. GridItem(.flexible(), spacing: 16),
  13. ]
  14. LazyVGrid(columns: columns, spacing: 16) {
  15. CommandButtonView(command: "Meal", iconName: "fork.knife", destination: MealView())
  16. CommandButtonView(command: "Bolus", iconName: "syringe", destination: BolusView())
  17. CommandButtonView(command: "Temp Target", iconName: "scope", destination: TempTargetView())
  18. CommandButtonView(command: "Overrides", iconName: "slider.horizontal.3", destination: OverrideView())
  19. }
  20. .padding(.horizontal)
  21. Spacer()
  22. }
  23. .navigationBarTitle("Trio Remote Control", displayMode: .inline)
  24. }
  25. }
  26. }
  27. struct CommandButtonView<Destination: View>: View {
  28. let command: String
  29. let iconName: String
  30. let destination: Destination
  31. var body: some View {
  32. NavigationLink(destination: destination) {
  33. VStack {
  34. Image(systemName: iconName)
  35. .resizable()
  36. .aspectRatio(contentMode: .fit)
  37. .frame(width: 50, height: 50)
  38. Text(command)
  39. }
  40. .frame(maxWidth: .infinity, minHeight: 100)
  41. .padding()
  42. .background(Color.blue)
  43. .foregroundColor(.white)
  44. .cornerRadius(8)
  45. }
  46. .buttonStyle(PlainButtonStyle())
  47. }
  48. }