From cfd9d8a30ce7f0ce4f3790196145b2624b7f5e50 Mon Sep 17 00:00:00 2001 From: xianyi Date: Wed, 21 Jan 2026 10:35:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/match-card-league.tsx | 75 +++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 16 deletions(-) diff --git a/components/match-card-league.tsx b/components/match-card-league.tsx index 4180a86..1140560 100644 --- a/components/match-card-league.tsx +++ b/components/match-card-league.tsx @@ -1,6 +1,7 @@ import { ThemedText } from "@/components/themed-text"; import { IconSymbol } from "@/components/ui/icon-symbol"; import { Colors } from "@/constants/theme"; +import { useAppState } from "@/context/AppStateContext"; import { useTheme } from "@/context/ThemeContext"; import { addFavorite, removeFavorite } from "@/lib/api"; import { Match } from "@/types/api"; @@ -29,6 +30,7 @@ export function MatchCardLeague({ }: MatchCardLeagueProps) { const router = useRouter(); const { theme } = useTheme(); + const { state } = useAppState(); const [isFav, setIsFav] = useState(match.fav); const [loading, setLoading] = useState(false); @@ -86,11 +88,21 @@ export function MatchCardLeague({ 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 (m) { + const homeNum = parseInt(m[1], 10); + const awayNum = parseInt(m[2], 10); + return { + home: m[1], + away: m[2], + hasScore: true, + homeLead: Number.isFinite(homeNum) && Number.isFinite(awayNum) && homeNum > awayNum, + awayLead: Number.isFinite(homeNum) && Number.isFinite(awayNum) && awayNum > homeNum, + }; + } 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 }; + return { home: s, away: "", hasScore: true, homeLead: false, awayLead: false }; + if (s === "0 - 0") return { home: "0", away: "0", hasScore: true, homeLead: false, awayLead: false }; + return { home: "", away: "", hasScore: false, homeLead: false, awayLead: false }; }, [match.scoreText]); const { homeRedCards, awayRedCards, homeYellowCards, awayYellowCards } = React.useMemo(() => { @@ -123,6 +135,7 @@ export function MatchCardLeague({ }, [(match as any).stats, (match as any).homeRedCards, (match as any).awayRedCards]); const cardBg = isDark ? "#1C1C1E" : "#F5F5F5"; + const showCards = state.cardsSettings?.enabled !== false; return ( {match.home || match.homeTeamName} - {homeYellowCards > 0 && } - {homeRedCards > 0 && } + {showCards && homeYellowCards > 0 && } + {showCards && homeRedCards > 0 && } @@ -165,8 +178,8 @@ export function MatchCardLeague({ {match.away || match.awayTeamName} - {awayYellowCards > 0 && } - {awayRedCards > 0 && } + {showCards && awayYellowCards > 0 && } + {showCards && awayRedCards > 0 && } @@ -177,18 +190,35 @@ export function MatchCardLeague({ style={[ styles.scoreBox, { - borderColor: isLive ? "#FF9500" : scoreBorder, + borderColor: + scoreParts.homeLead || scoreParts.awayLead ? "#FF9500" : scoreBorder, backgroundColor: scoreBg, }, ]} > - - {scoreParts.home} - - - - {scoreParts.away} - + + + {scoreParts.home} + + + + + + {scoreParts.away} + + ) : ( @@ -292,6 +322,19 @@ const styles = StyleSheet.create({ height: 1, marginVertical: 1, }, + scoreHalf: { + width: "100%", + flex: 1, + alignItems: "center", + justifyContent: "center", + borderRadius: 6, + }, + scoreHalfLead: { + backgroundColor: "rgba(255, 149, 0, 0.12)", + }, + scoreTextLead: { + color: "#FF9500", + }, scoreBoxPlaceholder: { width: 36, height: 54,