offer update
This commit is contained in:
94
lib/src/data/cod_order_response.dart
Normal file
94
lib/src/data/cod_order_response.dart
Normal file
@@ -0,0 +1,94 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final codOrderResponse = codOrderResponseFromJson(jsondynamic);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
CodOrderResponse codOrderResponseFromJson(dynamic str) => CodOrderResponse.fromJson(json.decode(str));
|
||||
|
||||
dynamic codOrderResponseToJson(CodOrderResponse data) => json.encode(data.toJson());
|
||||
|
||||
class CodOrderResponse {
|
||||
dynamic id;
|
||||
dynamic orderNumber;
|
||||
dynamic userId;
|
||||
int? totalItems;
|
||||
dynamic subtotal;
|
||||
dynamic deliveryCharge;
|
||||
dynamic discount;
|
||||
dynamic grandTotal;
|
||||
dynamic paymentMethod;
|
||||
dynamic paymentStatus;
|
||||
dynamic transactionId;
|
||||
dynamic orderStatus;
|
||||
dynamic deliveryAddressId;
|
||||
dynamic couponId;
|
||||
dynamic cancelReason;
|
||||
dynamic cancelledBy;
|
||||
dynamic cancelledAt;
|
||||
|
||||
|
||||
CodOrderResponse({
|
||||
this.id,
|
||||
this.orderNumber,
|
||||
this.userId,
|
||||
this.totalItems,
|
||||
this.subtotal,
|
||||
this.deliveryCharge,
|
||||
this.discount,
|
||||
this.grandTotal,
|
||||
this.paymentMethod,
|
||||
this.paymentStatus,
|
||||
this.transactionId,
|
||||
this.orderStatus,
|
||||
this.deliveryAddressId,
|
||||
this.couponId,
|
||||
this.cancelReason,
|
||||
this.cancelledBy,
|
||||
this.cancelledAt,
|
||||
|
||||
});
|
||||
|
||||
factory CodOrderResponse.fromJson(Map<dynamic, dynamic> json) => CodOrderResponse(
|
||||
id: json["id"],
|
||||
orderNumber: json["orderNumber"],
|
||||
userId: json["userId"],
|
||||
totalItems: json["totalItems"],
|
||||
subtotal: json["subtotal"],
|
||||
deliveryCharge: json["deliveryCharge"],
|
||||
discount: json["discount"],
|
||||
grandTotal: json["grandTotal"],
|
||||
paymentMethod: json["paymentMethod"],
|
||||
paymentStatus: json["paymentStatus"],
|
||||
transactionId: json["transactionId"],
|
||||
orderStatus: json["orderStatus"],
|
||||
deliveryAddressId: json["deliveryAddressId"],
|
||||
couponId: json["couponId"],
|
||||
cancelReason: json["cancelReason"],
|
||||
cancelledBy: json["cancelledBy"],
|
||||
cancelledAt: json["cancelledAt"],
|
||||
|
||||
);
|
||||
|
||||
Map<dynamic, dynamic> toJson() => {
|
||||
"id": id,
|
||||
"orderNumber": orderNumber,
|
||||
"userId": userId,
|
||||
"totalItems": totalItems,
|
||||
"subtotal": subtotal,
|
||||
"deliveryCharge": deliveryCharge,
|
||||
"discount": discount,
|
||||
"grandTotal": grandTotal,
|
||||
"paymentMethod": paymentMethod,
|
||||
"paymentStatus": paymentStatus,
|
||||
"transactionId": transactionId,
|
||||
"orderStatus": orderStatus,
|
||||
"deliveryAddressId": deliveryAddressId,
|
||||
"couponId": couponId,
|
||||
"cancelReason": cancelReason,
|
||||
"cancelledBy": cancelledBy,
|
||||
"cancelledAt": cancelledAt,
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:geocoding/geocoding.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
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/data/address.dart';
|
||||
import 'package:grocery_app/src/data/all_cart_items.dart';
|
||||
import 'package:grocery_app/src/logic/repo/product_repo.dart';
|
||||
@@ -219,65 +220,55 @@ class AddtocartProvider extends ChangeNotifier {
|
||||
Future<void> paymentCODOrder(
|
||||
BuildContext context,
|
||||
double subtotal,
|
||||
String deliverCharge,
|
||||
double deliverCharge,
|
||||
double discountPrice,
|
||||
String grandTotal,
|
||||
double grandTotal,
|
||||
String couponId,
|
||||
String addressId,
|
||||
) async {
|
||||
print("sdkjfhgkjdfhgjkldfkjghkdf");
|
||||
ispaymentLoader = true;
|
||||
notifyListeners();
|
||||
var data;
|
||||
if (couponId.isNotEmpty)
|
||||
{
|
||||
if (couponId != '00') {
|
||||
data = {
|
||||
{
|
||||
"addressId": addressId,
|
||||
"paymentMethod": "COD",
|
||||
"paymentStatus": "PENDING",
|
||||
"orderStatus": "PENDING",
|
||||
"subtotal": subtotal,
|
||||
"deliveryCharge": deliverCharge,
|
||||
"discount": discountPrice,
|
||||
"grandTotal": grandTotal,
|
||||
"couponId": couponId
|
||||
}
|
||||
"addressId": addressId,
|
||||
"paymentMethod": "COD",
|
||||
"paymentStatus": "PENDING",
|
||||
"orderStatus": "PENDING",
|
||||
"subtotal": subtotal,
|
||||
"deliveryCharge": deliverCharge,
|
||||
"discount": discountPrice,
|
||||
"grandTotal": grandTotal,
|
||||
"couponId": couponId
|
||||
};
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
print("skfdjdsjfg");
|
||||
data = {
|
||||
{
|
||||
"addressId": addressId,
|
||||
"paymentMethod": "COD",
|
||||
"paymentStatus": "PENDING",
|
||||
"orderStatus": "PENDING",
|
||||
"subtotal": subtotal,
|
||||
"deliveryCharge": deliverCharge,
|
||||
"discount": discountPrice,
|
||||
"grandTotal": grandTotal,
|
||||
}
|
||||
"addressId": addressId,
|
||||
"paymentMethod": "COD",
|
||||
"paymentStatus": "PENDING",
|
||||
"orderStatus": "PENDING",
|
||||
"subtotal": subtotal,
|
||||
"deliveryCharge": deliverCharge,
|
||||
"discount": discountPrice,
|
||||
"grandTotal": grandTotal,
|
||||
};
|
||||
}
|
||||
|
||||
print("kjfhxgkljfhg ${data}");
|
||||
|
||||
try {
|
||||
var result = await _homeRepo.paymentCODOrder(data);
|
||||
|
||||
return result.fold(
|
||||
(error) {
|
||||
ispaymentLoader = false;
|
||||
notifyListeners();
|
||||
},
|
||||
(response) {
|
||||
if (response.data!.instrumentResponse!.redirectInfo != null &&
|
||||
response.data!.instrumentResponse!.redirectInfo != '') {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PaymentWebView(
|
||||
paymentUrl:
|
||||
response.data!.instrumentResponse!.redirectInfo!.url),
|
||||
),
|
||||
);
|
||||
}
|
||||
context.clearAndPush(routePath: MyRoutes.SUCCESSPAYMENT);
|
||||
|
||||
ispaymentLoader = false;
|
||||
notifyListeners();
|
||||
},
|
||||
|
||||
@@ -69,6 +69,8 @@ class ProductProvider extends ChangeNotifier {
|
||||
bool isBestdealingloading = true;
|
||||
|
||||
Future<void> getBestDealProduct(BuildContext context) async {
|
||||
isBestdealingloading = true;
|
||||
notifyListeners();
|
||||
var data = {};
|
||||
|
||||
var result = await _homeRepo.getBestDealProduct(data, context);
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'package:grocery_app/src/data/all_cart_items.dart';
|
||||
import 'package:grocery_app/src/data/banners.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/cod_order_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/product_category.dart';
|
||||
@@ -114,15 +115,13 @@ class ProductRepo {
|
||||
}
|
||||
}
|
||||
|
||||
FutureResult<OrderPaymnet> paymentCODOrder(data) async {
|
||||
FutureResult<CodOrderResponse> paymentCODOrder(data) async {
|
||||
try {
|
||||
|
||||
var response = await _productService.paymentCODOrder(data);
|
||||
print("kjdfglkjfdgjklfgkldj${data} ${response} ");
|
||||
|
||||
OrderPaymnet productCategory = orderPaymnetFromJson(response.toString());
|
||||
CodOrderResponse productCategory = codOrderResponseFromJson(response.toString());
|
||||
|
||||
print("lkjdflkjfhgdkhfgkd ");
|
||||
// final String model = response.toString();
|
||||
|
||||
|
||||
return right(productCategory);
|
||||
} on DioException catch (e) {
|
||||
|
||||
@@ -55,7 +55,6 @@ class ProductService extends ApiService {
|
||||
}
|
||||
|
||||
Future paymentOrder(data) async {
|
||||
print("kdjfgkjjkdfgkjdkfgjkdfgj ${data}");
|
||||
var response = await api.post(APIURL.paymentOrder, data: jsonEncode(data));
|
||||
|
||||
return response;
|
||||
@@ -69,7 +68,6 @@ class ProductService extends ApiService {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
Future similarProduct(data, id) async {
|
||||
var response = await api.get(APIURL.similarProduct + id + "/similar",
|
||||
data: jsonEncode(data));
|
||||
|
||||
@@ -23,6 +23,28 @@ class BestDealScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _BestDealScreenState extends State<BestDealScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
Provider.of<ProductProvider>(context, listen: false)
|
||||
.getBestDealProduct(context);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
int calculateDiscountPercentage(double basePrice, double discountPrice) {
|
||||
print(
|
||||
"Base Price (Before Discount): $basePrice, Discount Price (After Discount): $discountPrice");
|
||||
|
||||
if (basePrice <= 0 || discountPrice <= 0 || discountPrice > basePrice) {
|
||||
print("Error: Invalid price values.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
double discountAmount = basePrice - discountPrice;
|
||||
double discountPercentage = (discountAmount / basePrice) * 100;
|
||||
|
||||
return discountPercentage.round();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -221,31 +243,24 @@ class _BestDealScreenState extends State<BestDealScreen> {
|
||||
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,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
Positioned(
|
||||
right: 1,
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${calculateDiscountPercentage(double.parse(bestdealproduct.basePrice), double.parse(bestdealproduct.discountPrice))}% OFF",
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 12)),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -153,6 +153,8 @@ class _BottomBarState extends State<BottomBarWidget> {
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,10 @@ class CardCheckoutScreen extends StatefulWidget {
|
||||
String cartId;
|
||||
String addressId;
|
||||
String remarks;
|
||||
double deliverCharge;
|
||||
double discountPrice;
|
||||
String? couponId;
|
||||
|
||||
CardCheckoutScreen(
|
||||
{super.key,
|
||||
required this.amount,
|
||||
@@ -30,7 +34,10 @@ class CardCheckoutScreen extends StatefulWidget {
|
||||
required this.userId,
|
||||
required this.cartId,
|
||||
required this.addressId,
|
||||
required this.remarks});
|
||||
required this.remarks,
|
||||
required this.deliverCharge,
|
||||
required this.discountPrice,
|
||||
this.couponId});
|
||||
|
||||
@override
|
||||
State<CardCheckoutScreen> createState() => _CardCheckoutScreenState();
|
||||
@@ -94,19 +101,18 @@ class _CardCheckoutScreenState extends State<CardCheckoutScreen> {
|
||||
widget.addressId,
|
||||
widget.remarks);
|
||||
} else {
|
||||
// paymentProvider.paymentCODOrder(
|
||||
// context,
|
||||
// subtotal,
|
||||
// deliverCharge,
|
||||
// discountPrice,
|
||||
// grandTotal,
|
||||
// couponId,
|
||||
|
||||
// widget.addressId,
|
||||
// );
|
||||
print("ldksjfgkljdfghljkfdg");
|
||||
paymentProvider.paymentCODOrder(
|
||||
context,
|
||||
widget.amount,
|
||||
widget.deliverCharge,
|
||||
widget.discountPrice,
|
||||
widget.originalAmount,
|
||||
// widget.couponId!,
|
||||
'00',
|
||||
widget.addressId,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
child: Container(
|
||||
height: 50,
|
||||
|
||||
@@ -153,6 +153,25 @@ class _MycartState extends State<Mycart> {
|
||||
"",
|
||||
backGroundColor: Colors.transparent,
|
||||
),
|
||||
Positioned(
|
||||
right: 1,
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${calculateDiscountPercentage(double.parse(provider.productDetails.data!.basePrice), double.parse(provider.productDetails.data!.discountPrice))}% OFF",
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12)),
|
||||
),
|
||||
),
|
||||
)
|
||||
// Positioned(
|
||||
// right: 5,
|
||||
// top: 5,
|
||||
@@ -713,7 +732,8 @@ class _MycartState extends State<Mycart> {
|
||||
);
|
||||
} else if (provider.allitem == null) {
|
||||
return Center(child: Text('🛒 Your Front Shop Cart is empty'));
|
||||
} else if (provider.allitem.items!.isEmpty) {
|
||||
} else if (provider.allitem.items == null ||
|
||||
provider.allitem.items!.isEmpty) {
|
||||
return Center(
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: Colors.green),
|
||||
@@ -729,7 +749,7 @@ class _MycartState extends State<Mycart> {
|
||||
),
|
||||
));
|
||||
} else {
|
||||
print("kldjhgjkhfgjkh ${provider.allitem.items}");
|
||||
print("kldjhgjkhfgjkh ");
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -977,21 +997,24 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context)
|
||||
{
|
||||
builder: (context) {
|
||||
return CardCheckoutScreen(
|
||||
amount: double.parse(
|
||||
paymentProvider.allitem.subtotal.toString()),
|
||||
currency: "INR",
|
||||
originalAmount: double.parse(
|
||||
paymentProvider.allitem.subtotal.toString()),
|
||||
name: paymentProvider.selecteUserName,
|
||||
phone: paymentProvider.selecteUserPhone,
|
||||
email: paymentProvider.selecteEmail,
|
||||
userId: paymentProvider.allitem.userId!,
|
||||
cartId: paymentProvider.allitem.id!,
|
||||
addressId: paymentProvider.selectedAddress,
|
||||
remarks: paymentProvider.selecteUserName);
|
||||
amount: double.parse(
|
||||
paymentProvider.allitem.subtotal.toString()),
|
||||
currency: "INR",
|
||||
originalAmount: double.parse(
|
||||
paymentProvider.allitem.subtotal.toString()),
|
||||
name: paymentProvider.selecteUserName,
|
||||
phone: paymentProvider.selecteUserPhone,
|
||||
email: paymentProvider.selecteEmail,
|
||||
userId: paymentProvider.allitem.userId!,
|
||||
cartId: paymentProvider.allitem.id!,
|
||||
addressId: paymentProvider.selectedAddress,
|
||||
remarks: paymentProvider.selecteUserName,
|
||||
deliverCharge: 0,
|
||||
discountPrice: 0,
|
||||
couponId: '',
|
||||
);
|
||||
},
|
||||
));
|
||||
},
|
||||
|
||||
@@ -80,8 +80,7 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
|
||||
Widget productWidget() {
|
||||
return Consumer<ProductProvider>(builder: (context, provider, child) {
|
||||
if (provider.isLoadingg)
|
||||
{
|
||||
if (provider.isLoadingg) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 120),
|
||||
child: Center(
|
||||
@@ -126,8 +125,7 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
var product = provider.products[index];
|
||||
|
||||
return InkWell(
|
||||
onTap: ()
|
||||
{
|
||||
onTap: () {
|
||||
context.push(MyRoutes.PRODUCTDETAILS,
|
||||
extra: product.id);
|
||||
},
|
||||
@@ -168,6 +166,26 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
"https://5.imimg.com/data5/SELLER/Default/2024/2/385126988/OL/DA/VW/8627346/1l-fortune-sunflower-oil.jpg",
|
||||
backGroundColor: Colors.transparent,
|
||||
),
|
||||
Positioned(
|
||||
right: 1,
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
borderRadius:
|
||||
BorderRadius.circular(5),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${calculateDiscountPercentage(double.parse(product.basePrice), double.parse(product!.discountPrice))}% OFF",
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12)),
|
||||
),
|
||||
),
|
||||
)
|
||||
// Positioned(
|
||||
// right: 5,
|
||||
// top: 5,
|
||||
@@ -343,8 +361,6 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -362,6 +378,21 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
});
|
||||
}
|
||||
|
||||
int calculateDiscountPercentage(double basePrice, double discountPrice) {
|
||||
print(
|
||||
"Base Price (Before Discount): $basePrice, Discount Price (After Discount): $discountPrice");
|
||||
|
||||
if (basePrice <= 0 || discountPrice <= 0 || discountPrice > basePrice) {
|
||||
print("Error: Invalid price values.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
double discountAmount = basePrice - discountPrice;
|
||||
double discountPercentage = (discountAmount / basePrice) * 100;
|
||||
|
||||
return discountPercentage.round();
|
||||
}
|
||||
|
||||
Widget filterCategory() {
|
||||
final activeIndexProvider = Provider.of<ProductProvider>(context);
|
||||
return Consumer<ProductProvider>(builder: (context, provider, child) {
|
||||
|
||||
@@ -326,6 +326,26 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
"",
|
||||
backGroundColor: Colors.transparent,
|
||||
),
|
||||
Positioned(
|
||||
right: 1,
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
borderRadius:
|
||||
BorderRadius.circular(5),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${calculateDiscountPercentage(double.parse(bestdealproduct.basePrice), double.parse(bestdealproduct.discountPrice))}% OFF",
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12)),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -457,225 +477,20 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
// Widget bestDeal() {
|
||||
// return Consumer<ProductProvider>(builder: (context, provider, child) {
|
||||
// if (provider.isBestdealingloading) {
|
||||
// return Center(child: CircularProgressIndicator());
|
||||
// } else if (provider.bestdeal.isEmpty) {
|
||||
// return Center(child: Text('No products available'));
|
||||
// } else {
|
||||
// return SizedBox(
|
||||
// height: MediaQuery.of(context).size.height * 0.28,
|
||||
// child: ListView.builder(
|
||||
// itemCount: provider.bestdeal.length,
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// itemBuilder: (context, index) {
|
||||
// var bestdealproduct = provider.bestdeal[index];
|
||||
// double cardWidth =
|
||||
// MediaQuery.of(context).size.width * 0.4; // Dynamic width
|
||||
int calculateDiscountPercentage(double basePrice, double discountPrice) {
|
||||
print(
|
||||
"Base Price (Before Discount): $basePrice, Discount Price (After Discount): $discountPrice");
|
||||
|
||||
// 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,
|
||||
// // ),
|
||||
// // ),
|
||||
// // ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// 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 (basePrice <= 0 || discountPrice <= 0 || discountPrice > basePrice) {
|
||||
print("Error: Invalid price values.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// if (await SharedPrefUtils.getToken() !=
|
||||
// null) {
|
||||
// // if (!(provider
|
||||
// // .isLoading[bestdealproduct.id] ??
|
||||
// // false))
|
||||
// // {
|
||||
double discountAmount = basePrice - discountPrice;
|
||||
double discountPercentage = (discountAmount / basePrice) * 100;
|
||||
|
||||
// await provider.addToCart(
|
||||
// context, bestdealproduct.id!,1);
|
||||
|
||||
// // }
|
||||
// } 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),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
return discountPercentage.round();
|
||||
}
|
||||
|
||||
Widget bannerview() {
|
||||
return Consumer<ProductProvider>(builder: (context, provider, child) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:grocery_app/src/core/routes/routes.dart';
|
||||
import 'package:grocery_app/src/logic/provider/order_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/extensions/extensions.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
@@ -32,8 +33,10 @@ class _MyOrderScreenState extends State<MyOrderScreen> {
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
onTap: ()
|
||||
{
|
||||
context.clearAndPush(routePath: MyRoutes.BOTTOMNAV);
|
||||
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
APPASSETS.back,
|
||||
|
||||
@@ -61,11 +61,12 @@ class PaymentSuccessScreen extends StatelessWidget {
|
||||
SizedBox(height: 20),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
context.clearAndPush(routePath: MyRoutes.BOTTOMNAV);
|
||||
context.push(MyRoutes.MYORDER);
|
||||
|
||||
// context.read<BottomNavProvider>().setIndex(0);
|
||||
// Navigator.pop(context);
|
||||
},
|
||||
child: Text("Go to Home"),
|
||||
child: Text("View Your Order"),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user