Advertisement
marcusziade

Untitled

Aug 26th, 2023
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.63 KB | None | 0 0
  1. struct NegativeProgressView: View {
  2.     var goalValue: Double = 275
  3.     var currentValue: Double = 285
  4.    
  5.     var body: some View {
  6.         GeometryReader { geometry in
  7.             let totalWidth = geometry.size.width
  8.            
  9.             ZStack(alignment: .leading) {
  10.                 Rectangle()
  11.                     .foregroundColor(Color.gray.opacity(0.3))
  12.                
  13.                 Rectangle()
  14.                     .foregroundColor(currentValue >= goalValue ? Color.green : Color.red)
  15.                     .frame(width: CGFloat(abs(currentValue - goalValue) / goalValue) * totalWidth)
  16.             }
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement