BolusProgressOverlay.swift 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // import SwiftUI
  2. //
  3. // struct BolusProgressOverlay: View {
  4. // let state: WatchState
  5. // let onCancelBolus: () -> Void
  6. //
  7. // private let progressGradient = LinearGradient(
  8. // colors: [
  9. // Color(red: 0.7215686275, green: 0.3411764706, blue: 1), // #B857FF
  10. // Color(red: 0.6235294118, green: 0.4235294118, blue: 0.9803921569), // #9F6CFA
  11. // Color(red: 0.4862745098, green: 0.5450980392, blue: 0.9529411765), // #7C8BF3
  12. // Color(red: 0.3411764706, green: 0.6666666667, blue: 0.9254901961), // #57AAEC
  13. // Color(red: 0.262745098, green: 0.7333333333, blue: 0.9137254902) // #43BBE9
  14. // ],
  15. // startPoint: .leading,
  16. // endPoint: .trailing
  17. // )
  18. //
  19. // private var isWatchStateDated: Bool {
  20. // // If `lastWatchStateUpdate` is nil, treat as "dated"
  21. // guard let lastUpdateTimestamp = state.lastWatchStateUpdate else {
  22. // return true
  23. // }
  24. // let now = Date().timeIntervalSince1970
  25. // let secondsSinceUpdate = now - lastUpdateTimestamp
  26. // // Return true if last update older than 5 min, so 1 loop cycle
  27. // return secondsSinceUpdate > 5 * 60
  28. // }
  29. //
  30. // private var isSessionUnreachable: Bool {
  31. // guard let session = state.session else {
  32. // return true // No session at all => unreachable
  33. // }
  34. // // Return true if not .activated OR not reachable
  35. // return session.activationState != .activated
  36. // }
  37. //
  38. // var body: some View {
  39. // VStack(spacing: 10) {
  40. // VStack {
  41. // Text("Bolusing")
  42. // .font(.footnote)
  43. // .foregroundStyle(.secondary)
  44. // .padding(.top)
  45. //
  46. //// ProgressView(value: state.bolusProgress, total: 1.0)
  47. // .tint(progressGradient)
  48. //
  49. // Text(String(
  50. // format: String(
  51. // localized: "%.2f U of %.2f U",
  52. // comment: "Format for showing delivered and active bolus amounts, 'x U of y U' on watch"
  53. // ),
  54. // state.deliveredAmount,
  55. // state.activeBolusAmount
  56. // ))
  57. // .font(.footnote)
  58. // .foregroundStyle(.secondary)
  59. //
  60. // Spacer()
  61. //
  62. // Button(action: {
  63. // state.sendCancelBolusRequest()
  64. // onCancelBolus()
  65. // }) {
  66. // Text("Cancel Bolus")
  67. // }
  68. // .buttonStyle(.bordered)
  69. // .padding()
  70. // .disabled(isWatchStateDated || isSessionUnreachable)
  71. // }
  72. // .padding()
  73. // .background(Color.black.opacity(0.9))
  74. // .cornerRadius(10)
  75. // }
  76. // .scenePadding()
  77. // .onChange(of: state.bolusProgress) { _, newProgress in
  78. // if newProgress >= 1.0 {
  79. // state.activeBolusAmount = 0 // Reset only when bolus is complete
  80. // }
  81. // }
  82. // .onDisappear {
  83. // state.activeBolusAmount = 0 // Triple-check to reset when view disappears
  84. // }
  85. // }
  86. // }