aboutsummaryrefslogtreecommitdiffstats
path: root/src/screens/Checkout/CheckoutScreen.js
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-10-17 20:39:35 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-10-17 20:39:35 +0530
commit6a76594f71ffba95a3480e57f4a4243e212e09ba (patch)
tree85b83a3656c83ef7e8ffe1be88b4c926568e7c76 /src/screens/Checkout/CheckoutScreen.js
parent3b6a18902ee9c4970dbcc5a2d8d111256a0b3736 (diff)
downloadmall-app-6a76594f71ffba95a3480e57f4a4243e212e09ba.tar.gz
mall-app-6a76594f71ffba95a3480e57f4a4243e212e09ba.tar.bz2
mall-app-6a76594f71ffba95a3480e57f4a4243e212e09ba.zip
Added styling to the Cart and Checkout page
Diffstat (limited to 'src/screens/Checkout/CheckoutScreen.js')
-rw-r--r--src/screens/Checkout/CheckoutScreen.js75
1 files changed, 70 insertions, 5 deletions
diff --git a/src/screens/Checkout/CheckoutScreen.js b/src/screens/Checkout/CheckoutScreen.js
index a8645d2..4cd8938 100644
--- a/src/screens/Checkout/CheckoutScreen.js
+++ b/src/screens/Checkout/CheckoutScreen.js
@@ -1,5 +1,5 @@
import React, { useContext } from 'react';
-import { View, Text, Button } from 'react-native';
+import { View, Text, Button, StyleSheet, ScrollView } from 'react-native';
import { CartContext } from '../../context/CartContext';
import emailService from '../../services/emailService';
@@ -13,14 +13,79 @@ const CheckoutScreen = ({ navigation }) => {
navigation.navigate('Invoice');
};
+ const totalAmount = cart.reduce((total, item) => total + item.price * item.quantity, 0);
+
return (
- <View>
+ <ScrollView contentContainerStyle={styles.container}>
+ <Text style={styles.title}>Checkout</Text>
{cart.map((item, index) => (
- <Text key={index}>{item.name} - ${item.price * item.quantity}</Text>
+ <View key={index} style={styles.itemContainer}>
+ <Text style={styles.itemText}>{item.name}</Text>
+ <Text style={styles.priceText}>${(item.price * item.quantity).toFixed(2)}</Text>
+ </View>
))}
- <Button title="Confirm and Pay" onPress={handlePayment} />
- </View>
+ <View style={styles.totalContainer}>
+ <Text style={styles.totalText}>Total: ${totalAmount.toFixed(2)}</Text>
+ </View>
+ <View style={styles.buttonContainer}>
+ <Button title="Confirm and Pay" onPress={handlePayment} />
+ </View>
+ </ScrollView>
);
};
+const styles = StyleSheet.create({
+ container: {
+ padding: 16,
+ backgroundColor: '#f8f9fa',
+ },
+ title: {
+ fontSize: 24,
+ fontWeight: 'bold',
+ marginBottom: 20,
+ textAlign: 'center',
+ },
+ itemContainer: {
+ backgroundColor: '#ffffff',
+ padding: 16,
+ borderRadius: 8,
+ marginBottom: 12,
+ elevation: 2,
+ shadowColor: '#000',
+ shadowOpacity: 0.2,
+ shadowRadius: 3,
+ shadowOffset: { width: 1, height: 2 },
+ },
+ itemText: {
+ fontSize: 18,
+ color: '#333',
+ },
+ priceText: {
+ fontSize: 16,
+ color: '#888',
+ },
+ totalContainer: {
+ marginTop: 20,
+ padding: 16,
+ backgroundColor: '#ffffff',
+ borderRadius: 8,
+ elevation: 2,
+ shadowColor: '#000',
+ shadowOpacity: 0.2,
+ shadowRadius: 3,
+ shadowOffset: { width: 1, height: 2 },
+ },
+ totalText: {
+ fontSize: 20,
+ fontWeight: 'bold',
+ textAlign: 'center',
+ color: '#333',
+ },
+ buttonContainer: {
+ marginTop: 20,
+ borderRadius: 8,
+ },
+});
+
export default CheckoutScreen;
+