AcknowledgementPendingView.swift 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import SwiftUI
  2. struct AcknowledgementPendingView: View {
  3. @Binding var navigationPath: [NavigationDestinations]
  4. let state: WatchState
  5. var trioBackgroundColor = LinearGradient(
  6. gradient: Gradient(colors: [Color.bgDarkBlue, Color.bgDarkerDarkBlue]),
  7. startPoint: .top,
  8. endPoint: .bottom
  9. )
  10. var statusIcon: some View {
  11. switch state.acknowledgementStatus {
  12. case .pending:
  13. return Image(systemName: "progress.indicator").foregroundStyle(Color.secondary)
  14. case .success:
  15. return Image(systemName: "checkmark.circle").foregroundStyle(Color.green)
  16. case .failure:
  17. return Image(systemName: "progress.indicator").foregroundStyle(Color.red)
  18. }
  19. }
  20. var body: some View {
  21. Group {
  22. VStack {
  23. if state.isMealBolusCombo {
  24. ProgressView()
  25. Text(state.mealBolusStep.rawValue).multilineTextAlignment(.center)
  26. } else if state.showCommsAnimation {
  27. ProgressView()
  28. Text("Processing…")
  29. } else if state.showAcknowledgmentBanner {
  30. statusIcon.padding()
  31. Text(state.acknowledgmentMessage).multilineTextAlignment(.center)
  32. }
  33. }
  34. .padding()
  35. .frame(maxWidth: .infinity, maxHeight: .infinity)
  36. }
  37. .navigationBarBackButtonHidden(true)
  38. .toolbar(.hidden)
  39. .background(trioBackgroundColor)
  40. .onChange(of: state.showAcknowledgmentBanner) { _, newValue in
  41. if !newValue {
  42. // Navigate back to the root when acknowledgment banner disappears
  43. navigationPath.removeAll()
  44. }
  45. }
  46. }
  47. }