Skip to content

Commit 606117f

Browse files
committed
initalCommit
0 parents  commit 606117f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+23366
-0
lines changed

.expo-shared/assets.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"12bb71342c6255bbf50437ec8f4441c083f47cdb74bd89160c15e4f43e52a1cb": true,
3+
"40b842e832070c58deac6aa9e08fa459302ee3f9da492c7e77d93d2fbf4a56fd": true
4+
}

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
node_modules/
2+
.expo/
3+
npm-debug.*
4+
*.jks
5+
*.p8
6+
*.p12
7+
*.key
8+
*.mobileprovision
9+
*.orig.*
10+
web-build/
11+
12+
# macOS
13+
.DS_Store

App.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import 'react-native-gesture-handler';
2+
import React, { useState } from 'react';
3+
import { StyleSheet} from 'react-native';
4+
import { createStore, combineReducers, applyMiddleware } from 'redux';
5+
import { Provider } from 'react-redux';
6+
import productsReducer from './store/reducers/products';
7+
import cartReducer from './store/reducers/cart';
8+
import orderReducer from './store/reducers/orders';
9+
import authReducer from './store/reducers/auth';
10+
import AppNavigator from './navigation/AppNavigator';
11+
import * as Font from 'expo-font';
12+
import AppLoading from 'expo-app-loading';
13+
import ReduxThunk from 'redux-thunk';
14+
15+
16+
17+
18+
19+
20+
const rootReducer = combineReducers({
21+
products: productsReducer,
22+
cart: cartReducer,
23+
orders: orderReducer,
24+
auth: authReducer
25+
})
26+
27+
const store = createStore(rootReducer, applyMiddleware(ReduxThunk));
28+
29+
const fetchFonts = () => {
30+
return Font.loadAsync({
31+
'open-sans': require('./assets/fonts/OpenSans-Regular.ttf'),
32+
'open-sans-bold': require('./assets/fonts/OpenSans-Bold.ttf'),
33+
})
34+
}
35+
36+
export default function App() {
37+
38+
const [fontLoaded, setFontLoaded] = useState(false);
39+
40+
41+
if (!fontLoaded) {
42+
return <AppLoading startAsync={fetchFonts} onFinish={() => setFontLoaded(true)} onError={(err) => console.log(err)} />
43+
}
44+
45+
46+
47+
return (
48+
<Provider store={store}>
49+
<AppNavigator />
50+
</Provider>
51+
);
52+
}
53+
54+
const styles = StyleSheet.create({
55+
container: {
56+
flex: 1,
57+
backgroundColor: '#fff',
58+
alignItems: 'center',
59+
justifyContent: 'center',
60+
},
61+
});

app.json

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"expo": {
3+
"name": "React Native Shop",
4+
"slug": "react-native-shop",
5+
6+
7+
"version": "1.0.0",
8+
9+
"description":"this is description only show in the expo cloud",
10+
"orientation": "portrait",
11+
12+
13+
"icon": "./assets/icon.png",
14+
"splash": {
15+
"image": "./assets/splash.png",
16+
"resizeMode": "contain",
17+
"backgroundColor": "#ffffff"
18+
},
19+
20+
"updates": {
21+
"fallbackToCacheTimeout": 0
22+
},
23+
24+
"assetBundlePatterns": [
25+
"**/*"
26+
],
27+
"ios": {
28+
"bundleIdentifier": "com.pavan709.react-native-shop",
29+
"supportsTablet": true,
30+
"buildNumber":"1.0.0"
31+
32+
},
33+
"android": {
34+
"package":"com.pavan709.react_native_shop",
35+
"versionCode":1,
36+
"adaptiveIcon": {
37+
"foregroundImage": "./assets/adaptive-icon.png",
38+
"backgroundColor": "#FFFFFF"
39+
},
40+
"permissions":[]
41+
},
42+
"web": {
43+
"favicon": "./assets/favicon.png"
44+
}
45+
46+
}
47+
}
48+
49+

assets/adaptive-icon.png

17.1 KB
Loading

assets/favicon.png

1.43 KB
Loading

assets/fonts/OpenSans-Bold.ttf

101 KB
Binary file not shown.

assets/fonts/OpenSans-Regular.ttf

94.2 KB
Binary file not shown.

assets/icon.png

21.9 KB
Loading

assets/splash.png

47.3 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/UI/Card.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import { View, StyleSheet } from 'react-native';
3+
4+
const Card = props => {
5+
return <View style={{...styles.card, ...props.style}}>
6+
{props.children}
7+
</View>
8+
}
9+
10+
const styles = StyleSheet.create({
11+
card:{
12+
shadowColor: 'black',
13+
shadowOpacity: 0.26,
14+
shadowOffset: { width: 0, height: 2 },
15+
shadowRadius:8,
16+
elevation: 5,
17+
borderRadius: 10,
18+
backgroundColor: 'white',
19+
}
20+
})
21+
22+
export default Card;

components/UI/HeaderButton.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
import { HeaderButton } from 'react-navigation-header-buttons';
3+
import Colors from '../../constants/Colors';
4+
import { Platform } from 'react-native';
5+
import {Ionicons} from '@expo/vector-icons';
6+
const CustomHeaderButton = props => {
7+
return <HeaderButton
8+
{...props}
9+
IconComponent={Ionicons}
10+
iconSize={23}
11+
color={Platform.OS === 'android' ? 'white' : Colors.blue12} />
12+
}
13+
14+
export default CustomHeaderButton;

