-
Notifications
You must be signed in to change notification settings - Fork 40
Add viewRef on SpatialNavigationFocusableView #218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Good idea. Bypassing the lib for native and using it for web makes sense 👍 |
|
There are some type errors. Here's the patch to fix them 😁 diff --git a/packages/example/src/modules/program/view/ProgramNode.tsx b/packages/example/src/modules/program/view/ProgramNode.tsx
index f11ffe5..b502bde 100644
--- a/packages/example/src/modules/program/view/ProgramNode.tsx
+++ b/packages/example/src/modules/program/view/ProgramNode.tsx
@@ -1,9 +1,11 @@
-import { SpatialNavigationFocusableView } from 'react-tv-space-navigation';
+import {
+ SpatialNavigationFocusableView,
+ SpatialNavigationFocusableViewRef,
+} from 'react-tv-space-navigation';
import { ProgramInfo } from '../domain/programInfo';
import { Program } from './Program';
import { forwardRef } from 'react';
-import { SpatialNavigationNodeRef } from '../../../../../lib/src/spatial-navigation/types/SpatialNavigationNodeRef';
import { useRotateAnimation } from './useRotateAnimation';
import { Animated } from 'react-native';
@@ -15,7 +17,7 @@ type Props = {
variant?: 'portrait' | 'landscape';
};
-export const ProgramNode = forwardRef<SpatialNavigationNodeRef, Props>(
+export const ProgramNode = forwardRef<SpatialNavigationFocusableViewRef, Props>(
({ programInfo, onSelect, indexRange, label, variant }: Props, ref) => {
const { rotate360, animatedStyle } = useRotateAnimation();
diff --git a/packages/example/src/pages/GridWithLongNodesPage.tsx b/packages/example/src/pages/GridWithLongNodesPage.tsx
index 6658a8b..da8203f 100644
--- a/packages/example/src/pages/GridWithLongNodesPage.tsx
+++ b/packages/example/src/pages/GridWithLongNodesPage.tsx
@@ -1,5 +1,6 @@
import {
DefaultFocus,
+ SpatialNavigationFocusableViewRef,
SpatialNavigationNode,
SpatialNavigationScrollView,
SpatialNavigationView,
@@ -22,8 +23,8 @@ import { BottomArrow, TopArrow } from '../design-system/components/Arrows';
const HEADER_SIZE = scaledPixels(400);
export const GridWithLongNodesPage = () => {
- const firstItemRef = useRef<SpatialNavigationNodeRef | null>(null);
- const lastItemRef = useRef<SpatialNavigationNodeRef | null>(null);
+ const firstItemRef = useRef<SpatialNavigationFocusableViewRef | null>(null);
+ const lastItemRef = useRef<SpatialNavigationFocusableViewRef | null>(null);
const parentRef = useRef<SpatialNavigationVirtualizedListRef | null>(null);
return (
@@ -73,7 +74,7 @@ export const GridWithLongNodesPage = () => {
);
};
-const FirstRow = forwardRef<SpatialNavigationNodeRef>((_, ref) => {
+const FirstRow = forwardRef<SpatialNavigationFocusableViewRef>((_, ref) => {
return (
<SpatialNavigationNode orientation="horizontal">
<ListContainer>
@@ -93,7 +94,7 @@ const FirstRow = forwardRef<SpatialNavigationNodeRef>((_, ref) => {
});
FirstRow.displayName = 'FirstRow';
-const SecondRow = forwardRef<SpatialNavigationNodeRef>((_, ref) => {
+const SecondRow = forwardRef<SpatialNavigationFocusableViewRef>((_, ref) => {
const programs = programInfos.slice(6, 13);
return (
<SpatialNavigationNode orientation="horizontal"> |
|
@pierpo Fixed the type errors. |
|
I do have the same errors when I rebase the branch to update it with main. |

We intend to use
viewRefto implement accessibility:This way the voice reader will announce the label when the button receives focus.