Skip to content

Commit 9bc432e

Browse files
Update to latest Expo SDK and use Expo Router tabs template
1 parent a369c90 commit 9bc432e

28 files changed

+3841
-4595
lines changed

remove-header-border-react-navigation/.expo-shared/assets.json

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,41 @@
1+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
2+
3+
# dependencies
14
node_modules/
5+
6+
# Expo
27
.expo/
38
dist/
4-
npm-debug.*
9+
web-build/
10+
11+
# Native
12+
*.orig.*
513
*.jks
614
*.p8
715
*.p12
816
*.key
917
*.mobileprovision
10-
*.orig.*
11-
web-build/
18+
19+
# Metro
20+
.metro-health-check*
21+
22+
# debug
23+
npm-debug.*
24+
yarn-debug.*
25+
yarn-error.*
1226

1327
# macOS
1428
.DS_Store
29+
*.pem
30+
31+
# local env files
32+
.env*.local
33+
34+
# typescript
35+
*.tsbuildinfo
36+
37+
# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
38+
# The following patterns were generated by expo-cli
1539

16-
# Misc
17-
article.md
40+
expo-env.d.ts
41+
# @end expo-cli

remove-header-border-react-navigation/App.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

remove-header-border-react-navigation/README.md

Lines changed: 0 additions & 31 deletions
This file was deleted.

remove-header-border-react-navigation/app.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
"resizeMode": "contain",
1313
"backgroundColor": "#ffffff"
1414
},
15-
"updates": {
16-
"fallbackToCacheTimeout": 0
17-
},
1815
"assetBundlePatterns": [
1916
"**/*"
2017
],
@@ -28,7 +25,15 @@
2825
}
2926
},
3027
"web": {
28+
"bundler": "metro",
29+
"output": "static",
3130
"favicon": "./assets/images/favicon.png"
31+
},
32+
"plugins": [
33+
"expo-router"
34+
],
35+
"experiments": {
36+
"typedRoutes": true
3237
}
3338
}
3439
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import FontAwesome from "@expo/vector-icons/FontAwesome";
2+
import { Link, Tabs } from "expo-router";
3+
import { Pressable, useColorScheme } from "react-native";
4+
5+
import Colors from "../../constants/Colors";
6+
7+
/**
8+
* You can explore the built-in icon families and icons on the web at https://icons.expo.fyi/
9+
*/
10+
function TabBarIcon(props: {
11+
name: React.ComponentProps<typeof FontAwesome>["name"];
12+
color: string;
13+
}) {
14+
return <FontAwesome size={28} style={{ marginBottom: -3 }} {...props} />;
15+
}
16+
17+
export default function TabLayout() {
18+
const colorScheme = useColorScheme();
19+
20+
return (
21+
<Tabs
22+
screenOptions={{
23+
tabBarActiveTintColor: Colors[colorScheme ?? "light"].tint,
24+
headerShadowVisible: false,
25+
}}
26+
>
27+
<Tabs.Screen
28+
name="index"
29+
options={{
30+
title: "Tab One",
31+
tabBarIcon: ({ color }) => <TabBarIcon name="code" color={color} />,
32+
headerRight: () => (
33+
<Link href="/modal" asChild>
34+
<Pressable>
35+
{({ pressed }) => (
36+
<FontAwesome
37+
name="info-circle"
38+
size={25}
39+
color={Colors[colorScheme ?? "light"].text}
40+
style={{ marginRight: 15, opacity: pressed ? 0.5 : 1 }}
41+
/>
42+
)}
43+
</Pressable>
44+
</Link>
45+
),
46+
}}
47+
/>
48+
<Tabs.Screen
49+
name="two"
50+
options={{
51+
title: "Tab Two",
52+
tabBarIcon: ({ color }) => <TabBarIcon name="code" color={color} />,
53+
}}
54+
/>
55+
</Tabs>
56+
);
57+
}

remove-header-border-react-navigation/screens/TabOneScreen.tsx renamed to remove-header-border-react-navigation/app/(tabs)/index.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { StyleSheet } from 'react-native';
22