components/UI/Input.js

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import React, { useReducer, useEffect } from 'react';
2+
import { View, Text, TextInput, StyleSheet } from 'react-native';
3+
import Colors from '../../constants/Colors';
4+
import { Entypo } from '@expo/vector-icons';
5+
6+
const INPUT_CHANGE = 'INPUT_CHANGE';
7+
const INPUT_BLUR = 'INPUT_BLUR';
8+
9+
const inputReducer = (state, action) => {
10+
switch (action.type) {
11+
case INPUT_CHANGE:
12+
return {
13+
...state,
14+
value: action.value,
15+
isValid: action.isValid,
16+
touched:action.isTouched,
17+
};
18+
case INPUT_BLUR:
19+
return {
20+
...state,
21+
touched: true
22+
};
23+
default:
24+
return state;
25+
}
26+
};
27+
28+
const Input = props => {
29+
const [inputState, dispatch] = useReducer(inputReducer, {
30+
value: props.initialValue ? props.initialValue : '',
31+
isValid: props.initiallyValid,
32+
touched: false
33+
});
34+
35+
const { onInputChange, id } = props;
36+
37+
useEffect(() => {
38+
if (inputState.touched) {
39+
onInputChange(id, inputState.value, inputState.isValid);
40+
}
41+
}, [inputState, onInputChange, id]);
42+
43+
const textChangeHandler = text => {
44+
const emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
45+
let isValid = true;
46+
if (props.required && text.trim().length === 0) {
47+
isValid = false;
48+
}
49+
if (props.email && !emailRegex.test(text.toLowerCase())) {
50+
isValid = false;
51+
}
52+
if (props.min && (+text < props.min || isNaN(text))) {
53+
isValid = false;
54+
}
55+
if (props.max != null && +text > props.max) {
56+
isValid = false;
57+
}
58+
if (props.minLength != null && text.length < props.minLength) {
59+
isValid = false;
60+
}
61+
dispatch({ type: INPUT_CHANGE, value: text, isValid: isValid, isTouched:true });
62+
};
63+
64+
const lostFocusHandler = () => {
65+
dispatch({ type: INPUT_BLUR });
66+
};
67+
68+
return (
69+
<View style={styles.formControl}>
70+
<Text style={styles.label}>{props.label}</Text>
71+
<TextInput
72+
{...props}
73+
style={{...styles.input,borderColor: (inputState.touched ? inputState.isValid ? Colors.green1 : Colors.red1 : Colors.fancy12),}}
74+
value={inputState.value}
75+
onChangeText={textChangeHandler}
76+
/>
77+
{inputState.touched && !inputState.isValid && (
78+
<View style={styles.errorContainer}>
79+
{/* <Entypo name="circle-with-cross" size={19} color={Colors.red1} /> */}
80+
<Text style={styles.errorText}>{props.errorText}</Text>
81+
</View>
82+
)}
83+
</View>
84+
);
85+
};
86+
87+
const styles = StyleSheet.create({
88+
formControl: {
89+
width: '100%'
90+
},
91+
label: {
92+
fontFamily: 'open-sans-bold',
93+
marginVertical: 8
94+
},
95+
input: {
96+
paddingHorizontal: 2,
97+
paddingVertical: 5,
98+
borderWidth:1,
99+
borderRadius:4,
100+
101+
},
102+
errorContainer: {
103+
marginVertical: 5,
104+
flexDirection:'row',
105+
justifyContent:'space-between',
106+
},
107+
errorText: {
108+
fontFamily: 'open-sans',
109+
color: 'red',
110+
fontSize: 13
111+
}
112+
});
113+
114+
export default Input;

components/shop/CartItem.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React from "react";
2+
import { View, Text, StyleSheet, Platform, TouchableOpacity, TouchableNativeFeedback } from 'react-native';
3+
import { Ionicons } from "@expo/vector-icons";
4+
5+
const CartItem = props => {
6+
return (
7+
<View style={styles.cartItem}>
8+
<Text style={styles.itemData}>
9+
<Text style={styles.quantity}>{props.quantity} </Text> <Text style={styles.mainText}>{props.title}</Text>
10+
</Text>
11+
12+
<View style={styles.itemData}>
13+
<Text style={styles.mainText}>${props.amount.toFixed(2)}</Text>
14+
15+
{props.deletable && <TouchableOpacity onPress={props.onRemove} style={styles.deleteButton}>
16+
<Ionicons name={Platform.OS === 'android' ? 'md-trash' : 'ios-trash'} size={23} color='red' />
17+
</TouchableOpacity>}
18+
</View>
19+
</View>
20+
)
21+
}
22+
23+
const styles = StyleSheet.create({
24+
cartItem: {
25+
padding: 10,
26+
backgroundColor: 'white',
27+
flexDirection: 'row',
28+
justifyContent: 'space-between',
29+
marginVertical: 20,
30+
},
31+
itemData: {
32+
flexDirection: 'row',
33+
alignItems: 'center',
34+
},
35+
quantity: {
36+
fontFamily: 'open-sans',
37+
color: '#888',
38+
fontSize: 16,
39+
},
40+
mainText: {
41+
fontFamily: 'open-sans-bold',
42+
fontSize: 16,
43+
},
44+
delete: {},
45+
deleteButton: {
46+
marginLeft: 20,
47+
},
48+
})
49+
50+
export default CartItem;

0 commit comments

Comments
 (0)