Skip to content

Commit 33be96f

Browse files
committed
Init app
0 parents  commit 33be96f

24 files changed

+10341
-0
lines changed

.expo-shared/assets.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"7adc6cdde1172c646f8dda7fcb1186d148e59e6d2a40774bd7e03281a653f19c": true,
3+
"796951473c719ad8e46b7b70380efd80d26df0c11d3469d6212a56e8ef71cc18": true,
4+
"dd783a7cbdbb29800782f11af86c80df4961140b1a280481f64df031e2ea0ff9": true,
5+
"89ed26367cdb9b771858e026f2eb95bfdb90e5ae943e716575327ec325f39c44": true
6+
}

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/**/*
2+
.expo/*
3+
npm-debug.*
4+
*.jks
5+
*.p12
6+
*.key
7+
*.mobileprovision

.watchmanconfig

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

App.js

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import React from 'react';
2+
import { Platform, StatusBar, StyleSheet, View } from 'react-native';
3+
import { AppLoading, Asset, Font, Icon } from 'expo';
4+
import AppNavigator from './navigation/AppNavigator';
5+
6+
export default class App extends React.Component {
7+
state = {
8+
isLoadingComplete: false,
9+
};
10+
11+
render() {
12+
if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
13+
return (
14+
<AppLoading
15+
startAsync={this._loadResourcesAsync}
16+
onError={this._handleLoadingError}
17+
onFinish={this._handleFinishLoading}
18+
/>
19+
);
20+
} else {
21+
return (
22+
<View style={styles.container}>
23+
{Platform.OS === 'ios' && <StatusBar barStyle="default" />}
24+
<AppNavigator />
25+
</View>
26+
);
27+
}
28+
}
29+
30+
_loadResourcesAsync = async () => {
31+
return Promise.all([
32+
Asset.loadAsync([
33+
require('./assets/images/robot-dev.png'),
34+
require('./assets/images/robot-prod.png'),
35+
]),
36+
Font.loadAsync({
37+
// This is the font that we are using for our tab bar
38+
...Icon.Ionicons.font,
39+
// We include SpaceMono because we use it in HomeScreen.js. Feel free
40+
// to remove this if you are not using it in your app
41+
'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
42+
}),
43+
]);
44+
};
45+
46+
_handleLoadingError = error => {
47+
// In this case, you might want to report the error to your error
48+
// reporting service, for example Sentry
49+
console.warn(error);
50+
};
51+
52+
_handleFinishLoading = () => {
53+
this.setState({ isLoadingComplete: true });
54+
};
55+
}
56+
57+
const styles = StyleSheet.create({
58+
container: {
59+
flex: 1,
60+
backgroundColor: '#fff',
61+
},
62+
});

__tests__/App-test.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import 'react-native';
2+
import React from 'react';
3+
import App from '../App';
4+
import renderer from 'react-test-renderer';
5+
import NavigationTestUtils from 'react-navigation/NavigationTestUtils';
6+
7+
describe('App snapshot', () => {
8+
jest.useFakeTimers();
9+
beforeEach(() => {
10+
NavigationTestUtils.resetInternalState();
11+
});
12+
13+
it('renders the loading screen', async () => {
14+
const tree = renderer.create(<App />).toJSON();
15+
expect(tree).toMatchSnapshot();
16+
});
17+
18+
it('renders the root without loading screen', async () => {
19+
const tree = renderer.create(<App skipLoadingScreen />).toJSON();
20+
expect(tree).toMatchSnapshot();
21+
});
22+
});

app.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"expo": {
3+
"name": "Maestro Travel",
4+
"slug": "react-native-app",
5+
"privacy": "public",
6+
"sdkVersion": "32.0.0",
7+
"platforms": [
8+
"ios",
9+
"android"
10+
],
11+
"version": "1.0.0",
12+
"orientation": "portrait",
13+
"icon": "./assets/images/icon.png",
14+
"splash": {
15+
"image": "./assets/images/splash.png",
16+
"resizeMode": "contain",
17+
"backgroundColor": "#ffffff"
18+
},
19+
"updates": {
20+
"fallbackToCacheTimeout": 0
21+
},
22+
"assetBundlePatterns": [
23+
"**/*"
24+
],
25+
"ios": {
26+
"supportsTablet": true
27+
},
28+
"description": ""
29+
}
30+
}

