-
Notifications
You must be signed in to change notification settings - Fork 0
create product page details with image slideshow,quantity and total … #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aboodswiti
wants to merge
1
commit into
main
Choose a base branch
from
detailPage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,186 @@ | ||
| import React, { useState, useEffect } from 'react'; | ||
| import { View, Text, Image, ScrollView, TouchableOpacity } from 'react-native'; | ||
| import { useSelector, useDispatch } from 'react-redux' | ||
| import React, {useState, useEffect} from 'react'; | ||
| import { | ||
| View, | ||
| Image, | ||
| ScrollView, | ||
| TouchableOpacity, | ||
| StyleSheet, | ||
| } from 'react-native'; | ||
| import {useSelector, useDispatch} from 'react-redux'; | ||
| import { | ||
| Card, | ||
| Divider, | ||
| ListItem, | ||
| Button, | ||
| Icon, | ||
| SearchBar, | ||
| Text, | ||
| } from 'react-native-elements'; | ||
|
|
||
| import ImageSliderz from 'react-native-image-slideshow'; | ||
|
|
||
| function CardDetails(props) { | ||
| const productDetails = useSelector(state => state) | ||
| console.log("cart", productDetails); | ||
| const productDetails = useSelector((state) => state.productDetails); | ||
| const [quantity, setQuantity] = useState(1); | ||
| const price = productDetails.price.slice(1); | ||
| const [total, setTotal] = useState(price); | ||
|
|
||
| console.log('cart', productDetails.picture); | ||
| // take the data from productDetails | ||
|
|
||
| const onPressDec = () => | ||
| setQuantity((prevCount) => (prevCount != 1 ? prevCount - 1 : 1)); | ||
| const onPressInc = () => setQuantity((prevCount) => prevCount + 1); | ||
|
|
||
| useEffect(() => { | ||
| setTotal(price * quantity); | ||
| }, [quantity]); | ||
|
|
||
| return ( | ||
| <View > | ||
| <Text>hi</Text> | ||
| </View > | ||
| <ScrollView> | ||
| <View style={styles.container}> | ||
| <Card containerStyle={styles.card}> | ||
| <ImageSliderz | ||
| dataSource={[ | ||
| { | ||
| url: productDetails.picture, | ||
| }, | ||
| { | ||
| url: productDetails.picture, | ||
| }, | ||
| { | ||
| url: productDetails.picture, | ||
| }, | ||
| ]} | ||
| height={250} | ||
| /> | ||
| <View style={styles.text}> | ||
| <Card.FeaturedTitle style={styles.cardName}> | ||
| <Icon name="price-tag" type="entypo" size={26} color="#015A20" /> | ||
|
|
||
| {productDetails.name} | ||
| </Card.FeaturedTitle> | ||
|
|
||
| <Card.FeaturedTitle style={styles.cardPrice}> | ||
| {productDetails.price} | ||
| </Card.FeaturedTitle> | ||
| </View> | ||
| </Card> | ||
| <View style={styles.description}> | ||
| <Text h4 h4Style={{fontSize: 15, paddingBottom: 8}}> | ||
| Description : | ||
| </Text> | ||
| <Text>{productDetails.brief}</Text> | ||
| </View> | ||
|
|
||
| <View style={styles.amount}> | ||
| <View style={styles.amount}> | ||
| <TouchableOpacity onPress={onPressDec}> | ||
| <Icon | ||
| name="circle-with-minus" | ||
| type="entypo" | ||
| size={26} | ||
| color="#015A20" | ||
| /> | ||
| </TouchableOpacity> | ||
|
|
||
| <Text h4> {quantity} </Text> | ||
| <TouchableOpacity onPress={onPressInc}> | ||
| <Icon | ||
| name="circle-with-plus" | ||
| type="entypo" | ||
| size={26} | ||
| color="#015A20" | ||
| /> | ||
| </TouchableOpacity> | ||
| </View> | ||
| <View> | ||
| <Text h4> | ||
| Total:{' '} | ||
| <Text h4 style={styles.total}> | ||
| ${total} | ||
| </Text> | ||
| </Text> | ||
| </View> | ||
| </View> | ||
| <TouchableOpacity style={styles.buttonContainer}> | ||
| <Text h4 style={styles.buttonText}> | ||
| Add to Cart | ||
| </Text> | ||
| </TouchableOpacity> | ||
| </View> | ||
| </ScrollView> | ||
| ); | ||
| } | ||
|
|
||
| export default CardDetails; | ||
| const styles = StyleSheet.create({ | ||
| container: { | ||
| paddingLeft: 15, | ||
| paddingRight: 15, | ||
| paddingTop: 15, | ||
| }, | ||
| card: { | ||
| shadowColor: '#000', | ||
| shadowOffset: { | ||
| width: 0, | ||
| height: 9, | ||
| }, | ||
| shadowOpacity: 0.48, | ||
| shadowRadius: 11.95, | ||
|
|
||
| elevation: 18, | ||
| }, | ||
| cardName: { | ||
| color: 'black', | ||
| fontSize: 16, | ||
| height: 40, | ||
| }, | ||
| cardPrice: { | ||
| alignSelf: 'flex-end', | ||
| color: 'white', | ||
| fontSize: 14, | ||
| padding: 10, | ||
| paddingTop: 6, | ||
| paddingBottom: 6, | ||
| borderRadius: 15, | ||
| backgroundColor: '#015A20', | ||
| }, | ||
| text: { | ||
| flex: 1, | ||
| margin: 5, | ||
| display: 'flex', | ||
| flexDirection: 'row', | ||
| justifyContent: 'space-between', | ||
| }, | ||
| description: { | ||
| margin: 15, | ||
| }, | ||
| amount: { | ||
| margin: 5, | ||
| display: 'flex', | ||
| flexDirection: 'row', | ||
| justifyContent: 'space-between', | ||
| }, | ||
| total: { | ||
| paddingTop: 2, | ||
| color: '#015A20', | ||
| }, | ||
| buttonContainer: { | ||
| margin: 10, | ||
| elevation: 8, | ||
| backgroundColor: '#013A20', | ||
| borderRadius: 10, | ||
| paddingVertical: 10, | ||
| paddingHorizontal: 10, | ||
| borderRadius: 35, | ||
| }, | ||
| buttonText: { | ||
| fontSize: 18, | ||
| color: '#fff', | ||
| fontWeight: 'bold', | ||
| alignSelf: 'center', | ||
| textTransform: 'uppercase', | ||
| }, | ||
| }); | ||
|
|
||
| export default CardDetails; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add function to add the product to the cart, you can use redux to save the items