couponApply

This commit is contained in:
2025-02-10 02:37:06 +05:30
parent 630a918307
commit b6ef70cfb6
21 changed files with 3308 additions and 1181 deletions

View File

@@ -1010,7 +1010,7 @@
"languageVersion": "3.4" "languageVersion": "3.4"
} }
], ],
"generated": "2025-02-08T20:21:28.051863Z", "generated": "2025-02-09T21:06:34.160787Z",
"generator": "pub", "generator": "pub",
"generatorVersion": "3.5.3", "generatorVersion": "3.5.3",
"flutterRoot": "file:///Users/apple/Documents/development/flutter", "flutterRoot": "file:///Users/apple/Documents/development/flutter",

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,7 @@
import Flutter import Flutter
import UIKit import UIKit
@UIApplicationMain @main
@objc class AppDelegate: FlutterAppDelegate { @objc class AppDelegate: FlutterAppDelegate {
override func application( override func application(
_ application: UIApplication, _ application: UIApplication,

View File

@@ -28,6 +28,10 @@ class APIURL {
static const String paymentOrder = "${BASE_URL}payment/initiate"; static const String paymentOrder = "${BASE_URL}payment/initiate";
static const String paymentCODOrder = "${BASE_URL}orders"; static const String paymentCODOrder = "${BASE_URL}orders";
static const String myOrder = "${BASE_URL}orders/my-orders"; static const String myOrder = "${BASE_URL}orders/my-orders";
static const String offerCoupon = "${BASE_URL}coupons";
static const String applyCoupon = "${BASE_URL}coupons/validate";
static const String forgetPassword = "${BASE_URL}auth/forgot-password/vendor"; static const String forgetPassword = "${BASE_URL}auth/forgot-password/vendor";
static const String verifyForgetPassword = static const String verifyForgetPassword =

View File

@@ -84,8 +84,12 @@ class MyRoutes {
animatedGoRoute( animatedGoRoute(
path: COUPONSSCREEN, path: COUPONSSCREEN,
name: COUPONSSCREEN, name: COUPONSSCREEN,
pageBuilder: (context, state) => CouponsScreen(), pageBuilder: (context, state) {
), final id = state.extra as String;
return CouponsScreen(
cartId: id,
);
}),
animatedGoRoute( animatedGoRoute(
path: ADDRESSS, path: ADDRESSS,
name: ADDRESSS, name: ADDRESSS,

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,165 @@
// To parse this JSON data, do
//
// final couponData = couponDataFromJson(jsondynamic);
import 'dart:convert';
CouponDataModel couponDataFromJson(dynamic str) => CouponDataModel.fromJson(json.decode(str));
dynamic couponDataToJson(CouponDataModel data) => json.encode(data.toJson());
class CouponDataModel {
List<CouponDatum>? data;
int? total;
int? page;
int? limit;
CouponDataModel({
this.data,
this.total,
this.page,
this.limit,
});
factory CouponDataModel.fromJson(Map<dynamic, dynamic> json) => CouponDataModel(
data: List<CouponDatum>.from(json["data"].map((x) => CouponDatum.fromJson(x))),
total: json["total"],
page: json["page"],
limit: json["limit"],
);
Map<dynamic, dynamic> toJson() => {
"data": List<dynamic>.from(data!.map((x) => x.toJson())),
"total": total,
"page": page,
"limit": limit,
};
}
class CouponDatum {
dynamic id;
dynamic code;
dynamic type;
dynamic discountValue;
dynamic maxDiscountAmount;
dynamic minPurchaseAmount;
DateTime? startDate;
DateTime? endDate;
int? totalUsageLimit;
int? perUserUsageLimit;
dynamic applicability;
dynamic status;
dynamic description;
dynamic terms;
int? buyQuantity;
int? getQuantity;
List<dynamic>? applicableUserRoles;
int? totalUsageCount;
bool? isActive;
dynamic createdBy;
DateTime? createdAt;
DateTime? updatedAt;
List<dynamic>? applicableStores;
List<dynamic>? applicableCategories;
List<dynamic>? applicableProducts;
List<dynamic>? usages;
List<dynamic>? applicableStoreIds;
List<dynamic>? applicableCategoryIds;
List<dynamic>? applicableProductIds;
CouponDatum({
this.id,
this.code,
this.type,
this.discountValue,
this.maxDiscountAmount,
this.minPurchaseAmount,
this.startDate,
this.endDate,
this.totalUsageLimit,
this.perUserUsageLimit,
this.applicability,
this.status,
this.description,
this.terms,
this.buyQuantity,
this.getQuantity,
this.applicableUserRoles,
this.totalUsageCount,
this.isActive,
this.createdBy,
this.createdAt,
this.updatedAt,
this.applicableStores,
this.applicableCategories,
this.applicableProducts,
this.usages,
this.applicableStoreIds,
this.applicableCategoryIds,
this.applicableProductIds,
});
factory CouponDatum.fromJson(Map<dynamic, dynamic> json) => CouponDatum(
id: json["id"],
code: json["code"],
type: json["type"],
discountValue: json["discountValue"],
maxDiscountAmount: json["maxDiscountAmount"],
minPurchaseAmount: json["minPurchaseAmount"],
startDate: DateTime.parse(json["startDate"]),
endDate: DateTime.parse(json["endDate"]),
totalUsageLimit: json["totalUsageLimit"],
perUserUsageLimit: json["perUserUsageLimit"],
applicability: json["applicability"],
status: json["status"],
description: json["description"],
terms: json["terms"],
buyQuantity: json["buyQuantity"],
getQuantity: json["getQuantity"],
applicableUserRoles: List<dynamic>.from(json["applicableUserRoles"].map((x) => x)),
totalUsageCount: json["totalUsageCount"],
isActive: json["isActive"],
createdBy: json["createdBy"],
createdAt: DateTime.parse(json["createdAt"]),
updatedAt: DateTime.parse(json["updatedAt"]),
applicableStores: List<dynamic>.from(json["applicableStores"].map((x) => x)),
applicableCategories: List<dynamic>.from(json["applicableCategories"].map((x) => x)),
applicableProducts: List<dynamic>.from(json["applicableProducts"].map((x) => x)),
usages: List<dynamic>.from(json["usages"].map((x) => x)),
applicableStoreIds: List<dynamic>.from(json["applicableStoreIds"].map((x) => x)),
applicableCategoryIds: List<dynamic>.from(json["applicableCategoryIds"].map((x) => x)),
applicableProductIds: List<dynamic>.from(json["applicableProductIds"].map((x) => x)),
);
Map<dynamic, dynamic> toJson() => {
"id": id,
"code": code,
"type": type,
"discountValue": discountValue,
"maxDiscountAmount": maxDiscountAmount,
"minPurchaseAmount": minPurchaseAmount,
"startDate": startDate,
"endDate": endDate,
"totalUsageLimit": totalUsageLimit,
"perUserUsageLimit": perUserUsageLimit,
"applicability": applicability,
"status": status,
"description": description,
"terms": terms,
"buyQuantity": buyQuantity,
"getQuantity": getQuantity,
"applicableUserRoles": List<dynamic>.from(applicableUserRoles!.map((x) => x)),
"totalUsageCount": totalUsageCount,
"isActive": isActive,
"createdBy": createdBy,
"createdAt": createdAt,
"updatedAt": updatedAt,
"applicableStores": List<dynamic>.from(applicableStores!.map((x) => x)),
"applicableCategories": List<dynamic>.from(applicableCategories!.map((x) => x)),
"applicableProducts": List<dynamic>.from(applicableProducts!.map((x) => x)),
"usages": List<dynamic>.from(usages!.map((x) => x)),
"applicableStoreIds": List<dynamic>.from(applicableStoreIds!.map((x) => x)),
"applicableCategoryIds": List<dynamic>.from(applicableCategoryIds!.map((x) => x)),
"applicableProductIds": List<dynamic>.from(applicableProductIds!.map((x) => x)),
};
}

View File

@@ -0,0 +1,69 @@
// To parse this JSON data, do
//
// final couponResponse = couponResponseFromJson(jsonString);
import 'dart:convert';
CouponResponse couponResponseFromJson(String str) => CouponResponse.fromJson(json.decode(str));
String couponResponseToJson(CouponResponse data) => json.encode(data.toJson());
class CouponResponse {
bool? isValid;
String? originalPrice;
int? discountAmount;
int? finalPrice;
String? message;
CouponDetails? couponDetails;
CouponResponse({
this.isValid,
this.originalPrice,
this.discountAmount,
this.finalPrice,
this.message,
this.couponDetails,
});
factory CouponResponse.fromJson(Map<String, dynamic> json) => CouponResponse(
isValid: json["isValid"],
originalPrice: json["originalPrice"],
discountAmount: json["discountAmount"],
finalPrice: json["finalPrice"],
message: json["message"],
couponDetails: CouponDetails.fromJson(json["couponDetails"]),
);
Map<String, dynamic> toJson() => {
"isValid": isValid,
"originalPrice": originalPrice,
"discountAmount": discountAmount,
"finalPrice": finalPrice,
"message": message,
"couponDetails": couponDetails!.toJson(),
};
}
class CouponDetails {
String? code;
String? type;
String? discountValue;
CouponDetails({
this.code,
this.type,
this.discountValue,
});
factory CouponDetails.fromJson(Map<String, dynamic> json) => CouponDetails(
code: json["code"],
type: json["type"],
discountValue: json["discountValue"],
);
Map<String, dynamic> toJson() => {
"code": code,
"type": type,
"discountValue": discountValue,
};
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,8 @@ import 'package:grocery_app/src/core/network_services/service_locator.dart';
import 'package:grocery_app/src/core/routes/routes.dart'; import 'package:grocery_app/src/core/routes/routes.dart';
import 'package:grocery_app/src/data/address.dart'; import 'package:grocery_app/src/data/address.dart';
import 'package:grocery_app/src/data/all_cart_items.dart'; import 'package:grocery_app/src/data/all_cart_items.dart';
import 'package:grocery_app/src/data/coupon_model.dart';
import 'package:grocery_app/src/data/coupon_response.dart';
import 'package:grocery_app/src/logic/repo/product_repo.dart'; import 'package:grocery_app/src/logic/repo/product_repo.dart';
import 'package:grocery_app/src/ui/payment/payment_webView.dart'; import 'package:grocery_app/src/ui/payment/payment_webView.dart';
import 'package:grocery_app/utils/extensions/extensions.dart'; import 'package:grocery_app/utils/extensions/extensions.dart';
@@ -125,6 +127,16 @@ class AddtocartProvider extends ChangeNotifier {
} }
} }
double _totalPrice = 0.0;
double _grandPrice = 0.0;
double _discount = 0.0;
double get totalPrice => _totalPrice;
double get grandPrice => _grandPrice;
double get discount => _discount;
final _homeRepo = getIt<ProductRepo>(); final _homeRepo = getIt<ProductRepo>();
AllCartItems allitem = AllCartItems(); AllCartItems allitem = AllCartItems();
@@ -144,6 +156,9 @@ class AddtocartProvider extends ChangeNotifier {
}, },
(response) { (response) {
allitem = response!; allitem = response!;
_totalPrice = double.parse(response.subtotal.toString());
_grandPrice = double.parse(response.subtotal.toString());
isLoaddcartItem = false; isLoaddcartItem = false;
notifyListeners(); notifyListeners();
}, },
@@ -154,36 +169,118 @@ class AddtocartProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
} }
//////////////////////////////////// coupon ////////////////////////////
bool iscouponLoading = true;
CouponDataModel couponDataModel = CouponDataModel();
Future<void> offerCoupon(BuildContext context) async {
iscouponLoading = true;
notifyListeners();
var data = {};
try {
var result = await _homeRepo.offerCoupon(data);
return result.fold(
(error) {
iscouponLoading = false;
notifyListeners();
},
(response) {
couponDataModel = response!;
iscouponLoading = false;
notifyListeners();
},
);
} catch (e) {
iscouponLoading = false;
notifyListeners();
}
}
bool isCouponApply = false;
CouponResponse couponResponse = CouponResponse();
String _couponId = '';
String get couponId => _couponId;
Future<bool> applyCoupon(
BuildContext context, String cartId, String couponscode, id) async {
context.showLoader(show: true);
isCouponApply = true;
notifyListeners();
var data = {"couponCode": couponscode, "cartId": cartId};
try {
var result = await _homeRepo.applyCoupon(data);
return result.fold(
(error) {
context.showLoader(show: false);
isCouponApply = false;
Fluttertoast.showToast(
msg: "Coupon Code invalid!",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 14.0,
);
notifyListeners();
return false;
},
(response) {
if (response != null) {
couponResponse = response;
_couponId = id;
_grandPrice = double.parse(response.finalPrice.toString());
_discount = double.parse(response.discountAmount.toString());
context.showLoader(show: false);
isCouponApply = false;
notifyListeners();
return true;
} else {
context.showLoader(show: false);
isCouponApply = false;
notifyListeners();
return false;
}
},
);
} catch (e) {
context.showLoader(show: false);
Fluttertoast.showToast(
msg: "Coupon Code invalid!",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 14.0,
);
isCouponApply = false;
notifyListeners();
return false; // Return false on exception
}
}
///////////////////////////////////orderPaymnet/////////////////////////// ///////////////////////////////////orderPaymnet///////////////////////////
bool ispaymentLoader = false; bool ispaymentLoader = false;
Future<void> orderPaymnet( Future<void> orderPaymnet(
BuildContext context, BuildContext context,
double amount,
String currency,
double originalAmount, double originalAmount,
String name,
String phone,
String email,
String userI,
String cartId, String cartId,
String addressId, String addressId,
String remarks, String couponId,
) async { ) async {
ispaymentLoader = true; ispaymentLoader = true;
notifyListeners(); notifyListeners();
var data = { var data = {
"amount": amount, "amount": originalAmount,
"currency": currency,
"originalAmount": amount,
"name": name,
"phone": phone,
"email": email,
"userId": userI,
"cartId": cartId,
"addressId": addressId, "addressId": addressId,
"remarks": remarks "cartId": cartId,
"couponId": couponId
}; };
try { try {
@@ -221,16 +318,13 @@ class AddtocartProvider extends ChangeNotifier {
BuildContext context, BuildContext context,
double subtotal, double subtotal,
double deliverCharge, double deliverCharge,
double discountPrice,
double grandTotal,
String couponId, String couponId,
String addressId, String addressId,
) async { ) async {
print("sdkjfhgkjdfhgjkldfkjghkdf");
ispaymentLoader = true; ispaymentLoader = true;
notifyListeners(); notifyListeners();
var data; var data;
if (couponId != '00') { if (couponId.isNotEmpty) {
data = { data = {
"addressId": addressId, "addressId": addressId,
"paymentMethod": "COD", "paymentMethod": "COD",
@@ -238,12 +332,10 @@ class AddtocartProvider extends ChangeNotifier {
"orderStatus": "PENDING", "orderStatus": "PENDING",
"subtotal": subtotal, "subtotal": subtotal,
"deliveryCharge": deliverCharge, "deliveryCharge": deliverCharge,
"discount": discountPrice, "transactionId": "phonepe_transaction_123",
"grandTotal": grandTotal,
"couponId": couponId "couponId": couponId
}; };
} else { } else {
print("skfdjdsjfg");
data = { data = {
"addressId": addressId, "addressId": addressId,
"paymentMethod": "COD", "paymentMethod": "COD",
@@ -251,8 +343,6 @@ class AddtocartProvider extends ChangeNotifier {
"orderStatus": "PENDING", "orderStatus": "PENDING",
"subtotal": subtotal, "subtotal": subtotal,
"deliveryCharge": deliverCharge, "deliveryCharge": deliverCharge,
"discount": discountPrice,
"grandTotal": grandTotal,
}; };
} }

View File

@@ -254,15 +254,16 @@ class ProductProvider extends ChangeNotifier {
} }
} }
void toggleWishlist1(String productId) { // void toggleWishlist1(String productId)
for (var product in products) { // {
if (product.id == productId) { // for (var product in products) {
product.isInWishlist = !product.isInWishlist; // Toggle value // if (product.id == productId) {
notifyListeners(); // Refresh UI // product.isInWishlist = !product.isInWishlist; // Toggle value
break; // notifyListeners(); // Refresh UI
} // break;
} // }
} // }
// }
// Future<bool> addToCart(BuildContext context, String productId) async // Future<bool> addToCart(BuildContext context, String productId) async
// { // {

View File

@@ -13,6 +13,8 @@ import 'package:grocery_app/src/data/banners.dart';
import 'package:grocery_app/src/data/best_dealProduct.dart'; import 'package:grocery_app/src/data/best_dealProduct.dart';
import 'package:grocery_app/src/data/check_pin_response.dart'; import 'package:grocery_app/src/data/check_pin_response.dart';
import 'package:grocery_app/src/data/cod_order_response.dart'; import 'package:grocery_app/src/data/cod_order_response.dart';
import 'package:grocery_app/src/data/coupon_model.dart';
import 'package:grocery_app/src/data/coupon_response.dart';
import 'package:grocery_app/src/data/login_response.dart'; import 'package:grocery_app/src/data/login_response.dart';
import 'package:grocery_app/src/data/order_paymnet.dart'; import 'package:grocery_app/src/data/order_paymnet.dart';
import 'package:grocery_app/src/data/product_category.dart'; import 'package:grocery_app/src/data/product_category.dart';
@@ -53,7 +55,7 @@ class ProductRepo {
var response = await _productService.getProductDetails(data, id); var response = await _productService.getProductDetails(data, id);
ProductDetailsData loginResponse = ProductDetailsData loginResponse =
productDetailsdataFromJson(response.toString()); productDetailsDataFromJson(response.toString());
final String model = response.toString(); final String model = response.toString();
@@ -117,11 +119,9 @@ class ProductRepo {
FutureResult<CodOrderResponse> paymentCODOrder(data) async { FutureResult<CodOrderResponse> paymentCODOrder(data) async {
try { try {
var response = await _productService.paymentCODOrder(data); var response = await _productService.paymentCODOrder(data);
CodOrderResponse productCategory = codOrderResponseFromJson(response.toString()); CodOrderResponse productCategory =
codOrderResponseFromJson(response.toString());
return right(productCategory); return right(productCategory);
} on DioException catch (e) { } on DioException catch (e) {
@@ -130,11 +130,6 @@ class ProductRepo {
} }
} }
FutureResult<List<Product>> similarProduct( FutureResult<List<Product>> similarProduct(
data, BuildContext context, id) async { data, BuildContext context, id) async {
try { try {
@@ -165,6 +160,34 @@ class ProductRepo {
} }
} }
FutureResult<CouponDataModel> offerCoupon(data) async {
try {
var response = await _productService.offerCoupon(data);
CouponDataModel couponmodel = couponDataFromJson(response.toString());
return right(couponmodel);
} on DioException catch (e) {
var error = CustomDioExceptions.handleError(e);
return left(error);
}
}
FutureResult<CouponResponse> applyCoupon(data) async {
try {
var response = await _productService.applyCoupon(data);
CouponResponse couponresponse = couponResponseFromJson(response.toString());
return right(couponresponse);
} on DioException catch (e) {
var error = CustomDioExceptions.handleError(e);
return left(error);
}
}
FutureResult<AddressResponse> getAddress(data) async { FutureResult<AddressResponse> getAddress(data) async {
try { try {
var response = await _productService.getAddress(data); var response = await _productService.getAddress(data);

View File

@@ -80,6 +80,22 @@ class ProductService extends ApiService {
return response; return response;
} }
Future offerCoupon(data) async {
var response = await api.get(APIURL.offerCoupon, data: jsonEncode(data));
return response;
}
Future applyCoupon(data) async {
var response = await api.post(APIURL.applyCoupon, data: jsonEncode(data));
return response;
}
Future checkPin(data, pin) async { Future checkPin(data, pin) async {
var response = await api.get(APIURL.checkPin + pin, data: jsonEncode(data)); var response = await api.get(APIURL.checkPin + pin, data: jsonEncode(data));

View File

@@ -184,6 +184,7 @@ class _BestDealScreenState extends State<BestDealScreen> {
} else if (provider.bestdeal.isEmpty) { } else if (provider.bestdeal.isEmpty) {
return Center(child: Text('No products available')); return Center(child: Text('No products available'));
} else { } else {
print("kjhfgjkdfkjghdhjfgk ${provider.bestdeal.first.additionalInfo}");
return Padding( return Padding(
padding: const EdgeInsets.all(15), padding: const EdgeInsets.all(15),
child: GridView.builder( child: GridView.builder(
@@ -273,8 +274,6 @@ class _BestDealScreenState extends State<BestDealScreen> {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: context.customMedium(APPCOLOR.balck1A1A1A, 16), style: context.customMedium(APPCOLOR.balck1A1A1A, 16),
), ),
SizedBox(
height: MediaQuery.of(context).size.height * 0.005),
Text( Text(
bestdealproduct.unit ?? "", bestdealproduct.unit ?? "",
textAlign: TextAlign.left, textAlign: TextAlign.left,
@@ -285,7 +284,7 @@ class _BestDealScreenState extends State<BestDealScreen> {
12, 12,
), ),
), ),
if (provider.productDetails.data!.quantity > 0) if (bestdealproduct!.quantity > 0)
Text("In Stock ", Text("In Stock ",
style: style:
TextStyle(color: Colors.green, fontSize: 14)), TextStyle(color: Colors.green, fontSize: 14)),
@@ -381,142 +380,6 @@ class _BestDealScreenState extends State<BestDealScreen> {
}, },
), ),
); );
// Padding(
// padding: const EdgeInsets.all(15),
// child: GridView.builder(
// itemCount: provider.bestdeal.length,
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
// crossAxisCount: 2,
// childAspectRatio: MediaQuery.of(context).size.width /
// (MediaQuery.of(context).size.height / 1.5),
// crossAxisSpacing: 10,
// mainAxisSpacing: 10),
// 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: 100.h,
// width: MediaQuery.sizeOf(context).width,
// // width: 150,
// decoration: BoxDecoration(
// color: APPCOLOR.bgGrey,
// borderRadius: BorderRadius.circular(15)),
// child: Stack(
// alignment: Alignment.center,
// children: [
// AppNetworkImage(
// height: 90.h,
// width: 140,
// imageUrl:
// bestdealproduct.productImages?.first.url ??
// "",
// backGroundColor: Colors.transparent),
// Positioned(
// right: 5,
// top: 5,
// child: Icon(Icons.favorite_border))
// ],
// ),
// ),
// Text(
// bestdealproduct.name ?? "",
// textAlign: TextAlign.left,
// maxLines: 2,
// overflow: TextOverflow.ellipsis,
// style: context.customMedium(APPCOLOR.balck1A1A1A, 16),
// ),
// const SizedBox(
// height: 5,
// ),
// Text(
// bestdealproduct.unit ?? "",
// textAlign: TextAlign.left,
// maxLines: 1,
// overflow: TextOverflow.ellipsis,
// style: context.customMedium(
// Colors.grey.withOpacity(0.8), 12),
// ),
// const SizedBox(
// height: 3,
// ),
// SizedBox(
// height: MediaQuery.of(context).size.height * 0.005,
// ),
// 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: 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: Text(
// 'Add',
// style:
// context.customRegular(Colors.white, 12),
// ),
// ),
// ),
// ),
// ],
// ),
// ],
// ),
// ),
// );
// },
// ),
// );
} }
}); });
} }

View File

@@ -153,8 +153,6 @@ class _BottomBarState extends State<BottomBarWidget> {
], ],
), ),
), ),
); );
} }
} }

