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; } export function DeviceProgressBar({ count, max, atLimit }: 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 ? t('devices.progress_at_limit') : t('devices.progress_label', { count, max })} {count}/{max} ); }