From e766a833f62ff11fdd4a2fb283217ad3335561dd Mon Sep 17 00:00:00 2001 From: yuchenglong Date: Mon, 19 Jan 2026 15:16:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=AF=94=E8=B5=9B=E5=8D=A1?= =?UTF-8?q?=E7=89=87=E6=98=BE=E7=A4=BA=EF=BC=8C=E6=B7=BB=E5=8A=A0=E7=90=83?= =?UTF-8?q?=E9=98=9F=E5=90=8D=E7=A7=B0=E5=92=8Clogo=EF=BC=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E6=A0=B7=E5=BC=8F=EF=BC=9B=E6=9B=B4=E6=96=B0=E5=AE=9E?= =?UTF-8?q?=E6=97=B6=E6=AF=94=E5=88=86=E5=8A=9F=E8=83=BD=EF=BC=8C=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/(tabs)/index.tsx | 27 ++++++-------- app/(tabs)/live.tsx | 13 ++++--- components/match-card.tsx | 74 ++++++++++++++++++++++++++++----------- 3 files changed, 72 insertions(+), 42 deletions(-) diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx index 3f70b18..89af04f 100644 --- a/app/(tabs)/index.tsx +++ b/app/(tabs)/index.tsx @@ -322,11 +322,6 @@ export default function HomeScreen() { deviceTimeZone, ); - //将isLive全改为true - list.forEach((m) => { - (m as Match).isLive = true; - }); - const normalizeDate = (d: Date) => { const year = d.getFullYear(); const month = String(d.getMonth() + 1).padStart(2, "0"); @@ -340,8 +335,8 @@ export default function HomeScreen() { let merged: Match[] = list.map((m) => ({ ...m, - date: (m as any).date || selectedStr, - sportId: (m as any).sportId ?? sportId, + date: m.date || selectedStr, + sportId: m.sportId ?? sportId, })); if (shouldMergeLive) { @@ -368,10 +363,16 @@ export default function HomeScreen() { return { id, league: item.league_name, + leagueName: item.league_name, + leagueLogo: item.league_logo, time: formatLiveTime(item.event_status, item.event_time), date: item.event_date, home: item.event_home_team, away: item.event_away_team, + homeTeamName: item.event_home_team, + awayTeamName: item.event_away_team, + homeTeamLogo: item.home_team_logo, + awayTeamLogo: item.away_team_logo, scoreText: item.event_final_result || "0 - 0", fav: false, sportId: sportId, @@ -415,18 +416,11 @@ export default function HomeScreen() { ); } - const isLiveRow = (m: Match) => { - const t = (m.time || "").trim(); - return ( - /\d+'$/.test(t) || /^\d{1,3}$/.test(t) || /\b(ht|half)\b/i.test(t) - ); - }; - // 收藏置顶,其次直播置顶 const sortedList = [...listWithFavStatus].sort((a, b) => { if (a.fav !== b.fav) return a.fav ? -1 : 1; - const aLive = isLiveRow(a); - const bLive = isLiveRow(b); + const aLive = !!a.isLive; + const bLive = !!b.isLive; if (aLive !== bLive) return aLive ? -1 : 1; return 0; }); @@ -597,7 +591,6 @@ export default function HomeScreen() { onSelectDate={updateDate} /> )} - ); } diff --git a/app/(tabs)/live.tsx b/app/(tabs)/live.tsx index 5601f13..06f6fc1 100644 --- a/app/(tabs)/live.tsx +++ b/app/(tabs)/live.tsx @@ -42,7 +42,7 @@ export default function LiveScreen() { const liveData = await fetchLiveScore( state.selectedSportId, state.selectedLeagueKey ? parseInt(state.selectedLeagueKey) : undefined, - state.timezone + state.timezone, ); // 检查返回的数据是否为空或无效 @@ -56,9 +56,15 @@ export default function LiveScreen() { const converted: Match[] = liveData.map((item: LiveScoreMatch) => ({ id: item.event_key.toString(), league: item.league_name, + leagueName: item.league_name, + leagueLogo: item.league_logo, time: item.event_time, home: item.event_home_team, away: item.event_away_team, + homeTeamName: item.event_home_team, + awayTeamName: item.event_away_team, + homeTeamLogo: item.home_team_logo, + awayTeamLogo: item.away_team_logo, meta: item.event_status, scoreText: item.event_final_result || "0 - 0", fav: false, @@ -66,7 +72,6 @@ export default function LiveScreen() { sportId: state.selectedSportId ?? undefined, isLive: true, date: item.event_date, - // sport: item.sport_name, })); const token = await storage.getAccessToken(); @@ -83,7 +88,7 @@ export default function LiveScreen() { console.error(`Check favorite failed for match ${m.id}:`, error); return m; } - }) + }), ); } @@ -104,7 +109,7 @@ export default function LiveScreen() { const handleFavoriteToggle = (matchId: string, isFav: boolean) => { setMatches((prev) => { const updated = prev.map((m) => - m.id === matchId ? { ...m, fav: isFav } : m + m.id === matchId ? { ...m, fav: isFav } : m, ); return [...updated].sort((a, b) => { if (a.fav === b.fav) return 0; diff --git a/components/match-card.tsx b/components/match-card.tsx index e6f22d6..9c62d22 100644 --- a/components/match-card.tsx +++ b/components/match-card.tsx @@ -4,6 +4,7 @@ import { Colors } from "@/constants/theme"; import { useTheme } from "@/context/ThemeContext"; import { addFavorite, removeFavorite } from "@/lib/api"; import { Match } from "@/types/api"; +import { Image } from "expo-image"; import { LinearGradient } from "expo-linear-gradient"; import { useRouter } from "expo-router"; import React, { useState } from "react"; @@ -50,17 +51,19 @@ export function MatchCard({ }, [match.time]); const leagueShort = React.useMemo(() => { - const league = (match.league || "").trim(); + const league = (match.leagueName || match.league || "").trim(); if (!league) return "--"; const first = league.split(/[^A-Za-z0-9]+/).filter(Boolean)[0] || league; return first.slice(0, 3).toUpperCase(); - }, [match.league]); + }, [match.leagueName, match.league]); const scoreParts = React.useMemo(() => { const s = (match.scoreText || "").trim(); const m = s.match(/(\d+)\s*[-:]\s*(\d+)/); if (m) return { home: m[1], away: m[2], hasScore: true }; - if (s && s !== "-") return { home: s, away: "", hasScore: true }; + if (s && s !== "-" && s !== "0 - 0") + return { home: s, away: "", hasScore: true }; + if (s === "0 - 0") return { home: "0", away: "0", hasScore: true }; return { home: "", away: "", hasScore: false }; }, [match.scoreText]); @@ -137,22 +140,40 @@ export function MatchCard({ {/* Middle: Teams */} - - {match.home} - - - {match.away} - + + {match.homeTeamLogo ? ( + + ) : null} + + {match.homeTeamName || match.home} + + + + {match.awayTeamLogo ? ( + + ) : null} + + {match.awayTeamName || match.away} + + {/* Right: Score box + favorite */} @@ -235,16 +256,27 @@ const styles = StyleSheet.create({ timeTextLive: { color: "#FF3B30", opacity: 1, + fontWeight: "bold", }, middle: { flex: 1, justifyContent: "center", - gap: 6, + gap: 8, minWidth: 0, }, + teamRow: { + flexDirection: "row", + alignItems: "center", + gap: 8, + }, + teamLogo: { + width: 24, + height: 24, + }, teamLine: { - fontSize: 16, + fontSize: 15, lineHeight: 18, + flex: 1, }, right: { flexDirection: "row",