TrioRemoteControlView.swift 1.9 KB

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