import SwiftUI /// A bounded percentage gauge; missing data keeps an empty track and an explicit -- label. struct MetricRingGauge: View { let title: LocalizedStringKey let value: Double? let color: Color private var fraction: Double { value.flatMap { $0.isFinite ? min(1, max(0, $0)) : nil } ?? 0 } var body: some View { VStack(spacing: 3) { ZStack { NativeMetricRing(value: fraction, color: color, lineWidth: 3, trackOpacity: 0.17, inset: 2) MetricText(value: MetricFormat.percent(value)).font(.system(size: 8, weight: .semibold)) .lineLimit(1).minimumScaleFactor(0.6).frame(width: 18, height: 12) }.frame(width: 28, height: 28).accessibilityHidden(true) Text(title).font(.system(size: 8)).foregroundStyle(.secondary) .lineLimit(1).minimumScaleFactor(0.7) } .frame(maxWidth: .infinity) .accessibilityElement(children: .ignore) .accessibilityLabel(Text(title)) .accessibilityValue(Text(verbatim: MetricFormat.percent(value))) } }