diff --git a/app/(auth)/(tabs)/(home)/settings.tsx b/app/(auth)/(tabs)/(home)/settings.tsx index 3c68024f..5b22ba19 100644 --- a/app/(auth)/(tabs)/(home)/settings.tsx +++ b/app/(auth)/(tabs)/(home)/settings.tsx @@ -2,7 +2,7 @@ import { useNavigation, useRouter } from "expo-router"; import { t } from "i18next"; import { useAtom } from "jotai"; import { useEffect } from "react"; -import { ScrollView, TouchableOpacity, View } from "react-native"; +import { Platform, ScrollView, TouchableOpacity, View } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { Text } from "@/components/common/Text"; import { ListGroup } from "@/components/list/ListGroup"; @@ -73,13 +73,13 @@ export default function settings() { - + {!Platform.isTV && } - + {!Platform.isTV && } - + {!Platform.isTV && } ); diff --git a/components/settings/StorageSettings.tsx b/components/settings/StorageSettings.tsx index 02c2ed0a..89f6a2e9 100644 --- a/components/settings/StorageSettings.tsx +++ b/components/settings/StorageSettings.tsx @@ -1,7 +1,6 @@ import { useQuery } from "@tanstack/react-query"; -import * as FileSystem from "expo-file-system"; import { useTranslation } from "react-i18next"; -import { View } from "react-native"; +import { Platform, View } from "react-native"; import { toast } from "sonner-native"; import { Text } from "@/components/common/Text"; import { Colors } from "@/constants/Colors"; @@ -21,10 +20,12 @@ export const StorageSettings = () => { queryFn: async () => { const app = await appSizeUsage(); - const remaining = await FileSystem.getFreeDiskStorageAsync(); - const total = await FileSystem.getTotalDiskCapacityAsync(); - - return { app, remaining, total, used: (total - remaining) / total }; + return { + appSize: app.appSize, + total: app.total, + remaining: app.remaining, + used: (app.total - app.remaining) / app.total, + }; }, }); @@ -39,6 +40,7 @@ export const StorageSettings = () => { }; const calculatePercentage = (value: number, total: number) => { + console.log("usage", value, total); return ((value / total) * 100).toFixed(2); }; @@ -61,13 +63,13 @@ export const StorageSettings = () => { @@ -81,7 +83,7 @@ export const StorageSettings = () => { {t("home.settings.storage.app_usage", { - usedSpace: calculatePercentage(size.app, size.total), + usedSpace: calculatePercentage(size.appSize, size.total), })} @@ -90,7 +92,7 @@ export const StorageSettings = () => { {t("home.settings.storage.device_usage", { availableSpace: calculatePercentage( - size.total - size.remaining - size.app, + size.total - size.remaining - size.appSize, size.total, ), })} @@ -100,13 +102,15 @@ export const StorageSettings = () => { )} - - - + {!Platform.isTV && ( + + + + )} ); }; diff --git a/providers/DownloadProvider.tsx b/providers/DownloadProvider.tsx index 88885f75..7a416890 100644 --- a/providers/DownloadProvider.tsx +++ b/providers/DownloadProvider.tsx @@ -687,7 +687,7 @@ function useDownloadProvider() { appSize += fileInfo.size; } } - return { total, remaining, app: appSize }; + return { total, remaining, appSize: appSize }; }; return { @@ -731,7 +731,7 @@ export function useDownload() { APP_CACHE_DOWNLOAD_DIRECTORY: "", cleanCacheDirectory: async () => {}, updateDownloadedItem: () => {}, - appSizeUsage: async () => ({ total: 0, remaining: 0, app: 0 }), + appSizeUsage: async () => ({ total: 0, remaining: 0, appSize: 0 }), }; }