diff --git a/TVOSExample/App.tsx b/TVOSExample/App.tsx
index f408f2e79b..ea67c0132a 100644
--- a/TVOSExample/App.tsx
+++ b/TVOSExample/App.tsx
@@ -1,26 +1,3 @@
-import React from 'react';
-import { NavigationContainer } from '@react-navigation/native';
-import { createNativeStackNavigator } from '@react-navigation/native-stack';
-import HomeScreen from './src/HomeScreen';
-import BottomTabsExample from './src/BottomTabsExample';
-import ModalsExample from './src/ModalsExample';
-import NativeStackExample from './src/NativeStackExample';
+import App from '../apps/examples';
-const Stack = createNativeStackNavigator();
-
-export default function App() {
- return (
-
-
-
-
-
-
-
-
- );
-}
+export default App;
diff --git a/TVOSExample/src/BottomTabsExample.tsx b/TVOSExample/src/BottomTabsExample.tsx
deleted file mode 100644
index c306c7a1df..0000000000
--- a/TVOSExample/src/BottomTabsExample.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import React from 'react';
-import { View, Text } from 'react-native';
-import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
-import { STYLES } from './styles';
-
-function Tab1() {
- return (
-
- This is tab 1
-
- );
-}
-
-function Tab2() {
- return (
-
- This is tab 2
-
- );
-}
-
-function Tab3() {
- return (
-
- This is tab 3
-
- );
-}
-
-const Tab = createBottomTabNavigator();
-
-export default function BottomTabsExample() {
- return (
-
-
-
-
-
- );
-}
diff --git a/TVOSExample/src/HomeScreen.tsx b/TVOSExample/src/HomeScreen.tsx
deleted file mode 100644
index 20bb53db2e..0000000000
--- a/TVOSExample/src/HomeScreen.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-import React from 'react';
-import { View, Text, Button } from 'react-native';
-import { EXAMPLES } from './examples';
-import { STYLES } from './styles';
-
-export default function HomeScreen({ navigation }) {
- return (
-
-
- This is the example app created for testing React Native Screens on 📺
-
- Examples:
- {EXAMPLES.map(name => (
-
- );
-}
diff --git a/TVOSExample/src/ModalsExample.tsx b/TVOSExample/src/ModalsExample.tsx
deleted file mode 100644
index 4da9ef2f5e..0000000000
--- a/TVOSExample/src/ModalsExample.tsx
+++ /dev/null
@@ -1,72 +0,0 @@
-import React from 'react';
-import { View, Button } from 'react-native';
-import {
- createNativeStackNavigator,
- NativeStackNavigationProp,
-} from '@react-navigation/native-stack';
-import { STYLES } from './styles';
-
-type StackParamList = {
- Main: undefined;
- Modal: undefined;
- FullscreenModal: undefined;
- Alert: undefined;
-};
-
-interface MainScreenProps {
- navigation: NativeStackNavigationProp;
-}
-
-const MainScreen = ({ navigation }: MainScreenProps): JSX.Element => (
-
-
-);
-
-interface ModalScreenProps {
- navigation: NativeStackNavigationProp;
-}
-
-const ModalScreen = ({ navigation }: ModalScreenProps): JSX.Element => (
-
- navigation.push('Modal')} />
- navigation.push('FullscreenModal')}
- />
- navigation.goBack()} />
-
-);
-
-const Stack = createNativeStackNavigator();
-
-const ModalsExample = (): JSX.Element => (
-
-
-
-
-
-);
-
-export default ModalsExample;
diff --git a/TVOSExample/src/NativeStackExample.tsx b/TVOSExample/src/NativeStackExample.tsx
deleted file mode 100644
index 443fc33152..0000000000
--- a/TVOSExample/src/NativeStackExample.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import React from 'react';
-import { View, Text, Button } from 'react-native';
-import { createNativeStackNavigator } from '@react-navigation/native-stack';
-import { STYLES } from './styles';
-
-function Root({ navigation }) {
- return (
-
- navigation.navigate('First')} />
- navigation.navigate('Second')} />
- navigation.navigate('Third')} />
-
- );
-}
-
-function First({ navigation }) {
- return (
-
- First
- navigation.navigate('Second')} />
- navigation.navigate('Third')} />
-
- );
-}
-
-function Second({ navigation }) {
- return (
-
- Second
- navigation.navigate('Third')} />
-
- );
-}
-
-function Third() {
- return (
-
- Third
-
- );
-}
-
-const Stack = createNativeStackNavigator();
-
-export default function NativeStackExample() {
- return (
-
-
-
-
-
-
- );
-}
diff --git a/TVOSExample/src/examples.ts b/TVOSExample/src/examples.ts
deleted file mode 100644
index 0cdd5e5674..0000000000
--- a/TVOSExample/src/examples.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const EXAMPLES = ['Bottom Tabs', 'Modals', 'Native Stack'] as const;
diff --git a/TVOSExample/src/styles.ts b/TVOSExample/src/styles.ts
deleted file mode 100644
index f613d3fecd..0000000000
--- a/TVOSExample/src/styles.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { StyleSheet } from 'react-native';
-
-export const STYLES = StyleSheet.create({
- screenContainer: {
- flex: 1,
- alignItems: 'center',
- justifyContent: 'center',
- },
-});
diff --git a/TVOSExample/tsconfig.json b/TVOSExample/tsconfig.json
index 304ab4e2d8..3c43903cfd 100644
--- a/TVOSExample/tsconfig.json
+++ b/TVOSExample/tsconfig.json
@@ -1,3 +1,3 @@
{
- "extends": "@react-native/typescript-config/tsconfig.json"
+ "extends": "../tsconfig.json"
}
diff --git a/apps/examples/App.tsx b/apps/examples/App.tsx
index d452f5b80d..dbf8c46757 100644
--- a/apps/examples/App.tsx
+++ b/apps/examples/App.tsx
@@ -43,12 +43,14 @@ const SCREENS: Record<
title: string;
component: () => React.JSX.Element;
type: 'example' | 'playground';
+ isTVOSReady?: boolean;
}
> = {
SimpleNativeStack: {
title: 'Simple Native Stack',
component: SimpleNativeStack,
type: 'example',
+ isTVOSReady: true,
},
SwipeBackAnimation: {
title: 'Swipe Back Animation',
@@ -59,16 +61,19 @@ const SCREENS: Record<
title: 'Stack Presentation',
component: StackPresentation,
type: 'example',
+ isTVOSReady: true,
},
BottomTabsAndStack: {
title: 'Bottom tabs and native stack',
component: BottomTabsAndStack,
type: 'example',
+ isTVOSReady: true,
},
Modals: {
title: 'Modals',
component: Modals,
type: 'example',
+ isTVOSReady: true,
},
HeaderOptions: {
title: 'Header Options',
@@ -107,6 +112,18 @@ const SCREENS: Record<
},
};
+const isPlatformReady = (name: keyof typeof SCREENS) => {
+ if (Platform.isTV) {
+ return !!SCREENS[name].isTVOSReady;
+ }
+
+ return true;
+};
+
+const screens = Object.keys(SCREENS);
+const examples = screens.filter(name => SCREENS[name].type === 'example');
+const playgrounds = screens.filter(name => SCREENS[name].type === 'playground');
+
type RootStackParamList = {
Main: undefined;
} & {
@@ -133,27 +150,25 @@ const MainScreen = ({ navigation }: MainScreenProps): React.JSX.Element => (
Examples
- {Object.keys(SCREENS)
- .filter(name => SCREENS[name].type === 'example')
- .map(name => (
- navigation.navigate(name)}
- />
- ))}
+ {examples.map(name => (
+ navigation.navigate(name)}
+ disabled={!isPlatformReady(name)}
+ />
+ ))}
Playgrounds
- {Object.keys(SCREENS)
- .filter(name => SCREENS[name].type === 'playground')
- .map(name => (
- navigation.navigate(name)}
- />
- ))}
+ {playgrounds.map(name => (
+ navigation.navigate(name)}
+ disabled={!isPlatformReady(name)}
+ />
+ ))}
);
@@ -164,7 +179,11 @@ const ExampleApp = (): React.JSX.Element => (
{Object.keys(SCREENS).map(name => (
diff --git a/apps/examples/src/shared/ListItem.tsx b/apps/examples/src/shared/ListItem.tsx
index bc76bbfcfa..4ea8d82d12 100644
--- a/apps/examples/src/shared/ListItem.tsx
+++ b/apps/examples/src/shared/ListItem.tsx
@@ -5,13 +5,19 @@ interface Props {
title: string;
onPress: () => void;
testID?: string;
+ disabled?: boolean;
}
-export const ListItem = ({ title, onPress, testID }: Props): React.JSX.Element => {
+export const ListItem = ({
+ title,
+ onPress,
+ testID,
+ disabled,
+}: Props): React.JSX.Element => {
return (
-
+
- {title}
+ {disabled && '(N/A) '}{title}
);
@@ -27,6 +33,9 @@ const styles = StyleSheet.create({
borderColor: '#ccc',
borderWidth: 1,
},
+ disabled: {
+ color: 'gray',
+ },
title: {
color: 'black',
},