pd-android-app/lib/widgets/product_card.dart
2024-08-26 11:04:37 +05:30

175 lines
7.1 KiB
Dart

import 'package:cheminova/models/product_model.dart';
import 'package:cheminova/screens/product/product_detail_screen.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
class ProductCard extends StatelessWidget {
final ProductModel product;
final bool isInCart;
final bool isCheckout;
const ProductCard({
super.key,
required this.product,
this.isInCart = false,
this.isCheckout = false,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => isInCart || isCheckout
? null
: Get.to(() => ProductDetailScreen(product: product)),
child: Card(
child: Row(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(15.0),
child: Container(
height: Get.height * 0.15,
width: Get.width * 0.30,
decoration: BoxDecoration(
image: DecorationImage(
image: Image.asset(product.image).image,
fit: BoxFit.cover,
),
),
),
),
),
const SizedBox(
width: 10,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
product.name,
style: GoogleFonts.roboto(
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
Text(
product.category.name,
style: GoogleFonts.roboto(
fontSize: 14,
fontWeight: FontWeight.w400,
),
),
Text(
"${product.price.toString()}0",
style: GoogleFonts.roboto(
fontSize: 22,
fontWeight: FontWeight.w700,
),
),
isCheckout
? const SizedBox()
: isInCart
? Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: 40,
width: 100,
decoration: BoxDecoration(
color: const Color(0xFF004791),
borderRadius: BorderRadius.circular(10),
),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
SizedBox(
height: 24,
width: 24,
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
padding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(8.0),
),
),
child: Text(
'+',
style: GoogleFonts.roboto(
fontSize: 16,
fontWeight: FontWeight.w800,
),
),
),
),
Text(
product.quantity.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 16,
),
),
SizedBox(
height: 24,
width: 24,
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
padding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(8.0),
),
),
child: Text(
'-',
style: GoogleFonts.roboto(
fontSize: 16,
fontWeight: FontWeight.w800,
),
),
),
),
],
),
),
IconButton(
onPressed: () {},
icon: const Icon(
Icons.delete_outline_rounded,
color: Colors.red,
),
)
],
)
: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: const Color(0xFF00784C),
padding: const EdgeInsets.symmetric(
horizontal: 18, vertical: 8),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
),
),
child: Text(
"Add To Cart",
style: GoogleFonts.roboto(
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
),
],
)
],
),
),
);
}
}