3-
import EditScreenInfo from '../components/EditScreenInfo';
4-
import { Text, View } from '../components/Themed';
5-
import { RootTabScreenProps } from '../types';
3+
import EditScreenInfo from '../../components/EditScreenInfo';
4+
import { Text, View } from '../../components/Themed';
65

7-
export default function TabOneScreen({ navigation }: RootTabScreenProps<'TabOne'>) {
6+
export default function TabOneScreen() {
87
return (
98
<View style={styles.container}>
109
<Text style={styles.title}>Tab One</Text>
1110
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
12-
<EditScreenInfo path="/screens/TabOneScreen.tsx" />
11+
<EditScreenInfo path="app/(tabs)/index.tsx" />
1312
</View>
1413
);
1514
}

remove-header-border-react-navigation/screens/TabTwoScreen.tsx renamed to remove-header-border-react-navigation/app/(tabs)/two.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { StyleSheet } from 'react-native';
22

3-
import EditScreenInfo from '../components/EditScreenInfo';
4-
import { Text, View } from '../components/Themed';
3+
import EditScreenInfo from '../../components/EditScreenInfo';
4+
import { Text, View } from '../../components/Themed';
55

66
export default function TabTwoScreen() {
77
return (
88
<View style={styles.container}>
99
<Text style={styles.title}>Tab Two</Text>
1010
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
11-
<EditScreenInfo path="/screens/TabTwoScreen.tsx" />
11+
<EditScreenInfo path="app/(tabs)/two.tsx" />
1212
</View>
1313
);
1414
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { ScrollViewStyleReset } from 'expo-router/html';
2+
3+
// This file is web-only and used to configure the root HTML for every
4+
// web page during static rendering.
5+
// The contents of this function only run in Node.js environments and
6+
// do not have access to the DOM or browser APIs.
7+
export default function Root({ children }: { children: React.ReactNode }) {
8+
return (
9+
<html lang="en">
10+
<head>
11+
<meta charSet="utf-8" />
12+
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
13+
14+
{/*
15+
This viewport disables scaling which makes the mobile website act more like a native app.
16+
However this does reduce built-in accessibility. If you want to enable scaling, use this instead:
17+
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
18+
*/}
19+
<meta
20+
name="viewport"
21+
content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1.00001,viewport-fit=cover"
22+
/>
23+
{/*
24+
Disable body scrolling on web. This makes ScrollView components work closer to how they do on native.
25+
However, body scrolling is often nice to have for mobile web. If you want to enable it, remove this line.
26+
*/}
27+
<ScrollViewStyleReset />
28+
29+
{/* Using raw CSS styles as an escape-hatch to ensure the background color never flickers in dark-mode. */}
30+
<style dangerouslySetInnerHTML={{ __html: responsiveBackground }} />
31+
{/* Add any additional <head> elements that you want globally available on web... */}
32+
</head>
33+
<body>{children}</body>
34+
</html>
35+
);
36+
}
37+
38+
const responsiveBackground = `
39+
body {
40+
background-color: #fff;
41+
}
42+
@media (prefers-color-scheme: dark) {
43+
body {
44+
background-color: #000;
45+
}
46+
}`;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { Link, Stack } from 'expo-router';
2+
import { StyleSheet } from 'react-native';
3+
4+
import { Text, View } from '../components/Themed';
5+
6+
export default function NotFoundScreen() {
7+
return (
8+
<>
9+
<Stack.Screen options={{ title: 'Oops!' }} />
10+
<View style={styles.container}>
11+
<Text style={styles.title}>This screen doesn't exist.</Text>
12+
13+
<Link href="/" style={styles.link}>
14+
<Text style={styles.linkText}>Go to home screen!</Text>
15+
</Link>
16+
</View>
17+
</>
18+
);
19+
}
20+
21+
const styles = StyleSheet.create({
22+
container: {
23+
flex: 1,
24+
alignItems: 'center',
25+
justifyContent: 'center',
26+
padding: 20,
27+
},
28+
title: {
29+
fontSize: 20,
30+
fontWeight: 'bold',
31+
},
32+
link: {
33+
marginTop: 15,
34+
paddingVertical: 15,
35+
},
36+
linkText: {
37+
fontSize: 14,
38+
color: '#2e78b7',
39+
},
40+
});

0 commit comments

Comments
 (0)