/* eslint max-len: off */ import React from "react"; import { TVEventHandlerComponent } from "@applicaster/zapp-react-native-tvos-ui-components/Components/TVEventHandlerComponent"; import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks"; import { useIsStandaloneFullscreen } from "@applicaster/zapp-react-native-utils/reactHooks/screen"; export const withTvEventHandler = (Component) => { return function WithTVEventHandler(props) { const navigator = useNavigation(); const isStandaloneFullscreen = useIsStandaloneFullscreen(); const remoteHandler = (event) => { const { eventType } = event; const canGoBack = navigator.canGoBack(); if (eventType === "menu" && isStandaloneFullscreen) { navigator.goHome(); return; } if (eventType === "menu" && canGoBack) { navigator.goBack(); } }; return ( ); }; };