import React, { useEffect, useRef } from 'react'; import { View, Animated, StyleSheet } from 'react-native'; import Svg, { Circle, G } from 'react-native-svg'; import { theme } from '../styles/theme'; const AnimatedCircle = Animated.createAnimatedComponent(Circle); export default function ConfidenceMeter({ confidence, size = 100 }) { const animatedValue = useRef(new Animated.Value(0)).current; const circleRef = useRef(); const radius = (size - 10) / 2; const circumference = 2 * Math.PI * radius; useEffect(() => { Animated.timing(animatedValue, { toValue: confidence, duration: 1000, useNativeDriver: true, }).start(); }, [confidence]); const strokeDashoffset = animatedValue.interpolate({ inputRange: [0, 1], outputRange: [circumference, 0], }); const getColor = () => { if (confidence < 0.5) return theme.colors.error; if (confidence < 0.75) return theme.colors.warning; return theme.colors.success; }; const percentage = Math.round(confidence * 100); return ( {} {} {} {percentage}% ); } const styles = StyleSheet.create({ container: { justifyContent: 'center', alignItems: 'center', }, textContainer: { position: 'absolute', justifyContent: 'center', alignItems: 'center', }, percentageText: { fontSize: 20, fontWeight: 'bold', }, });