GlucoseTrendView.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import SwiftUI
  2. struct GlucoseTrendView: View {
  3. let state: WatchState
  4. let rotationDegrees: Double
  5. private var is40mm: Bool {
  6. let size = WKInterfaceDevice.current().screenBounds.size
  7. return size.height < 225 && size.width < 185
  8. }
  9. var body: some View {
  10. VStack {
  11. ZStack {
  12. TrendShape(rotationDegrees: rotationDegrees, isSmallDevice: is40mm)
  13. .animation(.spring(response: 0.5, dampingFraction: 0.6), value: rotationDegrees)
  14. VStack(alignment: .center) {
  15. Text(state.currentGlucose)
  16. .fontWeight(.semibold)
  17. .font(.system(is40mm ? .title2 : .title, design: .rounded))
  18. if let delta = state.delta {
  19. Text(delta)
  20. .fontWeight(.semibold)
  21. .font(.system(.caption, design: .rounded))
  22. .foregroundStyle(.secondary)
  23. }
  24. }
  25. }
  26. Spacer()
  27. // TODO: set loop colors conditionally, not hard coded
  28. HStack {
  29. Image(systemName: "circle")
  30. .foregroundStyle(.green)
  31. Text(state.lastLoopTime ?? "--")
  32. }.font(is40mm ? .footnote : .caption)
  33. Spacer()
  34. }.frame(maxWidth: .infinity, maxHeight: .infinity)
  35. }
  36. }