import React from 'react'; import { View, TouchableOpacity, Animated, Easing } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; import { MyText , tw , colors } from "common-ui"; import { Ionicons } from '@expo/vector-icons'; import { useThemeColor } from '@/hooks/useThemeColor'; import { IconButton } from 'react-native-paper'; interface DashboardHeaderProps { onMenuPress: () => void; onNotificationsPress: () => void; onProfilePress: () => void; onRefreshPress?: () => void; refreshing?: boolean; } const DashboardHeader: React.FC = ({ onMenuPress, onNotificationsPress, onProfilePress, onRefreshPress, refreshing = false }) => { const accentColor = useThemeColor({ light: '#4f46e5', dark: '#818cf8' }, 'tint'); // For the refresh animation const spinAnim = React.useRef(new Animated.Value(0)).current; // Update animation when refreshing prop changes React.useEffect(() => { let animation: Animated.CompositeAnimation | null = null; if (refreshing) { animation = Animated.loop( Animated.timing(spinAnim, { toValue: 1, duration: 1000, easing: Easing.linear, useNativeDriver: true, }) ); animation.start(); } else { spinAnim.stopAnimation(); spinAnim.setValue(0); } return () => { if (animation) { animation.stop(); } }; }, [refreshing]); const spin = spinAnim.interpolate({ inputRange: [0, 1], outputRange: ['0deg', '360deg'], }); return ( {/* Menu Button */} {/* Logo/App Name */} HealthPetal {/* Right Actions */} {/* Refresh Button */} {onRefreshPress && ( )} {/* Notifications */} {/* Notification Badge */} {/* Profile */} ); }; export default DashboardHeader;