Add viewRef on SpatialNavigationFocusableView#218
Open
aistrate wants to merge 3 commits intobamlab:mainfrom
Open
Add viewRef on SpatialNavigationFocusableView#218aistrate wants to merge 3 commits intobamlab:mainfrom
aistrate wants to merge 3 commits intobamlab:mainfrom
Conversation
Member
|
Good idea. Bypassing the lib for native and using it for web makes sense 👍 |
Member
|
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"> |
Author
|
@pierpo Fixed the type errors. |
Member
Member
|
I do have the same errors when I rebase the branch to update it with main. |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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