Skip to content

Commit 2ee78d8

Browse files
authored
feat: add pages to the example app (#2)
* feat: use navigation visualizer * feat: add new pages to the example app
1 parent b5475d2 commit 2ee78d8

File tree

18 files changed

+290
-4
lines changed

18 files changed

+290
-4
lines changed

apps/example/src/app/_layout.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { useReactNavigationDevTools } from '@dev-plugins/react-navigation';
1+
import { useReactNavigationDevTools } from '@bam.tech/react-navigation-visualizer-dev-plugin';
22
import FontAwesome from '@expo/vector-icons/FontAwesome';
33
import { useFonts } from 'expo-font';
4-
import { SplashScreen, Stack } from 'expo-router';
5-
import { useEffect } from 'react';
6-
import { useNavigationContainerRef } from 'expo-router';
4+
import { SplashScreen, Stack, useNavigationContainerRef } from 'expo-router';
75
import { StatusBar } from 'expo-status-bar';
6+
import { useEffect } from 'react';
87

98
export {
109
// Catch any errors thrown by the Layout component.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Tabs, usePathname } from 'expo-router';
2+
3+
export default function TabLayout() {
4+
const path = usePathname();
5+
console.log('TabLayout', path);
6+
7+
return <Tabs />;
8+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Button } from '@/components/ Button';
2+
import { Spacer } from '@/components/Spacer';
3+
import { useRouter } from 'expo-router';
4+
import { Text, View } from 'react-native';
5+
6+
export default function Cards() {
7+
const router = useRouter();
8+
9+
return (
10+
<View>
11+
<Text>Cards</Text>
12+
<Button onPress={router.back} text="Go back" />
13+
<Spacer />
14+
<Button
15+
onPress={() => router.navigate('/example-stack/a-stack/a-stack-page-1')}
16+
text="Go to a stack page 1"
17+
/>
18+
<Spacer />
19+
<Button onPress={() => router.navigate('/example-stack/(tabs)/home')} text="Go to home" />
20+
</View>
21+
);
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Button } from '@/components/ Button';
2+
import { Spacer } from '@/components/Spacer';
3+
import { useRouter } from 'expo-router';
4+
import { Text, View } from 'react-native';
5+
6+
export default function Home() {
7+
const router = useRouter();
8+
9+
return (
10+
<View>
11+
<Text>Home</Text>
12+
<Button onPress={router.back} text="Go back" />
13+
<Spacer />
14+
<Button
15+
onPress={() => router.navigate('/example-stack/a-stack/a-stack-page-1')}
16+
text="Go to a stack page 1"
17+
/>
18+
<Spacer />
19+
<Button onPress={() => router.navigate('/example-stack/(tabs)/cards')} text="Go to cards" />
20+
</View>
21+
);
22+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { Stack } from 'expo-router';
2+
3+
export default function ExampleStackLayout() {
4+
return <Stack />;
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { Stack } from 'expo-router';
2+
3+
export default function AStackLayout() {
4+
return <Stack initialRouteName="a-stack-page-1" />;
5+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Button } from '@/components/ Button';
2+
import { Spacer } from '@/components/Spacer';
3+
import { useRouter } from 'expo-router';
4+
import { Text, View } from 'react-native';
5+
6+
export default function AStackPage1() {
7+
const router = useRouter();
8+
9+
return (
10+
<View>
11+
<Text>A Stack Page 1</Text>
12+
<Button onPress={router.back} text="Go back" />
13+
<Spacer />
14+
<Button
15+
onPress={() => router.navigate('/example-stack/a-stack/a-stack-page-2')}
16+
text="Go to page 2"
17+
/>
18+
<Spacer />
19+
<Button onPress={() => router.replace('/example-stack/(tabs)/home')} text="Go to home" />
20+
</View>
21+
);
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Button } from '@/components/ Button';
2+
import { Spacer } from '@/components/Spacer';
3+
import { useRouter } from 'expo-router';
4+
import { Text, View } from 'react-native';
5+
6+
export default function AStackPage2() {
7+
const router = useRouter();
8+
9+
return (
10+
<View>
11+
<Text>A Stack Page 2</Text>
12+
<Button onPress={router.back} text="Go back" />
13+
<Spacer />
14+
<Button
15+
onPress={() => router.navigate('/example-stack/a-stack/page-3')}
16+
text="Go to page 3"
17+
/>
18+
</View>
19+
);
20+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Button } from '@/components/ Button';
2+
import { Spacer } from '@/components/Spacer';
3+
import { useRouter } from 'expo-router';
4+
import { Text, View } from 'react-native';
5+
6+
export default function Page3() {
7+
const router = useRouter();
8+
return (
9+
<View>
10+
<Text>Page 3 in the first stack</Text>
11+
<Button onPress={router.back} text="Go back" />
12+
<Spacer />
13+
<Button
14+
onPress={() => router.navigate('/example-stack/another-stack/another-stack-page-1')}
15+
text="Go to second stack page 1"
16+
/>
17+
</View>
18+
);
19+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { Stack } from 'expo-router';
2+
3+
export default function AnotherStackLayout() {
4+
return <Stack />;
5+
}

0 commit comments

Comments
 (0)