import { EventsTimeline } from "@/components/live-detail/events-timeline"; import { LiveLeagueInfo } from "@/components/live-detail/live-league-info"; import { LiveMatchTabs } from "@/components/live-detail/live-match-tabs"; import { LiveScoreHeader } from "@/components/live-detail/live-score-header"; import { OddsCard } from "@/components/live-detail/odds-card"; import { OtherInfoCard } from "@/components/live-detail/other-info-card"; import { StatsCard } from "@/components/live-detail/stats-card"; import { ThemedText } from "@/components/themed-text"; import { ThemedView } from "@/components/themed-view"; import { Colors } from "@/constants/theme"; import { useTheme } from "@/context/ThemeContext"; import { fetchLiveScore } from "@/lib/api"; import { LiveScoreMatch } from "@/types/api"; import { useLocalSearchParams } from "expo-router"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { ActivityIndicator, ScrollView, StyleSheet, TouchableOpacity, View, } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; export default function LiveDetailScreen() { const { id, league_id, sport_id } = useLocalSearchParams<{ id: string; league_id: string; sport_id: string; }>(); const { theme } = useTheme(); const { t } = useTranslation(); const insets = useSafeAreaInsets(); const isDark = theme === "dark"; const [loading, setLoading] = useState(true); const [match, setMatch] = useState(null); const [activeTab, setActiveTab] = useState("detail"); // Default to detail to show all data useEffect(() => { loadLiveDetail(); }, [id, league_id]); const loadLiveDetail = async () => { try { setLoading(true); // Fetch live scores for the league const sportId = parseInt(sport_id || "1"); const leagueId = parseInt(league_id || "0"); const liveData = await fetchLiveScore(sportId, leagueId); if (liveData && Array.isArray(liveData)) { // Find the specific match const found = liveData.find((m) => m.event_key.toString() === id); if (found) { setMatch(found); } } } catch (err) { console.error(err); } finally { setLoading(false); } }; if (loading) { return ( ); } if (!match) { return ( {t("detail.not_found")} {t("detail.retry")} ); } const renderTabContent = () => { switch (activeTab) { case "stats": return ; case "odds": return ; case "detail": return ( <> ); default: return ( {t("detail.empty_stats")} ); } }; return ( {renderTabContent()} ); } const styles = StyleSheet.create({ container: { flex: 1, }, center: { flex: 1, justifyContent: "center", alignItems: "center", padding: 20, minHeight: 200, }, retryButton: { marginTop: 20, paddingHorizontal: 20, paddingVertical: 10, backgroundColor: "#007AFF", borderRadius: 8, }, retryText: { color: "#FFF", fontWeight: "600", }, });