Skip to content

Commit 1002434

Browse files
committed
Created a new Expo app
0 parents  commit 1002434

29 files changed

+9259
-0
lines changed

.expo-shared/assets.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"e997a5256149a4b76e6bfd6cbf519c5e5a0f1d278a3d8fa1253022b03c90473b": true,
3+
"af683c96e0ffd2cf81287651c9433fa44debc1220ca7cb431fe482747f34a505": true,
4+
"12bb71342c6255bbf50437ec8f4441c083f47cdb74bd89160c15e4f43e52a1cb": true,
5+
"40b842e832070c58deac6aa9e08fa459302ee3f9da492c7e77d93d2fbf4a56fd": true
6+
}

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
node_modules/**/*
2+
.expo/*
3+
npm-debug.*
4+
*.jks
5+
*.p8
6+
*.p12
7+
*.key
8+
*.mobileprovision
9+
*.orig.*
10+
web-build/
11+
12+
# macOS
13+
.DS_Store

App.tsx

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { StatusBar } from 'expo-status-bar';
2+
import React from 'react';
3+
import { SafeAreaProvider } from 'react-native-safe-area-context';
4+
5+
import useCachedResources from './hooks/useCachedResources';
6+
import useColorScheme from './hooks/useColorScheme';
7+
import Navigation from './navigation';
8+
9+
export default function App() {
10+
const isLoadingComplete = useCachedResources();
11+
const colorScheme = useColorScheme();
12+
13+
if (!isLoadingComplete) {
14+
return null;
15+
} else {
16+
return (
17+
<SafeAreaProvider>
18+
<Navigation colorScheme={colorScheme} />
19+
<StatusBar />
20+
</SafeAreaProvider>
21+
);
22+
}
23+
}

app.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"expo": {
3+
"name": "celodapp",
4+
"slug": "celodapp",
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+
"updates": {
16+
"fallbackToCacheTimeout": 0
17+
},
18+
"assetBundlePatterns": [
19+
"**/*"
20+
],
21+
"ios": {
22+
"supportsTablet": true
23+
},
24+
"android": {
25+
"adaptiveIcon": {
26+
"foregroundImage": "./assets/images/adaptive-icon.png",
27+
"backgroundColor": "#FFFFFF"
28+
}
29+
},
30+
"web": {
31+
"favicon": "./assets/images/favicon.png"
32+
}
33+
}
34+
}

assets/fonts/SpaceMono-Regular.ttf

91.1 KB
Binary file not shown.

assets/images/adaptive-icon.png

17.1 KB
Loading

assets/images/favicon.png

1.43 KB
Loading

assets/images/icon.png

21.9 KB
Loading

assets/images/splash.png

47.3 KB
Loading

babel.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = function(api) {
2+
api.cache(true);
3+
return {
4+
presets: ['babel-preset-expo'],
5+
};
6+
};

components/EditScreenInfo.tsx

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import * as WebBrowser from 'expo-web-browser';
2+
import React from 'react';
3+
import { StyleSheet, TouchableOpacity } from 'react-native';
4+
5+
import Colors from '../constants/Colors';
6+
import { MonoText } from './StyledText';
7+
import { Text, View } from './Themed';
8+
9+
export default function EditScreenInfo({ path }: { path: string }) {
10+
return (
11+
<View>
12+
<View style={styles.getStartedContainer}>
13+
<Text
14+
style={styles.getStartedText}
15+
lightColor="rgba(0,0,0,0.8)"
16+
darkColor="rgba(255,255,255,0.8)">
17+
Open up the code for this screen:
18+
</Text>
19+
20+
<View
21+
style={[styles.codeHighlightContainer, styles.homeScreenFilename]}
22+
darkColor="rgba(255,255,255,0.05)"
23+
lightColor="rgba(0,0,0,0.05)">
24+
<MonoText>{path}</MonoText>
25+
</View>
26+
27+
<Text
28+
style={styles.getStartedText}
29+
lightColor="rgba(0,0,0,0.8)"
30+
darkColor="rgba(255,255,255,0.8)">
31+
Change any of the text, save the file, and your app will automatically update.
32+
</Text>
33+
</View>
34+
35+
<View style={styles.helpContainer}>
36+
<TouchableOpacity onPress={handleHelpPress} style={styles.helpLink}>
37+
<Text style={styles.helpLinkText} lightColor={Colors.light.tint}>
38+
Tap here if your app doesn't automatically update after making changes
39+
</Text>
40+
</TouchableOpacity>
41+
</View>
42+
</View>
43+
);
44+
}
45+
46+
function handleHelpPress() {
47+
WebBrowser.openBrowserAsync(
48+
'https://docs.expo.io/get-started/create-a-new-app/#opening-the-app-on-your-phonetablet'
49+
);
50+
}
51+
52+
const styles = StyleSheet.create({
53+
container: {
54+
flex: 1,
55+
backgroundColor: '#fff',
56+
},
57+
developmentModeText: {
58+
marginBottom: 20,
59+
fontSize: 14,
60+
lineHeight: 19,
61+
textAlign: 'center',
62+
},
63+
contentContainer: {
64+
paddingTop: 30,
65+
},
66+
welcomeContainer: {
67+
alignItems: 'center',
68+
marginTop: 10,
69+
marginBottom: 20,
70+
},
71+
welcomeImage: {
72+
width: 100,
73+
height: 80,
74+
resizeMode: 'contain',
75+
marginTop: 3,
76+
marginLeft: -10,
77+
},
78+
getStartedContainer: {
79+
alignItems: 'center',
80+
marginHorizontal: 50,
81+
},
82+
homeScreenFilename: {
83+
marginVertical: 7,
84+
},
85+
codeHighlightText: {
86+
color: 'rgba(96,100,109, 0.8)',
87+
},
88+
codeHighlightContainer: {
89+
borderRadius: 3,
90+
paddingHorizontal: 4,
91+
},
92+
getStartedText: {
93+
fontSize: 17,
94+
lineHeight: 24,
95+
textAlign: 'center',
96+
},
97+
helpContainer: {
98+
marginTop: 15,
99+
marginHorizontal: 20,
100+
alignItems: 'center',
101+
},
102+
helpLink: {
103+
paddingVertical: 15,
104+
},
105+
helpLinkText: {
106+
textAlign: 'center',
107+
},
108+
});

