Skip to content

Commit

Permalink
Camping App - release
Browse files Browse the repository at this point in the history
  • Loading branch information
hetmann committed Jan 25, 2019
1 parent 995caa1 commit 95297ba
Show file tree
Hide file tree
Showing 28 changed files with 1,294 additions and 0 deletions.
8 changes: 8 additions & 0 deletions camping-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules/**/*
.expo/*
npm-debug.*
*.jks
*.p12
*.key
*.mobileprovision
yarn.*
1 change: 1 addition & 0 deletions camping-app/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
67 changes: 67 additions & 0 deletions camping-app/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React from 'react';
import { Provider } from 'react-redux';
import { Platform, StatusBar, StyleSheet, View } from 'react-native';
import { AppLoading, Asset, Font, Icon } from 'expo';
import AppNavigator from './navigation/AppNavigator';

import store from './modules';

export default class App extends React.Component {
state = {
isLoadingComplete: false,
};

render() {
if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
return (
<AppLoading
startAsync={this._loadResourcesAsync}
onError={this._handleLoadingError}
onFinish={this._handleFinishLoading}
/>
);
} else {
return (
<Provider store={store}>
<View style={styles.container}>
{Platform.OS === 'ios' && <StatusBar barStyle="default" />}
<AppNavigator />
</View>
</Provider>
);
}
}

_loadResourcesAsync = async () => {
return Promise.all([
Asset.loadAsync([
require('./assets/images/robot-dev.png'),
require('./assets/images/robot-prod.png'),
]),
Font.loadAsync({
// This is the font that we are using for our tab bar
...Icon.Ionicons.font,
// We include SpaceMono because we use it in HomeScreen.js. Feel free
// to remove this if you are not using it in your app
'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
}),
]);
};

_handleLoadingError = error => {
// In this case, you might want to report the error to your error
// reporting service, for example Sentry
console.warn(error);
};

_handleFinishLoading = () => {
this.setState({ isLoadingComplete: true });
};
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
});
22 changes: 22 additions & 0 deletions camping-app/__tests__/App-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'react-native';
import React from 'react';
import App from '../App';
import renderer from 'react-test-renderer';
import NavigationTestUtils from 'react-navigation/NavigationTestUtils';

describe('App snapshot', () => {
jest.useFakeTimers();
beforeEach(() => {
NavigationTestUtils.resetInternalState();
});

it('renders the loading screen', async () => {
const tree = renderer.create(<App />).toJSON();
expect(tree).toMatchSnapshot();
});

it('renders the root without loading screen', async () => {
const tree = renderer.create(<App skipLoadingScreen />).toJSON();
expect(tree).toMatchSnapshot();
});
});
27 changes: 27 additions & 0 deletions camping-app/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"expo": {
"name": "camping",
"slug": "camping",
"privacy": "public",
"sdkVersion": "32.0.0",
"platforms": [
"ios",
"android"
],
"version": "0.0.1",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"splash": {
"backgroundColor": "#E9E542"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
}
}
}
Binary file added camping-app/assets/fonts/SpaceMono-Regular.ttf
Binary file not shown.
Binary file added camping-app/assets/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added camping-app/assets/images/robot-dev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added camping-app/assets/images/robot-prod.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added camping-app/assets/images/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions camping-app/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};
8 changes: 8 additions & 0 deletions camping-app/components/StyledText.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import { Text } from 'react-native';

export class MonoText extends React.Component {
render() {
return <Text {...this.props} style={[this.props.style, { fontFamily: 'space-mono' }]} />;
}
}
17 changes: 17 additions & 0 deletions camping-app/components/TabBarIcon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { Icon } from 'expo';

import Colors from '../constants/Colors';

export default class TabBarIcon extends React.Component {
render() {
return (
<Icon.Ionicons
name={this.props.name}
size={26}
style={{ marginBottom: -3 }}
color={this.props.focused ? Colors.tabIconSelected : Colors.tabIconDefault}
/>
);
}
}
10 changes: 10 additions & 0 deletions camping-app/components/__tests__/StyledText-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'react-native';
import React from 'react';
import { MonoText } from '../StyledText';
import renderer from 'react-test-renderer';

it('renders correctly', () => {
const tree = renderer.create(<MonoText>Snapshot test!</MonoText>).toJSON();

expect(tree).toMatchSnapshot();
});
14 changes: 14 additions & 0 deletions camping-app/constants/Colors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const tintColor = '#2f95dc';

export default {
tintColor,
tabIconDefault: '#ccc',
tabIconSelected: tintColor,
tabBar: '#fefefe',
errorBackground: 'red',
errorText: '#fff',
warningBackground: '#EAEB5E',
warningText: '#666804',
noticeBackground: tintColor,
noticeText: '#fff',
};
12 changes: 12 additions & 0 deletions camping-app/constants/Layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Dimensions } from 'react-native';

const width = Dimensions.get('window').width;
const height = Dimensions.get('window').height;

export default {
window: {
width,
height,
},
isSmallDevice: width < 375,
};
34 changes: 34 additions & 0 deletions camping-app/mock/campings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const campings = [
{
id: 1,
type: 'rv',
name: 'Camping Paradise',
description: 'Popular spot for trekkers.',
rating: 4.9,
distance: 2.9,
price: 'Free',
image: 'https://images.unsplash.com/photo-1525811902-f2342640856e?fit=crop&w=900&h=600&q=130',
latlng: {
latitude: 37.79335,
longitude: -122.4424,
}
},
{
id: 2,
type: 'tent',
name: 'Lake Florida',
description: 'This is for all sunset lovers.',
rating: 4.9,
distance: 2.9,
price: 'Free',
image: 'https://images.unsplash.com/photo-1506535995048-638aa1b62b77?fit=crop&w=900&h=600&q=130',
latlng: {
latitude: 37.78865,
longitude: -122.4324,
}
},
];

export {
campings,
};
92 changes: 92 additions & 0 deletions camping-app/modules/campings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@

// Actions
const SET_CAMPINGS = "Spots/campings/SET_CAMPINGS";
const SET_LOCATION = "Spots/campings/SET_LOCATION";
const SET_FILTERS = "Spots/campings/SET_FILTERS";
const SET_LOADING = "Spots/campings/SET_LOADING";

// Initial state
const INITIAL_STATE = {
spots: [],
mylocation: {
latitude: 37.79035,
longitude: -122.4384,
},
filters: {
sort: 'distance',
type: 'all',
price: 'free',
option_full: true,
option_rated: true,
option_free: false,
},
loading: false,
};

// Reducer
export default function reducer(state = INITIAL_STATE, action = {}) {
switch (action.type) {
case SET_CAMPINGS:
return {
...state,
spots: action.payload
}
case SET_LOCATION:
return {
...state,
location: action.payload
}
case SET_FILTERS:
return {
...state,
filters: {
...state.filters,
...action.payload
}
}
case SET_LOADING:
return {
...state,
loading: action.payload
}
default:
return state;
}
};

// Actions
export function setCampings(payload) {
return dispatch => {
dispatch({
type: SET_CAMPINGS,
payload
})
}
};

export function setLocation(payload) {
return dispatch => {
dispatch({
type: SET_LOCATION,
payload
})
}
};

export function setFilters(payload) {
return dispatch => {
dispatch({
type: SET_FILTERS,
payload
})
}
};

export function setLoading(payload) {
return dispatch => {
dispatch({
type: SET_LOADING,
payload
})
}
};
13 changes: 13 additions & 0 deletions camping-app/modules/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createStore, combineReducers, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import campings from './campings';

const middlewares = [thunk];
const store = createStore(
combineReducers({
campings: campings,
}),
applyMiddleware(...middlewares)
);

export default store;
10 changes: 10 additions & 0 deletions camping-app/navigation/AppNavigator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import { createAppContainer, createSwitchNavigator } from 'react-navigation';

import ScreensNavigator from './ScreensNavigator';

export default createAppContainer(createSwitchNavigator({
// You could add another route here for authentication.
// Read more at https://reactnavigation.org/docs/en/auth-flow.html
Main: ScreensNavigator,
}));
Loading

0 comments on commit 95297ba

Please sign in to comment.