优化比赛详情页面和网球力量图组件的代码格式

This commit is contained in:
yuchenglong
2026-01-23 13:43:24 +08:00
parent 0ec996408f
commit dad06dd27d
2 changed files with 35 additions and 21 deletions

View File

@@ -54,14 +54,14 @@ export default function LiveDetailScreen() {
CreatedAt: "", CreatedAt: "",
UpdatedAt: "", UpdatedAt: "",
DeletedAt: null, DeletedAt: null,
eventKey: match.event_key.toString(), eventKey: match.event_key?.toString() || "",
eventDate: match.event_date, eventDate: match.event_date,
eventTime: match.event_time, eventTime: match.event_time,
eventHomeTeam: match.event_home_team, eventHomeTeam: match.event_home_team,
homeTeamKey: match.home_team_key.toString(), homeTeamKey: match.home_team_key?.toString() || "",
homeTeamLogo: match.home_team_logo || "", homeTeamLogo: match.home_team_logo || "",
eventAwayTeam: match.event_away_team, eventAwayTeam: match.event_away_team,
awayTeamKey: match.away_team_key.toString(), awayTeamKey: match.away_team_key?.toString() || "",
awayTeamLogo: match.away_team_logo || "", awayTeamLogo: match.away_team_logo || "",
eventHalftimeResult: match.event_halftime_result || "", eventHalftimeResult: match.event_halftime_result || "",
eventFinalResult: match.event_final_result, eventFinalResult: match.event_final_result,
@@ -70,7 +70,7 @@ export default function LiveDetailScreen() {
eventStatus: match.event_status, eventStatus: match.event_status,
countryName: match.country_name, countryName: match.country_name,
leagueName: match.league_name, leagueName: match.league_name,
leagueKey: match.league_key.toString(), leagueKey: match.league_key?.toString() || "",
leagueRound: match.league_round, leagueRound: match.league_round,
leagueSeason: match.league_season, leagueSeason: match.league_season,
eventLive: match.event_live, eventLive: match.event_live,
@@ -92,16 +92,18 @@ export default function LiveDetailScreen() {
eventManOfMatch: "", eventManOfMatch: "",
scores: match.scores, scores: match.scores,
stats: match.statistics, stats: match.statistics,
players: match.player_statistics ? { players: match.player_statistics
home_team: (match.player_statistics.home_team || []).map(p => ({ ? {
home_team: (match.player_statistics.home_team || []).map((p) => ({
...p, ...p,
player_oncourt: p.player_oncourt || undefined, player_oncourt: p.player_oncourt || undefined,
})), })),
away_team: (match.player_statistics.away_team || []).map(p => ({ away_team: (match.player_statistics.away_team || []).map((p) => ({
...p, ...p,
player_oncourt: p.player_oncourt || undefined, player_oncourt: p.player_oncourt || undefined,
})), })),
} : undefined, }
: undefined,
}, },
}; };
}, [match, sport_id]); }, [match, sport_id]);
@@ -134,7 +136,7 @@ export default function LiveDetailScreen() {
if (liveData && Array.isArray(liveData)) { if (liveData && Array.isArray(liveData)) {
const found = liveData.find((m) => m.event_key.toString() === id); const found = liveData.find((m) => m.event_key.toString() === id);
console.log("found", JSON.stringify(found, null, 2)); // console.log("found", JSON.stringify(found, null, 2));
if (found) { if (found) {
setMatch(found); setMatch(found);
} }
@@ -176,9 +178,16 @@ export default function LiveDetailScreen() {
if (numericSportId === 2 && convertToMatchDetailData) { if (numericSportId === 2 && convertToMatchDetailData) {
switch (activeTab) { switch (activeTab) {
case "stats": case "stats":
return <BasketballStats data={convertToMatchDetailData} isDark={isDark} />; return (
<BasketballStats data={convertToMatchDetailData} isDark={isDark} />
);
case "overall": case "overall":
return <BasketballOverallStats data={convertToMatchDetailData} isDark={isDark} />; return (
<BasketballOverallStats
data={convertToMatchDetailData}
isDark={isDark}
/>
);
case "odds": case "odds":
return ( return (
<OddsCard match={match} isDark={isDark} sportId={numericSportId} /> <OddsCard match={match} isDark={isDark} sportId={numericSportId} />
@@ -186,7 +195,10 @@ export default function LiveDetailScreen() {
case "detail": case "detail":
return ( return (
<> <>
<BasketballScoreTable data={convertToMatchDetailData} isDark={isDark} /> <BasketballScoreTable
data={convertToMatchDetailData}
isDark={isDark}
/>
</> </>
); );
default: default:

View File

@@ -110,7 +110,8 @@ export function TennisPowerGraph({ match, isDark }: TennisPowerGraphProps) {
<View style={styles.contentRow}> <View style={styles.contentRow}>
{/* Sidebar - Avatars */} {/* Sidebar - Avatars */}
<View style={styles.sidebar}> <View style={styles.sidebar}>
<View style={{ flex: 1 }} /> {/* Spacer top */} {/* Spacer top */}
<View style={{ flex: 1 }} />
<View style={styles.avatarContainer}> <View style={styles.avatarContainer}>
{p1Logo ? ( {p1Logo ? (
<Image source={{ uri: p1Logo }} style={styles.avatar} /> <Image source={{ uri: p1Logo }} style={styles.avatar} />
@@ -118,7 +119,7 @@ export function TennisPowerGraph({ match, isDark }: TennisPowerGraphProps) {
<View style={[styles.avatar, { backgroundColor: "#ccc" }]} /> <View style={[styles.avatar, { backgroundColor: "#ccc" }]} />
)} )}
</View> </View>
<View style={{ height: 10 }} />{" "} <View style={{ height: 10 }} />
{/* Gap corresponding to center line if needed, but styling is easier with even spacing */} {/* Gap corresponding to center line if needed, but styling is easier with even spacing */}
<View style={styles.avatarContainer}> <View style={styles.avatarContainer}>
{p2Logo ? ( {p2Logo ? (
@@ -127,7 +128,8 @@ export function TennisPowerGraph({ match, isDark }: TennisPowerGraphProps) {
<View style={[styles.avatar, { backgroundColor: "#ccc" }]} /> <View style={[styles.avatar, { backgroundColor: "#ccc" }]} />
)} )}
</View> </View>
<View style={{ flex: 1 }} /> {/* Spacer bottom */} {/* Spacer bottom */}
<View style={{ flex: 1 }} />
</View> </View>
{/* Scrollable Graph */} {/* Scrollable Graph */}