1// ── PRODUCT CARD WIDGET ──
2class ProductCard extends StatelessWidget {
3 final Product product;
4 final VoidCallback onTap;
5 const ProductCard({super.key, required this.product, required this.onTap});
6
7 @override
8 Widget build(BuildContext context) {
9 return GestureDetector(
10 onTap: onTap,
11 child: Card(
12 clipBehavior: Clip.antiAlias,
13 child: Column(
14 crossAxisAlignment: CrossAxisAlignment.start,
15 children: [
16 // Product image with sale badge
17 Stack(
18 children: [
19 AspectRatio(
20 aspectRatio: 1,
21 child: Image.network(
22 product.images.first,
23 fit: BoxFit.cover,
24 ),
25 ),
26 if (product.salePrice != null)
27 Positioned(
28 top: 8, left: 8,
29 child: Container(
30 padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
31 decoration: BoxDecoration(
32 color: Colors.red,
33 borderRadius: BorderRadius.circular(4),
34 ),
35 child: Text(
36 '-${product.discountPercent.toInt()}%',
37 style: const TextStyle(color: Colors.white, fontSize: 12),
38 ),
39 ),
40 ),
41 ],
42 ),
43
44 Padding(
45 padding: const EdgeInsets.all(8),
46 child: Column(
47 crossAxisAlignment: CrossAxisAlignment.start,
48 children: [
49 Text(product.name,
50 maxLines: 2, overflow: TextOverflow.ellipsis,
51 style: const TextStyle(fontWeight: FontWeight.w600)),
52 const SizedBox(height: 4),
53 // Rating
54 Row(
55 children: [
56 ...List.generate(5, (i) => Icon(
57 i < product.rating.round() ? Icons.star : Icons.star_border,
58 size: 14, color: Colors.amber,
59 )),
60 Text(' (${product.reviewCount})',
61 style: TextStyle(fontSize: 12, color: Colors.grey[600])),
62 ],
63 ),
64 const SizedBox(height: 4),
65 // Price
66 Row(
67 children: [
68 Text('$${product.effectivePrice.toStringAsFixed(2)}',
69 style: const TextStyle(
70 fontSize: 16, fontWeight: FontWeight.bold, color: Colors.green)),
71 if (product.salePrice != null) ...[
72 const SizedBox(width: 4),
73 Text('$${product.price.toStringAsFixed(2)}',
74 style: const TextStyle(
75 fontSize: 12, decoration: TextDecoration.lineThrough,
76 color: Colors.grey)),
77 ],
78 ],
79 ),
80 ],
81 ),
82 ),
83 ],
84 ),
85 ),
86 );
87 }
88}
89
90// ── CHECKOUT FLOW ──
91// Step 1: Review cart items
92// Step 2: Enter shipping address
93// Step 3: Select payment method
94// Step 4: Confirm and place order
95// Step 5: Show order confirmation with tracking ID