AGPView.swift 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // LoopFollow
  2. // AGPView.swift
  3. import SwiftUI
  4. struct AGPView: View {
  5. @ObservedObject var viewModel: AGPViewModel
  6. var body: some View {
  7. if !viewModel.agpData.isEmpty {
  8. VStack(alignment: .leading, spacing: 8) {
  9. Text("Ambulatory Glucose Profile (AGP)")
  10. .font(.caption)
  11. .foregroundColor(.secondary)
  12. AGPGraphView(agpData: viewModel.agpData)
  13. .frame(height: 200)
  14. .padding(.top, 10)
  15. .padding(.horizontal, 8)
  16. .padding(.bottom, 4)
  17. .allowsHitTesting(false)
  18. // Legend
  19. HStack(spacing: 16) {
  20. LegendItem(color: .gray.opacity(0.6), label: "5th-95th")
  21. LegendItem(color: .blue.opacity(0.7), label: "25th-75th")
  22. LegendItem(color: .blue, label: "Median")
  23. }
  24. .font(.caption2)
  25. }
  26. .frame(maxWidth: .infinity, alignment: .leading)
  27. .padding()
  28. .background(Color(.systemGray6))
  29. .cornerRadius(12)
  30. }
  31. }
  32. }
  33. struct LegendItem: View {
  34. let color: Color
  35. let label: String
  36. var body: some View {
  37. HStack(spacing: 4) {
  38. Rectangle()
  39. .fill(color)
  40. .frame(width: 12, height: 12)
  41. Text(label)
  42. .foregroundColor(.secondary)
  43. }
  44. }
  45. }