import React, { memo } from 'react'; import { StyleSheet, Text, View } from 'react-native'; import Ionicons from '@react-native-vector-icons/ionicons'; import { useTheme } from '../../../theme'; import { formatDate } from '../../../utils/formatters'; import { Card } from '../../../components'; interface TimelineStep { stage: string; timestamp: string; active: boolean; } interface LoanTimelineCardProps { title: string; subtitle?: string; timeline: TimelineStep[]; } const LoanTimelineCardComponent = ({ title, subtitle, timeline }: LoanTimelineCardProps) => { const theme = useTheme(); return ( {title} {subtitle && ( {subtitle} )} {timeline.map((step, index) => { const isLast = index === timeline.length - 1; const isCompleted = step.active && step.timestamp !== ''; const isCurrent = step.active && step.timestamp === '' && index > 0 ? false : step.active && !timeline[index + 1]?.active; const isPending = !step.active; let dotColor = theme.colors.textMuted; let iconName = 'ellipse-outline'; if (isCompleted) { dotColor = theme.colors.success; iconName = 'checkmark-circle'; } else if (isCurrent) { dotColor = theme.colors.primary; iconName = 'radio-button-on'; } return ( {!isLast && ( )} {step.stage} {step.timestamp ? ( {formatDate(step.timestamp)} ) : ( Pending )} ); })} ); }; const styles = StyleSheet.create({ card: { gap: 14 }, header: { gap: 4 }, title: { fontSize: 16, fontWeight: '800' }, subtitle: { fontSize: 13, lineHeight: 18 }, timeline: { gap: 0 }, stepRow: { flexDirection: 'row', gap: 12 }, stepIndicator: { alignItems: 'center', width: 24 }, connector: { width: 2, flex: 1, minHeight: 20 }, stepContent: { flex: 1, paddingTop: 1 }, stepContentSpaced: { paddingBottom: 16 }, stepLabel: { fontSize: 14 }, stepTime: { fontSize: 12, marginTop: 2 }, }); export const LoanTimelineCard = memo(LoanTimelineCardComponent);