NoriginMedia / Norigin-Spatial-Navigation

React Hooks based Spatial Navigation (Key & Remote Control Navigation) / Web Browsers, Smart TVs and Connected TVs
MIT License
315 stars 94 forks source link

Demo for android TV #101

Closed jeremies closed 11 months ago

jeremies commented 12 months ago

Does anyone can publish a github repo containing a minimal Demo using Norigin-Spatial-Navigation for AndroidTV?

I am struggling trying to figure out how to code it.

Thanks!

predikament commented 11 months ago

Hello @jeremies.

I assume you are wanting to use react-native in this instance? If so then it should just be a matter of following the example here: https://github.com/NoriginMedia/Norigin-Spatial-Navigation/#using-the-library-in-react-native-environment

Here is an example React Native Android TV project: https://github.com/wouterds/react-native-tv-example, which has several example components you could wrap in the example provided above, f.ex. something similar to the Touchable component.

Perhaps you could elaborate a bit on where you are struggling?

jeremies commented 11 months ago

Hello @predikament.

Yes, you are correct, we want to use react-native in this instance. I have followed the example https://github.com/NoriginMedia/Norigin-Spatial-Navigation/#using-the-library-in-react-native-environment you gave me with an expo blank app (npx create-expo-app NameApp) and it doesn't work.

Here you have the repo: https://github.com/jeremies/demo-norigin-spatial-navigation-androidtv

The important file is App.js: https://github.com/jeremies/demo-norigin-spatial-navigation-androidtv/blob/main/App.js

This demo has two blue buttons that should change to backgroundColor red when focused. But in an AndroidTV simulator doesn't work because the onFocus event never gets called. We can listen the sound when pressing arrow keys but the focus doesn't move.

How can this be fixed?

Thank you!

predikament commented 11 months ago

Hello again @jeremies,

I cannot see that this example is following the documentation quite as intended.

You are missing initializing the actual library.. : https://github.com/NoriginMedia/Norigin-Spatial-Navigation/#init

As well as enabling the native flag which is needed for React Native: https://github.com/NoriginMedia/Norigin-Spatial-Navigation/#nativemode-boolean-default-false

Please make sure to properly read the documentation before opening issues here. Best of luck to you!

jeremies commented 9 months ago

Hello @predikament

Sorry, I have updated the repo https://github.com/jeremies/demo-norigin-spatial-navigation-androidtv with init function, but still doesn't work. Which are the steps that I have to follow to fix it?

Thank you!

guilleccc commented 9 months ago

Hi @jeremies

Sorry, I have updated the repo https://github.com/jeremies/demo-norigin-spatial-navigation-androidtv with init function, but still doesn't work. Which are the steps that I have to follow to fix it?

I believe the problem is that you need to use the react-native-tvos Please look at the example that @predikament has provided above (https://github.com/wouterds/react-native-tv-example).

Just to be clear, we don't include any logic for focusing items natively. When your Android app has received focus on your items, then you can sync it with our library.