Skip to content

Commit

Permalink
Merge pull request #3 from nat-sharpe/filterscreen
Browse files Browse the repository at this point in the history
Adds FilterScreen, Redux and complex Fetch request
  • Loading branch information
nat-sharpe committed Oct 9, 2018
2 parents 873dd59 + 3163535 commit 24a5b40
Show file tree
Hide file tree
Showing 22 changed files with 452 additions and 199 deletions.
1 change: 1 addition & 0 deletions .env.development.local
@@ -0,0 +1 @@
REACT_APP_API_URL='dev'
1 change: 1 addition & 0 deletions .env.production.local
@@ -0,0 +1 @@
REACT_APP_API_URL='pro'
74 changes: 59 additions & 15 deletions App.js
@@ -1,25 +1,69 @@
import React, {Component} from 'react';
import {AppRegistry, Text, View, StyleSheet} from 'react-native';
import React from 'react';
import { Platform, StatusBar, StyleSheet, View } from 'react-native';
import { AppLoading, Asset, Font, Icon } from 'expo';
import AppNavigator from './navigation/AppNavigator';
import store from './redux/store';
import {Provider} from 'react-redux';

import Component5 from './screens/Component5';
export default class App extends React.Component {
state = {
isLoadingComplete: false,
};

export default class foodbetter extends Component{
render(){
return(
<View style={styles.container}>
<Component5 />
</View>
)
render() {
// if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
// return (
// <AppLoading
// startAsync={this._loadResourcesAsync}
// onError={this._handleLoadingError}
// onFinish={this._handleFinishLoading}
// />
// );
// } else {
console.log(store)
return (
<Provider store={store}>
<View style={styles.container}>
{console.log(store.getState())}
{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,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#ecf0f1',
}
backgroundColor: '#fff',
},
});

AppRegistry.registerComponent('Food Better', () => foodbetter);
25 changes: 25 additions & 0 deletions App2.js
@@ -0,0 +1,25 @@
import React, {Component} from 'react';
import {AppRegistry, Text, View, StyleSheet} from 'react-native';

import ScannerScreen from './screens/ScannerScreen';

export default class foodbetter extends Component{
render(){
return(
<View style={styles.container}>
<ScannerScreen />
</View>
)
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#ecf0f1',
}
});

AppRegistry.registerComponent('Food Better', () => foodbetter);
62 changes: 0 additions & 62 deletions AppOld.js

This file was deleted.

6 changes: 0 additions & 6 deletions app.json
Expand Up @@ -8,12 +8,6 @@
"platforms": ["ios", "android"],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"splash": {
"image": "./assets/images/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
Expand Down
Binary file removed assets/images/icon.png
Binary file not shown.
Binary file added assets/images/no.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/robot-dev.png
Binary file not shown.
Binary file removed assets/images/robot-prod.png
Binary file not shown.
Binary file removed assets/images/splash.png
Binary file not shown.
Binary file added assets/images/yes.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions navigation/MainTabNavigator.js
Expand Up @@ -4,8 +4,8 @@ import { createStackNavigator, createBottomTabNavigator } from 'react-navigation

import TabBarIcon from '../components/TabBarIcon';
import HomeScreen from '../screens/HomeScreen';
import LinksScreen from '../screens/LinksScreen';
import SettingsScreen from '../screens/SettingsScreen';
import ScannerScreen from '../screens/ScannerScreen';
import FilterScreen from '../screens/FilterScreen';

const HomeStack = createStackNavigator({
Home: HomeScreen,
Expand All @@ -25,12 +25,12 @@ HomeStack.navigationOptions = {
),
};

const LinksStack = createStackNavigator({
Links: LinksScreen,
const ScannerStack = createStackNavigator({
Scanner: ScannerScreen,
});

LinksStack.navigationOptions = {
tabBarLabel: 'Links',
ScannerStack.navigationOptions = {
tabBarLabel: 'Scanner',
tabBarIcon: ({ focused }) => (
<TabBarIcon
focused={focused}
Expand All @@ -39,12 +39,12 @@ LinksStack.navigationOptions = {
),
};

const SettingsStack = createStackNavigator({
Settings: SettingsScreen,
const FilterStack = createStackNavigator({
Filter: FilterScreen,
});

SettingsStack.navigationOptions = {
tabBarLabel: 'Settings',
FilterStack.navigationOptions = {
tabBarLabel: 'Filter',
tabBarIcon: ({ focused }) => (
<TabBarIcon
focused={focused}
Expand All @@ -55,6 +55,6 @@ SettingsStack.navigationOptions = {

export default createBottomTabNavigator({
HomeStack,
LinksStack,
SettingsStack,
ScannerStack,
FilterStack,
});
53 changes: 53 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -22,7 +22,10 @@
"react-native-permissions": "^1.1.1",
"react-native-qr-scanner": "^1.3.2",
"react-native-qrcode-scanner": "^1.1.0",
"react-navigation": "^2.16.0"
"react-navigation": "^2.16.0",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"tcomb-form-native": "^0.6.19"
},
"devDependencies": {
"jest-expo": "30.0.0"
Expand Down
36 changes: 36 additions & 0 deletions redux/reducer.js
@@ -0,0 +1,36 @@
const reducer = (oldState, action) => {
if (action.type === 'CHANGE_SETTINGS') {
// console.log('Poo')
// console.log(action)
// console.log(oldState)
// console.log(oldState.settings)
// console.log(action.settings.vegan)
return {
...oldState,
settings: action.settings
}
} else if (action.type === 'UPDATE_ITEMS') {
let newItem = {
id: action.id,
allowed: action.allowed,
name: action.name,
brand: action.brand,
imageURL: action.imageURL,
carbs: action.carbs,
calories: action.calories,
organic: action.organic,
vegan: naction.vegan,
glutenFree: action.glutenFree,
};
let newScans = [...oldState.oldScans];
newScans.splice(0, 1);
newScans.push(newItem);
return {
...oldState,
oldScans: newScans
}
}
return oldState;
}

export default reducer;

0 comments on commit 24a5b40

Please sign in to comment.