import SwiftUI /// Fitness-style progress ring: track + rounded-cap arc + centered percentage. /// Color is semantic (pace/achievement), passed by the caller. struct ProgressRing: View { let progress: Double var tint: Color = .appPrimary var size: CGFloat = 56 var lineWidth: CGFloat = 6 private var clamped: Double { min(max(progress, 0), 1) } var body: some View { ZStack { Circle() .stroke(tint.opacity(0.15), lineWidth: lineWidth) Circle() .trim(from: 0, to: clamped) .stroke(tint, style: StrokeStyle(lineWidth: lineWidth, lineCap: .round)) .rotationEffect(.degrees(-90)) .animation(.easeOut(duration: 0.6), value: clamped) Text("\(Int((clamped * 100).rounded()))%") .font(.system(size: size * 0.26, weight: .bold, design: .rounded)) .foregroundColor(tint) .minimumScaleFactor(0.7) } .frame(width: size, height: size) .accessibilityLabel(Text("\(Int((clamped * 100).rounded()))%")) } }