Skip to content

Commit

Permalink
Products displayed in home screen and ProductDetailScreen add
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanoPitto committed Dec 12, 2022
1 parent 0edf6a4 commit aeb5e41
Show file tree
Hide file tree
Showing 10 changed files with 7,171 additions and 36 deletions.
2 changes: 1 addition & 1 deletion App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default function App() {
<Navigator />
</NavigationContainer>
);
}
}
44 changes: 25 additions & 19 deletions assets/products.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,68 @@
"products": [
{
"id": 1,
"productName": "JORDAN 1",
"productName": "Jordan 1",
"imageURL": "https://cdn.shopify.com/s/files/1/0575/1560/6175/products/air-jordan-1-mid-beige-white-red-1-1000.png?v=1652833639",
"productPrice": 500
},
{
"id": 2,
"productName": "JORDAN 1",
"imageURL": "https://www.pngmart.com/files/21/Air-Jordan-PNG-Isolated-Photo.png",
"productName": "Jordan 1",
"imageURL": "https://static.nike.com/a/images/t_default/4aba5b61-ed0e-47eb-aa36-2f59c3236087/calzado-grandes-air-jordan-1-mid-se-tq5tn3.png",
"productPrice": 500
},
{
"id": 3,
"productName": "JORDAN 1",
"imageURL": "https://static.nike.com/a/images/t_default/4aba5b61-ed0e-47eb-aa36-2f59c3236087/calzado-grandes-air-jordan-1-mid-se-tq5tn3.png",
"productName": "Jordan 1",
"imageURL": "https://cdn.shopify.com/s/files/1/0388/8847/2707/products/flowerkickzAir_Jordan_1_Mid_Light_Mulberry-DC7267-500-0_2000x.png?v=1652698987",
"productPrice": 500
},
{
"id": 4,
"productName": "JORDAN 1",
"imageURL": "https://cdn.shopify.com/s/files/1/0388/8847/2707/products/flowerkickzAir_Jordan_1_Mid_Light_Mulberry-DC7267-500-0_2000x.png?v=1652698987",
"productName": "Jordan 1",
"imageURL": "https://www.backseries.com/wp-content/uploads/2021/08/Nike-Air-Jordan-1-High-Pollen-555088_701_A_PREM-800x800.png",
"productPrice": 500
},
{
"id": 5,
"productName": "JORDAN 1",
"imageURL": "https://www.backseries.com/wp-content/uploads/2021/08/Nike-Air-Jordan-1-High-Pollen-555088_701_A_PREM-800x800.png",
"productName": "Jordan 1",
"imageURL": "https://static.nike.com/a/images/t_default/18684354-59f1-4ec0-ac7d-874e62063634/air-jordan-1-mid-se-shoes-hHltxp.png",
"productPrice": 500
},
{
"id": 6,
"productName": "JORDAN 1",
"imageURL": "https://static.nike.com/a/images/t_default/18684354-59f1-4ec0-ac7d-874e62063634/air-jordan-1-mid-se-shoes-hHltxp.png",
"productName": "Jordan 1",
"imageURL": "https://static.nike.com/a/images/t_default/585f399c-2ae5-4e12-9a4e-df531c0de400/calzado-air-jordan-1-retro-high-og-llwS2v.png",
"productPrice": 500
},
{
"id": 7,
"productName": "JORDAN 1",
"imageURL": "https://static.nike.com/a/images/t_default/585f399c-2ae5-4e12-9a4e-df531c0de400/calzado-air-jordan-1-retro-high-og-llwS2v.png",
"productName": "Jordan 1",
"imageURL": "https://cdn.shopify.com/s/files/1/0086/0946/4375/products/555088-037-PHSLH000-2000_400x.png?v=1661198717",
"productPrice": 500
},
{
"id": 8,
"productName": "JORDAN 1",
"imageURL": "https://cdn.shopify.com/s/files/1/0086/0946/4375/products/555088-037-PHSLH000-2000_400x.png?v=1661198717",
"productName": "Jordan 1",
"imageURL": "https://static.nike.com/a/images/t_default/7cf13a77-290d-40f3-a58e-7174966c504d/air-jordan-1-mid-se-big-kids-shoes-7rQxbT.png",
"productPrice": 500
},
{
"id": 9,
"productName": "JORDAN 1",
"imageURL": "https://cdn.shopify.com/s/files/1/0571/9526/6231/products/air-jordan-1-hi-flyease-older-shoes-GLXvxk.png?v=1666325859",
"productName": "Air Force 1 High",
"imageURL": "https://static.nike.com/a/images/t_default/0d82a8f5-561e-4f12-bac9-c4102e75b8c7/custom-nike-air-force-1-high-by-you-shoes.png",
"productPrice": 500
},
{
"id": 10,
"productName": "JORDAN 1",
"imageURL": "https://static.nike.com/a/images/t_default/7cf13a77-290d-40f3-a58e-7174966c504d/air-jordan-1-mid-se-big-kids-shoes-7rQxbT.png",
"productName": "Air Force 1 Mid",
"imageURL": "https://static.nike.com/a/images/t_default/60618c33-70df-45c4-98eb-4870f2625b6c/custom-nike-air-force-1-mid-by-you-shoes.png",
"productPrice": 500
},
{
"id": 11,
"productName": "Nike Dunk High",
"imageURL": "https://static.nike.com/a/images/t_default/e3bdb728-8ab2-4812-80c0-a1484c5966bc/custom-nike-dunk-high-by-you-shoes.png",
"productPrice": 500
}
]
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@
},
"dependencies": {
"@expo-google-fonts/inter": "^0.2.2",
"@expo/vector-icons": "^13.0.0",
"@react-navigation/bottom-tabs": "^6.5.0",
"@react-navigation/native": "^6.1.0",
"@react-navigation/native-stack": "^6.9.5",
"@react-navigation/stack": "^6.3.8",
"expo": "~47.0.8",
"expo-font": "~11.0.1",
"expo-linear-gradient": "~12.0.1",
"expo-status-bar": "~1.4.2",
"react": "18.1.0",
"react-native": "0.70.5",
"react-native-safe-area-context": "4.4.1"
"react-native-gesture-handler": "~2.8.0",
"react-native-reanimated": "~2.12.0",
"react-native-safe-area-context": "4.4.1",
"react-native-screens": "~3.18.0"
},
"devDependencies": {
"@babel/core": "^7.12.9"
Expand Down
47 changes: 40 additions & 7 deletions src/Components/ProductItem.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,59 @@
import React from "react";
import { View, Image, StyleSheet } from "react-native";
import { View, Image, StyleSheet, TouchableOpacity } from "react-native";
import { Text } from "./Text";
import { useNavigation } from "@react-navigation/native";

export const ProductItem = ({ item }) => {
const navigator = useNavigation();
return (
<View style={styles.container}>
<Image style={styles.image} source={{ uri: item.imageURL }} />
<Text style={styles.textStyle}>{item.productName}</Text>
</View>
<TouchableOpacity
onPress={() => {
navigator.navigate("ProductDetailScreen", item);
}}
>
<View style={styles.container}>
<View style={styles.imageContainer}>
<Image style={styles.image} source={{ uri: item.imageURL }} />
</View>
<View style={styles.textContainer}>
<Text style={styles.textStyle}>{item.productName}</Text>
<Text>${item.productPrice}</Text>
</View>
</View>
</TouchableOpacity>
);
};

const styles = StyleSheet.create({
container: { width: 180, marginTop: 80 },
container: {
width: 300,
marginTop: 40,
paddingVertical: 20,
marginRight: "auto",
marginLeft: "auto",
backgroundColor: "#a8edf599",
borderRadius: 10,
},
imageContainer: {
width: 180,
height: 180,
marginRight: "auto",
marginLeft: "auto",
},
image: {
widht: 180,
height: 180,
resizeMode: "contain",
},
textStyle: {
textAlign: "left",
marginTop: 40,
color: "#ffffff",
fontSize: 16,
},
textContainer: {
display: "flex",
justifyContent: "space-around",
alignItems: "center",
flexDirection: "row",
},
});
8 changes: 6 additions & 2 deletions src/Navigator/Navigator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { HomeScreen } from "../Screens/HomeScreen";
import { HomeStackNavigator } from "../StackNavigator/HomeStackNavigator";

const Tab = createBottomTabNavigator();

Expand All @@ -10,6 +10,10 @@ export const Navigator = () => (
headerShown: false,
}}
>
<Tab.Screen name="Home" component={HomeScreen} />
<Tab.Screen
name="HomeStackNavigator"
options={{ title: "Home" }}
component={HomeStackNavigator}
/>
</Tab.Navigator>
);
3 changes: 1 addition & 2 deletions src/Screens/HomeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
FlatList,
StyleSheet,
} from "react-native";

import { Text } from "../Components/Text";
import { useProducts } from "../Hooks/useProducts";
import { LinearGradient } from "expo-linear-gradient";
Expand Down Expand Up @@ -39,7 +40,6 @@ export const HomeScreen = () => {
contentContainerStyle={style.list}
data={products}
style={style.list}
numColumns="2"
renderItem={({ item }) => <ProductItem item={item} />}
showsVerticalScrollIndicator={false}
/>
Expand All @@ -52,7 +52,6 @@ export const HomeScreen = () => {

const style = StyleSheet.create({
list: {
marginLeft: 12,
marginBottom: 100,
},
});
Loading

0 comments on commit aeb5e41

Please sign in to comment.