68 lines
2.0 KiB
Dart
68 lines
2.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../domain/entities/cart_item.dart';
|
|
import '../../../../shared/widgets/price_display.dart';
|
|
|
|
/// Cart item card widget
|
|
class CartItemCard extends StatelessWidget {
|
|
final CartItem item;
|
|
final VoidCallback? onRemove;
|
|
final Function(int)? onQuantityChanged;
|
|
|
|
const CartItemCard({
|
|
super.key,
|
|
required this.item,
|
|
this.onRemove,
|
|
this.onQuantityChanged,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Card(
|
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(12.0),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
item.productName,
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
),
|
|
const SizedBox(height: 4),
|
|
PriceDisplay(price: item.price),
|
|
],
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
IconButton(
|
|
icon: const Icon(Icons.remove_circle_outline),
|
|
onPressed: item.quantity > 1
|
|
? () => onQuantityChanged?.call(item.quantity - 1)
|
|
: null,
|
|
),
|
|
Text(
|
|
'${item.quantity}',
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.add_circle_outline),
|
|
onPressed: () => onQuantityChanged?.call(item.quantity + 1),
|
|
),
|
|
],
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.delete_outline),
|
|
onPressed: onRemove,
|
|
color: Theme.of(context).colorScheme.error,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|