diff --git a/app/(auth)/(tabs)/(home)/_layout.tsx b/app/(auth)/(tabs)/(home)/_layout.tsx index 5bea39a0..763b89c9 100644 --- a/app/(auth)/(tabs)/(home)/_layout.tsx +++ b/app/(auth)/(tabs)/(home)/_layout.tsx @@ -18,19 +18,6 @@ export default function IndexLayout() { headerBlurEffect: "prominent", headerTransparent: Platform.OS === "ios" ? true : false, headerShadowVisible: false, - headerLeft: () => ( - { - router.push("/(auth)/downloads"); - }} - className="p-2" - > - - - ), headerRight: () => ( diff --git a/app/(auth)/(tabs)/(home)/index.tsx b/app/(auth)/(tabs)/(home)/index.tsx index f5b1a68e..62d89b07 100644 --- a/app/(auth)/(tabs)/(home)/index.tsx +++ b/app/(auth)/(tabs)/(home)/index.tsx @@ -5,9 +5,10 @@ import { ScrollingCollectionList } from "@/components/home/ScrollingCollectionLi import { Loader } from "@/components/Loader"; import { MediaListSection } from "@/components/medialists/MediaListSection"; import { TAB_HEIGHT } from "@/constants/Values"; +import { useDownload } from "@/providers/DownloadProvider"; import { apiAtom, userAtom } from "@/providers/JellyfinProvider"; import { useSettings } from "@/utils/atoms/settings"; -import { Ionicons } from "@expo/vector-icons"; +import { Feather, Ionicons } from "@expo/vector-icons"; import { Api } from "@jellyfin/sdk"; import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models"; import { @@ -17,9 +18,10 @@ import { getUserLibraryApi, getUserViewsApi, } from "@jellyfin/sdk/lib/utils/api"; +import AsyncStorage from "@react-native-async-storage/async-storage"; import NetInfo from "@react-native-community/netinfo"; import { useQuery, useQueryClient } from "@tanstack/react-query"; -import { useRouter } from "expo-router"; +import { useNavigation, useRouter } from "expo-router"; import { useAtom } from "jotai"; import { useCallback, useEffect, useMemo, useState } from "react"; import { @@ -27,6 +29,7 @@ import { Platform, RefreshControl, ScrollView, + TouchableOpacity, View, } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; @@ -61,6 +64,7 @@ export default function index() { const [isConnected, setIsConnected] = useState(null); const [loadingRetry, setLoadingRetry] = useState(false); + const navigation = useNavigation(); const checkConnection = useCallback(async () => { setLoadingRetry(true); @@ -69,6 +73,27 @@ export default function index() { setLoadingRetry(false); }, []); + const { downloadedFiles } = useDownload(); + + useEffect(() => { + const color = + downloadedFiles && downloadedFiles?.length > 0 ? "#9334E9" : "white"; + navigation.setOptions({ + headerLeft: () => ( + { + router.push("/(auth)/downloads"); + }} + > + + + ), + }); + }, [downloadedFiles, navigation]); + useEffect(() => { const unsubscribe = NetInfo.addEventListener((state) => { if (state.isConnected == false || state.isInternetReachable === false)