TrioRemoteControlView.swift 1.8 KB

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