components/StyledText.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as React from 'react';
2+
3+
import { Text, TextProps } from './Themed';
4+
5+
export function MonoText(props: TextProps) {
6+
return <Text {...props} style={[props.style, { fontFamily: 'space-mono' }]} />;
7+
}

components/Themed.tsx

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import * as React from 'react';
2+
import { Text as DefaultText, View as DefaultView } from 'react-native';
3+
4+
import Colors from '../constants/Colors';
5+
import useColorScheme from '../hooks/useColorScheme';
6+
7+
export function useThemeColor(
8+
props: { light?: string; dark?: string },
9+
colorName: keyof typeof Colors.light & keyof typeof Colors.dark
10+
) {
11+
const theme = useColorScheme();
12+
const colorFromProps = props[theme];
13+
14+
if (colorFromProps) {
15+
return colorFromProps;
16+
} else {
17+
return Colors[theme][colorName];
18+
}
19+
}
20+
21+
type ThemeProps = {
22+
lightColor?: string;
23+
darkColor?: string;
24+
};
25+
26+
export type TextProps = ThemeProps & DefaultText['props'];
27+
export type ViewProps = ThemeProps & DefaultView['props'];
28+
29+
export function Text(props: TextProps) {
30+
const { style, lightColor, darkColor, ...otherProps } = props;
31+
const color = useThemeColor({ light: lightColor, dark: darkColor }, 'text');
32+
33+
return <DefaultText style={[{ color }, style]} {...otherProps} />;
34+
}
35+
36+
export function View(props: ViewProps) {
37+
const { style, lightColor, darkColor, ...otherProps } = props;
38+
const backgroundColor = useThemeColor({ light: lightColor, dark: darkColor }, 'background');
39+
40+
return <DefaultView style={[{ backgroundColor }, style]} {...otherProps} />;
41+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as React from 'react';
2+
import renderer from 'react-test-renderer';
3+
4+
import { MonoText } from '../StyledText';
5+
6+
it(`renders correctly`, () => {
7+
const tree = renderer.create(<MonoText>Snapshot test!</MonoText>).toJSON();
8+
9+
expect(tree).toMatchSnapshot();
10+
});

constants/Colors.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const tintColorLight = '#2f95dc';
2+
const tintColorDark = '#fff';
3+
4+
export default {
5+
light: {
6+
text: '#000',
7+
background: '#fff',
8+
tint: tintColorLight,
9+
tabIconDefault: '#ccc',
10+
tabIconSelected: tintColorLight,
11+
},
12+
dark: {
13+
text: '#fff',
14+
background: '#000',
15+
tint: tintColorDark,
16+
tabIconDefault: '#ccc',
17+
tabIconSelected: tintColorDark,
18+
},
19+
};

constants/Layout.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Dimensions } from 'react-native';
2+
3+
const width = Dimensions.get('window').width;
4+
const height = Dimensions.get('window').height;
5+
6+
export default {
7+
window: {
8+
width,
9+
height,
10+
},
11+
isSmallDevice: width < 375,
12+
};

hooks/useCachedResources.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Ionicons } from '@expo/vector-icons';
2+
import * as Font from 'expo-font';
3+
import * as SplashScreen from 'expo-splash-screen';
4+
import * as React from 'react';
5+
6+
export default function useCachedResources() {
7+
const [isLoadingComplete, setLoadingComplete] = React.useState(false);
8+
9+
// Load any resources or data that we need prior to rendering the app
10+
React.useEffect(() => {
11+
async function loadResourcesAndDataAsync() {
12+
try {
13+
SplashScreen.preventAutoHideAsync();
14+
15+
// Load fonts
16+
await Font.loadAsync({
17+
...Ionicons.font,
18+
'space-mono': require('../assets/fonts/SpaceMono-Regular.ttf'),
19+
});
20+
} catch (e) {
21+
// We might want to provide this error information to an error reporting service
22+
console.warn(e);
23+
} finally {
24+
setLoadingComplete(true);
25+
SplashScreen.hideAsync();
26+
}
27+
}
28+
29+
loadResourcesAndDataAsync();
30+
}, []);
31+
32+
return isLoadingComplete;
33+
}

hooks/useColorScheme.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ColorSchemeName, useColorScheme as _useColorScheme } from 'react-native';
2+
3+
// The useColorScheme value is always either light or dark, but the built-in
4+
// type suggests that it can be null. This will not happen in practice, so this
5+
// makes it a bit easier to work with.
6+
export default function useColorScheme(): NonNullable<ColorSchemeName> {
7+
return _useColorScheme() as NonNullable<ColorSchemeName>;
8+
}

hooks/useColorScheme.web.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// useColorScheme from react-native does not support web currently. You can replace
2+
// this with react-native-appearance if you would like theme support on web.
3+
export default function useColorScheme() {
4+
return 'light';
5+
}

0 commit comments

Comments
 (0)