import React from 'react'; import { StyleSheet, View } from 'react-native'; import { useTheme, Card, Text, Avatar, Chip, Button, } from 'react-native-paper'; import type { Match } from '../../types/match'; import { formatFare } from '../../utils/fareCalculator'; export interface MatchCardProps { /** The match / match-with-user object */ match: Match; /** Callback when the Accept button is pressed */ onAccept?: () => void; /** Callback when the Message button is pressed */ onMessage?: () => void; } /** * Match result card showing another user's ride offer/request. * Displays avatar, name, rating, vehicle type, pickup distance, * overlap %, fare range, and action buttons. */ export function MatchCard({ match, onAccept, onMessage }: MatchCardProps) { const theme = useTheme(); const displayName = match.riderName ?? match.passengerName ?? 'User'; const rating = match.riderRating ?? match.passengerRating ?? 0; const avatar = match.riderAvatar ?? match.passengerAvatar; return ( {/* User info row */} {displayName} ⭐ {rating > 0 ? rating.toFixed(1) : 'New'} {/* Stats chips */} {match.overlapPercentage != null && ( {Math.round(match.overlapPercentage)}% match )} {match.detourDistanceKm != null && ( {match.detourDistanceKm.toFixed(1)} km detour )} {match.fareAgreed != null && ( {formatFare(match.fareAgreed)} )} {/* Action buttons */} ); } const styles = StyleSheet.create({ card: { borderRadius: 12, marginVertical: 4, }, content: { gap: 12, paddingVertical: 14, paddingHorizontal: 16, }, userRow: { flexDirection: 'row', alignItems: 'center', gap: 12, }, userInfo: { flex: 1, gap: 2, }, ratingRow: { flexDirection: 'row', alignItems: 'center', gap: 4, }, chipsRow: { flexDirection: 'row', flexWrap: 'wrap', gap: 8, }, chip: { height: 30, }, actionsRow: { flexDirection: 'row', justifyContent: 'flex-end', gap: 8, }, messageButton: { borderRadius: 20, }, acceptButton: { borderRadius: 20, }, buttonContent: { paddingHorizontal: 12, paddingVertical: 4, }, buttonLabel: { fontSize: 13, }, });