productdetails
This commit is contained in:
@@ -190,192 +190,198 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
double cardWidth =
|
||||
MediaQuery.of(context).size.width * 0.4; // Dynamic width
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 10, bottom: 5, top: 5),
|
||||
child: Container(
|
||||
width: cardWidth,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.1),
|
||||
blurRadius: 1,
|
||||
offset: const Offset(5, 5),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height * 0.12,
|
||||
width: cardWidth * 0.9,
|
||||
decoration: BoxDecoration(
|
||||
color: APPCOLOR.bgGrey,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push(MyRoutes.PRODUCTDETAILS,
|
||||
extra: bestdealproduct.id);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 10, bottom: 5, top: 5),
|
||||
child: Container(
|
||||
width: cardWidth,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.1),
|
||||
blurRadius: 1,
|
||||
offset: const Offset(5, 5),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height * 0.12,
|
||||
width: cardWidth * 0.9,
|
||||
decoration: BoxDecoration(
|
||||
color: APPCOLOR.bgGrey,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
AppNetworkImage(
|
||||
height: MediaQuery.of(context).size.height *
|
||||
0.08,
|
||||
width: cardWidth * 0.7,
|
||||
imageUrl: bestdealproduct
|
||||
.productImages?.first?.url ??
|
||||
"",
|
||||
backGroundColor: Colors.transparent,
|
||||
),
|
||||
// Positioned(
|
||||
// right: 5,
|
||||
// top: 5,
|
||||
// child: InkWell(
|
||||
// onTap: () async {
|
||||
// if (await SharedPrefUtils.getToken() !=
|
||||
// null) {
|
||||
// provider.toggleWishlist(
|
||||
// context, bestdealproduct.id!);
|
||||
// } else {
|
||||
// context.push(MyRoutes.LOGIN);
|
||||
// }
|
||||
// },
|
||||
// child: Icon(
|
||||
// provider.wishlist
|
||||
// .contains(bestdealproduct.id)
|
||||
// ? Icons.favorite
|
||||
// : Icons.favorite_border,
|
||||
// color: provider.wishlist
|
||||
// .contains(bestdealproduct.id)
|
||||
// ? Colors.red
|
||||
// : Colors.grey,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
AppNetworkImage(
|
||||
height:
|
||||
MediaQuery.of(context).size.height * 0.08,
|
||||
width: cardWidth * 0.7,
|
||||
imageUrl: bestdealproduct
|
||||
.productImages?.first?.url ??
|
||||
"",
|
||||
backGroundColor: Colors.transparent,
|
||||
),
|
||||
Positioned(
|
||||
right: 5,
|
||||
top: 5,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
if (await SharedPrefUtils.getToken() !=
|
||||
null) {
|
||||
provider.toggleWishlist(
|
||||
context, bestdealproduct.id!);
|
||||
} else {
|
||||
context.push(MyRoutes.LOGIN);
|
||||
}
|
||||
},
|
||||
child: Icon(
|
||||
provider.wishlist
|
||||
.contains(bestdealproduct.id)
|
||||
? Icons.favorite
|
||||
: Icons.favorite_border,
|
||||
color: provider.wishlist
|
||||
.contains(bestdealproduct.id)
|
||||
? Colors.red
|
||||
: Colors.grey,
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.01,
|
||||
),
|
||||
Text(
|
||||
bestdealproduct.name ?? "",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style:
|
||||
context.customMedium(APPCOLOR.balck1A1A1A, 14),
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.005,
|
||||
),
|
||||
Text(
|
||||
bestdealproduct.unit ?? "",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context.customMedium(
|
||||
Colors.grey.withOpacity(0.8),
|
||||
12,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.005,
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"\$${bestdealproduct.discountPrice ?? ""} ",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context.customSemiBold(
|
||||
Colors.black, 12),
|
||||
),
|
||||
Text(
|
||||
"\$${bestdealproduct.basePrice ?? ""}",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context
|
||||
.customMedium(
|
||||
Colors.grey.withOpacity(0.8),
|
||||
12,
|
||||
)
|
||||
.copyWith(
|
||||
decoration:
|
||||
TextDecoration.lineThrough,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: GestureDetector(
|
||||
onTap: () async {
|
||||
print(
|
||||
"Add to Cart Pressed for ${bestdealproduct.id}");
|
||||
|
||||
if (await SharedPrefUtils.getToken() !=
|
||||
null) {
|
||||
// if (!(provider
|
||||
// .isLoading[bestdealproduct.id] ??
|
||||
// false))
|
||||
// {
|
||||
|
||||
await provider.addToCart(
|
||||
context, bestdealproduct.id!);
|
||||
|
||||
// }
|
||||
} else {
|
||||
context.push(MyRoutes.SIGNUP);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height *
|
||||
0.035,
|
||||
width:
|
||||
MediaQuery.of(context).size.width * 0.1,
|
||||
decoration: BoxDecoration(
|
||||
color: APPCOLOR.lightGreen,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Center(
|
||||
child: provider.isLoading[
|
||||
bestdealproduct.id] ??
|
||||
false
|
||||
? Padding(
|
||||
padding:
|
||||
const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
height: 10,
|
||||
width: 10,
|
||||
child:
|
||||
CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 2),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
'Add',
|
||||
style: context.customRegular(
|
||||
Colors.white, 12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.01,
|
||||
),
|
||||
Text(
|
||||
bestdealproduct.name ?? "",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.005,
|
||||
),
|
||||
Text(
|
||||
bestdealproduct.unit ?? "",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context.customMedium(
|
||||
Colors.grey.withOpacity(0.8),
|
||||
12,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.005,
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"\$${bestdealproduct.discountPrice ?? ""} ",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style:
|
||||
context.customSemiBold(Colors.black, 12),
|
||||
),
|
||||
Text(
|
||||
"\$${bestdealproduct.basePrice ?? ""}",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context
|
||||
.customMedium(
|
||||
Colors.grey.withOpacity(0.8),
|
||||
12,
|
||||
)
|
||||
.copyWith(
|
||||
decoration: TextDecoration.lineThrough,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: GestureDetector(
|
||||
onTap: () async {
|
||||
print(
|
||||
"Add to Cart Pressed for ${bestdealproduct.id}");
|
||||
|
||||
if (await SharedPrefUtils.getToken() !=
|
||||
null) {
|
||||
// if (!(provider
|
||||
// .isLoading[bestdealproduct.id] ??
|
||||
// false))
|
||||
// {
|
||||
|
||||
await provider.addToCart(
|
||||
context, bestdealproduct.id!);
|
||||
|
||||
// }
|
||||
} else {
|
||||
context.push(MyRoutes.LOGIN);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height *
|
||||
0.035,
|
||||
width:
|
||||
MediaQuery.of(context).size.width * 0.1,
|
||||
decoration: BoxDecoration(
|
||||
color: APPCOLOR.lightGreen,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Center(
|
||||
child: provider.isLoading[
|
||||
bestdealproduct.id] ??
|
||||
false
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
height: 10,
|
||||
width: 10,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 2),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
// provider.cartItems
|
||||
// .contains(bestdealproduct.id)
|
||||
// ? 'Added'
|
||||
// :
|
||||
'Add',
|
||||
style: context.customRegular(
|
||||
Colors.white, 12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -505,7 +511,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
var product = provider.products[index];
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push(MyRoutes.PRODUCTDETAILS, extra: product);
|
||||
context.push(MyRoutes.PRODUCTDETAILS, extra: product.id);
|
||||
},
|
||||
child: SizedBox(
|
||||
child: Column(
|
||||
|
||||
Reference in New Issue
Block a user