import SwiftUI /// Clips both layers to the track, including fills narrower than the track height. struct MetricProgressBar: View { let value: Double let color: Color private var fraction: Double { value.isFinite ? min(1, max(0, value)) : 0 } var body: some View { GeometryReader { proxy in ZStack(alignment: .leading) { Capsule().fill(color.opacity(0.15)) Capsule().fill(color).frame(width: proxy.size.width * fraction) } .frame(width: proxy.size.width, height: proxy.size.height) .clipShape(Capsule()) .transaction { $0.animation = nil; $0.disablesAnimations = true } } } }