Alert and Toasts

This commit is contained in:
Simon Caron
2025-01-01 21:31:04 -05:00
parent 34fc26ed18
commit e833b4bc68
15 changed files with 143 additions and 66 deletions

View File

@@ -17,6 +17,7 @@ import {BottomSheetBackdrop, BottomSheetBackdropProps, BottomSheetModal, BottomS
import {toast} from "sonner-native";
import {writeToLog} from "@/utils/log";
import { useTranslation } from "react-i18next";
import { t } from 'i18next';
export default function page() {
const navigation = useNavigation();
@@ -68,16 +69,16 @@ export default function page() {
}, [downloadedFiles]);
const deleteMovies = () => deleteFileByType("Movie")
.then(() => toast.success("Deleted all movies successfully!"))
.then(() => toast.success(t("home.downloads.toasts.deleted_all_movies_successfully")))
.catch((reason) => {
writeToLog("ERROR", reason);
toast.error("Failed to delete all movies");
toast.error(t("home.downloads.toasts.failed_to_delete_all_movies"));
});
const deleteShows = () => deleteFileByType("Episode")
.then(() => toast.success("Deleted all TV-Series successfully!"))
.then(() => toast.success(t("home.downloads.toasts.deleted_all_tvseries_successfully")))
.catch((reason) => {
writeToLog("ERROR", reason);
toast.error("Failed to delete all TV-Series");
toast.error(t("home.downloads.toasts.failed_to_delete_all_tvseries"));
});
const deleteAllMedia = async () => await Promise.all([deleteMovies(), deleteShows()])
@@ -216,15 +217,15 @@ function migration_20241124() {
const router = useRouter();
const { deleteAllFiles } = useDownload();
Alert.alert(
"New app version requires re-download",
"The new update reqires content to be downloaded again. Please remove all downloaded content and try again.",
t("home.downloads.new_app_version_requires_re_download"),
t("home.downloads.new_app_version_requires_re_download_description"),
[
{
text: "Back",
text: t("home.downloads.back"),
onPress: () => router.back(),
},
{
text: "Delete",
text: t("home.downloads.delete"),
style: "destructive",
onPress: async () => await deleteAllFiles(),
},

View File

@@ -75,7 +75,7 @@ export default function settings() {
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
} catch (e) {
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error);
toast.error("Error deleting files");
toast.error(t("home.settings.toasts.error_deleting_files"));
}
};

View File

@@ -48,11 +48,13 @@ import {
import { useSharedValue } from "react-native-reanimated";
import settings from "../(tabs)/(home)/settings";
import { useSettings } from "@/utils/atoms/settings";
import { useTranslation } from "react-i18next";
export default function page() {
const videoRef = useRef<VlcPlayerViewRef>(null);
const user = useAtomValue(userAtom);
const api = useAtomValue(apiAtom);
const { t } = useTranslation();
const [isPlaybackStopped, setIsPlaybackStopped] = useState(false);
const [showControls, _setShowControls] = useState(true);
@@ -160,7 +162,7 @@ export default function page() {
const { mediaSource, sessionId, url } = res;
if (!sessionId || !mediaSource || !url) {
Alert.alert("Error", "Failed to get stream url");
Alert.alert(t("player.error"), t("player.failed_to_get_stream_url"));
return null;
}
@@ -466,8 +468,8 @@ export default function page() {
onVideoError={(e) => {
console.error("Video Error:", e.nativeEvent);
Alert.alert(
"Error",
"An error occurred while playing the video. Check logs in settings."
t("player.error"),
t("player.an_error_occured_while_playing_the_video")
);
writeToLog("ERROR", "Video Error", e.nativeEvent);
}}

View File

@@ -3,10 +3,12 @@ import { useState, useCallback, useEffect, useMemo } from "react";
import { Button, Dimensions } from "react-native";
import { Alert, View } from "react-native";
import YoutubePlayer, { PLAYER_STATES } from "react-native-youtube-iframe";
import { useTranslation } from "react-i18next";
export default function page() {
const searchParams = useGlobalSearchParams();
const navigation = useNavigation();
const { t } = useTranslation();
console.log(searchParams);
const { url } = searchParams as { url: string };
@@ -20,7 +22,7 @@ export default function page() {
const onStateChange = useCallback((state: PLAYER_STATES) => {
if (state === "ended") {
setPlaying(false);
Alert.alert("video has finished playing!");
Alert.alert(t("player.video_has_finished_playing"));
}
}, []);