setFontsLoaded(true)}
25 | />
26 | )
27 | }
28 | };
29 |
30 |
--------------------------------------------------------------------------------
/src/screens/MyOrder/orders.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import { StyleSheet, TouchableOpacity, Text, View } from 'react-native';
3 | import { MaterialIcons } from '@expo/vector-icons';
4 | import styles from './styles'
5 |
6 | export default function TodoItem({ pressHandler, item }) {
7 | return (
8 |
9 |
10 | OrderId : {item.key}
11 | Product Name : {item.productName}
12 | Price : {item.price}
13 | Quantity : {item.quantity}
14 | Contact : {item.Contact}
15 | Address : {item.Address}
16 |
17 |
18 | )
19 | }
20 |
--------------------------------------------------------------------------------
/src/screens/OrderDetails/orders.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import { StyleSheet, TouchableOpacity, Text, View } from 'react-native';
3 | import { MaterialIcons } from '@expo/vector-icons';
4 | import styles from './styles'
5 |
6 | export default function TodoItem({ pressHandler, item }) {
7 | return (
8 |
9 |
10 | OrderId : {item.key}
11 | Costumer Name : {item.CustName}
12 | Contact : {item.Contact}
13 | Address : {item.Address}
14 | pressHandler(item.key)} name='check-circle' Text="done" size={18} color='#545' />
15 |
16 |
17 | )
18 | }
19 |
--------------------------------------------------------------------------------
/src/components/MenuButton/MenuButton.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { TouchableHighlight, Image, Text, View } from 'react-native';
3 | import PropTypes from 'prop-types';
4 | import styles from './styles';
5 |
6 | export default class MenuButton extends React.Component {
7 | render() {
8 | return (
9 |
14 |
15 |
16 | {this.props.title}
17 |
18 |
19 | );
20 | }
21 | }
22 |
23 | MenuButton.propTypes = {
24 | onPress: PropTypes.func,
25 | source: PropTypes.number,
26 | title: PropTypes.string
27 | };
28 |
--------------------------------------------------------------------------------
/src/screens/ItemDetails/styles.js:
--------------------------------------------------------------------------------
1 | import { StyleSheet, Dimensions, Platform } from 'react-native';
2 |
3 | const { width: viewportWidth } = Dimensions.get('window');
4 |
5 | const styles = StyleSheet.create({
6 | container: {
7 | backgroundColor: 'white',
8 | flex: 1,
9 | justifyContent: 'center',
10 | alignItems: "center",
11 | padding: 10,
12 | margin: 10
13 | },
14 | title: {
15 | fontSize: 20,
16 | },
17 | price: {
18 | fontFamily: 'comic-bold',
19 | paddingTop: 22,
20 | marginHorizontal: 30,
21 | fontSize: 20,
22 | },
23 | review: {
24 | paddingTop: 10,
25 | fontSize: 18,
26 | fontWeight: 'bold'
27 | },
28 | photo: {
29 | height: 450,
30 | width: 450
31 | },
32 | addbtn: {
33 | backgroundColor: "#008037",
34 | margin: 20,
35 | padding: 8,
36 | fontFamily: 'lilita-regular',
37 | }
38 | });
39 | export default styles;
40 |
--------------------------------------------------------------------------------
/src/screens/MyOrder/styles.js:
--------------------------------------------------------------------------------
1 | import { StyleSheet } from 'react-native';
2 |
3 | const styles = StyleSheet.create({
4 | item: {
5 | flex: 1,
6 | padding: 16,
7 | marginTop: 16,
8 | borderColor: '#bbb',
9 | borderWidth: 1,
10 | borderStyle: "dashed",
11 | borderRadius: 1,
12 | borderRadius: 10,
13 | flexDirection: 'column',
14 | },
15 | itemText: {
16 | marginLeft: 10,
17 | },
18 | done: {
19 | flex: 1,
20 | alignSelf: "flex-end",
21 | fontSize: 30
22 | },
23 | container: {
24 | flex: 1,
25 | backgroundColor: '#fff',
26 | },
27 | list: {
28 | marginTop: 20,
29 | flex: 1,
30 | paddingLeft: "10%",
31 | paddingRight: "10%"
32 | },
33 | header: {
34 | height: 50,
35 | backgroundColor: '#008037',
36 | justifyContent: 'center'
37 | },
38 | title: {
39 | textAlign: 'center',
40 | color: '#fff',
41 | fontSize: 20,
42 | fontWeight: 'bold',
43 | }
44 | });
45 |
46 | export default styles;
47 |
--------------------------------------------------------------------------------
/src/screens/OrderDetails/styles.js:
--------------------------------------------------------------------------------
1 | import { StyleSheet } from 'react-native';
2 |
3 | const styles = StyleSheet.create({
4 | item: {
5 | flex: 1,
6 | padding: 16,
7 | marginTop: 16,
8 | borderColor: '#bbb',
9 | borderWidth: 1,
10 | borderStyle: "dashed",
11 | borderRadius: 1,
12 | borderRadius: 10,
13 | flexDirection: 'column',
14 | },
15 | itemText: {
16 | marginLeft: 10,
17 | },
18 | done: {
19 | flex: 1,
20 | alignSelf: "flex-end",
21 | fontSize: 30
22 | },
23 | container: {
24 | flex: 1,
25 | backgroundColor: '#fff',
26 | },
27 | list: {
28 | marginTop: 20,
29 | flex: 1,
30 | paddingLeft: "10%",
31 | paddingRight: "10%"
32 | },
33 | header: {
34 | height: 50,
35 | backgroundColor: '#008037',
36 | justifyContent: 'center'
37 | },
38 | title: {
39 | textAlign: 'center',
40 | color: '#fff',
41 | fontSize: 20,
42 | fontWeight: 'bold',
43 | }
44 | });
45 |
46 | export default styles;
47 |
--------------------------------------------------------------------------------
/src/AppStyles.js:
--------------------------------------------------------------------------------
1 | import { StyleSheet, Dimensions } from 'react-native';
2 |
3 | // screen sizing
4 | const { width, height } = Dimensions.get('window');
5 | // orientation must fixed
6 | const SCREEN_WIDTH = width < height ? width : height;
7 |
8 | const recipeNumColums = 2;
9 | // item size
10 | const RECIPE_ITEM_HEIGHT = 160;
11 | const RECIPE_ITEM_MARGIN = 20;
12 |
13 | // 2 photos per width
14 | export const RecipeCard = StyleSheet.create({
15 | container: {
16 | flex: 1,
17 | justifyContent: 'center',
18 | alignItems: 'center',
19 | marginLeft: RECIPE_ITEM_MARGIN,
20 | marginTop: 13,
21 | marginBottom: 7,
22 | width: (SCREEN_WIDTH - (recipeNumColums + 1) * RECIPE_ITEM_MARGIN) / recipeNumColums,
23 | height: RECIPE_ITEM_HEIGHT + 45,
24 | borderColor: '#545454',
25 | borderWidth: 0.15,
26 | borderRadius: 5
27 | },
28 | photo: {
29 | width: (SCREEN_WIDTH - (recipeNumColums + 1) * RECIPE_ITEM_MARGIN) / recipeNumColums,
30 | height: RECIPE_ITEM_HEIGHT - 20,
31 | borderRadius: 5,
32 | borderBottomLeftRadius: 0,
33 | borderBottomRightRadius: 0
34 | },
35 | title: {
36 | flex: 1,
37 | fontFamily: 'comic-bold',
38 | fontSize: 18,
39 | textAlign: 'center',
40 | color: '#545454',
41 | height: 200,
42 | marginTop: 15,
43 | marginRight: 5,
44 | marginLeft: 5,
45 | },
46 | });
47 |
--------------------------------------------------------------------------------
/src/screens/MyOrder/OrderDetailsScreen.js:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react';
2 | import { View, FlatList, AsyncStorage } from 'react-native';
3 | import OrderItem from './orders';
4 | import styles from './styles';
5 |
6 | export default async function App() {
7 | const [orders, setorder] = useState([
8 | { key: '1', productName: 'atta 5kg', price: '200', quantity: '1', Contact: "+919876543210", Address: "Shaheed Nagar 1st line" },
9 | { key: '2', productName: 'oil 1ltr', price: '100', quantity: '2', Contact: "+919876543210", Address: "Shaheed Nagar 1st line" },
10 | ]);
11 | // var orders = []
12 | // var user = await AsyncStorage.getItem('user');
13 | // var parsed = JSON.parse(user);
14 | // await fetch('http://testdeployment-env.eba-eqdcmu3a.us-east-2.elasticbeanstalk.com/api/cart/getCart', {
15 | // method: 'POST',
16 | // body: JSON.stringify({
17 | // phone: parsed.phone
18 | // })
19 | // })
20 | // .then(res => res.json())
21 | // .then((res) => orders.)
22 |
23 | return (
24 |
25 |
26 | (
29 |
30 | )}
31 | />
32 |
33 |
34 | );
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "node_modules/expo/AppEntry.js",
3 | "scripts": {
4 | "start": "expo start",
5 | "android": "expo start --android",
6 | "ios": "expo start --ios",
7 | "web": "expo start --web",
8 | "eject": "expo eject"
9 | },
10 | "dependencies": {
11 | "@react-native-community/masked-view": "0.1.5",
12 | "expo": "^38.0.8",
13 | "expo-status-bar": "^1.0.2",
14 | "formik": "^2.1.5",
15 | "react": "~16.11.0",
16 | "react-dom": "~16.11.0",
17 | "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
18 | "react-native-elements": "^2.0.4",
19 | "react-native-fbsdk": "^2.0.0",
20 | "react-native-gesture-handler": "~1.5.0",
21 | "react-native-reanimated": "~1.4.0",
22 | "react-native-responsive-screen": "^1.4.1",
23 | "react-native-safe-area-context": "0.6.0",
24 | "react-native-screens": "2.0.0-alpha.12",
25 | "react-native-searchbar": "^1.16.0",
26 | "react-native-snap-carousel": "^3.8.0",
27 | "react-native-vector-icons": "^6.6.0",
28 | "react-native-web": "~0.11.7",
29 | "react-navigation": "^4.3.5",
30 | "react-navigation-drawer": "^2.4.9",
31 | "react-navigation-stack": "^2.3.9",
32 | "react-redux": "^7.2.0",
33 | "redux": "^4.0.5",
34 | "redux-logger": "^3.0.6",
35 | "redux-thunk": "^2.3.0"
36 | },
37 | "devDependencies": {
38 | "@babel/core": "^7.8.6",
39 | "babel-preset-expo": "~8.1.0"
40 | },
41 | "private": true
42 | }
43 |
--------------------------------------------------------------------------------
/src/screens/OrderDetails/OrderDetailsScreen.js:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react';
2 | import { View, FlatList } from 'react-native';
3 | import Header from './header';
4 | import OrderItem from './orders';
5 | import styles from './styles';
6 |
7 | export default function App() {
8 | const [orders, setorder] = useState([
9 | { CustName: 'Ramachandra Panda', key: '1', Contact: "+919876543210", Address: "Shaheed Nagar 1st line" },
10 | { CustName: 'Harekrushna Mishra', key: '2', Contact: "+919876543210", Address: "Baramunda 3rd line" },
11 | { CustName: 'Ajitesh Panda', key: '3', Contact: "+919876543210", Address: "Gothapatna 2nd line" },
12 | { CustName: 'Sidhrtha Mallick', key: '4', Contact: "+919876543210", Address: "Master Canteen 3rd line" },
13 | ]);
14 |
15 | const pressHandler = (key) => {
16 | const msg = "OrderId " + key + " Delivered Successfully"
17 | alert(msg);
18 | setorder(prevorder => {
19 | return prevorder.filter(todo => todo.key != key);
20 | });
21 | };
22 |
23 | return (
24 |
25 | {/* */}
26 |
27 | (
30 |
31 | )}
32 | />
33 |
34 |
35 | );
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ECommerce app usign react-native and expo-cli
2 |
3 | Checkout our eCommerce admin app at : https://github.com/ahtrahdis7/my-market-admin
4 |
5 | ## Screens
6 |
7 | 
8 | 
9 |
10 | ## Features/Screens
11 | - OTP Based Login
12 | - Home Screen
13 | - Categories Screen
14 | - Local Storage Cart
15 | - Add/Remove Cart
16 | - Product Details Screen
17 | ## Tech Stack
18 |
33 |
34 | ## Development
35 | This project doesot require basic react native setup to get up and running. Install the expo-sdk and get started. Read more about expo at: https://expo.io
36 | Run the below commands in sequence to start the development server in expo.
37 | In order to start the development server without expo, read the React Native docs at https://reactnative.dev
38 |
39 | 1. git clone https://github.com/ahtrahdis7/e-commerce-store-react-native.git
40 | 2. cd my-market
41 | 3. yarn add expo
42 | 4. expo install or yarn install
43 | 5. expo start
44 |
45 |
46 | ### If you find this repo useful, please give a `Star`, and let others know about it.
47 |
48 | ### !! Happy Coding !!
49 |
--------------------------------------------------------------------------------
/src/screens/ItemDetails/ItemDetailsScreen.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Image,
4 | View,
5 | Text,
6 | Dimensions,
7 | AsyncStorage, ScrollView,
8 | } from 'react-native';
9 | import { Button } from 'react-native-elements';
10 | import styles from './styles';
11 |
12 | const { width: viewportWidth } = Dimensions.get('window');
13 |
14 | async function addtocart(props) {
15 | const itemDetails = props.getParam('item');
16 | var user = await AsyncStorage.getItem('user');
17 | var parsedUser = JSON.parse(user);
18 |
19 | if (parsedUser == null) {
20 | alert('Please Login to continue')
21 | } else {
22 | parsedUser.cart.push(itemDetails);
23 | }
24 | AsyncStorage.setItem('user', JSON.stringify(parsedUser));
25 |
26 | user = await AsyncStorage.getItem('user');
27 | parsedUser = JSON.parse(user);
28 | alert('Item added to cart successfully');
29 | }
30 | export default class RecipeScreen extends React.Component {
31 | static navigationOptions = ({ navigation }) => {
32 | return {
33 | title: navigation.getParam('item').name.toUpperCase(),
34 | };
35 | }
36 |
37 |
38 |
39 | render() {
40 | const itemDetails = this.props.navigation.getParam('item');
41 | // console.log(itemDetails)
42 | return (
43 |
44 |
45 |
46 |
47 |
48 | {itemDetails.name}
49 | Rs.{itemDetails.price}
50 | addtocart(this.props.navigation)}
54 | />
55 |
56 |
57 |
58 | );
59 | }
60 | }
61 |
62 |
63 |
--------------------------------------------------------------------------------
/src/navigations/AppNavigation.js:
--------------------------------------------------------------------------------
1 | import { createAppContainer } from 'react-navigation';
2 | import { createDrawerNavigator } from 'react-navigation-drawer'
3 | import { createStackNavigator } from 'react-navigation-stack'
4 | import HomeScreen from '../screens/Home/HomeScreen';
5 | import CheckoutScreen from '../screens/Checkout/CheckoutScreen';
6 | import ItemDetailsScreen from '../screens/ItemDetails/ItemDetailsScreen';
7 | import ItemsListScreen from '../screens/ItemsList/ItemsListScreen';
8 | import DrawerContainer from '../screens/DrawerContainer/DrawerContainer';
9 | import CartScreen from '../screens/Cart/CartScreen';
10 | import AboutScreen from '../screens/About/AboutScreen';
11 | import ContactScreen from '../screens/Contact/ContactScreen';
12 | import LoginScreen from '../screens/login/login';
13 | import OrderDetails from '../screens/OrderDetails/OrderDetailsScreen'
14 | import SearchScreen from '../screens/Search/SearchScreen'
15 | // import MyOrder from '../screens/MyOrder/OrderDetailsScreen'
16 |
17 | const screens = {
18 | Home: HomeScreen,
19 | Search: SearchScreen,
20 | ItemDetails: ItemDetailsScreen,
21 | ItemsList: ItemsListScreen,
22 | About: AboutScreen,
23 | Contact: ContactScreen,
24 | Cart: CartScreen,
25 | Checkout: CheckoutScreen,
26 | Login: LoginScreen,
27 | OrderDetails: OrderDetails,
28 | // Orders: MyOrder,
29 | };
30 |
31 | const MainNavigator = createStackNavigator(screens, {
32 | defaultNavigationOptions: {
33 | headerStyle: { backgroundColor: '#545454', height: 50, },
34 | headerTintColor: 'white',
35 | headerTitleStyle: {
36 | color: 'white'
37 | },
38 | headerForceInset: { top: 'never' },
39 | }
40 | });
41 |
42 | const DrawerStack = createDrawerNavigator(
43 | {
44 | Main: MainNavigator
45 | },
46 | {
47 | drawerPosition: 'left',
48 | initialRouteName: 'Main',
49 | drawerWidth: 230,
50 | contentComponent: DrawerContainer,
51 | }
52 | );
53 |
54 | export default AppContainer = createAppContainer(DrawerStack);
55 |
56 | console.disableYellowBox = true;
57 |
58 |
--------------------------------------------------------------------------------
/src/screens/DrawerContainer/DrawerContainer.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { View, Image } from 'react-native';
3 | import PropTypes from 'prop-types';
4 | import styles from './styles';
5 | import MenuButton from '../../components/MenuButton/MenuButton';
6 |
7 | export default class DrawerContainer extends React.Component {
8 | render() {
9 | const { navigation } = this.props;
10 | return (
11 |
12 |
13 |
14 | {
17 | navigation.navigate('Home');
18 | navigation.closeDrawer();
19 | }}
20 | />
21 | {
24 | navigation.navigate('Search');
25 | navigation.closeDrawer();
26 | }}
27 | />
28 | {
31 | navigation.navigate('Cart');
32 | navigation.closeDrawer();
33 | }}
34 | />
35 | {/* {
38 | navigation.navigate('Orders');
39 | navigation.closeDrawer();
40 | }}
41 | /> */}
42 | {
45 | navigation.navigate('Contact');
46 | navigation.closeDrawer();
47 | }}
48 | />
49 | {
52 | navigation.navigate('Login');
53 | navigation.closeDrawer();
54 | }}
55 | />
56 |
57 |
58 | );
59 | }
60 | }
61 |
62 | DrawerContainer.propTypes = {
63 | navigation: PropTypes.shape({
64 | navigate: PropTypes.func.isRequired
65 | })
66 | };
67 |
--------------------------------------------------------------------------------
/src/screens/Categories/CategoriesScreen.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | FlatList,
4 | Text,
5 | ScrollView,
6 | View,
7 | Image,
8 | TouchableHighlight
9 | } from 'react-native';
10 | import styles from './styles';
11 |
12 | export default class CategoriesScreen extends React.Component {
13 | static navigationOptions = {
14 | title: 'Categories'
15 | };
16 |
17 | constructor(props) {
18 |
19 | super(props);
20 | this.state = {
21 | categories: []
22 | }
23 | }
24 |
25 | getData(categories) {
26 | // console.log("hello")
27 | this.setState({
28 | categories: categories
29 | })
30 | }
31 |
32 | componentDidMount() {
33 | // console.log(this.state)
34 |
35 | fetch("http://192.168.43.55:3000/api/search/getCategories")
36 | .then(response => response.json())
37 | .then((categories) => this.getData(categories))
38 | .catch(err => console.log(err));
39 | }
40 |
41 |
42 |
43 | render() {
44 | const { navigate } = this.props.navigation;
45 |
46 | const renderMenuItem = (item) => {
47 | return (
48 | navigate('ItemsList', { itemType: item.item })}>
50 |
51 |
52 | {item.item.toUpperCase()}
53 |
54 |
55 | )
56 | };
57 | const data = this.state.categories;
58 | if (data != undefined)
59 | return (
60 |
61 | item}
68 | />
69 |
70 | );
71 | else
72 | return (
73 |
74 | Check Your Network
75 |
76 | )
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/screens/login/style.js:
--------------------------------------------------------------------------------
1 | import { StyleSheet } from 'react-native';
2 |
3 | const styles = StyleSheet.create({
4 | containerView: {
5 | flex: 1,
6 | justifyContent: 'center',
7 | backgroundColor: '#fff'
8 | },
9 | loginScreenContainer: {
10 | flex: 1,
11 | },
12 | loginFormView: {
13 | flex: 1,
14 | },
15 | loginFormTextInput: {
16 | height: 43,
17 | fontSize: 16,
18 | borderRadius: 5,
19 | borderWidth: 1,
20 | borderColor: '#eaeaea',
21 | backgroundColor: '#fafafa',
22 | paddingLeft: 10,
23 | marginLeft: 35,
24 | marginRight: 35,
25 | marginTop: "35%",
26 | marginBottom: 25,
27 | },
28 | otpButton: {
29 | backgroundColor: '#008037',
30 | borderRadius: 5,
31 | height: 45,
32 | marginTop: "5%",
33 | marginLeft: "35%",
34 | marginRight: "35%"
35 | },
36 | submitButton: {
37 | backgroundColor: '#008037',
38 | borderRadius: 5,
39 | height: 45,
40 | marginTop: "10%",
41 | marginLeft: "35%",
42 | marginRight: "35%"
43 | },
44 | submitPartnerButton: {
45 | backgroundColor: '#fdc400',
46 | borderRadius: 5,
47 | height: 45,
48 | marginTop: "20%",
49 | marginLeft: "25%",
50 | marginRight: "25%"
51 | },
52 | OtpInput: {
53 | height: 43,
54 | fontSize: 20,
55 | borderRadius: 10,
56 | borderWidth: 2,
57 | borderColor: '#eaeaea',
58 | backgroundColor: '#fafafa',
59 | marginLeft: "28%",
60 | marginRight: "28%",
61 | marginTop: "15%",
62 | alignItems: 'center',
63 | textAlign: 'center',
64 | justifyContent: 'center'
65 | },
66 | // otpBoxesContainer: {
67 | // flexDirection: 'row',
68 | // marginTop: 35,
69 | // textAlign: 'center',
70 | // justifyContent: 'center',
71 | // alignItems: 'center'
72 | // },
73 | // otpBox: {
74 | // padding: 10,
75 | // marginRight: 10,
76 | // borderWidth: 1,
77 | // borderColor: '#eaeaea',
78 | // height: 45,
79 | // width: 45,
80 | // margin: 10,
81 | // textAlign: 'center',
82 | // alignItems: 'center',
83 | // },
84 | header: {
85 | width: 400,
86 | height: 120,
87 | },
88 | head: {
89 | marginTop: 0,
90 | position: 'absolute',
91 | alignSelf: 'center'
92 | }
93 | });
94 |
95 | export default styles;
96 |
--------------------------------------------------------------------------------
/src/screens/ItemsList/ItemsListScreen.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | FlatList,
4 | Text,
5 | View,
6 | TouchableHighlight,
7 | Image,
8 | ScrollView
9 | } from 'react-native';
10 | import styles from './styles';
11 |
12 | export default class ItemsListScreen extends React.Component {
13 | static navigationOptions = ({ navigation }) => {
14 | return {
15 | title: navigation.getParam('itemType').toUpperCase()
16 | };
17 | };
18 |
19 | constructor(props) {
20 | super(props);
21 | this.state = {
22 | itemlist: [],
23 | render: true
24 | }
25 | }
26 | getData(itemlist) {
27 | this.setState({
28 | itemlist: itemlist,
29 | render: true
30 | })
31 | }
32 |
33 | componentDidMount() {
34 | const itemType = this.props.navigation.getParam('itemType');
35 | fetch("http://testdeployment-env.eba-eqdcmu3a.us-east-2.elasticbeanstalk.com/api/search/category/" + itemType)
36 | .then(response => response.json())
37 | .then((itemlist) => this.getData(itemlist))
38 | .catch(err => console.log(err));
39 |
40 | console.log(this.state.itemlist)
41 | }
42 |
43 | onPressItem = item => {
44 | this.props.navigation.navigate('ItemDetails', { item: item });
45 | };
46 |
47 | renderMenuItem = ({ item }) => {
48 | return (
49 | this.onPressItem(item)}
50 | >
51 |
52 |
53 | {item.name}
54 |
55 |
56 | )
57 | };
58 |
59 | render() {
60 |
61 | const { navigation } = this.props;
62 | const data = this.state.itemlist;
63 | if (data != undefined)
64 | return (
65 |
66 | item._id}
73 | />
74 |
75 | );
76 | else
77 | return (
78 |
79 | Check Your Network
80 |
81 | )
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/screens/Cart/CartItem.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from "react";
2 | import { View, Image, Text, TouchableOpacity, AsyncStorage } from "react-native";
3 | import { MaterialIcons } from '@expo/vector-icons';
4 | import styles from './styles';
5 |
6 | async function pressHandler(itemObj){
7 | var user = await AsyncStorage.getItem('user');
8 | var parsedUser = JSON.parse(user);
9 | var data = parsedUser.cart;
10 |
11 | var index = -1;
12 | var count = 0;
13 | for(var item of data){
14 | if(item._id == itemObj._id){
15 | index = count;
16 | break;
17 | }
18 | count = count + 1;
19 | }
20 | if (index > -1) {
21 | data.splice(index, 1);
22 | }
23 | parsedUser.cart = data;
24 | await AsyncStorage.setItem('user', JSON.stringify(parsedUser));
25 | itemObj.navigation.navigate('Home', {fromCart: true});
26 | // itemObj.getdata();
27 | }
28 |
29 | class BasketItem extends Component {
30 | render() {
31 | // console.log(this.props.productId)
32 | // for(var i in this.props){
33 | // console.log(i)
34 | // }
35 | const { imageLink, name, price } = this.props;
36 | return (
37 |
38 |
39 |
42 |
43 |
44 |
45 | {name}
46 |
47 |
48 |
49 | Rs.{price}
50 |
51 |
52 |
53 | pressHandler(this.props)} name='delete' Text="delete" size={40} color='#545' />
54 |
55 |
56 |
57 |
58 |
59 | );
60 | }
61 | }
62 |
63 | export default BasketItem;
64 |
--------------------------------------------------------------------------------
/src/screens/Home/HomeScreen.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | FlatList,
4 | Text,
5 | ScrollView,
6 | View,
7 | Image,
8 | TouchableHighlight
9 | } from 'react-native';
10 |
11 | import MenuImage from '../../components/MenuImage/MenuImage';
12 | import styles from './styles';
13 |
14 | export default class HomeScreen extends React.Component {
15 | static navigationOptions = ({ navigation }) => ({
16 | title: 'Home',
17 | headerLeft: () =>
18 | {
20 | navigation.openDrawer();
21 | }}
22 | />
23 | });
24 | constructor(props) {
25 |
26 | super(props);
27 | this.state = {
28 | categories: []
29 | }
30 | }
31 |
32 | getData(categories) {
33 | this.setState({
34 | categories: categories
35 | })
36 | }
37 |
38 | componentDidMount() {
39 | // console.log(this.state)
40 | fetch("http://testdeployment-env.eba-eqdcmu3a.us-east-2.elasticbeanstalk.com/api/search/getCategories")
41 | .then(response => response.json())
42 | .then((categories) => this.getData(categories))
43 | .catch(err => console.log(err));
44 | }
45 |
46 |
47 | render() {
48 | const { navigate } = this.props.navigation;
49 | var fromCart = this.props.navigation.getParam('fromCart');
50 | if(fromCart == true){
51 | navigate('Cart');
52 | }
53 | const renderMenuItem = (item) => {
54 | return (
55 | navigate('ItemsList', { itemType: item.item })}>
57 |
58 |
59 | {item.item.toUpperCase()}
60 |
61 |
62 | )
63 | };
64 | const data = this.state.categories;
65 | if (data != undefined)
66 | return (
67 |
68 | item}
75 | />
76 |
77 | );
78 | else
79 | return (
80 |
81 | Check Your Network
82 |
83 | )
84 | }
85 | }
86 |
87 |
--------------------------------------------------------------------------------
/src/screens/Cart/styles.js:
--------------------------------------------------------------------------------
1 | import { StyleSheet } from 'react-native';
2 | import { widthPercentageToDP as wp } from "react-native-responsive-screen";
3 |
4 | const styles = StyleSheet.create({
5 | container: {
6 | flex: 1,
7 | justifyContent: 'center',
8 | alignItems: 'center'
9 | },
10 | items: {
11 | height: "80%"
12 | },
13 | checkoutbtn: {
14 | flexDirection: "row",
15 | backgroundColor: "#008037",
16 | justifyContent: "center",
17 | alignItems: "center",
18 | borderRadius: 2,
19 | shadowOffset: { width: 1, height: 2 },
20 | shadowColor: "#000",
21 | shadowOpacity: 0.4,
22 | elevation: 4,
23 | paddingVertical: 10
24 | },
25 | checkoutcontainer: {
26 | flex: 1,
27 | paddingHorizontal: 20,
28 | justifyContent: "flex-end",
29 | paddingBottom: 15,
30 | },
31 | checkout: {
32 | fontSize: 18,
33 | fontFamily: 'comic-bold',
34 | fontWeight: "500",
35 | color: "white"
36 | },
37 | totalcontainer: {
38 | flexDirection: "row",
39 | justifyContent: "space-between",
40 | alignItems: "center",
41 | paddingLeft: 20,
42 | paddingRight: 20,
43 | },
44 | total: {
45 | fontSize: 22,
46 | fontFamily: 'comic-bold',
47 | },
48 | cartitemcontainer: {
49 | height: wp("30%"),
50 | width: wp("100%"),
51 | backgroundColor: "white",
52 | flexDirection: "row",
53 | paddingHorizontal: 10,
54 | paddingVertical: 14,
55 | marginBottom: 5
56 | },
57 | imagecontainer: {
58 | width: wp("24%"),
59 | height: wp("24%"),
60 | marginRight: 10
61 | },
62 | image: {
63 | flex: 1,
64 | width: null,
65 | height: null,
66 | resizeMode: "contain"
67 | },
68 | itemdetails: {
69 | flex: 2,
70 | alignSelf: "flex-start",
71 | flexDirection: "row",
72 | justifyContent: "space-between"
73 | },
74 | namecontainer: {
75 | flex: 3,
76 | justifyContent: "space-around"
77 | },
78 | itemname: {
79 | fontSize: 20,
80 | fontFamily: 'comic-bold',
81 | },
82 | pricecontainer: {
83 | flex: 2,
84 | justifyContent: "center",
85 | alignItems: "center",
86 | flexDirection: 'column'
87 | },
88 | delete: {
89 | flexDirection: "column",
90 | justifyContent: 'center',
91 | paddingTop: 10
92 | },
93 | price: {
94 | fontSize: 20,
95 | fontFamily: 'comic-bold',
96 | }
97 | });
98 |
99 | export default styles;
100 |
--------------------------------------------------------------------------------
/src/screens/Search/SearchScreen.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Text, View, ScrollView, FlatList, TouchableHighlight, Image } from 'react-native';
3 | import { SearchBar } from 'react-native-elements';
4 | import styles from './styles';
5 |
6 |
7 | export default function SearchScreen(props) {
8 | const onPressItem = item => {
9 | props.navigation.navigate('ItemDetails', { item: item });
10 | };
11 |
12 | const renderMenuItem = ({ item }) => {
13 | return (
14 | onPressItem(item)}
15 | >
16 |
17 |
18 | {item.name}
19 |
20 |
21 | )
22 | };
23 |
24 | const [search, setSearch] = React.useState(" ");
25 | const [itemlist, setItemlist] = React.useState("");
26 | const updateSearch = (search) => {
27 | // search = search.toLowerCase()
28 | setSearch(search);
29 | fetch("http://testdeployment-env.eba-eqdcmu3a.us-east-2.elasticbeanstalk.com/api/search/text/" + search.toLowerCase(), {
30 | header: {
31 | 'Accept': 'application/json',
32 | 'Content-Type': 'application/json'
33 | },
34 | })
35 | .then(response => response.json())
36 | .then((item) => setItemlist(item))
37 | .catch(err => console.log(err));
38 | };
39 | if (itemlist)
40 | return (
41 |
42 |
47 |
48 | item._id}
55 | />
56 |
57 |
58 | )
59 | else return (
60 |
61 |
66 |
67 | );
68 | }
69 |
--------------------------------------------------------------------------------
/src/screens/Cart/CartScreen.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from "react";
2 | import { View, ScrollView, Text, TouchableOpacity, FlatList, AsyncStorage, RefreshControl } from "react-native";
3 | import { widthPercentageToDP as wp } from "react-native-responsive-screen";
4 | import Icon from "@expo/vector-icons/Ionicons";
5 | import CartItem from "./CartItem";
6 | import styles from './styles'
7 |
8 | function sleepFor(sleepDuration) {
9 | var now = new Date().getTime();
10 | while (new Date().getTime() < now + sleepDuration) { /* do nothing */ }
11 | }
12 |
13 | function calculatePrice(itemlist) {
14 | var price = 0;
15 | for (let i of itemlist) {
16 | price = price + i.price;
17 | }
18 | return price
19 | }
20 |
21 |
22 | class Cart extends Component {
23 |
24 | constructor(props) {
25 | super(props);
26 | this.state = {
27 | itemlist: [],
28 | render: true,
29 | price: 0,
30 | // refreshing: false,
31 | }
32 | }
33 |
34 |
35 | async getData() {
36 | var user = await AsyncStorage.getItem('user');
37 | var parsedUser = JSON.parse(user);
38 | // console.log(parsedUser.cart)
39 | this.setState({
40 | itemlist: parsedUser.cart,
41 | price: calculatePrice(parsedUser.cart)
42 | })
43 | // return parsedUser;
44 | }
45 | componentDidMount() {
46 | this.getData();
47 | }
48 |
49 | renderMenuItem = ({ item }) => {
50 | // console.log(item.price)
51 | return (
52 |
57 | )
58 | };
59 | render() {
60 | var data = this.state.itemlist;
61 | var price = this.state.price;
62 | return (
63 |
69 |
70 |
71 | item.id}
77 | />
78 |
79 |
80 |
86 |
87 | Total
88 | Rs.{price}
89 |
90 |
91 | {
94 | if (price > 0) {
95 | this.props.navigation.navigate("Checkout", { data: data })
96 | }
97 | else {
98 | alert("Your cart is empty");
99 | }
100 | }}
101 | style={styles.checkoutbtn}
102 | >
103 |
108 |
109 |
110 |
113 | CHECKOUT
114 |
115 |
116 |
117 |
118 |
119 | );
120 | }
121 | }
122 |
123 | export default Cart;
124 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/src/screens/login/login.js:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import styles from "./style";
3 | import logo from '../../../assets/logo.jpg';
4 | import { Keyboard, Text, View, TextInput, TouchableWithoutFeedback, Alert, KeyboardAvoidingView, ImageBackground } from 'react-native';
5 | import { Button } from 'react-native-elements';
6 | import { AsyncStorage } from 'react-native';
7 |
8 | export default function LoginScreen(props) {
9 | // console.log(props)
10 | const onOtpPress = () => {
11 | if (phoneNumber.length == 10) {
12 | fetch('http://testdeployment-env.eba-eqdcmu3a.us-east-2.elasticbeanstalk.com/api/login/init',
13 | {
14 | method: 'POST',
15 | headers: {
16 | Accept: 'application/json',
17 | 'Content-Type': 'application/json'
18 | },
19 | body: JSON.stringify({
20 | "phone": '+91' + phoneNumber
21 | })
22 | })
23 | .then(res => res.json())
24 | .then(function (res) {
25 | if (res != undefined) {
26 | alert("OTP sent successfully")
27 | }
28 | })
29 | .catch(function (error) {
30 | alert("Something went wrong");
31 | });
32 | } else {
33 | alert('Invalid Phone Number')
34 | }
35 | }
36 | const onSubmit = () => {
37 | fetch('http://testdeployment-env.eba-eqdcmu3a.us-east-2.elasticbeanstalk.com/api/login/verify',
38 | {
39 | method: 'POST',
40 | headers: {
41 | Accept: 'application/json',
42 | 'Content-Type': 'application/json'
43 | },
44 | body: JSON.stringify({
45 | "phone": '+91' + phoneNumber,
46 | "otp": otpVal
47 | })
48 | })
49 | .then(res => res.json())
50 | .then(async function (res) {
51 | if (res != null) {
52 | alert('success');
53 | console.log(res);
54 | AsyncStorage.setItem('user', JSON.stringify(res));
55 |
56 | var user = await AsyncStorage.getItem('user');
57 | var parsed = JSON.parse(user);
58 |
59 | // console.log('fetched user');
60 | // console.log(parsed);
61 |
62 |
63 | props.navigation.navigate('Home')
64 | } else {
65 | alert('try again')
66 | }
67 | })
68 | .catch(function (error) {
69 | alert(error);
70 | });
71 |
72 | }
73 | const onSubmitPartner = () => {
74 | console.log("submit form");
75 | }
76 | const [phoneNumber, onChangeNumber] = useState('')
77 | const [loginbtn, setloginbtn] = useState('Get OTP');
78 | const [otp, setOtp] = useState(['1', '2', '3', '4']);
79 | const [otpVal, setOtpVal] = useState('');
80 |
81 | return (
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 | onChangeNumber(text)}
98 | />
99 |
104 | setOtpVal(text)}
112 | />
113 |
118 | props.navigation.navigate('OrderDetails')}
122 | />
123 |
124 |
125 |
126 |
127 | );
128 | }
--------------------------------------------------------------------------------
/src/screens/Checkout/CheckoutScreen.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { TextInput, View, AsyncStorage } from 'react-native';
3 | import { Formik } from 'formik';
4 | import { Button } from 'react-native-elements';
5 |
6 | import styles from './styles';
7 |
8 | async function clearCart(props) {
9 | var user = await AsyncStorage.getItem('user');
10 | var parsedUser = JSON.parse(user);
11 | parsedUser.cart = [];
12 | AsyncStorage.setItem('user', JSON.stringify(parsedUser));
13 | props.navigation.navigate('Orders');
14 | }
15 | export default function ReviewForm(props) {
16 | const data = props.navigation.getParam('data');
17 | return (
18 |
19 | {
22 | var count = 0;
23 | for (let i of data) {
24 | count = count + 1;
25 | var orderObject = {
26 | name: values.name,
27 | userId: values.name,
28 | productId: i.productId,
29 | price: i.price,
30 | quantity: 1,
31 | addressLine1: values.address1,
32 | addressLine2: values.address2,
33 | pincode: values.pincode,
34 | city: values.city,
35 | state: values.state,
36 | }
37 |
38 | const myHeaders = new Headers();
39 | // myHeaders.append('sessionId', sessionID );
40 |
41 | await fetch("http://testdeployment-env.eba-eqdcmu3a.us-east-2.elasticbeanstalk.com/api/order/placeOrder", {
42 | method: 'POST',
43 | body: JSON.stringify(orderObject),
44 | headers: {
45 | 'Content-Type': 'application/json'
46 | }
47 | })
48 | .then(response => response.json())
49 | .then(async function (res) {
50 | if (res != null && count === data.length - 1) {
51 | alert('Order Placed Successfully');
52 | props.navigation.navigate('Home')
53 | }
54 | })
55 | .catch(err => console.log("Something went Wrong"));
56 | }
57 | clearCart(props);
58 | }}
59 | >
60 | {props => (
61 |
62 |
68 |
69 |
77 |
78 |
84 |
90 |
97 |
103 |
109 |
110 |
111 | )}
112 |
113 |
114 | );
115 | }
116 |
--------------------------------------------------------------------------------