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

@@ -23,8 +23,11 @@ class APIURL {
static const String addAddress = "${BASE_URL}user/addresses";
static const String getprofile = "${BASE_URL}user/profile/customer";
static const String refresh_token = "${BASE_URL}auth/refresh-token";
static const String uploadImage = "${BASE_URL}images/upload";
static const String updateProfile = "${BASE_URL}user/profile";
static const String uploadImage = "${BASE_URL}images/upload";
static const String updateProfile = "${BASE_URL}user/profile";
static const String paymentOrder = "${BASE_URL}payment/order";

View File

@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:grocery_app/src/data/allProduct_model.dart';
import 'package:grocery_app/src/ui/bottomnavigation/bottom_bar_widget.dart';
import 'package:grocery_app/src/ui/card_checkout/card_checkout_screen.dart';
import 'package:grocery_app/src/ui/coupons/coupons_screen.dart';
import 'package:grocery_app/src/ui/entername/enter_fullname_screen.dart';
import 'package:grocery_app/src/ui/fruitvegidetail/fruit_veggie_detail.dart';
@@ -94,11 +95,11 @@ class MyRoutes {
},
),
// animatedGoRoute(
// path: TERMANDCONDITIONS,
// name: TERMANDCONDITIONS,
// pageBuilder: (context, state) => const TermsAndConditionsScreen(),
// ),
// animatedGoRoute(
// path: SELECTPAYMENTSCREEN,
// name: SELECTPAYMENTSCREEN,
// pageBuilder: (context, state) => const CardCheckoutScreen(),
// ),
// animatedGoRoute(
// path: SETUPBUSSINESS,
// name: SETUPBUSSINESS,
@@ -228,6 +229,7 @@ class MyRoutes {
static const LOGIN = "/login";
static const SIGNUP = "/signup";
static const ONBOARDING = "/onboarding";
static const SELECTPAYMENTSCREEN = "/paymnetscreen";
// static const TERMANDCONDITIONS = "/termsandcondition";
// static const SETUPBUSSINESS = "/setupbussiness";

View File

@@ -0,0 +1,104 @@
// To parse this JSON data, do
//
// final orderPaymnet = orderPaymnetFromJson(jsondynamic);
import 'dart:convert';
OrderPaymnet orderPaymnetFromJson(dynamic str) =>
OrderPaymnet.fromJson(json.decode(str));
dynamic orderPaymnetToJson(OrderPaymnet data) => json.encode(data.toJson());
class OrderPaymnet {
bool? success;
dynamic code;
dynamic message;
PaymentData? data;
OrderPaymnet({
this.success,
this.code,
this.message,
this.data,
});
factory OrderPaymnet.fromJson(Map<dynamic, dynamic> json) => OrderPaymnet(
success: json["success"],
code: json["code"],
message: json["message"],
data: PaymentData.fromJson(json["data"]),
);
Map<dynamic, dynamic> toJson() => {
"success": success,
"code": code,
"message": message,
"data": data!.toJson(),
};
}
class PaymentData {
dynamic merchantId;
dynamic merchantTransactionId;
InstrumentResponse? instrumentResponse;
PaymentData({
this.merchantId,
this.merchantTransactionId,
this.instrumentResponse,
});
factory PaymentData.fromJson(Map<dynamic, dynamic> json) => PaymentData(
merchantId: json["merchantId"],
merchantTransactionId: json["merchantTransactionId"],
instrumentResponse:
InstrumentResponse.fromJson(json["instrumentResponse"]),
);
Map<dynamic, dynamic> toJson() => {
"merchantId": merchantId,
"merchantTransactionId": merchantTransactionId,
"instrumentResponse": instrumentResponse!.toJson(),
};
}
class InstrumentResponse {
dynamic type;
RedirectInfo? redirectInfo;
InstrumentResponse({
this.type,
this.redirectInfo,
});
factory InstrumentResponse.fromJson(Map<dynamic, dynamic> json) =>
InstrumentResponse(
type: json["type"],
redirectInfo: RedirectInfo.fromJson(json["redirectInfo"]),
);
Map<dynamic, dynamic> toJson() => {
"type": type,
"redirectInfo": redirectInfo!.toJson(),
};
}
class RedirectInfo {
dynamic url;
dynamic method;
RedirectInfo({
this.url,
this.method,
});
factory RedirectInfo.fromJson(Map<dynamic, dynamic> json) => RedirectInfo(
url: json["url"],
method: json["method"],
);
Map<dynamic, dynamic> toJson() => {
"url": url,
"method": method,
};
}

View File

@@ -7,6 +7,7 @@ import 'package:grocery_app/src/core/network_services/service_locator.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';
import 'package:grocery_app/src/ui/payment/payment_webView.dart';
import 'package:grocery_app/utils/extensions/extensions.dart';
import 'package:http/http.dart' as http;
@@ -152,8 +153,61 @@ class AddtocartProvider extends ChangeNotifier {
notifyListeners();
}
}
///////////////////////////////////orderPaymnet///////////////////////////
///////////////////////////////// address/////////////////////////
Future<void> orderPaymnet(
BuildContext context,
double amount,
String currency,
double originalAmount,
String name,
String phone,
String email,
String userI,
String cartId,
String addressId,
String remarks,
) async {
notifyListeners();
var data = {
{
"amount": amount,
"currency": currency,
"originalAmount": amount,
"name": name,
"phone": phone,
"email": email,
"userId": userI,
"cartId": cartId,
"addressId": addressId,
"remarks": remarks
}
};
print("kjdfhgkj ${data}");
try {
var result = await _homeRepo.paymentOrder(data);
return result.fold(
(error) {
notifyListeners();
},
(response) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PaymentWebView(paymentUrl: ''),
),
);
},
);
} catch (e) {
notifyListeners();
}
}
///////////////////////////////// address/////////////////////////
List<Datum> addresslist = [];
Future<void> getAddress(BuildContext context) async {
@@ -170,7 +224,10 @@ class AddtocartProvider extends ChangeNotifier {
(response) {
addresslist = response.data!;
if (response.data!.isNotEmpty) {
_selectedAddress = addresslist.last.id ?? "";
_selectedAddress = addresslist.first.id ?? "";
_selecteUserName = addresslist.first.name ?? "";
_selecteUserPhone = addresslist.first.phoneNumber ?? "";
_selecteEmail = addresslist.first.user!.email ?? "";
} else {
_selectedAddress = "";
}
@@ -186,11 +243,26 @@ class AddtocartProvider extends ChangeNotifier {
}
String _selectedAddress = "";
String _selecteUserName = "";
String _selecteUserPhone = "";
String _selecteEmail = "";
String get selectedAddress => _selectedAddress;
String get selecteUserName => _selecteUserName;
String get selecteUserPhone => _selecteUserPhone;
String get selecteEmail => _selecteEmail;
void bydefaultSetAddress(phoneNumber, name, email) {
_selecteUserName = name;
_selecteUserPhone = phoneNumber;
_selecteEmail = email;
notifyListeners();
}
void selectAddress(String address) {
void selectAddress(String address, phoneNumber, name, email) {
_selectedAddress = address;
_selecteUserName = name;
_selecteUserPhone = phoneNumber;
_selecteEmail = email;
notifyListeners();
}
@@ -313,4 +385,13 @@ class AddtocartProvider extends ChangeNotifier {
notifyListeners(); // Ensure UI updates after operation
}
}
String _selectedPaymentMethod = "Online"; // Default selection
String get selectedPaymentMethod => _selectedPaymentMethod;
void selectPaymentMethod(String method) {
_selectedPaymentMethod = method;
notifyListeners();
}
}

View File

@@ -91,12 +91,33 @@ class ProductRepo {
return right(productCategory);
} on DioException catch (e) {
print("djhgfjdfhjg ${e}");
var error = CustomDioExceptions.handleError(e);
return left(error);
}
}
FutureResult<ProductCategory> paymentOrder(
data) async
{
try {
var response = await _productService.paymentOrder(data);
ProductCategory productCategory = productCategoryFromJson(response.toString());
// final String model = response.toString();
return right(productCategory);
} on DioException catch (e) {
var error = CustomDioExceptions.handleError(e);
return left(error);
}
}
FutureResult<List<Product>> similarProduct(
data, BuildContext context, id) async {
try {

View File

@@ -53,6 +53,11 @@ class ProductService extends ApiService {
return response;
}
Future paymentOrder(data) async {
var response = await api.post(APIURL.paymentOrder, data: jsonEncode(data));
return response;
}
Future similarProduct(data, id) async {
var response = await api.get(APIURL.similarProduct + id + "/similar",

View File

@@ -2,12 +2,35 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:grocery_app/src/common_widget/name_text_field.dart';
import 'package:grocery_app/src/common_widget/network_image.dart';
import 'package:grocery_app/src/logic/provider/addTocart_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/uicontext.dart';
import 'package:provider/provider.dart';
class CardCheckoutScreen extends StatefulWidget {
const CardCheckoutScreen({super.key});
double amount;
String currency;
double originalAmount;
String name;
String phone;
String email;
String userId;
String cartId;
String addressId;
String remarks;
CardCheckoutScreen(
{super.key,
required this.amount,
required this.currency,
required this.originalAmount,
required this.name,
required this.phone,
required this.email,
required this.userId,
required this.cartId,
required this.addressId,
required this.remarks});
@override
State<CardCheckoutScreen> createState() => _CardCheckoutScreenState();
@@ -42,218 +65,300 @@ class _CardCheckoutScreenState extends State<CardCheckoutScreen> {
),
),
),
bottomNavigationBar: Container(
color: Colors.transparent,
height: 60,
child: Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Row(
children: [
const SizedBox(
width: 15,
),
Expanded(
child: InkWell(
onTap: () {},
child: Container(
height: 50,
decoration: BoxDecoration(color: APPCOLOR.lightGreen, borderRadius: BorderRadius.circular(10)),
child: Center(
child: Text(
"Next",
style: context.customRegular(Colors.white, 16),
bottomNavigationBar: Consumer<AddtocartProvider>(
builder: (context, paymentProvider, child) {
return Container(
color: Colors.transparent,
height: 60,
child: Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Row(
children: [
const SizedBox(
width: 15,
),
Expanded(
child: InkWell(
onTap: () {
paymentProvider.orderPaymnet(
context,
widget.amount,
widget.currency,
widget.originalAmount,
widget.name,
widget.phone,
widget.email,
widget.userId,
widget.cartId,
widget.addressId,
widget.remarks);
},
child: Container(
height: 50,
decoration: BoxDecoration(
color: APPCOLOR.lightGreen,
borderRadius: BorderRadius.circular(10)),
child: Center(
child: Text(
"Continue",
style: context.customRegular(Colors.white, 16),
),
),
),
),
),
),
const SizedBox(
width: 15,
),
],
const SizedBox(
width: 15,
),
],
),
),
),
),
);
}),
body: Padding(
padding: context.bodyAllPadding,
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Saved Cards",
style: context.customExtraBold(Colors.black, 16),
),
const SizedBox(
height: 15,
),
Container(
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(15)),
child: Padding(
padding: const EdgeInsets.all(10),
child: Row(
children: [
const AppNetworkImage(
height: 50,
width: 50,
imageUrl: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSeaqcsR_xDLZTOQ7G-NxCe7mLDxFe-xC2JC_DIojrF2CiVJRnviMf9fvGGFZyzyII3jdY&usqp=CAU',
backGroundColor: Colors.transparent),
const SizedBox(
width: 10,
),
Expanded(
child: Text(
"6895 8578 8578 5525",
style: context.customMedium(Colors.black, 16),
)),
const SizedBox(
width: 10,
),
Icon(
Icons.radio_button_off_outlined,
color: Colors.grey.withOpacity(0.3),
)
],
child: SingleChildScrollView(child: 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),
),
),
),
const SizedBox(
height: 10,
),
Container(
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(15)),
child: Padding(
padding: const EdgeInsets.all(10),
child: Row(
children: [
const AppNetworkImage(
height: 50, width: 50, imageUrl: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQIXY75wxXccxnFoger82T83BZxDPpMavUI1A&s', backGroundColor: Colors.transparent),
const SizedBox(
width: 10,
),
Expanded(
child: Text(
"6895 8578 8578 5525",
style: context.customMedium(Colors.black, 16),
)),
const SizedBox(
width: 10,
),
Icon(
Icons.radio_button_off_outlined,
color: Colors.grey.withOpacity(0.3),
)
],
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");
// Navigator.pop(context);
},
),
),
),
const SizedBox(
height: 10,
),
ClipRRect(
borderRadius: BorderRadius.circular(15),
child: ExpansionTile(
minTileHeight: 0,
backgroundColor: Colors.white,
collapsedBackgroundColor: Colors.white,
//trailing: SizedBox(),
childrenPadding: const EdgeInsets.only(left: 10, right: 10, bottom: 10),
tilePadding: const EdgeInsets.only(right: 10),
title: Container(
width: MediaQuery.sizeOf(context).width,
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(15)),
child: Padding(
padding: const EdgeInsets.only(left: 10, right: 10),
child: Row(
children: [
const AppNetworkImage(
height: 50,
width: 50,
imageUrl: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSeaqcsR_xDLZTOQ7G-NxCe7mLDxFe-xC2JC_DIojrF2CiVJRnviMf9fvGGFZyzyII3jdY&usqp=CAU',
backGroundColor: Colors.transparent),
const SizedBox(
width: 10,
),
Expanded(
child: Text(
"6895 8578 8578 5525",
style: context.customMedium(Colors.black, 16),
)),
],
),
),
// 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");
// Navigator.pop(context);
},
),
children: const [
NameTextField(
name: 'Card Number',
initText: "2352 5285 8545 7528",
),
SizedBox(
height: 10,
),
NameTextField(
name: 'Card Holder Name',
initText: "Smith Watson",
),
SizedBox(
height: 10,
),
Row(
children: [
Expanded(
child: NameTextField(
name: 'Expiry Date',
initText: "09/22",
),
),
SizedBox(
width: 10,
),
Expanded(
child: NameTextField(
name: 'CVV',
initText: "129",
),
)
],
)
],
),
],
),
const SizedBox(
height: 10,
),
Container(
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(15)),
child: Padding(
padding: const EdgeInsets.all(10),
child: Row(
children: [
const AppNetworkImage(
height: 50, width: 50, imageUrl: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTwiraGT0PrLTwZKDg-u25PAlVRgnkdeL96mA&s', backGroundColor: Colors.transparent),
const SizedBox(
width: 10,
),
Expanded(
child: Text(
"Paypal",
style: context.customMedium(Colors.black, 16),
)),
const SizedBox(
width: 10,
),
Icon(
Icons.radio_button_off_outlined,
color: Colors.grey.withOpacity(0.3),
)
],
),
),
),
],
),
),
);
},
)
// Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// "Saved Cards",
// style: context.customExtraBold(Colors.black, 16),
// ),
// const SizedBox(
// height: 15,
// ),
// Container(
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(15)),
// child: Padding(
// padding: const EdgeInsets.all(10),
// child: Row(
// children: [
// const AppNetworkImage(
// height: 50,
// width: 50,
// imageUrl:
// 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSeaqcsR_xDLZTOQ7G-NxCe7mLDxFe-xC2JC_DIojrF2CiVJRnviMf9fvGGFZyzyII3jdY&usqp=CAU',
// backGroundColor: Colors.transparent),
// const SizedBox(
// width: 10,
// ),
// Expanded(
// child: Text(
// "6895 8578 8578 5525",
// style: context.customMedium(Colors.black, 16),
// )),
// const SizedBox(
// width: 10,
// ),
// Icon(
// Icons.radio_button_off_outlined,
// color: Colors.grey.withOpacity(0.3),
// )
// ],
// ),
// ),
// ),
// const SizedBox(
// height: 10,
// ),
// Container(
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(15)),
// child: Padding(
// padding: const EdgeInsets.all(10),
// child: Row(
// children: [
// const AppNetworkImage(
// height: 50,
// width: 50,
// imageUrl:
// 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQIXY75wxXccxnFoger82T83BZxDPpMavUI1A&s',
// backGroundColor: Colors.transparent),
// const SizedBox(
// width: 10,
// ),
// Expanded(
// child: Text(
// "6895 8578 8578 5525",
// style: context.customMedium(Colors.black, 16),
// )),
// const SizedBox(
// width: 10,
// ),
// Icon(
// Icons.radio_button_off_outlined,
// color: Colors.grey.withOpacity(0.3),
// )
// ],
// ),
// ),
// ),
// const SizedBox(
// height: 10,
// ),
// ClipRRect(
// borderRadius: BorderRadius.circular(15),
// child: ExpansionTile(
// minTileHeight: 0,
// backgroundColor: Colors.white,
// collapsedBackgroundColor: Colors.white,
// //trailing: SizedBox(),
// childrenPadding:
// const EdgeInsets.only(left: 10, right: 10, bottom: 10),
// tilePadding: const EdgeInsets.only(right: 10),
// title: Container(
// width: MediaQuery.sizeOf(context).width,
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(15)),
// child: Padding(
// padding: const EdgeInsets.only(left: 10, right: 10),
// child: Row(
// children: [
// const AppNetworkImage(
// height: 50,
// width: 50,
// imageUrl:
// 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSeaqcsR_xDLZTOQ7G-NxCe7mLDxFe-xC2JC_DIojrF2CiVJRnviMf9fvGGFZyzyII3jdY&usqp=CAU',
// backGroundColor: Colors.transparent),
// const SizedBox(
// width: 10,
// ),
// Expanded(
// child: Text(
// "6895 8578 8578 5525",
// style: context.customMedium(Colors.black, 16),
// )),
// ],
// ),
// ),
// ),
// children: const [
// NameTextField(
// name: 'Card Number',
// initText: "2352 5285 8545 7528",
// ),
// SizedBox(
// height: 10,
// ),
// NameTextField(
// name: 'Card Holder Name',
// initText: "Smith Watson",
// ),
// SizedBox(
// height: 10,
// ),
// Row(
// children: [
// Expanded(
// child: NameTextField(
// name: 'Expiry Date',
// initText: "09/22",
// ),
// ),
// SizedBox(
// width: 10,
// ),
// Expanded(
// child: NameTextField(
// name: 'CVV',
// initText: "129",
// ),
// )
// ],
// )
// ],
// ),
// ),
// const SizedBox(
// height: 10,
// ),
// Container(
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(15)),
// child: Padding(
// padding: const EdgeInsets.all(10),
// child: Row(
// children: [
// const AppNetworkImage(
// height: 50,
// width: 50,
// imageUrl:
// 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTwiraGT0PrLTwZKDg-u25PAlVRgnkdeL96mA&s',
// backGroundColor: Colors.transparent),
// const SizedBox(
// width: 10,
// ),
// Expanded(
// child: Text(
// "Paypal",
// style: context.customMedium(Colors.black, 16),
// )),
// const SizedBox(
// width: 10,
// ),
// Icon(
// Icons.radio_button_off_outlined,
// color: Colors.grey.withOpacity(0.3),
// )
// ],
// ),
// ),
// ),
// ],
// ),
),
),
);
}

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 {

View File

@@ -0,0 +1,31 @@
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;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Complete Your Payment")),
body: InAppWebView(
initialUrlRequest: URLRequest(url: WebUri.uri(Uri.parse(widget.paymentUrl))),
onWebViewCreated: (controller) {
webViewController = controller;
},
onLoadStop: (controller, url) async {
print("Payment page loaded: $url");
},
),
);
}
}

