From 1842cf93fb5b7dba16e750d5d6060aca6d2a8574 Mon Sep 17 00:00:00 2001 From: yuchenglong Date: Wed, 21 Jan 2026 10:09:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=8B=E6=8B=89=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BC=98=E5=8C=96=E6=AF=94?= =?UTF-8?q?=E8=B5=9B=E5=8A=A0=E8=BD=BD=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 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx index c18ef58..03ef8f2 100644 --- a/app/(tabs)/index.tsx +++ b/app/(tabs)/index.tsx @@ -24,6 +24,7 @@ import { useTranslation } from "react-i18next"; import { ActivityIndicator, FlatList, + RefreshControl, StyleSheet, TouchableOpacity, View, @@ -44,6 +45,7 @@ export default function HomeScreen() { const [leagues, setLeagues] = useState([]); const [matches, setMatches] = useState([]); const [loading, setLoading] = useState(true); + const [refreshing, setRefreshing] = useState(false); const [loadingLeagues, setLoadingLeagues] = useState(false); const [now, setNow] = useState(() => new Date()); const [liveLeagueIdByMatchId, setLiveLeagueIdByMatchId] = useState< @@ -321,8 +323,8 @@ export default function HomeScreen() { } }; - const loadMatches = async (sportId: number) => { - setLoading(true); + const loadMatches = async (sportId: number, isRefresh = false) => { + if (!isRefresh) setLoading(true); try { const res = await fetchTodayMatches({ sportId, @@ -441,10 +443,17 @@ export default function HomeScreen() { } catch (e) { console.error(e); } finally { - setLoading(false); + if (!isRefresh) setLoading(false); } }; + const onRefresh = async () => { + if (!selectedSportId) return; + setRefreshing(true); + await loadMatches(selectedSportId, true); + setRefreshing(false); + }; + const loadMoreMatches = async () => { if (loadingMore || loading) return; if (!selectedSportId) return; @@ -604,6 +613,9 @@ export default function HomeScreen() { renderItem={({ item }) => ( )} + refreshControl={ + + } onEndReached={loadMoreMatches} onEndReachedThreshold={0.4} ListFooterComponent={