CustomProgressView.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import SwiftUI
  2. struct CustomProgressView: View {
  3. @State var animate = false
  4. let text: String
  5. @Environment(\.colorScheme) var colorScheme
  6. var body: some View {
  7. ZStack {
  8. Text(text)
  9. .font(.system(.body, design: .rounded))
  10. .bold()
  11. .offset(x: 0, y: -25)
  12. RoundedRectangle(cornerRadius: 3)
  13. .stroke(Color(.systemGray5), lineWidth: 3)
  14. .frame(width: 250, height: 3)
  15. RoundedRectangle(cornerRadius: 3)
  16. .stroke(LinearGradient(colors: [
  17. Color(red: 0.7215686275, green: 0.3411764706, blue: 1),
  18. Color(red: 0.6235294118, green: 0.4235294118, blue: 0.9803921569),
  19. Color(red: 0.4862745098, green: 0.5450980392, blue: 0.9529411765),
  20. Color(red: 0.3411764706, green: 0.6666666667, blue: 0.9254901961),
  21. Color(red: 0.262745098, green: 0.7333333333, blue: 0.9137254902)
  22. ], startPoint: .leading, endPoint: .trailing), lineWidth: 3)
  23. .frame(width: 250, height: 3)
  24. .mask(
  25. RoundedRectangle(cornerRadius: 3)
  26. .frame(width: 80, height: 3)
  27. .offset(x: self.animate ? 180 : -180, y: 0)
  28. .animation(
  29. Animation.linear(duration: 1)
  30. .repeatForever(autoreverses: false), value: UUID()
  31. )
  32. )
  33. }
  34. .onAppear {
  35. self.animate.toggle()
  36. }
  37. }
  38. }
  39. enum ProgressText: String {
  40. case updatingIOB = "Updating IOB ..."
  41. case updatingCOB = "Updating COB ..."
  42. case updatingHistory = "Updating History ..."
  43. case updatingTreatments = "Updating Treatments ..."
  44. case updatingIOBandCOB = "Updating IOB and COB ..."
  45. }