diff options
author | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-10-16 16:18:13 +0530 |
---|---|---|
committer | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-10-16 16:18:13 +0530 |
commit | cb65e181d120d2d9ff0672e12fc2db3b16d85d1c (patch) | |
tree | 4375346d953527c1c195dd9951c1218b69a54ef4 /src | |
parent | 89ccd1e2597ed77c985c49dc075f7a038ec6a5d1 (diff) | |
download | mall-app-cb65e181d120d2d9ff0672e12fc2db3b16d85d1c.tar.gz mall-app-cb65e181d120d2d9ff0672e12fc2db3b16d85d1c.tar.bz2 mall-app-cb65e181d120d2d9ff0672e12fc2db3b16d85d1c.zip |
Add ProductScannerScreen with barcode scanning and add-to-cart
Diffstat (limited to 'src')
-rw-r--r-- | src/screens/ProductScannerScreen.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/screens/ProductScannerScreen.js b/src/screens/ProductScannerScreen.js new file mode 100644 index 0000000..95d5865 --- /dev/null +++ b/src/screens/ProductScannerScreen.js @@ -0,0 +1,29 @@ +import React, { useState } from 'react'; +import { View, Text, Button } from 'react-native'; +import BarcodeScanner from '../../components/BarcodeScanner'; + +const ProductScannerScreen = ({ navigation }) => { + const [scannedProduct, setScannedProduct] = useState(null); + + const handleScan = (product) => setScannedProduct(product); + + const handleAddToCart = () => { + // Add product to cart and navigate to cart screen + navigation.navigate('Cart'); + }; + + return ( + <View> + <BarcodeScanner onScan={handleScan} /> + {scannedProduct && ( + <View> + <Text>{scannedProduct.name}</Text> + <Text>{scannedProduct.price}</Text> + <Button title="Add to Cart" onPress={handleAddToCart} /> + </View> + )} + </View> + ); +}; + +export default ProductScannerScreen; |