feat: settings toggle for safe areas in controls

This commit is contained in:
Fredrik Burmester
2024-12-23 10:26:15 +01:00
parent 8608ad02f7
commit dd09f3d4d9
4 changed files with 49 additions and 41 deletions

View File

@@ -2,18 +2,18 @@ import { Button } from "@/components/Button";
import { Text } from "@/components/common/Text";
import { ListItem } from "@/components/ListItem";
import { SettingToggles } from "@/components/settings/SettingToggles";
import {bytesToReadable, useDownload} from "@/providers/DownloadProvider";
import { bytesToReadable, useDownload } from "@/providers/DownloadProvider";
import { apiAtom, useJellyfin, userAtom } from "@/providers/JellyfinProvider";
import {clearLogs, useLog} from "@/utils/log";
import { clearLogs, useLog } from "@/utils/log";
import { getQuickConnectApi } from "@jellyfin/sdk/lib/utils/api";
import { useQuery } from "@tanstack/react-query";
import * as FileSystem from "expo-file-system";
import * as Haptics from "expo-haptics";
import { useAtom } from "jotai";
import {Alert, ScrollView, View} from "react-native";
import { Alert, ScrollView, View } from "react-native";
import * as Progress from "react-native-progress";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { toast } from "sonner-native";
import * as Progress from 'react-native-progress';
import * as FileSystem from "expo-file-system";
export default function settings() {
const { logout } = useJellyfin();
@@ -25,17 +25,17 @@ export default function settings() {
const insets = useSafeAreaInsets();
const {data: size , isLoading: appSizeLoading } = useQuery({
const { data: size, isLoading: appSizeLoading } = useQuery({
queryKey: ["appSize", appSizeUsage],
queryFn: async () => {
const app = await appSizeUsage
const app = await appSizeUsage;
const remaining = await FileSystem.getFreeDiskStorageAsync()
const total = await FileSystem.getTotalDiskCapacityAsync()
const remaining = await FileSystem.getFreeDiskStorageAsync();
const total = await FileSystem.getTotalDiskCapacityAsync();
return {app, remaining, total, used: (total - remaining) / total}
}
})
return { app, remaining, total, used: (total - remaining) / total };
},
});
const openQuickConnectAuthCodeInput = () => {
Alert.prompt(
@@ -69,22 +69,16 @@ export default function settings() {
const onDeleteClicked = async () => {
try {
await deleteAllFiles();
Haptics.notificationAsync(
Haptics.NotificationFeedbackType.Success
);
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
} catch (e) {
Haptics.notificationAsync(
Haptics.NotificationFeedbackType.Error
);
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error);
toast.error("Error deleting files");
}
}
};
const onClearLogsClicked = async () => {
clearLogs();
Haptics.notificationAsync(
Haptics.NotificationFeedbackType.Success
);
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
};
return (
@@ -140,19 +134,16 @@ export default function settings() {
progress={size?.used}
/>
{size && (
<Text>Available: {bytesToReadable(size.remaining)}, Total: {bytesToReadable(size.total)}</Text>
<Text>
Available: {bytesToReadable(size.remaining)}, Total:{" "}
{bytesToReadable(size.total)}
</Text>
)}
</View>
<Button
color="red"
onPress={onDeleteClicked}
>
<Button color="red" onPress={onDeleteClicked}>
Delete all downloaded files
</Button>
<Button
color="red"
onPress={onClearLogsClicked}
>
<Button color="red" onPress={onClearLogsClicked}>
Delete all logs
</Button>
</View>