Skip to content

Commit ac8e621

Browse files
committed
fix compilation error on web apps
1 parent d0a5f15 commit ac8e621

30 files changed

Lines changed: 18292 additions & 7 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.6
2+
3+
- fix compilation error on web apps
4+
15
## 0.3.5
26

37
- better version of the session id generator
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
2+
3+
# dependencies
4+
node_modules/
5+
6+
# Expo
7+
.expo/
8+
dist/
9+
web-build/
10+
11+
# Native
12+
*.orig.*
13+
*.jks
14+
*.p8
15+
*.p12
16+
*.key
17+
*.mobileprovision
18+
19+
# Metro
20+
.metro-health-check*
21+
22+
# debug
23+
npm-debug.*
24+
yarn-debug.*
25+
yarn-error.*
26+
27+
# macOS
28+
.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
39+
40+
expo-env.d.ts
41+
# @end expo-cli
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"expo": {
3+
"name": "HelloWorldExpoRouter",
4+
"slug": "HelloWorldExpoRouter",
5+
"version": "1.0.0",
6+
"orientation": "portrait",
7+
"icon": "./assets/images/icon.png",
8+
"scheme": "myapp",
9+
"userInterfaceStyle": "automatic",
10+
"splash": {
11+
"image": "./assets/images/splash.png",
12+
"resizeMode": "contain",
13+
"backgroundColor": "#ffffff"
14+
},
15+
"assetBundlePatterns": [
16+
"**/*"
17+
],
18+
"ios": {
19+
"supportsTablet": true
20+
},
21+
"android": {
22+
"adaptiveIcon": {
23+
"foregroundImage": "./assets/images/adaptive-icon.png",
24+
"backgroundColor": "#ffffff"
25+
}
26+
},
27+
"web": {
28+
"bundler": "metro",
29+
"output": "static",
30+
"favicon": "./assets/images/favicon.png"
31+
},
32+
"plugins": [
33+
"expo-router"
34+
],
35+
"experiments": {
36+
"typedRoutes": true
37+
}
38+
}
39+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
}}>
25+
<Tabs.Screen
26+
name="index"
27+
options={{
28+
title: 'Tab One',
29+
tabBarIcon: ({ color }) => <TabBarIcon name="code" color={color} />,
30+
headerRight: () => (
31+
<Link href="/modal" asChild>
32+
<Pressable>
33+
{({ pressed }) => (
34+
<FontAwesome
35+
name="info-circle"
36+
size={25}
37+
color={Colors[colorScheme ?? 'light'].text}
38+
style={{ marginRight: 15, opacity: pressed ? 0.5 : 1 }}
39+
/>
40+
)}
41+
</Pressable>
42+
</Link>
43+
),
44+
}}
45+
/>
46+
<Tabs.Screen
47+
name="two"
48+
options={{
49+
title: 'Tab Two',
50+
tabBarIcon: ({ color }) => <TabBarIcon name="code" color={color} />,
51+
}}
52+
/>
53+
</Tabs>
54+
);
55+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { StyleSheet } from 'react-native';
2+
3+
import EditScreenInfo from '../../components/EditScreenInfo';
4+
import { Text, View } from '../../components/Themed';
5+
6+
export default function TabOneScreen() {
7+
return (
8+
<View style={styles.container}>
9+
<Text style={styles.title}>Tab One</Text>
10+
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
11+
<EditScreenInfo path="app/(tabs)/index.tsx" />
12+
</View>
13+
);
14+
}
15+
16+
const styles = StyleSheet.create({
17+
container: {
18+
flex: 1,
19+
alignItems: 'center',
20+
justifyContent: 'center',
21+
},
22+
title: {
23+
fontSize: 20,
24+
fontWeight: 'bold',
25+
},
26+
separator: {
27+
marginVertical: 30,
28+
height: 1,
29+
width: '80%',
30+
},
31+
});
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { StyleSheet } from 'react-native';
2+
3+
import EditScreenInfo from '../../components/EditScreenInfo';
4+
import { Text, View } from '../../components/Themed';
5+
6+
export default function TabTwoScreen() {
7+
return (
8+
<View style={styles.container}>
9+
<Text style={styles.title}>Tab Two</Text>
10+
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
11+
<EditScreenInfo path="app/(tabs)/two.tsx" />
12+
</View>
13+
);
14+
}
15+
16+
const styles = StyleSheet.create({
17+
container: {
18+
flex: 1,
19+
alignItems: 'center',
20+
justifyContent: 'center',
21+
},
22+
title: {
23+
fontSize: 20,
24+
fontWeight: 'bold',
25+
},
26+
separator: {
27+
marginVertical: 30,
28+
height: 1,
29+
width: '80%',
30+
},
31+
});
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+
});
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import FontAwesome from "@expo/vector-icons/FontAwesome";
2+
import {
3+
DarkTheme,
4+
DefaultTheme,
5+
ThemeProvider,
6+
} from "@react-navigation/native";
7+
import { useFonts } from "expo-font";
8+
import { SplashScreen, Stack } from "expo-router";
9+
import { useEffect } from "react";
10+
import { useColorScheme } from "react-native";
11+
import { init, trackEvent } from "@aptabase/react-native";
12+
13+
export {
14+
// Catch any errors thrown by the Layout component.
15+
ErrorBoundary,
16+
} from "expo-router";
17+
18+
export const unstable_settings = {
19+
// Ensure that reloading on `/modal` keeps a back button present.
20+
initialRouteName: "(tabs)",
21+
};
22+
23+
// Prevent the splash screen from auto-hiding before asset loading is complete.
24+
SplashScreen.preventAutoHideAsync();
25+
26+
export default function RootLayout() {
27+
const [loaded, error] = useFonts({
28+
SpaceMono: require("../assets/fonts/SpaceMono-Regular.ttf"),
29+
...FontAwesome.font,
30+
});
31+
32+
// Expo Router uses Error Boundaries to catch errors in the navigation tree.
33+
useEffect(() => {
34+
if (error) throw error;
35+
}, [error]);
36+
37+
useEffect(() => {
38+
if (loaded) {
39+
SplashScreen.hideAsync();
40+
}
41+
}, [loaded]);
42+
43+
if (!loaded) {
44+
return null;
45+
}
46+
47+
return <RootLayoutNav />;
48+
}
49+
50+
function RootLayoutNav() {
51+
const colorScheme = useColorScheme();
52+
53+
return (
54+
<ThemeProvider value={colorScheme === "dark" ? DarkTheme : DefaultTheme}>
55+
<Stack>
56+
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
57+
<Stack.Screen name="modal" options={{ presentation: "modal" }} />
58+
</Stack>
59+
</ThemeProvider>
60+
);
61+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { StatusBar } from 'expo-status-bar';
2+
import { Platform, StyleSheet } from 'react-native';
3+
4+
import EditScreenInfo from '../components/EditScreenInfo';
5+
import { Text, View } from '../components/Themed';
6+
7+
export default function ModalScreen() {
8+
return (
9+
<View style={styles.container}>
10+
<Text style={styles.title}>Modal</Text>
11+
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
12+
<EditScreenInfo path="app/modal.tsx" />
13+
14+
{/* Use a light status bar on iOS to account for the black space above the modal */}
15+
<StatusBar style={Platform.OS === 'ios' ? 'light' : 'auto'} />
16+
</View>
17+
);
18+
}
19+
20+
const styles = StyleSheet.create({
21+
container: {
22+
flex: 1,
23+
alignItems: 'center',
24+
justifyContent: 'center',
25+
},
26+
title: {
27+
fontSize: 20,
28+
fontWeight: 'bold',
29+
},
30+
separator: {
31+
marginVertical: 30,
32+
height: 1,
33+
width: '80%',
34+
},
35+
});

0 commit comments

Comments
 (0)