View File

@@ -9,34 +9,33 @@ import 'package:grocery_app/utils/extensions/uicontext.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class CardCheckoutScreen extends StatefulWidget { class CardCheckoutScreen extends StatefulWidget {
double amount; // double amount;
String currency; // String currency;
double originalAmount; double originalAmount;
String name; // String name;
String phone; // String phone;
String email; // String email;
String userId; // String userId;
String cartId; String cartId;
String addressId; String addressId;
String remarks; // String remarks;
double deliverCharge; double deliverCharge;
double discountPrice;
String? couponId; String? couponId;
CardCheckoutScreen( CardCheckoutScreen(
{super.key, {super.key,
required this.amount, // required this.amount,
required this.currency, // required this.currency,
required this.originalAmount, required this.originalAmount,
required this.name, // required this.name,
required this.phone, // required this.phone,
required this.email, // required this.email,
required this.userId, // required this.userId,
required this.cartId, required this.cartId,
required this.addressId, required this.addressId,
required this.remarks, // required this.remarks,
required this.deliverCharge, required this.deliverCharge,
required this.discountPrice,
this.couponId}); this.couponId});
@override @override
@@ -88,28 +87,19 @@ class _CardCheckoutScreenState extends State<CardCheckoutScreen> {
child: InkWell( child: InkWell(
onTap: () { onTap: () {
if (paymentProvider.selectedPaymentMethod == "Online") { if (paymentProvider.selectedPaymentMethod == "Online") {
print("dsjfkhkdfhgdkfghdfg");
paymentProvider.orderPaymnet( paymentProvider.orderPaymnet(
context, context,
widget.amount,
widget.currency,
widget.originalAmount, widget.originalAmount,
widget.name,
widget.phone,
widget.email,
widget.userId,
widget.cartId, widget.cartId,
widget.addressId, widget.addressId,
widget.remarks); widget.couponId!);
} else { } else {
print("ldksjfgkljdfghljkfdg");
paymentProvider.paymentCODOrder( paymentProvider.paymentCODOrder(
context, context,
widget.amount,
widget.deliverCharge,
widget.discountPrice,
widget.originalAmount, widget.originalAmount,
// widget.couponId!, widget.deliverCharge,
'00', widget.couponId!,
widget.addressId, widget.addressId,
); );
} }

View File

@@ -1,5 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_animate/flutter_animate.dart'; import 'package:flutter_animate/flutter_animate.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
@@ -37,13 +37,15 @@ class Mycart extends StatefulWidget {
class _MycartState extends State<Mycart> { class _MycartState extends State<Mycart> {
@override @override
void initState() { void initState() {
Provider.of<AddtocartProvider>(context, listen: false) Future.microtask(() {
.getItemCards(context); final addToCartProvider =
Provider.of<AddtocartProvider>(context, listen: false);
Provider.of<AddtocartProvider>(context, listen: false)
.getCurrentLocation(context);
Provider.of<AddtocartProvider>(context, listen: false).getAddress(context);
addToCartProvider.getItemCards(context);
addToCartProvider.offerCoupon(context);
addToCartProvider.getCurrentLocation(context);
addToCartProvider.getAddress(context);
});
super.initState(); super.initState();
} }
@@ -165,38 +167,13 @@ class _MycartState extends State<Mycart> {
), ),
child: Center( child: Center(
child: Text( child: Text(
"${calculateDiscountPercentage(double.parse(provider.productDetails.data!.basePrice), double.parse(provider.productDetails.data!.discountPrice))}% OFF", "${calculateDiscountPercentage(double.parse(bestdealproduct!.basePrice), double.parse(bestdealproduct!.discountPrice))}% OFF",
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 12)), fontSize: 12)),
), ),
), ),
) )
// 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,
// ),
// ),
// ),
], ],
), ),
), ),
@@ -749,7 +726,6 @@ class _MycartState extends State<Mycart> {
), ),
)); ));
} else { } else {
print("kldjhgjkhfgjkh ");
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@@ -759,18 +735,29 @@ class _MycartState extends State<Mycart> {
style: TextStyle(fontWeight: FontWeight.bold)), style: TextStyle(fontWeight: FontWeight.bold)),
trailing: Icon(Icons.arrow_forward_ios), trailing: Icon(Icons.arrow_forward_ios),
onTap: () { onTap: () {
context.push(MyRoutes.COUPONSSCREEN); if (provider.couponDataModel.data!.isNotEmpty) {
context.push(MyRoutes.COUPONSSCREEN,
extra: provider.allitem.id);
} else {
Fluttertoast.showToast(
msg: "Coupon's not available !",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 14.0,
);
}
}, },
), ),
SummaryRow( SummaryRow(
label: 'Item Total Price', label: 'Item Total Price', value: '\$${provider.totalPrice}'),
value: '\$${provider.allitem.subtotal}'), SummaryRow(label: 'Discount', value: "${provider.discount}"),
SummaryRow(label: 'Discount', value: '0.0'),
SummaryRow(label: 'Delivery Free', value: 'Free', isGreen: true), SummaryRow(label: 'Delivery Free', value: 'Free', isGreen: true),
Divider(), Divider(),
SummaryRow( SummaryRow(
label: 'Grand Total', label: 'Grand Total',
value: '\$${provider.allitem.subtotal}', value: '\$${provider.grandPrice}',
isBold: true), isBold: true),
ListTile( ListTile(
leading: Icon(Icons.home, color: Colors.green), leading: Icon(Icons.home, color: Colors.green),
@@ -991,32 +978,40 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
SizedBox(height: 16), SizedBox(height: 16),
Consumer<AddtocartProvider>( Consumer<AddtocartProvider>(
builder: (context, paymentProvider, child) { builder: (context, paymentProvider, child) {
print(
"prxvsvxvice ${double.parse(paymentProvider.allitem.subtotal.toString())} ${paymentProvider.selecteUserName} ${paymentProvider.selectedAddress} ${paymentProvider.selecteEmail} ${paymentProvider.selecteUserPhone}");
return ElevatedButton.icon( return ElevatedButton.icon(
onPressed: () { onPressed: () {
if (paymentProvider.selectedAddress.isNotEmpty) {
Navigator.pop(context); Navigator.pop(context);
Navigator.of(context).push(MaterialPageRoute( Navigator.of(context).push(MaterialPageRoute(
builder: (context) { builder: (context) {
return CardCheckoutScreen( return CardCheckoutScreen(
amount: double.parse( // amount: double.parse(
paymentProvider.allitem.subtotal.toString()), // paymentProvider.allitem.subtotal.toString()),
currency: "INR", // currency: "INR",
originalAmount: double.parse( originalAmount: paymentProvider.grandPrice,
paymentProvider.allitem.subtotal.toString()),
name: paymentProvider.selecteUserName, // name: paymentProvider.selecteUserName,
phone: paymentProvider.selecteUserPhone, // phone: paymentProvider.selecteUserPhone,
email: paymentProvider.selecteEmail, // email: paymentProvider.selecteEmail,
userId: paymentProvider.allitem.userId!, // userId: paymentProvider.allitem.userId!,
cartId: paymentProvider.allitem.id!, cartId: paymentProvider.allitem.id!,
addressId: paymentProvider.selectedAddress, addressId: paymentProvider.selectedAddress,
remarks: paymentProvider.selecteUserName, // remarks: paymentProvider.selecteUserName,
deliverCharge: 0, deliverCharge: 0,
discountPrice: 0, couponId: paymentProvider.couponId,
couponId: '',
); );
}, },
)); ));
} else {
Fluttertoast.showToast(
msg: "Please add a delivery address",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.green,
textColor: Colors.white,
fontSize: 14.0,
);
}
}, },
label: Text( label: Text(
"Continue", "Continue",
@@ -1049,13 +1044,6 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
itemBuilder: (context, index) { itemBuilder: (context, index) {
var address = addressProvider.addresslist[index]; var address = addressProvider.addresslist[index];
// // if (addressProvider.addresslist.length == 1) {
// // addressProvider.bydefaultSetAddress(
// // address.phoneNumber, address.name, address.user!.email);
// // }
// print("sdhfjdjkfhg ${address.id} ${index}");
return Card( return Card(
elevation: 0, elevation: 0,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(

View File

@@ -1,26 +1,17 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:grocery_app/src/logic/provider/addTocart_provider.dart';
import 'package:grocery_app/src/logic/provider/home_provider.dart';
import 'package:provider/provider.dart';
class CouponsScreen extends StatelessWidget { class CouponsScreen extends StatelessWidget {
final List<Map<String, String>> coupons = [ String cartId;
{ CouponsScreen({super.key, required this.cartId});
"title": "Flat 10% OFF on Standard Chartered Digismart Credit Cards", TextEditingController inpucode = TextEditingController();
"description": "No Minimum Order Value", final _formKey = GlobalKey<FormState>();
"code": "DIGISMART"
},
{
"title": "Flat 10% OFF upto \$10 on HSBC Cashback Credit Card",
"description": "Total Value of Items Must be \$3 or More",
"code": "HSBC10"
},
{
"title": "Get Upto 50 OFF on Your First Payment",
"description": "Total Value of Items Must be \$10 or More",
"code": "PAYMENT50"
}
];
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print("kldfjgdfkljgdf ${cartId}");
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
backgroundColor: Colors.white, backgroundColor: Colors.white,
@@ -34,8 +25,14 @@ class CouponsScreen extends StatelessWidget {
padding: EdgeInsets.all(16.0), padding: EdgeInsets.all(16.0),
child: Column( child: Column(
children: [ children: [
TextField( Form(
key: _formKey,
child: Consumer<AddtocartProvider>(
builder: (context, provider, child) {
return TextFormField(
controller: inpucode,
cursorHeight: 20, cursorHeight: 20,
readOnly: false,
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Enter Coupon Code", hintText: "Enter Coupon Code",
border: OutlineInputBorder( border: OutlineInputBorder(
@@ -44,8 +41,18 @@ class CouponsScreen extends StatelessWidget {
suffixIcon: Padding( suffixIcon: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: ElevatedButton( child: ElevatedButton(
onPressed: () { onPressed: () async {
Navigator.pop(context); if (_formKey.currentState!.validate()) {
// var status = await provider.applyCoupon(
// context,
// cartId,
// inpucode.text,
// );
// if (status) {
// Navigator.pop(context);
// }
}
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: Colors.green, backgroundColor: Colors.green,
@@ -57,13 +64,28 @@ class CouponsScreen extends StatelessWidget {
), ),
), ),
), ),
validator: (value) {
if (value == null || value.trim().isEmpty) {
return "Please enter a coupon code";
}
return null;
},
);
},
),
), ),
SizedBox(height: 16), SizedBox(height: 16),
Expanded( Consumer<AddtocartProvider>(builder: (context, provider, child) {
if (provider.iscouponLoading) {
return Center(child: CircularProgressIndicator());
} else if (provider.couponDataModel.data!.isEmpty) {
return SizedBox.shrink();
} else {
return Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: coupons.length, itemCount: provider.couponDataModel.data!.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final coupon = coupons[index]; final coupon = provider.couponDataModel.data![index];
return Card( return Card(
color: Colors.white, color: Colors.white,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
@@ -76,7 +98,7 @@ class CouponsScreen extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
coupon["title"]!, coupon.description!,
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@@ -84,12 +106,13 @@ class CouponsScreen extends StatelessWidget {
), ),
SizedBox(height: 5), SizedBox(height: 5),
Text( Text(
coupon["description"]!, coupon.terms!,
style: TextStyle(color: Colors.grey[600]), style: TextStyle(color: Colors.grey[600]),
), ),
SizedBox(height: 10), SizedBox(height: 10),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
Container( Container(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
@@ -99,7 +122,7 @@ class CouponsScreen extends StatelessWidget {
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
child: Text( child: Text(
coupon["code"]!, coupon.code!,
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Colors.green, color: Colors.green,
@@ -107,8 +130,16 @@ class CouponsScreen extends StatelessWidget {
), ),
), ),
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () async {
var status = await provider.applyCoupon(
context,
cartId,
coupon.code,
coupon.id);
{
Navigator.pop(context); Navigator.pop(context);
}
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: Colors.green, backgroundColor: Colors.green,
@@ -126,7 +157,9 @@ class CouponsScreen extends StatelessWidget {
); );
}, },
), ),
), );
}
}),
], ],
), ),
), ),

View File

@@ -33,10 +33,8 @@ class _MyOrderScreenState extends State<MyOrderScreen> {
height: 20, height: 20,
width: 20, width: 20,
child: InkWell( child: InkWell(
onTap: () onTap: () {
{
context.clearAndPush(routePath: MyRoutes.BOTTOMNAV); context.clearAndPush(routePath: MyRoutes.BOTTOMNAV);
}, },
child: SvgPicture.asset( child: SvgPicture.asset(
APPASSETS.back, APPASSETS.back,
@@ -71,7 +69,8 @@ class _MyOrderScreenState extends State<MyOrderScreen> {
final order = orderProvider.orderList[index]; final order = orderProvider.orderList[index];
return InkWell( return InkWell(
onTap: () { onTap: ()
{
context.pushNamed(MyRoutes.ORDERDETAILS, extra: order); context.pushNamed(MyRoutes.ORDERDETAILS, extra: order);
//context.push(MyRoutes.ORDERDETAILS); //context.push(MyRoutes.ORDERDETAILS);
}, },
@@ -155,7 +154,7 @@ class _MyOrderScreenState extends State<MyOrderScreen> {
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text("\$" + order.grandTotal, Text("\$" + order.subtotal,
style: style:
TextStyle(fontWeight: FontWeight.bold)), TextStyle(fontWeight: FontWeight.bold)),
Row( Row(
@@ -185,8 +184,8 @@ class _MyOrderScreenState extends State<MyOrderScreen> {
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
print("lkdhgkjdfgj"); print("lkdhgkjdfgj");
_makePhoneCall( // _makePhoneCall(
order.stores!.first.vendor!.phone); // order.stores!.first.vendor!.phone);
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: Colors.green, backgroundColor: Colors.green,

View File

@@ -10,7 +10,7 @@ import 'package:gap/gap.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:grocery_app/src/common_widget/network_image.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/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/data/product_details.dart';
import 'package:grocery_app/src/logic/provider/bottom_navbar_provider.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/src/logic/provider/home_provider.dart';
@@ -327,6 +327,8 @@ class _ProductDetailsState extends State<ProductDetails> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (provider.productDetails.data!.productHighlight!
.isNotEmpty) ...{
Row( Row(
children: [ children: [
Text("Highlights", Text("Highlights",
@@ -347,29 +349,22 @@ class _ProductDetailsState extends State<ProductDetails> {
curve: Curves.easeInOut, curve: Curves.easeInOut,
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Column( child: ListView.builder(
children: [ shrinkWrap: true,
if (provider.productDetails.data!.brand != physics: NeverScrollableScrollPhysics(),
null) itemCount: isHilightsExpanded
_buildText( ? provider.productDetails.data!
"Brand ", .productHighlight!.length
'${provider.productDetails.data!.brand ?? ''}', : 2,
), itemBuilder: (context, index) {
// if (isHilightsExpanded) final item = provider.productDetails.data!
_buildText( .productHighlight![index];
"Weight", return _buildText(
'${provider.productDetails.data!.unit ?? ""}', item.key ?? '', item.value ?? '');
), },
if (isHilightsExpanded)
_buildText(
"Product Type",
'${provider.productDetails.data!.productType ?? ""}',
),
],
), ),
), ),
), ),
Center( Center(
child: TextButton( child: TextButton(
onPressed: () { onPressed: () {
@@ -378,11 +373,15 @@ class _ProductDetailsState extends State<ProductDetails> {
}); });
}, },
child: Text( child: Text(
isHilightsExpanded ? "View Less" : "View More", isHilightsExpanded
? "View Less"
: "View More",
style: TextStyle(color: APPCOLOR.appGreen), style: TextStyle(color: APPCOLOR.appGreen),
), ),
), ),
), ),
},
Row( Row(
children: [ children: [
Text("Information", Text("Information",
@@ -419,11 +418,12 @@ class _ProductDetailsState extends State<ProductDetails> {
"Seller Address", "Seller Address",
'${provider.productDetails.data!.store!.storeAddress ?? ""}', '${provider.productDetails.data!.store!.storeAddress ?? ""}',
), ),
if (isExpanded) // if (isExpanded)
_buildText( // _buildText(
"GST Number", // "GST Number",
'${provider.productDetails.data!.store!.gstNumber ?? ""}', // '${provider.productDetails.data!.store!.gstNumber ?? ""}',
),
// ),
], ],
), ),
), ),