View File

@@ -115,7 +115,7 @@ class _ProductDetailsState extends State<ProductDetails> {
);
}
double calculateDiscountPercentage(double basePrice, double discountPrice) {
int calculateDiscountPercentage(double basePrice, double discountPrice) {
print(
"Base Price (Before Discount): $basePrice, Discount Price (After Discount): $discountPrice");
@@ -127,7 +127,7 @@ class _ProductDetailsState extends State<ProductDetails> {
double discountAmount = basePrice - discountPrice;
double discountPercentage = (discountAmount / basePrice) * 100;
return discountPercentage;
return discountPercentage.round();
}
Widget prodectDtails() {
@@ -231,8 +231,39 @@ class _ProductDetailsState extends State<ProductDetails> {
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: 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,
),
),
],
),
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),
),
],
),
),

View File

@@ -171,12 +171,13 @@ class _ProfileScreenState extends State<ProfileScreen> {
trailing: Icon(MdiIcons.chevronRight),
),
ListTile(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) {
return const CardCheckoutScreen();
},
));
onTap: ()
{
// Navigator.of(context).push(MaterialPageRoute(
// builder: (context) {
// return const CardCheckoutScreen();
// },
// ));
},
leading: Icon(MdiIcons.cardOutline),
title: const Text('Payment Method'),