mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-05-03 05:46:28 +01:00
feat(tv): add smart back button handler to prevent unwanted app exit
This commit is contained in:
@@ -12,6 +12,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { Platform, View } from "react-native";
|
||||
import { SystemBars } from "react-native-edge-to-edge";
|
||||
import { Colors } from "@/constants/Colors";
|
||||
import { useTVBackHandler } from "@/hooks/useTVBackHandler";
|
||||
import { useSettings } from "@/utils/atoms/settings";
|
||||
import { eventBus } from "@/utils/eventBus";
|
||||
|
||||
@@ -36,6 +37,9 @@ export default function TabLayout() {
|
||||
const { settings } = useSettings();
|
||||
const { t } = useTranslation();
|
||||
|
||||
// Handle TV back button - prevent app exit when at root
|
||||
useTVBackHandler();
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<SystemBars hidden={false} style='light' />
|
||||
|
||||
@@ -10,6 +10,7 @@ import * as BackgroundTask from "expo-background-task";
|
||||
import * as Device from "expo-device";
|
||||
import { Platform } from "react-native";
|
||||
import { GlobalModal } from "@/components/GlobalModal";
|
||||
import { enableTVMenuKeyInterception } from "@/hooks/useTVBackHandler";
|
||||
|
||||
import i18n from "@/i18n";
|
||||
import { DownloadProvider } from "@/providers/DownloadProvider";
|
||||
@@ -233,6 +234,11 @@ function Layout() {
|
||||
const _segments = useSegments();
|
||||
const router = useRouter();
|
||||
|
||||
// Enable TV menu key interception so React Native handles it instead of tvOS
|
||||
useEffect(() => {
|
||||
enableTVMenuKeyInterception();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
i18n.changeLanguage(
|
||||
settings?.preferedLanguage ?? getLocales()[0].languageCode ?? "en",
|
||||
|
||||
Reference in New Issue
Block a user