import { StyleSheet, View, type StyleProp, type ViewStyle } from 'react-native'; import Svg, { Circle } from 'react-native-svg'; import { AppText } from './app-text'; import { colors, type SemanticTone } from './tokens'; type Props = { percentage: number; tone?: Extract | 'brand'; size?: number; strokeWidth?: number; label?: string; accessibilityLabel: string; style?: StyleProp; }; /** An accessible determinate progress ring for real attendance values. */ export function AttendanceRing({ percentage, tone = 'brand', size = 112, strokeWidth = 10, label = 'Attendance', accessibilityLabel, style }: Props) { const value = Math.max(0, Math.min(100, Math.round(percentage))); const center = size / 2; const ringRadius = (size - strokeWidth) / 2; const circumference = 2 * Math.PI * ringRadius; const dashOffset = circumference * (1 - value / 100); const accent = tone === 'brand' ? colors.brand.cobalt : colors.semantic[tone].solid; return {value}% {label} ; } const styles = StyleSheet.create({ container: { alignItems: 'center', justifyContent: 'center' }, copy: { ...StyleSheet.absoluteFillObject, alignItems: 'center', justifyContent: 'center', paddingHorizontal: 12 }, value: { fontVariant: ['tabular-nums'] }, });