orderpayment

This commit is contained in:
2025-02-03 18:16:41 +05:30
parent 1f7254ecaa
commit 8fb5ac1f31
21 changed files with 1433 additions and 789 deletions

View File

@@ -13,6 +13,7 @@ import 'package:grocery_app/src/logic/provider/addTocart_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/ui/bestdeal/bestdeal_screen.dart';
import 'package:grocery_app/src/ui/card_checkout/card_checkout_screen.dart';
import 'package:grocery_app/src/ui/widgets/custom_icon_button.dart';
import 'package:grocery_app/src/ui/widgets/elevated_button.dart';
@@ -304,7 +305,7 @@ class _MycartState extends State<Mycart> {
});
}
double calculateDiscountPercentage(double basePrice, double discountPrice) {
int calculateDiscountPercentage(double basePrice, double discountPrice) {
print(
"Base Price (Before Discount): $basePrice, Discount Price (After Discount): $discountPrice");
@@ -316,7 +317,8 @@ class _MycartState extends State<Mycart> {
double discountAmount = basePrice - discountPrice;
double discountPercentage = (discountAmount / basePrice) * 100;
return discountPercentage;
print("kjhfjhdsfghjk ${discountPercentage.round()}");
return discountPercentage.round();
}
Widget cartItems() {
@@ -331,7 +333,7 @@ class _MycartState extends State<Mycart> {
padding: EdgeInsets.only(top: 12.h, bottom: 24.h),
child: const Divider(thickness: 1),
),
itemCount: 3, // Display 3 skeleton items
itemCount: 2,
itemBuilder: (context, index) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 10.w),
@@ -1135,8 +1137,6 @@ class AddressBottomSheet extends StatefulWidget {
}
class _AddressBottomSheetState extends State<AddressBottomSheet> {
// String selectedAddress = "Home";
@override
Widget build(BuildContext context) {
return Padding(
@@ -1180,19 +1180,45 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
),
),
SizedBox(height: 16),
ElevatedButton.icon(
onPressed: () {},
label: Text(
"Continue",
style: TextStyle(color: Colors.white, fontSize: 16),
),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green,
minimumSize: Size(double.infinity, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
),
),
Consumer<AddtocartProvider>(
builder: (context, paymentProvider, child) {
print(
"prxvsvxvice ${double.parse(paymentProvider.allitem.subtotal.toString())} ${paymentProvider.selecteUserName} ${paymentProvider.selectedAddress} ${paymentProvider.selecteEmail} ${paymentProvider.selecteUserPhone}");
return ElevatedButton.icon(
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(
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);
},
));
// showPaymentMethodBottomSheet(context);
// context.push(MyRoutes.SELECTPAYMENTSCREEN);
//Navigator.pop(context);
},
label: Text(
"Continue",
style: TextStyle(color: Colors.white, fontSize: 16),
),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green,
minimumSize: Size(double.infinity, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
),
);
}),
SizedBox(height: 10),
],
),
@@ -1212,6 +1238,13 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
itemBuilder: (context, 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(
elevation: 0,
shape: RoundedRectangleBorder(
@@ -1219,11 +1252,14 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
child: ListTile(
leading: Radio(
value: address.id ?? "",
groupValue: addressProvider
.selectedAddress, // Use provider's value
groupValue: addressProvider.selectedAddress,
activeColor: Colors.green,
onChanged: (value) {
addressProvider.selectAddress(value.toString());
addressProvider.selectAddress(
value.toString(),
address.phoneNumber,
address.name,
address.user!.email);
},
),
title: Text(
@@ -1243,6 +1279,76 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
},
);
}
// void showPaymentMethodBottomSheet(BuildContext context) {
// showModalBottomSheet(
// context: context,
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
// ),
// builder: (context) {
// return Consumer<AddtocartProvider>(
// builder: (context, paymentProvider, child) {
// return Container(
// padding: EdgeInsets.all(16),
// height: 250,
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// "Select Payment Method",
// style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
// ),
// SizedBox(height: 20),
// // Online Payment Option
// ListTile(
// leading: Icon(Icons.payment, color: Colors.blue),
// title: Text("Online Payment"),
// trailing: paymentProvider.selectedPaymentMethod == "Online"
// ? Icon(Icons.check_circle, color: Colors.green)
// : null,
// onTap: () {
// paymentProvider.selectPaymentMethod("Online");
// },
// ),
// // Cash on Delivery (COD) Option
// ListTile(
// leading: Icon(Icons.money, color: Colors.orange),
// title: Text("Cash on Delivery (COD)"),
// trailing: paymentProvider.selectedPaymentMethod == "COD"
// ? Icon(Icons.check_circle, color: Colors.green)
// : null,
// onTap: () {
// paymentProvider.selectPaymentMethod("COD");
// },
// ),
// ElevatedButton.icon(
// onPressed: () {
// //context.push(MyRoutes.SELECTPAYMENTSCREEN);
// //Navigator.pop(context);
// },
// label: Text(
// "Continue",
// style: TextStyle(color: Colors.white, fontSize: 16),
// ),
// style: ElevatedButton.styleFrom(
// backgroundColor: Colors.green,
// minimumSize: Size(double.infinity, 50),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(10)),
// ),
// ),
// ],
// ),
// );
// },
// );
// },
// );
// }
}
class SummaryRow extends StatelessWidget {