Skip to content

Commit

Permalink
hi
Browse files Browse the repository at this point in the history
  • Loading branch information
dragondevelops committed Mar 31, 2020
1 parent 5109e12 commit 5afb6a1
Show file tree
Hide file tree
Showing 35 changed files with 12,764 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .expo-shared/assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"f9155ac790fd02fadcdeca367b02581c04a353aa6d5aa84409a59f6804c87acd": true,
"89ed26367cdb9b771858e026f2eb95bfdb90e5ae943e716575327ec325f39c44": true
}
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
node_modules/**/*
.expo/*
npm-debug.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision
*.orig.*
web-build/
web-report/

# macOS
.DS_Store

.vs/ProjectSettings.json

.vs/slnx.sqlite
2 changes: 2 additions & 0 deletions .idea/.gitignore

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

17 changes: 17 additions & 0 deletions .idea/Grocer.iml

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

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

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

9 changes: 9 additions & 0 deletions .idea/discord.xml

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

6 changes: 6 additions & 0 deletions .idea/jsLibraryMappings.xml

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

6 changes: 6 additions & 0 deletions .idea/misc.xml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

113 changes: 113 additions & 0 deletions App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import React, {useState, useEffect} from 'react';
import {Text, View} from 'react-native';
import GroceryItemSearchScreen from './screens/GroceryItemSearchScreen';
import GroceryListSearchScreen from './screens/GroceryListSearchScreen';
import YourGroceryListScreen from './screens/YourGroceryListScreen';
import {NavigationContainer, DrawerActions} from "@react-navigation/native";
import {navigationRef, isMountedRef} from "./navigation/RootNavigation";
import CurrentStoreContext from "./contexts/CurrentStore";
import GroceryListContext from "./contexts/GroceryList";
import UserContext from "./contexts/User";
import ScannerScreen from "./screens/ScannerScreen";
import {
createDrawerNavigator,
DrawerContentScrollView,
DrawerItemList,
} from "@react-navigation/drawer";
import {Notifications} from 'expo';
import * as Permissions from 'expo-permissions';
import * as SecureStore from 'expo-secure-store';

const Drawer = createDrawerNavigator();

const userInfo = {
name: "John Doe",
email: "[email protected]",
phone: "(416) 132-4634",
timeout: "00:34",
role: "Worker",
description: "Worker for Walmart"
};

function DrawerContent(props) {
return(
<DrawerContentScrollView {...props}>
<View style={{flex: 1, padding: 15}}>
<Text style={{fontWeight: "bold", fontSize: 25}}>{userInfo.name}</Text>
<Text>{userInfo.email}</Text>
<Text>{userInfo.phone}</Text>
<Text>Timeout: {userInfo.timeout}</Text>
<Text>Role: {userInfo.role}</Text>
<Text>Description: {userInfo.description}</Text>
</View>
<DrawerItemList {...props} />
</DrawerContentScrollView>
);
}

export default function App() {
const [currentStore, setCurrentStore] = useState({name: "Walmart", id: 0});
const [groceryList, setGroceryList] = useState({});
const [user, setUser] = useState({});

useEffect(() => {
(async() => {
const pushToken = await SecureStore.getItemAsync('pushToken');
if (pushToken) return;

const {status} = await Permissions.askAsync(Permissions.NOTIFICATIONS);
if (status !== 'granted') {
alert('No notification permissions!');
return;
}
let token = await Notifications.getExpoPushTokenAsync();
await SecureStore.setItemAsync('pushToken', token);
})();
}, []);

React.useEffect(() => {
isMountedRef.current = true;
return () => (isMountedRef.current = false);
}, []);

return (
<CurrentStoreContext.Provider value={{currentStore, setCurrentStore}}>
<GroceryListContext.Provider value={{groceryList, setGroceryList}}>
<UserContext.Provider value={{user, setUser}}>
<NavigationContainer ref={navigationRef}>
<Drawer.Navigator drawerContent={props => <DrawerContent {...props}/>}>
<Drawer.Screen
name="GrocerySearch"
options={{
title: "Groceries"
}}
component={GroceryItemSearchScreen}
/>
<Drawer.Screen
name="GroceryListSearch"
options={{
title: "Grocery Lists"
}}
component={GroceryListSearchScreen}
/>
<Drawer.Screen
name="YourGroceryList"
options={{
title: "Your Grocery List"
}}
component={YourGroceryListScreen}
/>
<Drawer.Screen
name="Scanner"
options={{
title: "Scan QR Code"
}}
component={ScannerScreen}
/>
</Drawer.Navigator>
</NavigationContainer>
</UserContext.Provider>
</GroceryListContext.Provider>
</CurrentStoreContext.Provider>
);
}
35 changes: 35 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"expo": {
"name": "Grocer",
"slug": "Grocer",
"privacy": "public",
"sdkVersion": "36.0.0",
"platforms": [
"ios",
"android",
"web"
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"androidStatusBar": {
"backgroundColor": "#FFFFFF",
"barStyle": "dark-content"
},
"description": ""
}
}
Binary file added assets/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 assets/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 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'],
};
};
69 changes: 69 additions & 0 deletions components/GroceryItemListing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React, {useContext} from 'react';
import {Text, Dimensions, StyleSheet, TouchableOpacity} from 'react-native';
import {Button, Card, Rating} from 'react-native-elements';
import GroceryListContext from "../contexts/GroceryList";
import {useNavigation} from '@react-navigation/native';

export default React.memo(function GroceryItemListing({
_id, name, imageUrl, rating, price
}) {
const {groceryList, setGroceryList} = useContext(GroceryListContext);
const navigation = useNavigation();
return (
<Card
title={name}
titleStyle={{flexWrap: 'wrap'}}
containerStyle={styles.cardContainer}
wrapperStyle={styles.cardWrapper}
imageProps={{resizeMode: 'contain'}}
image={{uri: imageUrl}}
>
<Rating
imageSize={20}
readonly
startingValue={rating}
style={{margin: 10}}
/>
<Button
title={`\$${price.toFixed(2)}`}
titleStyle={styles.price}
onPress={() => {
navigation.navigate("GroceryItemScreen", {_id, rating, name, imageUrl, price});
/*
groceryList[_id] = groceryList[_id] || {
name,
imageUrl,
price,
count: 0,
};
const count = groceryList[_id].count;
if (count < 9) {
const newItem = {
...groceryList[_id],
count: count + 1
};
setGroceryList({...groceryList, [_id]: newItem});
}
*/
}}
/>
</Card>
)
});

