BolusProgressOverlay.swift 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import SwiftUI
  2. struct BolusProgressOverlay: View {
  3. let state: WatchState
  4. @ObservedObject var navigationState: NavigationState
  5. private let progressGradient = LinearGradient(
  6. colors: [
  7. Color(red: 0.7215686275, green: 0.3411764706, blue: 1), // #B857FF
  8. Color(red: 0.6235294118, green: 0.4235294118, blue: 0.9803921569), // #9F6CFA
  9. Color(red: 0.4862745098, green: 0.5450980392, blue: 0.9529411765), // #7C8BF3
  10. Color(red: 0.3411764706, green: 0.6666666667, blue: 0.9254901961), // #57AAEC
  11. Color(red: 0.262745098, green: 0.7333333333, blue: 0.9137254902) // #43BBE9
  12. ],
  13. startPoint: .leading,
  14. endPoint: .trailing
  15. )
  16. var body: some View {
  17. if state.bolusProgress > 0 && state.bolusProgress < 1.0 {
  18. VStack {
  19. Spacer()
  20. VStack(spacing: 4) {
  21. HStack {
  22. ProgressView(value: state.bolusProgress, total: 1.0)
  23. .tint(progressGradient)
  24. Button(action: {
  25. state.sendCancelBolusRequest()
  26. navigationState.resetToRoot()
  27. }) {
  28. Image(systemName: "xmark.circle.fill")
  29. .foregroundStyle(.red)
  30. .font(.system(size: 20))
  31. }
  32. .buttonStyle(.plain)
  33. }
  34. Text(String(
  35. format: "%.1f U of %.1f U",
  36. state.bolusProgress * state.activeBolusAmount,
  37. state.activeBolusAmount
  38. ))
  39. .font(.caption2)
  40. .foregroundStyle(.secondary)
  41. }
  42. .padding()
  43. .background(Color.black.opacity(0.7))
  44. .cornerRadius(10)
  45. .padding()
  46. }
  47. }
  48. }
  49. }