GlucoseTrendView.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. // TODO: set loop colors conditionally, not hard coded
  15. .shadow(color: .green, radius: is40mm ? 8 : 12)
  16. VStack(alignment: .center) {
  17. Text(state.currentGlucose)
  18. .fontWeight(.semibold)
  19. .font(.system(is40mm ? .title2 : .title, design: .rounded))
  20. if let delta = state.delta {
  21. Text(delta)
  22. .fontWeight(.semibold)
  23. .font(.system(.caption, design: .rounded))
  24. .foregroundStyle(.secondary)
  25. }
  26. }
  27. }
  28. Spacer()
  29. Text(state.lastLoopTime ?? "--").font(is40mm ? .footnote : .caption)
  30. Spacer()
  31. }.frame(maxWidth: .infinity, maxHeight: .infinity)
  32. }
  33. }