assets/fonts/SpaceMono-Regular.ttf

91.1 KB
Binary file not shown.

assets/images/icon.png

1.47 KB
Loading

assets/images/robot-dev.png

10.3 KB
Loading

assets/images/robot-prod.png

9.5 KB
Loading

assets/images/splash.png

7.01 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/StyledText.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react';
2+
import { Text } from 'react-native';
3+
4+
export class MonoText extends React.Component {
5+
render() {
6+
return <Text {...this.props} style={[this.props.style, { fontFamily: 'space-mono' }]} />;
7+
}
8+
}

components/TabBarIcon.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
import { Icon } from 'expo';
3+
4+
import Colors from '../constants/Colors';
5+
6+
export default class TabBarIcon extends React.Component {
7+
render() {
8+
return (
9+
<Icon.Ionicons
10+
name={this.props.name}
11+
size={26}
12+
style={{ marginBottom: -3 }}
13+
color={this.props.focused ? Colors.tabIconSelected : Colors.tabIconDefault}
14+
/>
15+
);
16+
}
17+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import 'react-native';
2+
import React from 'react';
3+
import { MonoText } from '../StyledText';
4+
import renderer from 'react-test-renderer';
5+
6+
it('renders correctly', () => {
7+
const tree = renderer.create(<MonoText>Snapshot test!</MonoText>).toJSON();
8+
9+
expect(tree).toMatchSnapshot();
10+
});

constants/Colors.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const tintColor = '#2f95dc';
2+
3+
export default {
4+
tintColor,
5+
tabIconDefault: '#ccc',
6+
tabIconSelected: tintColor,
7+
tabBar: '#fefefe',
8+
errorBackground: 'red',
9+
errorText: '#fff',
10+
warningBackground: '#EAEB5E',
11+
warningText: '#666804',
12+
noticeBackground: tintColor,
13+
noticeText: '#fff',
14+
};

constants/Layout.js

+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+
};

navigation/AppNavigator.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
import { createAppContainer, createSwitchNavigator } from 'react-navigation';
3+
4+
import MainTabNavigator from './MainTabNavigator';
5+
6+
export default createAppContainer(createSwitchNavigator({
7+
// You could add another route here for authentication.
8+
// Read more at https://reactnavigation.org/docs/en/auth-flow.html
9+
Main: MainTabNavigator,
10+
}));

navigation/MainTabNavigator.js

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import React from 'react';
2+
import { Platform } from 'react-native';
3+
import { createStackNavigator, createBottomTabNavigator } from 'react-navigation';
4+
5+
import TabBarIcon from '../components/TabBarIcon';
6+
import HomeScreen from '../screens/HomeScreen';
7+
import LinksScreen from '../screens/LinksScreen';
8+
import SettingsScreen from '../screens/SettingsScreen';
9+
10+
const HomeStack = createStackNavigator({
11+
Home: HomeScreen,
12+
});
13+
14+
HomeStack.navigationOptions = {
15+
tabBarLabel: 'Home',
16+
tabBarIcon: ({ focused }) => (
17+
<TabBarIcon
18+
focused={focused}
19+
name={
20+
Platform.OS === 'ios'
21+
? `ios-information-circle${focused ? '' : '-outline'}`
22+
: 'md-information-circle'
23+
}
24+
/>
25+
),
26+
};
27+
28+
const LinksStack = createStackNavigator({
29+
Links: LinksScreen,
30+
});
31+
32+
LinksStack.navigationOptions = {
33+
tabBarLabel: 'Links',
34+
tabBarIcon: ({ focused }) => (
35+
<TabBarIcon
36+
focused={focused}
37+
name={Platform.OS === 'ios' ? 'ios-link' : 'md-link'}
38+
/>
39+
),
40+
};
41+
42+
const SettingsStack = createStackNavigator({
43+
Settings: SettingsScreen,
44+
});
45+
46+
SettingsStack.navigationOptions = {
47+
tabBarLabel: 'Settings',
48+
tabBarIcon: ({ focused }) => (
49+
<TabBarIcon
50+
focused={focused}
51+
name={Platform.OS === 'ios' ? 'ios-options' : 'md-options'}
52+
/>
53+
),
54+
};
55+
56+
export default createBottomTabNavigator({
57+
HomeStack,
58+
LinksStack,
59+
SettingsStack,
60+
});

0 commit comments

Comments
 (0)