addProductInformation

This commit is contained in:
2025-02-05 19:03:07 +05:30
parent f92e0300a4
commit 96e4c10656
14 changed files with 1399 additions and 1109 deletions

View File

@@ -68,15 +68,11 @@ class _BestDealScreenState extends State<BestDealScreen> {
));
}
Widget floatingAction()
{
return Consumer<ProductProvider>(builder: (context, provider, child)
{
if (provider.countList.isEmpty)
{
Widget floatingAction() {
return Consumer<ProductProvider>(builder: (context, provider, child) {
if (provider.countList.isEmpty) {
return Center();
} else
{
} else {
return Padding(
padding: const EdgeInsets.only(left: 30),
child: Container(
@@ -274,6 +270,10 @@ class _BestDealScreenState extends State<BestDealScreen> {
12,
),
),
if (provider.productDetails.data!.quantity > 0)
Text("In Stock ",
style:
TextStyle(color: Colors.green, fontSize: 14)),
Spacer(),
Row(
children: [

View File

@@ -514,6 +514,15 @@ class _MycartState extends State<Mycart> {
),
],
),
Gap(5),
InkWell(
onTap: () {
showReturnPolicyBottomSheet(context);
},
child: Text("3 days Return & Exchange ",
style:
TextStyle(color: Colors.green, fontSize: 1)),
),
],
),
),
@@ -605,307 +614,93 @@ class _MycartState extends State<Mycart> {
});
}
// Widget relatedProduct() {
// return SizedBox(
// height: 222,
// child: ListView.builder(
// itemCount: 5,
// scrollDirection: Axis.horizontal,
// itemBuilder: (context, index) {
// return Padding(
// padding: const EdgeInsets.only(right: 10, bottom: 5, top: 5),
// child: Container(
// height: 215,
// width: 150,
// 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: 100,
// width: 150,
// decoration: BoxDecoration(
// color: APPCOLOR.bgGrey,
// borderRadius: BorderRadius.circular(15)),
// child: const Stack(
// alignment: Alignment.center,
// children: [
// AppNetworkImage(
// height: 70,
// width: 70,
// imageUrl:
// "https://5.imimg.com/data5/SELLER/Default/2024/2/385126988/OL/DA/VW/8627346/1l-fortune-sunflower-oil.jpg",
// backGroundColor: Colors.transparent),
// Positioned(
// right: 5,
// top: 5,
// child: Icon(Icons.favorite_border))
// ],
// ),
// ),
// Text(
// "Fortune Arhar Dal (Toor Dal)",
// textAlign: TextAlign.left,
// maxLines: 2,
// overflow: TextOverflow.ellipsis,
// style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
// ),
// const SizedBox(
// height: 5,
// ),
// Text(
// "500 ML",
// textAlign: TextAlign.left,
// maxLines: 1,
// overflow: TextOverflow.ellipsis,
// style: context.customMedium(
// Colors.grey.withOpacity(0.8), 12),
// ),
// const SizedBox(
// height: 3,
// ),
// Row(
// children: [
// Expanded(
// child: Row(
// children: [
// Text(
// "\$12",
// textAlign: TextAlign.left,
// maxLines: 1,
// overflow: TextOverflow.ellipsis,
// style: context.customSemiBold(Colors.black, 12),
// ),
// const SizedBox(
// width: 5,
// ),
// Text(
// "\$14",
// textAlign: TextAlign.left,
// maxLines: 1,
// overflow: TextOverflow.ellipsis,
// style: context
// .customMedium(
// Colors.grey.withOpacity(0.8), 12)
// .copyWith(
// decoration: TextDecoration.lineThrough,
// ),
// ),
// ],
// )),
// Expanded(
// child: Align(
// alignment: Alignment.centerRight,
// child: Container(
// height: 30,
// width: 50,
// decoration: BoxDecoration(
// color: APPCOLOR.lightGreen,
// borderRadius: BorderRadius.circular(5),
// ),
// child: Center(
// child: Text(
// 'Add',
// style: context.customRegular(Colors.white, 12),
// )),
// ),
// ),
// )
// ],
// ),
// ],
// ),
// ),
// ),
// );
// },
// ),
// );
// }
void showReturnPolicyBottomSheet(BuildContext context) {
showModalBottomSheet(
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
backgroundColor: Colors.white,
builder: (context) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Close Button
Align(
alignment: Alignment.topRight,
child: IconButton(
icon: Icon(Icons.close),
onPressed: () => Navigator.pop(context),
),
),
// Widget cartItems() {
// return Consumer<AddtocartProvider>(builder: (context, provider, child) {
// if (provider.isLoaddcartItem) {
// return Center(
// child: CircularProgressIndicator(
// color: Colors.green,
// ),
// );
// } else if (provider.allitem == null) {
// return Center(child: Text('🛒 Your Front Shop Cart is empty'));
// } else if (provider.allitem.items == null ||
// provider.allitem.items!.isEmpty) {
// return Center(child: Text('🛒 Your Front Shop Cart is empty'));
// } else {
// return ListView.separated(
// shrinkWrap: true, // Prevents internal scrolling
// physics: NeverScrollableScrollPhysics(), // Disables inner scroll
// separatorBuilder: (_, index) => Padding(
// padding: EdgeInsets.only(top: 12.h, bottom: 24.h),
// child: const Divider(thickness: 1),
// ),
// itemCount: provider.allitem.items!.length,
// itemBuilder: (context, index) {
// var items = provider.allitem.items![index];
// Title
Text(
"3 days Return & Exchange",
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 10),
// return Padding(
// padding: EdgeInsets.symmetric(horizontal: 10.w),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Container(
// decoration: BoxDecoration(
// color: Colors.greenAccent.withOpacity(0.1),
// borderRadius: BorderRadius.circular(5),
// ),
// child: AppNetworkImage(
// width: 60.w,
// height: 70.h,
// imageUrl: items.product!.productImages!.first.url ?? " ",
// backGroundColor: APPCOLOR.bgGrey,
// radius: 10,
// ),
// ),
// // Image.asset(product.image, width: 50.w, height: 40.h),
// Table Headers
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text("Return Reason",
style: TextStyle(fontWeight: FontWeight.bold))),
Expanded(
child: Text("Return Period",
style: TextStyle(fontWeight: FontWeight.bold))),
Expanded(
child: Text("Return Policy",
style: TextStyle(fontWeight: FontWeight.bold))),
],
),
Divider(),
// 16.horizontalSpace,
// Container(
// width: 150.w,
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.start,
// children: [
// Text(
// items.product!.name ?? "",
// maxLines: 2,
// overflow: TextOverflow.ellipsis,
// style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
// ),
// 5.verticalSpace,
// Text(
// items.product!.unit ?? "",
// style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
// ),
// Row(
// children: [
// Text(
// "\$${items.product!.discountPrice ?? ""} ",
// textAlign: TextAlign.left,
// maxLines: 1,
// overflow: TextOverflow.ellipsis,
// style: context.customSemiBold(Colors.black, 12),
// ),
// Text(
// "\$${items.product!.basePrice ?? ""}",
// textAlign: TextAlign.left,
// maxLines: 1,
// overflow: TextOverflow.ellipsis,
// style: context
// .customMedium(
// Colors.grey.withOpacity(0.8),
// 12,
// )
// .copyWith(
// decoration: TextDecoration.lineThrough,
// ),
// ),
// ],
// ),
// ],
// ),
// ),
// const Spacer(),
// First Row
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(child: Text("Size too small, Size too large")),
Expanded(child: Text("3 days from delivery")),
Expanded(
child: Text("Exchange with a different size or colour")),
],
),
SizedBox(height: 10),
// Column(
// children: [
// Row(
// children: [
// CustomIconButton(
// width: 14.w,
// height: 14.h,
// onPressed: () {
// // provider.decreaseQuantity(items);
// },
// icon: SvgPicture.asset(
// APPASSETS.removeIcon,
// fit: BoxFit.none,
// ),
// backgroundColor: APPCOLOR.appGreen,
// ),
// 5.horizontalSpace,
// Text(
// items.quantity.toString(),
// style:
// context.customMedium(APPCOLOR.balck1A1A1A, 14),
// ),
// 5.horizontalSpace,
// CustomIconButton(
// width: 14.w,
// height: 14.h,
// onPressed: () {
// // provider..increaseQuantity(items);
// },
// icon: SvgPicture.asset(
// APPASSETS.addIcon,
// fit: BoxFit.none,
// ),
// backgroundColor: APPCOLOR.appGreen,
// ),
// ],
// ),
// Gap(20),
// InkWell(
// onTap: () {
// provider.deleteItem(context, items.id);
// },
// child: Container(
// height: 25,
// width: 70,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.all(Radius.circular(10)),
// shape: BoxShape.rectangle,
// border: Border.all(
// color: Colors
// .blue, // Replace with your desired border color
// width: 2, // Border width
// ),
// ),
// child: provider.isRemoveItem[items.id] ?? false
// ? Center(
// child: Padding(
// padding: const EdgeInsets.all(8.0),
// child: Container(
// height: 5,
// width: 5,
// child: CircularProgressIndicator(
// color: Colors.green, strokeWidth: 1),
// ),
// ),
// )
// : Center(child: Text("Delete")),
// ),
// )
// ],
// )
// ],
// ),
// );
// },
// );
// }
// });
// }
// Second Row
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(child: Text("Any other reason")),
Expanded(child: Text("10 days from delivery")),
Expanded(child: Text("Full refund")),
],
),
SizedBox(height: 20),
// Know More Link
InkWell(
onTap: () {
// Handle navigation to more details
},
child: Text(
"Know More",
style: TextStyle(
color: Colors.blue, fontWeight: FontWeight.bold),
),
),
],
),
);
},
);
}
Widget cartPlace() {
return Consumer<AddtocartProvider>(builder: (context, provider, child) {

View File

@@ -8,43 +8,41 @@ class PaymentFailureScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
centerTitle: true,
leading: Center(
child: SizedBox(
height: 20,
width: 20,
child: InkWell(
onTap: () {
Navigator.of(context).pop();
},
child: SvgPicture.asset(
APPASSETS.back,
height: 20,
width: 20,
)),
),
appBar: AppBar(
backgroundColor: Colors.white,
centerTitle: true,
leading: Center(
child: SizedBox(
height: 20,
width: 20,
child: InkWell(
onTap: () {
Navigator.of(context).pop();
},
child: SvgPicture.asset(
APPASSETS.back,
height: 20,
width: 20,
)),
),
title: const Text(
"Payment Failed",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
),
),
actions: [
InkWell(
onTap: () {},
child: Icon(
MdiIcons.magnify,
size: 35,
),
)
],
),
title: const Text(
"Payment Failed",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
),
),
actions: [
InkWell(
onTap: () {},
child: Icon(
MdiIcons.magnify,
size: 35,
),
)
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,

View File

@@ -3,9 +3,11 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
import 'package:grocery_app/src/core/routes/routes.dart';
import 'package:grocery_app/src/logic/provider/bottom_navbar_provider.dart';
import 'package:grocery_app/utils/constants/assets_constant.dart';
import 'package:grocery_app/utils/extensions/extensions.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:provider/provider.dart';
class PaymentSuccessScreen extends StatelessWidget {
@override
@@ -19,8 +21,7 @@ class PaymentSuccessScreen extends StatelessWidget {
height: 20,
width: 20,
child: InkWell(
onTap: ()
{
onTap: () {
context.clearAndPush(routePath: MyRoutes.BOTTOMNAV);
},
child: SvgPicture.asset(
@@ -31,7 +32,7 @@ class PaymentSuccessScreen extends StatelessWidget {
),
),
title: const Text(
"Payment Successful",
"Payment Successfully Done",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
@@ -60,7 +61,9 @@ class PaymentSuccessScreen extends StatelessWidget {
SizedBox(height: 20),
ElevatedButton(
onPressed: () {
Navigator.pop(context); // Navigate back
context.clearAndPush(routePath: MyRoutes.BOTTOMNAV);
// context.read<BottomNavProvider>().setIndex(0);
// Navigator.pop(context);
},
child: Text("Go to Home"),
),

View File

@@ -29,101 +29,21 @@ class _PaymentWebViewState extends State<PaymentWebView> {
webViewController = controller;
},
onLoadStop: (controller, url) async {
print("Payment page loaded: $url");
// ✅ Check if payment is successful
if (url.toString().contains("success")) {
if (url.toString().contains("success"))
{
context.push(MyRoutes.SUCCESSPAYMENT);
print("kjdsfkjghdfhgkjdfhgkjdf");
// Navigator.pop(context, true);
} else if (url.toString().contains("failure")) {
context.push(MyRoutes.PAYMENTFAILD);
print("faild");
// Navigator.pop(context, false);
}
},
),
);
}
}
// import 'package:flutter/material.dart';
// import 'package:flutter_inappwebview/flutter_inappwebview.dart';
// class PaymentWebView extends StatefulWidget {
// final String paymentUrl;
// PaymentWebView({required this.paymentUrl});
// @override
// _PaymentWebViewState createState() => _PaymentWebViewState();
// }
// class _PaymentWebViewState extends State<PaymentWebView> {
// InAppWebViewController? webViewController;
// bool isErrorPage = false; // Track error state
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// appBar: AppBar(title: Text("Complete Your Payment")),
// body: Stack(
// children: [
// Visibility(
// visible: !isErrorPage, // Show WebView only if there's no error
// child: InAppWebView(
// initialUrlRequest:
// URLRequest(url: WebUri.uri(Uri.parse(widget.paymentUrl))),
// onWebViewCreated: (controller) {
// webViewController = controller;
// },
// onLoadStop: (controller, url) async {
// print("Payment page loaded: $url");
// // ✅ Check if payment is successful
// if (url.toString().contains("success")) {
// Navigator.pop(context, true); // Send success result
// } else if (url.toString().contains("failure")) {
// Navigator.pop(context, false); // Send failure result
// }
// },
// onReceivedHttpError: (controller, request, response) {
// if (response.statusCode == 404) {
// setState(() {
// isErrorPage = true;
// });
// }
// },
// ),
// ),
// if (isErrorPage) _buildErrorPage(context), // Show custom error page
// ],
// ),
// );
// }
// Widget _buildErrorPage(BuildContext context) {
// return Center(
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Icon(Icons.error_outline, color: Colors.red, size: 80),
// SizedBox(height: 10),
// Text("Payment Failed",
// style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
// SizedBox(height: 10),
// Text("Something went wrong. Please try again.",
// textAlign: TextAlign.center),
// SizedBox(height: 20),
// ElevatedButton(
// onPressed: () {
// Navigator.pop(context); // Navigate back to previous screen
// },
// child: Text("Go Back"),
// ),
// ],
// ),
// );
// }
// }

View File

@@ -6,16 +6,19 @@ import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_rating_stars/flutter_rating_stars.dart';
import 'package:flutter_svg/svg.dart';
import 'package:gap/gap.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/allProduct_model.dart';
import 'package:grocery_app/src/data/product_details.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';
import 'package:grocery_app/utils/constants/shared_pref_utils.dart';
import 'package:grocery_app/utils/extensions/uicontext.dart';
import 'package:intl/intl.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:provider/provider.dart';
import 'package:readmore/readmore.dart';
@@ -39,12 +42,12 @@ class _ProductDetailsState extends State<ProductDetails> {
super.initState();
Provider.of<ProductProvider>(context, listen: false)
.getProduuctDetails(context, widget.id);
}
double value = 3.5;
bool isExpanded = false;
bool isHilightsExpanded = false;
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -83,6 +86,7 @@ class _ProductDetailsState extends State<ProductDetails> {
prodectDtails(),
Divider(),
reviews(),
Gap(5),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text("Similar Products",
@@ -177,89 +181,285 @@ class _ProductDetailsState extends State<ProductDetails> {
),
SizedBox(height: 10),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
padding: const EdgeInsets.symmetric(horizontal: 1.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
provider.productDetails.data!.name ?? "",
style: context.customExtraBold(Colors.black, 18),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
provider.productDetails.data!.name ?? "",
style: context.customExtraBold(Colors.black, 18),
),
Gap(5),
Row(
children: [
Container(
padding: EdgeInsets.symmetric(
horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(5),
),
child: Row(
children: [
Icon(
Icons.star,
size: 20,
color: Colors.white,
),
Text(
provider.productDetails.data!
.averageRating ??
"0.0",
style: TextStyle(
color: Colors.white, fontSize: 14)),
],
),
),
Text(
" (${provider.productDetails.data!.productReview!.length + 1} Review)",
style: TextStyle(
color: Colors.black, fontSize: 14)),
Spacer(),
if (provider.productDetails.data!.quantity > 0)
Text("In Stock",
style: TextStyle(
color: Colors.green, fontSize: 14)),
],
),
Gap(5),
Row(
children: [
Text(
"\$${provider.productDetails.data!.discountPrice}",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.green),
),
SizedBox(width: 10),
Text(
"\$${provider.productDetails.data!.basePrice}",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
decoration: TextDecoration.lineThrough,
color: Colors.grey,
),
),
SizedBox(width: 10),
Container(
padding: EdgeInsets.symmetric(
horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(5),
),
child: Text(
"${calculateDiscountPercentage(double.parse(provider.productDetails.data!.basePrice), double.parse(provider.productDetails.data!.discountPrice))}% OFF",
style: TextStyle(
color: Colors.white, fontSize: 14)),
),
Spacer(),
InkWell(
onTap: () async {
if (await SharedPrefUtils.getToken() != null) {
provider.toggleWishlist(context,
provider.productDetails.data!.id!);
} else {
context.push(MyRoutes.SIGNUP);
}
},
child: provider.iswishloading
? Container(
width: 10,
height: 10,
child: CircularProgressIndicator(
color: Colors.green,
strokeWidth: 1,
),
)
: Icon(
provider.wishlist.contains(
provider.productDetails.data!.id)
? Icons.favorite
: Icons.favorite_border,
color: provider.wishlist.contains(
provider.productDetails.data!.id)
? Colors.red
: Colors.grey,
),
),
],
),
Gap(5),
ReadMoreText(
provider.productDetails.data!.description ?? "",
trimMode: TrimMode.Line,
trimLines: 2,
colorClickableText: APPCOLOR.appGreen,
trimCollapsedText: 'Read More',
trimExpandedText: 'Show less',
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
),
Gap(5),
InkWell(
onTap: () {
showReturnPolicyBottomSheet(context);
},
child: Text("3 days Return & Exchange ",
style:
TextStyle(color: Colors.green, fontSize: 14)),
),
],
),
),
Row(
children: [
Text(
"\$${provider.productDetails.data!.discountPrice}",
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
color: Colors.green),
),
SizedBox(width: 10),
Text(
"\$${provider.productDetails.data!.basePrice}",
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
decoration: TextDecoration.lineThrough,
color: Colors.grey,
),
),
SizedBox(width: 10),
Container(
padding:
EdgeInsets.symmetric(horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(5),
),
child: Text(
"${calculateDiscountPercentage(double.parse(provider.productDetails.data!.basePrice), double.parse(provider.productDetails.data!.discountPrice))}% OFF",
style:
TextStyle(color: Colors.white, fontSize: 14)),
),
Spacer(),
InkWell(
onTap: () async {
if (await SharedPrefUtils.getToken() != null) {
provider.toggleWishlist(
context, provider.productDetails.data!.id!);
} else {
context.push(MyRoutes.SIGNUP);
}
},
child: provider.iswishloading
? Container(
width: 10,
height: 10,
child: CircularProgressIndicator(
color: Colors.green,
strokeWidth: 1,
Gap(5),
Card(
elevation: 5,
color: Colors.white,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text("Highlights",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold)),
Gap(2),
Expanded(
child: Container(
color: Colors.grey,
height: 0.4,
),
)
: Icon(
provider.wishlist.contains(
provider.productDetails.data!.id)
? Icons.favorite
: Icons.favorite_border,
color: provider.wishlist.contains(
provider.productDetails.data!.id)
? Colors.red
: Colors.grey,
],
),
AnimatedSize(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
if (provider.productDetails.data!.brand !=
null)
_buildText(
"Brand ",
'${provider.productDetails.data!.brand ?? ''}',
),
// if (isHilightsExpanded)
_buildText(
"Weight",
'${provider.productDetails.data!.unit ?? ""}',
),
if (isHilightsExpanded)
_buildText(
"Product Type",
'${provider.productDetails.data!.productType ?? ""}',
),
],
),
),
),
Center(
child: TextButton(
onPressed: () {
setState(() {
isHilightsExpanded = !isHilightsExpanded;
});
},
child: Text(
isHilightsExpanded ? "View Less" : "View More",
style: TextStyle(color: APPCOLOR.appGreen),
),
),
),
Row(
children: [
Text("Information",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold)),
Gap(2),
Expanded(
child: Container(
color: Colors.grey,
height: 0.4,
),
)
],
),
AnimatedSize(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
_buildText(
"Customer Care Details ",
'In case of any issue, contact us${provider.productDetails.data!.store!.officialPhoneNumber ?? ''}',
),
if (isExpanded)
_buildText(
"Seller Name ",
'${provider.productDetails.data!.store!.storeName ?? ""}',
),
if (isExpanded)
_buildText(
"Seller Address",
'${provider.productDetails.data!.store!.storeAddress ?? ""}',
),
if (isExpanded)
_buildText(
"GST Number",
'${provider.productDetails.data!.store!.gstNumber ?? ""}',
),
],
),
),
),
// Padding(
// padding: const EdgeInsets.symmetric(vertical: 4.0),
// child: Column(
// children: [
// _buildText("Customer Care Details ",
// 'In case of any issue, contact us${provider.productDetails.data!.store!.officialPhoneNumber ?? ''}'),
// _buildText("Seller Name ",
// '${provider.productDetails.data!.store!.storeName ?? ""}'),
// _buildText("Seller Address",
// '${provider.productDetails.data!.store!.storeAddress ?? ""}'),
// _buildText("GST Number",
// '${provider.productDetails.data!.store!.gstNumber ?? ""}'),
// ],
// ),
// ),
Center(
child: TextButton(
onPressed: () {
setState(() {
isExpanded = !isExpanded;
});
},
child: Text(
isExpanded ? "View Less" : "View More",
style: TextStyle(color: APPCOLOR.appGreen),
),
),
),
],
),
],
),
SizedBox(height: 10),
ReadMoreText(
provider.productDetails.data!.description ?? "",
trimMode: TrimMode.Line,
trimLines: 2,
colorClickableText: APPCOLOR.appGreen,
trimCollapsedText: 'Read More',
trimExpandedText: 'Show less',
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
),
),
],
),
@@ -270,6 +470,119 @@ class _ProductDetailsState extends State<ProductDetails> {
});
}
void showReturnPolicyBottomSheet(BuildContext context) {
showModalBottomSheet(
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
backgroundColor: Colors.white,
builder: (context) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Close Button
Align(
alignment: Alignment.topRight,
child: IconButton(
icon: Icon(Icons.close),
onPressed: () => Navigator.pop(context),
),
),
// Title
Text(
"3 days Return & Exchange",
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 10),
// Table Headers
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text("Return Reason",
style: TextStyle(fontWeight: FontWeight.bold))),
Expanded(
child: Text("Return Period",
style: TextStyle(fontWeight: FontWeight.bold))),
Expanded(
child: Text("Return Policy",
style: TextStyle(fontWeight: FontWeight.bold))),
],
),
Divider(),
// First Row
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(child: Text("Size too small, Size too large")),
Expanded(child: Text("3 days from delivery")),
Expanded(
child: Text("Exchange with a different size or colour")),
],
),
SizedBox(height: 10),
// Second Row
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(child: Text("Any other reason")),
Expanded(child: Text("10 days from delivery")),
Expanded(child: Text("Full refund")),
],
),
SizedBox(height: 20),
// Know More Link
InkWell(
onTap: () {
// Handle navigation to more details
},
child: Text(
"Know More",
style: TextStyle(
color: Colors.blue, fontWeight: FontWeight.bold),
),
),
],
),
);
},
);
}
Widget _buildText(String title, String value) {
return Padding(
padding: const EdgeInsets.only(top: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 2,
child: Text(
title,
style: TextStyle(fontSize: 12),
),
),
Expanded(
flex: 4,
child: Text(
value,
style: TextStyle(fontSize: 16),
),
),
],
),
);
}
Widget _buildSkeletonLoader() {
return Padding(
padding: const EdgeInsets.all(16.0),
@@ -328,7 +641,7 @@ class _ProductDetailsState extends State<ProductDetails> {
SizedBox(height: 10),
Row(
children: [
Text("4.2",
Text(provider.productDetails.data!.averageRating ?? "",
style: TextStyle(
fontSize: 30, fontWeight: FontWeight.bold)),
SizedBox(
@@ -338,7 +651,9 @@ class _ProductDetailsState extends State<ProductDetails> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RatingStars(
value: value,
value:
provider.productDetails.data!.averageRating ??
0,
onValueChanged: (v) {
//
setState(() {
@@ -369,10 +684,6 @@ class _ProductDetailsState extends State<ProductDetails> {
starOffColor: const Color(0xffe7e8ea),
starColor: Colors.green,
),
Text(
"April 10, 2023",
style: TextStyle(color: Colors.grey),
),
],
),
],
@@ -398,12 +709,27 @@ class _ProductDetailsState extends State<ProductDetails> {
.spaceBetween, // Proper spacing
children: [
Text(
"Johnson Smith",
provider.productDetails.data!.productReview!
.first.user!.firstName +
" " +
provider
.productDetails
.data!
.productReview!
.first
.user!
.lastName,
style:
TextStyle(fontWeight: FontWeight.bold),
),
RatingStars(
value: value,
value: double.parse(provider
.productDetails
.data!
.productReview!
.first
.rating ??
0),
starBuilder: (index, color) => Icon(
Icons.star,
color: color,
@@ -428,7 +754,9 @@ class _ProductDetailsState extends State<ProductDetails> {
),
SizedBox(height: 4),
Text(
"April 10, 2023",
formatDate(provider.productDetails.data!
.productReview!.first.createdAt
.toString()),
style: TextStyle(color: Colors.grey),
),
],
@@ -438,7 +766,9 @@ class _ProductDetailsState extends State<ProductDetails> {
),
SizedBox(height: 10),
ReadMoreText(
'Flutter is Googles mobile UI open source framework to build high-quality native (super fast) interfaces for iOS and Android apps with the unified codebase.',
"${provider.productDetails.data!.productReview!.first.title ?? ""}" +
"\n" +
"${provider.productDetails.data!.productReview!.first.description ?? ""}",
trimMode: TrimMode.Line,
trimLines: 2,
colorClickableText: APPCOLOR.appGreen,
@@ -446,6 +776,10 @@ class _ProductDetailsState extends State<ProductDetails> {
trimExpandedText: 'Show less',
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
),
if (provider.productDetails.data!.productReview!.first
.productReviewImage!.isNotEmpty)
reviewImage(provider.productDetails.data!.productReview!
.first.productReviewImage)
],
),
)
@@ -473,9 +807,6 @@ class _ProductDetailsState extends State<ProductDetails> {
value: value,
onValueChanged: (v) {
//
setState(() {
value = v;
});
},
starBuilder: (index, color) => Icon(
Icons.star,
@@ -585,6 +916,45 @@ class _ProductDetailsState extends State<ProductDetails> {
});
}
Widget reviewImage(List<ProductReviewImage>? productReviewImage) {
return SizedBox(
height: 100,
child: ListView.builder(
itemCount: 10,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return InkWell(
onTap: () {},
child: Center(
child: Container(
height: 100,
width: 100,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(15),
),
child: AppNetworkImage(
height: 90,
width: 90,
imageUrl: "",
backGroundColor: Colors.transparent,
),
),
),
);
},
),
);
}
String formatDate(String dateStr) {
// Parse the date string to DateTime
DateTime date = DateTime.parse(dateStr).toLocal();
// Format the date
return DateFormat('MMMM d, yyyy').format(date); // "February 4, 2025"
}
Widget bestDeal() {
return Consumer<ProductProvider>(builder: (context, provider, child) {
if (provider.isBestdealingloading) {
@@ -805,8 +1175,7 @@ class _ProductDetailsState extends State<ProductDetails> {
});
}
Widget bottomBar()
{
Widget bottomBar() {
return Consumer<ProductProvider>(builder: (context, cartProvider, child) {
return Container(
padding: EdgeInsets.all(16),