import React, { useRef } from "react"; import { View, TouchableOpacity, ViewStyle, TextStyle, Text, Platform, } from "react-native"; import { FocusableGroup } from "@applicaster/zapp-react-native-ui-components/Components/FocusableGroup"; import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable"; import { focusManager } from "@applicaster/zapp-react-native-utils/focusManager/FocusManager"; type Props = { styles: { button: ViewStyle; focusedButton: ViewStyle; buttonText: TextStyle; focusedText: TextStyle; }; onPress: () => void; text: string; }; export function ButtonTV(props: Props) { const buttonRef = useRef(null); const renderButton = (focused) => { return ( { props?.onPress?.(); }} activeOpacity={1} style={[ props?.styles?.button, focused ? props?.styles?.focusedButton : {}, ]} > {props?.text} ); }; const focusableGroupId = "error_screen_button_group"; const focusableId = "error_screen_button"; React.useEffect(() => { if (buttonRef.current) { focusManager.setFocus(buttonRef); } }, [buttonRef.current]); return Platform.OS !== "android" ? ( props?.onPress?.()} > {(focused) => renderButton(focused)} ) : ( { props?.onPress?.(); }} > {(focused) => renderButton(focused)} ); }