diff options
author | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-10-16 16:29:28 +0530 |
---|---|---|
committer | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-10-16 16:29:28 +0530 |
commit | ff21a7ff19d0eb67016c1a3b297aa227c315c910 (patch) | |
tree | 35e30d45833a962f7363b5ca447b9ba6b37b3093 /src/components | |
parent | 4773102af221fc38342869c4ba0b571e02f4400e (diff) | |
download | mall-app-ff21a7ff19d0eb67016c1a3b297aa227c315c910.tar.gz mall-app-ff21a7ff19d0eb67016c1a3b297aa227c315c910.tar.bz2 mall-app-ff21a7ff19d0eb67016c1a3b297aa227c315c910.zip |
Add ProductModal component for showing product details and add-to-cart functionality
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/ProductModal.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/components/ProductModal.js b/src/components/ProductModal.js index e69de29..a78e86a 100644 --- a/src/components/ProductModal.js +++ b/src/components/ProductModal.js @@ -0,0 +1,40 @@ +import React from 'react'; +import { View, Text, Button, Modal, StyleSheet } from 'react-native'; + +const ProductModal = ({ visible, product, onClose, onAddToCart }) => ( + <Modal visible={visible} transparent animationType="slide"> + <View style={styles.modalContainer}> + <View style={styles.modalContent}> + <Text style={styles.productName}>{product.name}</Text> + <Text style={styles.productDescription}>{product.description}</Text> + <Text style={styles.productPrice}>Price: ${product.price}</Text> + <View style={styles.buttonContainer}> + <Button title="Add to Cart" onPress={onAddToCart} /> + <Button title="Cancel" onPress={onClose} /> + </View> + </View> + </View> + </Modal> +); + +const styles = StyleSheet.create({ + modalContainer: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + backgroundColor: 'rgba(0, 0, 0, 0.5)', + }, + modalContent: { + width: 300, + padding: 20, + backgroundColor: 'white', + borderRadius: 8, + alignItems: 'center', + }, + productName: { fontSize: 20, fontWeight: 'bold' }, + productDescription: { fontSize: 16, marginVertical: 10 }, + productPrice: { fontSize: 18, color: '#333' }, + buttonContainer: { flexDirection: 'row', marginTop: 15 }, +}); + +export default ProductModal; |