import { useEffect, useRef } from 'react'; import { Animated, Text, View } from 'react-native'; import { useTranslation } from 'react-i18next'; import { useColors } from '../../lib/theme'; interface DeviceProgressBarProps { count: number; max: number; atLimit: boolean; /** Optionales Label (z.B. "Mobil" / "Computer") statt generischem progress_label */ label?: string; } export function DeviceProgressBar({ count, max, atLimit, label }: DeviceProgressBarProps) { const { t } = useTranslation(); const colors = useColors(); const fillAnim = useRef(new Animated.Value(0)).current; const ratio = max > 0 ? Math.min(count / max, 1) : 0; useEffect(() => { Animated.timing(fillAnim, { toValue: ratio, duration: 380, useNativeDriver: false, }).start(); }, [ratio]); const fillColor = atLimit ? colors.brandOrange : colors.success; return ( {atLimit ? (label ? `${label} — ${t('devices.progress_at_limit')}` : t('devices.progress_at_limit')) : (label ?? t('devices.progress_label', { count, max }))} {count}/{max} ); }