import { useEffect, useRef, useState } from "react"; import { AccessibilityInfo, ActivityIndicator, StyleSheet, Text, TouchableOpacity, View } from "react-native"; import { Ionicons } from "@expo/vector-icons"; import { LinearGradient } from "expo-linear-gradient"; import { router, useLocalSearchParams } from "expo-router"; import { GradientBackground, GlassButton } from "../../src/components/ui"; import { colors, gradients, spacing, typography } from "../../src/theme"; import { useAuthStore, useMatchStore } from "../../src/store"; import { markPairedUnlockSeen } from "../../src/lib/pairedUnlockSeen"; import { Events } from "../../src/lib/analytics"; export const POST_PAIR_ENTRY = "/(app)/swipe" as const; const bucket = (n: number) => n === 0 ? "0" : n <= 2 ? "1-2" : n <= 5 ? "3-5" : n <= 10 ? "6-10" : n <= 25 ? "11-25" : "26+"; export default function PairedScreen() { const { user, couple, partner } = useAuthStore(); const { newMatchesCount, fetchMatches } = useMatchStore(); const [ready, setReady] = useState(false); const { role: rawRole } = useLocalSearchParams<{ role?: "inviter" | "joiner" }>(); const heading = useRef(null); const role = rawRole === "inviter" ? "inviter" : "joiner"; useEffect(() => { void fetchMatches(true).finally(() => setReady(true)); }, [fetchMatches]); useEffect(() => { if (!ready || !user || !couple) return; void markPairedUnlockSeen(user.id, couple.id); Events.pairingUnlockViewed(role, bucket(newMatchesCount)); const timer = setTimeout(() => { if (heading.current) AccessibilityInfo.setAccessibilityFocus(heading.current as never); }, 250); return () => clearTimeout(timer); }, [ready, user, couple, newMatchesCount]); const partnerName = partner?.name?.split(" ")[0] || "your partner"; const viewMatches = () => { Events.pairingUnlockCtaTapped(role, "view_matches"); router.replace("/(app)/matches"); }; const start = () => { Events.pairingUnlockCtaTapped(role, "start_session"); router.replace(POST_PAIR_ENTRY); }; const dismiss = () => { Events.pairingUnlockCtaTapped(role, "dismiss"); router.replace("/(app)"); }; if (!ready) { return ; } return You're paired with {partnerName} {newMatchesCount > 0 ? <>{newMatchesCount} thing{newMatchesCount === 1 ? "" : "s"} you already agree onFrom answers you both gave before now.See what you agree onStart a session : <>Nothing to compare yet. Answer a few questions and anything you agree on shows up here.Answer your first questions} Not now ; } const styles = StyleSheet.create({ container:{flex:1,justifyContent:"center",padding:spacing.xl,gap:spacing.lg,alignItems:"center"}, icon:{width:88,height:88,borderRadius:44,alignItems:"center",justifyContent:"center"}, title:{...typography.largeTitle,color:colors.text,textAlign:"center"}, count:{...typography.title2,color:colors.premium.rose,textAlign:"center"}, body:{...typography.callout,color:colors.textSecondary,textAlign:"center"}, dismiss:{minHeight:44,justifyContent:"center",paddingHorizontal:spacing.lg}, dismissText:{...typography.subhead,color:colors.textSecondary} });