import React, { useState } from 'react'; import { View, Text, ActivityIndicator, ScrollView, TouchableOpacity, } from 'react-native'; import Icon from 'react-native-vector-icons/Ionicons'; import { useTheme } from '@theme'; import { DashboardProjectActivityItem } from '@interfaces'; import { getStyles } from './projectActivityFeed.styles'; import { ProjectActivityFeedProps } from './projectActivityFeed.props'; import { colors as globalColors } from '@theme'; const AVATAR_COLORS = [ '#5B4CF5', // indigo '#8B5CF6', // violet '#06B6D4', // cyan '#10B981', // emerald '#F59E0B', // amber '#EF4444', // red '#EC4899', // pink ]; const getInitials = (name: string): string => { const parts = name.trim().split(' '); if (parts.length >= 2) { return `${parts[0][0]}${parts[1][0]}`.toUpperCase(); } return name.slice(0, 2).toUpperCase(); }; const ActivityRow = ({ item, index, isLast, styles, textMutedColor, }: { item: DashboardProjectActivityItem; index: number; isLast: boolean; styles: ReturnType; textMutedColor: string; }) => { const avatarColor = AVATAR_COLORS[index % AVATAR_COLORS.length]; const initials = getInitials(item.fullname_formatted || item.fullname); return ( {/* ── Left: avatar + timeline connector ── */} {initials} {!isLast && } {/* ── Right: bubble content ── */} {/* Name + time */} {item.fullname_formatted || item.fullname} {item.date_time_ago} {/* Action description */} {item.description} {/* Project chip */} {item.project_name} {/* Additional data tag */} {!!item.additional_data && ( {item.additional_data} )} ); }; export const ProjectActivityFeed = ({ data = [], loading = false, }: ProjectActivityFeedProps) => { const { theme: colors, isDark } = useTheme(); const styles = getStyles(colors, isDark); const [expanded, setExpanded] = useState(false); const displayData = expanded ? data : data.slice(0, 5); const hasMore = data.length > 5; return ( {/* ── Header ── */} Latest Project Activity recent actions across projects {!loading && data.length > 0 && ( {data.length} )} {/* ── Divider ── */} {/* ── Body ── */} {loading ? ( ) : data.length === 0 ? ( No recent activity ) : ( <> {displayData.map((item, index) => ( ))} {hasMore && ( setExpanded(!expanded)} > {expanded ? 'Show Less' : `Show More (${data.length - 5} more)`} )} )} ); };