import { View, Text, StyleSheet, FlatList, RefreshControl, TouchableOpacity, ActivityIndicator, Platform } from "react-native"; import { useMatchStore, useAuthStore } from "../../src/store"; import { useEffect } from "react"; import { Ionicons } from "@expo/vector-icons"; import { useRouter } from "expo-router"; import Animated, { FadeInDown, FadeInRight } from "react-native-reanimated"; import { GradientBackground, GlassCard } from "../../src/components/ui"; import { colors, spacing, typography, radius } from "../../src/theme"; export default function MatchesScreen() { const { matches, fetchMatches, markAllAsSeen } = useMatchStore(); const { user } = useAuthStore(); const router = useRouter(); useEffect(() => { fetchMatches(); }, []); useEffect(() => { if (matches.length > 0) { markAllAsSeen(); } }, [matches.length]); const renderItem = ({ item, index }: { item: any; index: number }) => { const userResponse = item.responses?.find((r: any) => r.user_id === user?.id); const partnerResponse = item.responses?.find((r: any) => r.user_id !== user?.id); let userText = item.question.text; let partnerText = item.question.partner_text; if (item.question.partner_text && userResponse && partnerResponse) { const userTime = new Date(userResponse.created_at).getTime(); const partnerTime = new Date(partnerResponse.created_at).getTime(); if (userTime > partnerTime) { userText = item.question.partner_text; partnerText = item.question.text; } } const isYesYes = item.match_type === "yes_yes"; return ( router.push(`/chat/${item.id}`)} activeOpacity={0.7} > {userText} {item.question.partner_text && ( Partner: {partnerText} )} {isYesYes ? "YES + YES" : "YES + MAYBE"} {new Date(item.created_at).toLocaleDateString()} ); }; if (!user) { return ( ); } return ( Your Matches {matches.length} {matches.length === 1 ? 'match' : 'matches'} found item.id} contentContainerStyle={styles.list} showsVerticalScrollIndicator={false} refreshControl={ } ListEmptyComponent={ No matches yet Keep swiping to find things you both enjoy! } /> ); } const styles = StyleSheet.create({ container: { flex: 1, }, loadingContainer: { flex: 1, justifyContent: "center", alignItems: "center", }, header: { paddingTop: 60, paddingHorizontal: spacing.lg, paddingBottom: spacing.md, }, title: { ...typography.title1, color: colors.text, }, subtitle: { ...typography.subhead, color: colors.textSecondary, marginTop: spacing.xs, }, list: { padding: spacing.lg, paddingBottom: Platform.OS === 'ios' ? 120 : 100, }, matchCard: { flexDirection: "row", alignItems: "center", marginBottom: spacing.sm, }, iconContainer: { width: 48, height: 48, borderRadius: 24, backgroundColor: colors.primaryLight, justifyContent: "center", alignItems: "center", marginRight: spacing.md, }, content: { flex: 1, }, questionText: { ...typography.body, color: colors.text, fontWeight: "600", marginBottom: spacing.xs, }, partnerText: { ...typography.subhead, color: colors.textSecondary, fontStyle: "italic", marginBottom: spacing.sm, }, metaContainer: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", }, tag: { backgroundColor: colors.glass.background, paddingHorizontal: spacing.sm, paddingVertical: spacing.xs, borderRadius: radius.xs, }, tagHighlight: { backgroundColor: colors.primaryLight, }, tagText: { ...typography.caption2, color: colors.textSecondary, fontWeight: "600", }, tagTextHighlight: { color: colors.primary, }, date: { ...typography.caption1, color: colors.textTertiary, }, chevronContainer: { marginLeft: spacing.sm, }, emptyContainer: { alignItems: "center", paddingVertical: spacing.xxl, }, emptyIconContainer: { width: 80, height: 80, borderRadius: 40, backgroundColor: colors.glass.background, justifyContent: "center", alignItems: "center", marginBottom: spacing.md, }, emptyTitle: { ...typography.title3, color: colors.text, marginBottom: spacing.xs, }, emptyText: { ...typography.body, color: colors.textSecondary, textAlign: "center", }, });