150 lines
4.8 KiB
Dart
150 lines
4.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../common/extension/extension.dart';
|
|
import '../../../common/theme/theme.dart';
|
|
import '../../../sample/product_sample_data.dart';
|
|
|
|
class ProductCard extends StatelessWidget {
|
|
final Product product;
|
|
const ProductCard({super.key, required this.product});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: AppColor.surface,
|
|
borderRadius: BorderRadius.circular(12),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: AppColor.black.withOpacity(0.06),
|
|
blurRadius: 8,
|
|
offset: Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Product image
|
|
Expanded(
|
|
flex: 3,
|
|
child: Stack(
|
|
children: [
|
|
Container(
|
|
width: double.infinity,
|
|
decoration: BoxDecoration(
|
|
color: AppColor.backgroundLight,
|
|
borderRadius: BorderRadius.vertical(
|
|
top: Radius.circular(12),
|
|
),
|
|
),
|
|
child: Center(
|
|
child: Icon(
|
|
Icons.fastfood,
|
|
size: 40,
|
|
color: AppColor.textLight,
|
|
),
|
|
),
|
|
),
|
|
|
|
// Availability overlay
|
|
if (!product.isAvailable)
|
|
Container(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
decoration: BoxDecoration(
|
|
color: AppColor.black.withOpacity(0.6),
|
|
borderRadius: BorderRadius.vertical(
|
|
top: Radius.circular(12),
|
|
),
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
"HABIS",
|
|
style: AppStyle.sm.copyWith(
|
|
color: AppColor.textWhite,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
|
|
// Rating badge
|
|
Positioned(
|
|
top: 8,
|
|
right: 8,
|
|
child: Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 6, vertical: 3),
|
|
decoration: BoxDecoration(
|
|
color: AppColor.surface,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(Icons.star, size: 12, color: AppColor.warning),
|
|
SizedBox(width: 2),
|
|
Text(
|
|
"${product.rating}",
|
|
style: AppStyle.xs.copyWith(
|
|
color: AppColor.textPrimary,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
// Product info
|
|
Expanded(
|
|
flex: 2,
|
|
child: Padding(
|
|
padding: EdgeInsets.all(12),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
product.name,
|
|
style: AppStyle.md.copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
color: AppColor.textPrimary,
|
|
),
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
|
|
Spacer(),
|
|
|
|
// Price and sold count
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
"Rp ${product.price.currencyFormatRp}",
|
|
style: AppStyle.md.copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
color: AppColor.primary,
|
|
),
|
|
),
|
|
Text(
|
|
"${product.soldCount} terjual",
|
|
style: AppStyle.xs.copyWith(
|
|
color: AppColor.textSecondary,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|