productdetails

This commit is contained in:
2025-01-31 19:02:20 +05:30
parent 028155a1d7
commit 42aaa7cdad
32 changed files with 2803 additions and 1987 deletions

View File

@@ -1,9 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:go_router/go_router.dart';
import 'package:grocery_app/src/common_widget/network_image.dart';
import 'package:grocery_app/src/core/routes/routes.dart';
import 'package:grocery_app/src/data/all_cart_items.dart';
import 'package:grocery_app/src/logic/provider/bottom_navbar_provider.dart';
import 'package:grocery_app/src/logic/provider/home_provider.dart';
import 'package:grocery_app/utils/constants/assets_constant.dart';
import 'package:grocery_app/utils/constants/color_constant.dart';
@@ -58,7 +61,16 @@ class _BestDealScreenState extends State<BestDealScreen> {
)
],
),
floatingActionButton: Padding(
floatingActionButton: floatingAction(),
body: itemBestdeal());
}
Widget floatingAction() {
return Consumer<ProductProvider>(builder: (context, provider, child) {
if (provider.countList.isEmpty) {
return Center();
} else {
return Padding(
padding: const EdgeInsets.only(left: 30),
child: Container(
height: 80,
@@ -106,34 +118,41 @@ class _BestDealScreenState extends State<BestDealScreen> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'2 Items',
provider.countList.length.toString(),
style: context.customRegular(Colors.white, 18),
),
Text(
'\$25',
style: context.customExtraBold(Colors.white, 20),
)
],
),
const Spacer(),
Text(
'View Cart',
style: context.customMedium(Colors.white, 24),
),
const SizedBox(
width: 10,
),
const Icon(
Icons.arrow_forward,
color: Colors.white,
size: 35,
),
InkWell(
onTap: () {
context.read<BottomNavProvider>().setIndex(2);
Navigator.pop(context);
},
child: Row(
children: [
Text(
'View Cart',
style: context.customMedium(Colors.white, 24),
),
const SizedBox(
width: 10,
),
const Icon(
Icons.arrow_forward,
color: Colors.white,
size: 35,
),
],
),
)
],
),
),
),
),
body: itemBestdeal());
);
}
});
}
Widget itemBestdeal() {
@@ -156,182 +175,183 @@ class _BestDealScreenState extends State<BestDealScreen> {
),
itemBuilder: (context, index) {
var bestdealproduct = provider.bestdeal[index];
return Container(
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: [
Container(
height: MediaQuery.of(context).size.height *
0.15, // Dynamic height
width: MediaQuery.of(context).size.width *
0.4, // Dynamic width
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(15),
),
child: Stack(
alignment: Alignment.center,
children: [
Center(
child: AppNetworkImage(
height:
MediaQuery.of(context).size.height * 0.13,
width: MediaQuery.of(context).size.width * 0.35,
imageUrl:
bestdealproduct.productImages?.first.url ??
"",
backGroundColor: Colors.transparent,
return InkWell(
onTap: () {
context.push(MyRoutes.PRODUCTDETAILS,
extra: bestdealproduct.id);
},
child: Container(
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: [
Container(
height: MediaQuery.of(context).size.height *
0.15, // Dynamic height
width: MediaQuery.of(context).size.width *
0.4, // Dynamic width
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(15),
),
child: Stack(
alignment: Alignment.center,
children: [
Center(
child: AppNetworkImage(
height:
MediaQuery.of(context).size.height * 0.13,
width:
MediaQuery.of(context).size.width * 0.35,
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.005),
Text(
bestdealproduct.name ?? "",
textAlign: TextAlign.left,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: context.customMedium(APPCOLOR.balck1A1A1A, 16),
),
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,
),
),
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,
),
),
],
),
Positioned(
right: 5,
top: 5,
child: InkWell(
Spacer(),
Align(
alignment: Alignment.centerRight,
child: GestureDetector(
onTap: () async {
if (await SharedPrefUtils.getToken() !=
null) {
provider.toggleWishlist(
context, bestdealproduct.id!);
await provider.addToWithCart(context,
bestdealproduct.id!, bestdealproduct);
} else {
context.push(MyRoutes.LOGIN);
context.push(MyRoutes.SIGNUP);
}
},
child: Icon(
provider.wishlist.contains(bestdealproduct.id)
? Icons.favorite
: Icons.favorite_border,
color: provider.wishlist
.contains(bestdealproduct.id)
? Colors.red
: Colors.grey,
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),
),
),
),
),
),
],
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.005),
Text(
bestdealproduct.name ?? "",
textAlign: TextAlign.left,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: context.customMedium(APPCOLOR.balck1A1A1A, 16),
),
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,
),
),
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,
),
),
],
),
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),
),
),
),
),
),
],
),
],
],
),
),
),
);