const styles = StyleSheet.create({
cardContainer: {
width: Dimensions.get('window').width / 2 - 30,
flex: -1,
flexDirection: 'column'
},
cardWrapper: {
flex: -1,
flexDirection: 'column',
justifyContent: 'flex-end',
flexGrow: 1
},
price: {
fontWeight: "bold"
},
});
8 changes: 8 additions & 0 deletions components/GroceryList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import {ListItem} from "react-native-elements";

function GroceryList() {
return <ListItem

/>
}
60 changes: 60 additions & 0 deletions components/ItemCounter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React, {useContext} from 'react';
import {View, StyleSheet, Text} from 'react-native';
import {Button, Input} from 'react-native-elements';
import GroceryListContext from "../contexts/GroceryList";

export default function ItemCounter({_id}) {
const {groceryList, setGroceryList} = useContext(GroceryListContext);

return (
<View style={styles.container}>
<Button
icon={{name: 'minus', type: 'entypo'}}
type='clear'
onPress={() => {
const count = groceryList[_id].count;
if (count > 1) {
const newItem = {
...groceryList[_id],
count: count - 1
};
setGroceryList({...groceryList, [_id]: newItem})
}
}}
/>
<Text style={styles.count}>{groceryList[_id].count ?? 0}</Text>
<Button
type="clear"
icon={{name: 'plus', type: 'entypo'}}
onPress={() => {
const count = groceryList[_id].count;
if (count < 9) {
const newItem = {
...groceryList[_id],
count: count + 1
};
setGroceryList({...groceryList, [_id]: newItem});
}
}}
/>
</View>
)
}

const styles = StyleSheet.create({
container: {
flex: -1,
flexDirection: 'row'
},
count: {
alignSelf: 'center',
padding: 10,
fontSize: 20,
fontWeight: 'bold',
width: 40,
textAlign: 'center'
},
surface: {
elevation: 4
}
});
Loading

0 comments on commit 5afb6a1

Please sign in to comment.