import { useEffect, useRef } from 'react'; import { Animated, Easing, Text, View } from 'react-native'; import { useTranslation } from 'react-i18next'; import { useColors } from '../../lib/theme'; import { MOBILE_COLOR, DESKTOP_COLOR } from './DeviceSlotDonut'; /** * Animierter Verteilungs-Balken (Gesamt) — gleiche Design-Sprache wie die * Slot-Ringe (grün=Mobil, blau=Computer, gleiche Easing/Dauer). Sitzt unter * den beiden Circles und zeigt die Aufteilung mobil/stationär. */ export function DeviceDistributionBar({ mobile, desktop, total, }: { mobile: number; desktop: number; total: number; }) { const { t } = useTranslation(); const colors = useColors(); const safeTotal = Math.max(1, total); const used = mobile + desktop; const anim = useRef(new Animated.Value(0)).current; useEffect(() => { anim.setValue(0); Animated.timing(anim, { toValue: 1, duration: 1400, easing: Easing.out(Easing.cubic), useNativeDriver: false, }).start(); }, [mobile, desktop, total, anim]); const mobileW = anim.interpolate({ inputRange: [0, 1], outputRange: ['0%', `${(mobile / safeTotal) * 100}%`], }); const desktopW = anim.interpolate({ inputRange: [0, 1], outputRange: ['0%', `${(desktop / safeTotal) * 100}%`], }); return ( {t('devices.progress_total')} {used} /{total} ); } function Legend({ color, label, count, colors, }: { color: string; label: string; count: number; colors: ReturnType; }) { return ( {label} {count} ); }