import { useEffect, useRef, useState } from 'react'; import { Animated, Easing, Text, View } from 'react-native'; import Svg, { Circle } from 'react-native-svg'; import { useColors } from '../../lib/theme'; const SIZE = 88; const STROKE = 11; const R = (SIZE - STROKE) / 2; const C = 2 * Math.PI * R; /** * Voller Progress-Ring (kein Half-Donut) für belegte/freie Geräte-Slots. * Mit react-native-svg (schon im Projekt) statt neuer Lib — animiert über * strokeDashoffset. Zwei nebeneinander (Mobil + Computer). */ export function DeviceSlotDonut({ count, max, atLimit, label, }: { count: number; max: number; atLimit: boolean; label: string; }) { const colors = useColors(); const ratio = max > 0 ? Math.min(count / max, 1) : 0; const fill = atLimit ? colors.brandOrange : colors.success; const anim = useRef(new Animated.Value(0)).current; const [progress, setProgress] = useState(0); useEffect(() => { anim.setValue(0); const l = anim.addListener(({ value }) => setProgress(value)); Animated.timing(anim, { toValue: 1, duration: 1400, easing: Easing.out(Easing.cubic), useNativeDriver: false, }).start(); return () => anim.removeListener(l); }, [ratio, anim]); const offset = C * (1 - ratio * progress); return ( {count} /{max} {label} ); }