import { ThemedText } from "@/components/themed-text"; import { MatchDetailData } from "@/types/api"; import { Image } from "expo-image"; import React from "react"; import { useTranslation } from "react-i18next"; import { StyleSheet, View } from "react-native"; import { LinearGradient } from "expo-linear-gradient"; import { getInitials, getLogoGradient } from "@/lib/avatar-utils"; interface TennisScoreTableProps { data: MatchDetailData; isDark: boolean; } export function TennisScoreTable({ data, isDark }: TennisScoreTableProps) { const { t } = useTranslation(); const { match } = data; const bgColor = isDark ? "#1C1C1E" : "#FFF"; const borderColor = isDark ? "#2C2C2E" : "rgba(0,0,0,0.06)"; const headerTextColor = isDark ? "#666" : "#999"; const textColor = isDark ? "#FFF" : "#000"; const isTennis = match.sportId === 3; const scores = (match.scores as any) || []; const firstPlayer = match.eventFirstPlayer || ""; const secondPlayer = match.eventSecondPlayer || ""; const firstPlayerLogo = match.eventFirstPlayerLogo || ""; const secondPlayerLogo = match.eventSecondPlayerLogo || ""; const hasFirstLogo = firstPlayerLogo && firstPlayerLogo.trim() !== "" && !firstPlayerLogo.includes("placehold"); const hasSecondLogo = secondPlayerLogo && secondPlayerLogo.trim() !== "" && !secondPlayerLogo.includes("placehold"); const firstGradient = getLogoGradient(firstPlayer); const secondGradient = getLogoGradient(secondPlayer); const firstInitials = getInitials(firstPlayer); const secondInitials = getInitials(secondPlayer); const headers = [t("detail.score_table.set") || "Set"]; scores.forEach((_, index) => { headers.push(`${index + 1}`); }); if (scores.length === 0) { headers.push("1"); } return ( {t("detail.score_table.player") || "Player"} {headers.slice(1).map((header, index) => ( {header} ))} {hasFirstLogo ? ( ) : ( {firstInitials} )} {firstPlayer} {scores.length > 0 ? ( scores.map((score: any, index: number) => ( {score.score_first || "0"} )) ) : ( 0 )} {hasSecondLogo ? ( ) : ( {secondInitials} )} {secondPlayer} {scores.length > 0 ? ( scores.map((score: any, index: number) => ( {score.score_second || "0"} )) ) : ( 0 )} ); } const styles = StyleSheet.create({ container: { marginHorizontal: 16, marginTop: 12, borderRadius: 16, borderWidth: 1, overflow: "hidden", }, header: { flexDirection: "row", borderBottomWidth: 1, paddingVertical: 12, paddingHorizontal: 12, }, headerLeft: { flex: 1, minWidth: 120, }, headerCell: { flex: 1, alignItems: "center", justifyContent: "center", minWidth: 40, }, headerText: { fontSize: 12, fontWeight: "600", }, row: { flexDirection: "row", borderBottomWidth: 1, paddingVertical: 12, paddingHorizontal: 12, alignItems: "center", }, playerCell: { flex: 1, flexDirection: "row", alignItems: "center", minWidth: 120, gap: 8, }, playerLogo: { width: 32, height: 32, borderRadius: 16, }, playerLogoGradient: { width: 32, height: 32, borderRadius: 16, alignItems: "center", justifyContent: "center", }, playerLogoText: { fontSize: 10, fontWeight: "700", color: "rgba(255, 255, 255, 0.92)", }, playerName: { flex: 1, fontSize: 13, fontWeight: "600", }, scoreCell: { flex: 1, alignItems: "center", justifyContent: "center", minWidth: 40, }, scoreText: { fontSize: 15, fontWeight: "700", }, });