1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
import React, { useContext } from 'react';
import { View, Text, Button, StyleSheet, ScrollView } from 'react-native';
import { CartContext } from '../../context/CartContext';
const CartScreen = ({ navigation }) => {
const { cart, updateQuantity } = useContext(CartContext);
const handleCheckout = () => navigation.navigate('Checkout');
return (
<ScrollView contentContainerStyle={styles.container}>
{cart.map((item, index) => (
<View key={index} style={styles.itemContainer}>
<Text style={styles.itemText}>{item.name}</Text>
<Text style={styles.quantityText}>Quantity: {item.quantity}</Text>
<Button
title="Increase Quantity"
onPress={() => updateQuantity(item.id, item.quantity + 1)}
/>
</View>
))}
<View style={styles.checkoutButton}>
<Button title="Proceed to Checkout" onPress={handleCheckout} />
</View>
</ScrollView>
);
};
const styles = StyleSheet.create({
container: {
padding: 16,
backgroundColor: '#f8f9fa',
},
itemContainer: {
backgroundColor: '#ffffff',
padding: 16,
borderRadius: 8,
marginBottom: 12,
elevation: 2, // for subtle shadow on Android
shadowColor: '#000', // for iOS shadow
shadowOpacity: 0.2,
shadowRadius: 3,
shadowOffset: { width: 1, height: 2 },
},
itemText: {
fontSize: 18,
fontWeight: 'bold',
color: '#333',
marginBottom: 4,
},
quantityText: {
fontSize: 16,
color: '#666',
marginBottom: 8,
},
checkoutButton: {
marginTop: 20,
paddingVertical: 10,
borderRadius: 8,
},
});
export default CartScreen;
|