Peter Steinbergerfeat(ui): add used-mode usage barscca0e7d11 months agoHistory
29 lines · 843 B · Swift
RawDownload
import SwiftUI /// Static progress fill with no implicit animations, used inside the menu card.struct UsageProgressBar: View {    let percent: Double    let tint: Color    let accessibilityLabel: String     private var clamped: Double {        min(100, max(0, self.percent))    }     var body: some View {        GeometryReader { proxy in            let fillWidth = proxy.size.width * self.clamped / 100            ZStack(alignment: .leading) {                Capsule()                    .fill(Color.secondary.opacity(0.25))                Capsule()                    .fill(self.tint)                    .frame(width: fillWidth)            }        }        .frame(height: 6)        .accessibilityLabel(self.accessibilityLabel)        .accessibilityValue("\(Int(self.clamped)) percent")        .drawingGroup()    }}