after fixed apyament

This commit is contained in:
2025-03-21 18:15:33 +05:30
parent 6a10900f68
commit 681a3932bd
18 changed files with 744 additions and 362 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -1004,7 +1004,7 @@
"languageVersion": "3.4" "languageVersion": "3.4"
} }
], ],
"generated": "2025-03-20T12:51:19.355653Z", "generated": "2025-03-21T12:45:09.442791Z",
"generator": "pub", "generator": "pub",
"generatorVersion": "3.4.4", "generatorVersion": "3.4.4",
"flutterRoot": "file:///Users/rajeevsingh/Documents/allSoftwares/flutter", "flutterRoot": "file:///Users/rajeevsingh/Documents/allSoftwares/flutter",

File diff suppressed because one or more lines are too long

View File

@@ -12,7 +12,7 @@ class APIURL {
static const String getBestDealProduct = "${BASE_URL}products/best-deals"; static const String getBestDealProduct = "${BASE_URL}products/best-deals";
static const String getAllcategory = "${BASE_URL}categories"; static const String getAllcategory = "${BASE_URL}categories";
static const String addToWish = "${BASE_URL}carts/wishlist/items"; static const String addToWish = "${BASE_URL}carts/wishlist/items";
static const String getSubcategory = "${BASE_URL}categories/by-level/2"; static const String getSubcategory = "${BASE_URL}categories/by-level/2";
static const String deleteToWish = "${BASE_URL}carts/wishlist/items"; static const String deleteToWish = "${BASE_URL}carts/wishlist/items";
static const String addToCart = "${BASE_URL}carts/items"; static const String addToCart = "${BASE_URL}carts/items";
static const String gettAllWishList = "${BASE_URL}carts/wishlist"; static const String gettAllWishList = "${BASE_URL}carts/wishlist";
@@ -32,7 +32,8 @@ class APIURL {
static const String offerCoupon = "${BASE_URL}coupons"; static const String offerCoupon = "${BASE_URL}coupons";
static const String applyCoupon = "${BASE_URL}coupons/validate"; 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 = "${BASE_URL}auth/forgot-password-verify-otp/vendor"; static const String verifyForgetPassword =
"${BASE_URL}auth/forgot-password-verify-otp/vendor";
static const String reset_password = "${BASE_URL}auth/reset-password/vendor"; static const String reset_password = "${BASE_URL}auth/reset-password/vendor";
static const String getProduct = "${BASE_URL}products"; static const String getProduct = "${BASE_URL}products";
@@ -44,10 +45,8 @@ class APIURL {
static const String deleteProduct = "${BASE_URL}products/"; static const String deleteProduct = "${BASE_URL}products/";
static const String updateProduct = "${BASE_URL}products/"; static const String updateProduct = "${BASE_URL}products/";
static const String getAssignedOtp = "${BASE_URL}delivery/customer-otp";
static const String getAssignedOtp ="${BASE_URL}delivery/customer-otp"; static const String updateStatus = "${BASE_URL}orders/items/";
static const String checkAddress = "${BASE_URL}distance/by-address/";
static const String updateStatus = "${BASE_URL}orders/items/";
} }

View File

@@ -0,0 +1,209 @@
// import 'dart:convert';
// CheckProduct checkProductFromJson(String str) =>
// CheckProduct.fromJson(json.decode(str));
// String checkProductToJson(CheckProduct data) => json.encode(data.toJson());
// class CheckProduct {
// double? maxDistance;
// int? maxDeliveryCharges;
// List<Distance>? distances;
// // List<NonDeliverableProduct>? nonDeliverableProducts;
// bool? isDeliverable;
// CheckProduct({
// this.maxDistance,
// this.maxDeliveryCharges,
// this.distances,
// // this.nonDeliverableProducts,
// this.isDeliverable,
// });
// factory CheckProduct.fromJson(Map<String, dynamic> json) => CheckProduct(
// maxDistance: json["maxDistance"].toDouble(),
// maxDeliveryCharges: json["maxDeliveryCharges"],
// distances: List<Distance>.from(
// json["distances"].map((x) => Distance.fromJson(x))),
// // nonDeliverableProducts: List<NonDeliverableProduct>.from(
// // json["nonDeliverableProducts"]
// // .map((x) => NonDeliverableProduct.fromJson(x))),
// isDeliverable: json["isDeliverable"],
// );
// Map<String, dynamic> toJson() => {
// "maxDistance": maxDistance,
// "maxDeliveryCharges": maxDeliveryCharges,
// "distances": List<dynamic>.from(distances!.map((x) => x.toJson())),
// // "nonDeliverableProducts":
// // List<dynamic>.from(nonDeliverableProducts!.map((x) => x.toJson())),
// "isDeliverable": isDeliverable,
// };
// }
// class Distance {
// int? rank;
// String? productId;
// String? categoryId;
// double? distance;
// String? productName;
// String? productDescription;
// String? productImage;
// String? maxDeliveryCharges;
// Distance({
// this.rank,
// this.productId,
// this.categoryId,
// this.distance,
// this.productName,
// this.productDescription,
// this.productImage,
// this.maxDeliveryCharges,
// });
// factory Distance.fromJson(Map<String, dynamic> json) => Distance(
// rank: json["rank"],
// productId: json["productId"],
// categoryId: json["categoryId"],
// distance: json["distance"].toDouble(),
// productName: json["productName"],
// productDescription: json["productDescription"],
// productImage: json["productImage"],
// maxDeliveryCharges: json["maxDeliveryCharges"],
// );
// Map<String, dynamic> toJson() => {
// "rank": rank,
// "productId": productId,
// "categoryId": categoryId,
// "distance": distance,
// "productName": productName,
// "productDescription": productDescription,
// "productImage": productImage,
// "maxDeliveryCharges": maxDeliveryCharges,
// };
// }
// class NonDeliverableProduct {
// String? productId;
// String? productName;
// String? productDescription;
// String? productImage;
// double? distance;
// NonDeliverableProduct({
// this.productId,
// this.productName,
// this.productDescription,
// this.productImage,
// this.distance,
// });
// factory NonDeliverableProduct.fromJson(Map<String, dynamic> json) =>
// NonDeliverableProduct(
// productId: json["productId"],
// productName: json["productName"],
// productDescription: json["productDescription"],
// productImage: json["productImage"],
// distance: json["distance"].toDouble(),
// );
// Map<String, dynamic> toJson() => {
// "productId": productId,
// "productName": productName,
// "productDescription": productDescription,
// "productImage": productImage,
// "distance": distance,
// };
// }
// To parse this JSON data, do
//
// final checkProduct = checkProductFromJson(jsonString);
import 'dart:convert';
CheckProduct checkProductFromJson(String str) =>
CheckProduct.fromJson(json.decode(str));
String checkProductToJson(CheckProduct data) => json.encode(data.toJson());
class CheckProduct {
double? maxDistance;
int? maxDeliveryCharges;
List<Distance>? distances;
List<dynamic>? nonDeliverableProducts;
bool? isDeliverable;
CheckProduct({
this.maxDistance,
this.maxDeliveryCharges,
this.distances,
this.nonDeliverableProducts,
this.isDeliverable,
});
factory CheckProduct.fromJson(Map<String, dynamic> json) => CheckProduct(
maxDistance: json["maxDistance"].toDouble(),
maxDeliveryCharges: json["maxDeliveryCharges"],
distances: List<Distance>.from(
json["distances"].map((x) => Distance.fromJson(x))),
nonDeliverableProducts:
List<dynamic>.from(json["nonDeliverableProducts"].map((x) => x)),
isDeliverable: json["isDeliverable"],
);
Map<String, dynamic> toJson() => {
"maxDistance": maxDistance,
"maxDeliveryCharges": maxDeliveryCharges,
"distances": List<dynamic>.from(distances!.map((x) => x.toJson())),
"nonDeliverableProducts":
List<dynamic>.from(nonDeliverableProducts!.map((x) => x)),
"isDeliverable": isDeliverable,
};
}
class Distance {
int? rank;
String? productId;
String? categoryId;
double? distance;
String? productName;
String? productDescription;
String? productImage;
int? maxDeliveryCharges;
Distance({
this.rank,
this.productId,
this.categoryId,
this.distance,
this.productName,
this.productDescription,
this.productImage,
this.maxDeliveryCharges,
});
factory Distance.fromJson(Map<String, dynamic> json) => Distance(
rank: json["rank"],
productId: json["productId"],
categoryId: json["categoryId"],
distance: json["distance"].toDouble(),
productName: json["productName"],
productDescription: json["productDescription"],
productImage: json["productImage"],
maxDeliveryCharges: json["maxDeliveryCharges"],
);
Map<String, dynamic> toJson() => {
"rank": rank,
"productId": productId,
"categoryId": categoryId,
"distance": distance,
"productName": productName,
"productDescription": productDescription,
"productImage": productImage,
"maxDeliveryCharges": maxDeliveryCharges,
};
}

View File

@@ -21,7 +21,7 @@ class AddtocartProvider extends ChangeNotifier {
String get pinCode => _pinCode; String get pinCode => _pinCode;
bool get isLoading => _isLoading; bool get isLoading => _isLoading;
bool get isDeliverable => _isDeliverable;
TextEditingController checkPinCode = TextEditingController(); TextEditingController checkPinCode = TextEditingController();
Future<void> getCurrentLocation(BuildContext context) async { Future<void> getCurrentLocation(BuildContext context) async {
@@ -101,6 +101,45 @@ class AddtocartProvider extends ChangeNotifier {
} }
} }
bool get isDeliverable => _isDeliverable;
int deliveryCharge = 0;
int get getdeliverycharge => deliveryCharge;
Future<void> checkAddress(BuildContext context, addressId) async {
ischeckpin = true;
notifyListeners();
var data = {};
try {
var result = await _homeRepo.checkAddress(data, addressId);
return result.fold(
(error) {
_isDeliverable = false;
notifyListeners();
},
(response) {
print(
"sjhjkdkfhgjdfkjgdfgjdfjjkhsdfghhfjkd ${response.isDeliverable}");
if (response.isDeliverable!) {
_isDeliverable = true;
deliveryCharge = response.maxDeliveryCharges!;
}
ischeckpin = false;
notifyListeners();
},
);
} catch (e) {
_isDeliverable = false;
notifyListeners();
}
}
// checkAddress
Map<String, bool> isRemoveItem = {}; Map<String, bool> isRemoveItem = {};
Future<void> deleteItem(BuildContext context, id) async { Future<void> deleteItem(BuildContext context, id) async {
@@ -286,8 +325,7 @@ class AddtocartProvider extends ChangeNotifier {
"addressId": addressId, "addressId": addressId,
"cartId": cartId, "cartId": cartId,
}; };
} else } else {
{
data = { data = {
"amount": originalAmount, "amount": originalAmount,
"addressId": addressId, "addressId": addressId,
@@ -339,7 +377,7 @@ class AddtocartProvider extends ChangeNotifier {
Future<void> paymentCODOrder( Future<void> paymentCODOrder(
BuildContext context, BuildContext context,
double subtotal, double subtotal,
double deliverCharge, int deliverCharge,
String couponId, String couponId,
String addressId, String addressId,
) async { ) async {
@@ -425,7 +463,8 @@ class AddtocartProvider extends ChangeNotifier {
(response) { (response) {
addresslist = response.data!; addresslist = response.data!;
if (response.data!.isNotEmpty) { if (response.data!.isNotEmpty) {
_selectedAddress = addresslist.first.id ?? ""; //checkAddress(context, addresslist.first.id ?? "");
// _selectedAddress = addresslist.first.id ?? "";
_selecteUserName = addresslist.first.name ?? ""; _selecteUserName = addresslist.first.name ?? "";
_selecteUserPhone = addresslist.first.phoneNumber ?? ""; _selecteUserPhone = addresslist.first.phoneNumber ?? "";
_selecteEmail = addresslist.first.user!.email ?? ""; _selecteEmail = addresslist.first.user!.email ?? "";
@@ -443,15 +482,19 @@ class AddtocartProvider extends ChangeNotifier {
} }
} }
String _selectedAddress = "";
String _selecteUserName = ""; String _selecteUserName = "";
String _selecteUserPhone = ""; String _selecteUserPhone = "";
String _selecteEmail = ""; String _selecteEmail = "";
String _selectedAddress = "";
String get selectedAddress => _selectedAddress; String get selectedAddress => _selectedAddress;
String get selecteUserName => _selecteUserName; String get selecteUserName => _selecteUserName;
String get selecteUserPhone => _selecteUserPhone; String get selecteUserPhone => _selecteUserPhone;
String get selecteEmail => _selecteEmail; String get selecteEmail => _selecteEmail;
selectedAddressId() {
_selectedAddress = "";
notifyListeners();
}
void bydefaultSetAddress(phoneNumber, name, email) { void bydefaultSetAddress(phoneNumber, name, email) {
_selecteUserName = name; _selecteUserName = name;
_selecteUserPhone = phoneNumber; _selecteUserPhone = phoneNumber;
@@ -460,6 +503,7 @@ class AddtocartProvider extends ChangeNotifier {
} }
void selectAddress(String address, phoneNumber, name, email) { void selectAddress(String address, phoneNumber, name, email) {
print("lksdjfhgkfdghhkkfdghkjfjdgkh");
_selectedAddress = address; _selectedAddress = address;
_selecteUserName = name; _selecteUserName = name;
_selecteUserPhone = phoneNumber; _selecteUserPhone = phoneNumber;

View File

@@ -4,9 +4,8 @@ import 'package:grocery_app/src/logic/repo/product_repo.dart';
class AddressProvider extends ChangeNotifier { class AddressProvider extends ChangeNotifier {
bool ischeckpin = false; bool ischeckpin = false;
final _homeRepo = getIt<ProductRepo>();
Future<bool> checkPin(BuildContext context, pin) async { Future<bool> checkPin(BuildContext context, pin) async {
final _homeRepo = getIt<ProductRepo>();
ischeckpin = true; ischeckpin = true;
notifyListeners(); notifyListeners();
var data = {}; var data = {};
@@ -16,7 +15,7 @@ class AddressProvider extends ChangeNotifier {
return result.fold( return result.fold(
(error) { (error) {
ischeckpin = false; ischeckpin = false;
ischeckpin = false; notifyListeners();
return false; return false;
}, },
(response) { (response) {
@@ -32,14 +31,9 @@ class AddressProvider extends ChangeNotifier {
} }
} }
Future<bool> addAddress(BuildContext context, name, pincode, phone, Future<bool> addAddress(BuildContext context, name, pincode, phone,
alternatePhoneNumber, address, landmark, addresstype) async alternatePhoneNumber, address, landmark, addresstype) async {
{ ischeckpin = true;
ischeckpin = false;
final _homeRepo = getIt<ProductRepo>();
notifyListeners(); notifyListeners();
var data = { var data = {
@@ -59,6 +53,8 @@ class AddressProvider extends ChangeNotifier {
return result.fold( return result.fold(
(error) { (error) {
ischeckpin = false; ischeckpin = false;
notifyListeners();
print("poodfgccccidfuiog ${error.message}");
return false; return false;
}, },
@@ -69,12 +65,10 @@ class AddressProvider extends ChangeNotifier {
}, },
); );
} catch (e) { } catch (e) {
print("poodfgidfuiog $e");
ischeckpin = false; ischeckpin = false;
notifyListeners(); notifyListeners();
return false; return false;
} }
} }
} }

View File

@@ -29,7 +29,8 @@ class OrderProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
}, },
); );
} catch (e) { } catch (e)
{
print("sfddsfdfff $e"); print("sfddsfdfff $e");
isloading = false; isloading = false;

View File

@@ -2,6 +2,7 @@ import 'package:dio/dio.dart';
import 'package:fpdart/fpdart.dart'; import 'package:fpdart/fpdart.dart';
import 'package:grocery_app/src/core/utils/custom_dio_exception.dart'; import 'package:grocery_app/src/core/utils/custom_dio_exception.dart';
import 'package:grocery_app/src/core/utils/response_type_def.dart'; import 'package:grocery_app/src/core/utils/response_type_def.dart';
import 'package:grocery_app/src/data/check_product.dart';
import 'package:grocery_app/src/data/myOrder.dart'; import 'package:grocery_app/src/data/myOrder.dart';
import 'package:grocery_app/src/data/order_OTP.dart'; import 'package:grocery_app/src/data/order_OTP.dart';
import 'package:grocery_app/src/data/order_paymnet.dart'; import 'package:grocery_app/src/data/order_paymnet.dart';
@@ -25,6 +26,10 @@ class OrderRepo {
} }
} }
FutureResult<DeliveryOtpmodel> getAssignedOtp(data) async { FutureResult<DeliveryOtpmodel> getAssignedOtp(data) async {
try { try {
var response = await _orderService.getAssignedOtp(data); var response = await _orderService.getAssignedOtp(data);

View File

@@ -14,6 +14,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/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/check_product.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_model.dart';
import 'package:grocery_app/src/data/coupon_response.dart'; import 'package:grocery_app/src/data/coupon_response.dart';
@@ -310,6 +311,24 @@ class ProductRepo {
} }
} }
FutureResult<CheckProduct> checkAddress(data, id) async {
try {
var response = await _productService.checkAddress(data, id);
print("kjlkjcjgklkjdhgfgkjfkdjghkjf $response");
CheckProduct productCategory = checkProductFromJson(response.toString());
print("kjxfgklhdfkgjkjdfg $productCategory");
return right(productCategory);
} on DioException catch (e) {
print("lkjxhdfgkfglkhkjfgh $e");
var error = CustomDioExceptions.handleError(e);
return left(error);
}
}
FutureResult<String> deleteItem(data, id) async { FutureResult<String> deleteItem(data, id) async {
try { try {
var response = await _productService.deleteItem(data, id); var response = await _productService.deleteItem(data, id);

View File

@@ -114,6 +114,12 @@ Future getCategoryByLevel(data) async {
return response; return response;
} }
Future checkAddress(data, id) async {
var response =
await api.get(APIURL.checkAddress + id, data: jsonEncode(data));
return response;
}
Future deleteItem(data, id) async { Future deleteItem(data, id) async {
var response = var response =
await api.delete(APIURL.deleteItem + id, data: jsonEncode(data)); await api.delete(APIURL.deleteItem + id, data: jsonEncode(data));

View File

@@ -14,6 +14,13 @@ class OrderService extends ApiService
} }
Future getAssignedOtp(data) async { Future getAssignedOtp(data) async {
var response = await api.get(APIURL.getAssignedOtp, var response = await api.get(APIURL.getAssignedOtp,
data: jsonEncode(data), queryParameters: data); data: jsonEncode(data), queryParameters: data);

View File

@@ -9,7 +9,7 @@ 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; int deliveryCharge;
// String currency; // String currency;
double originalAmount; double originalAmount;
// String name; // String name;
@@ -19,13 +19,12 @@ class CardCheckoutScreen extends StatefulWidget {
String cartId; String cartId;
String addressId; String addressId;
// String remarks; // String remarks;
double deliverCharge;
String? couponId; String? couponId;
CardCheckoutScreen( CardCheckoutScreen(
{super.key, {super.key,
// required this.amount, required this.deliveryCharge,
// required this.currency, // required this.currency,
required this.originalAmount, required this.originalAmount,
// required this.name, // required this.name,
@@ -35,7 +34,7 @@ class CardCheckoutScreen extends StatefulWidget {
required this.cartId, required this.cartId,
required this.addressId, required this.addressId,
// required this.remarks, // required this.remarks,
required this.deliverCharge,
this.couponId}); this.couponId});
@override @override
@@ -90,7 +89,7 @@ class _CardCheckoutScreenState extends State<CardCheckoutScreen> {
print("dsjfkhkdfhgdkfghdfg"); print("dsjfkhkdfhgdkfghdfg");
paymentProvider.orderPaymnet( paymentProvider.orderPaymnet(
context, context,
widget.originalAmount, widget.originalAmount + widget.deliveryCharge,
widget.cartId, widget.cartId,
widget.addressId, widget.addressId,
widget.couponId!); widget.couponId!);
@@ -98,7 +97,7 @@ class _CardCheckoutScreenState extends State<CardCheckoutScreen> {
paymentProvider.paymentCODOrder( paymentProvider.paymentCODOrder(
context, context,
widget.originalAmount, widget.originalAmount,
widget.deliverCharge, widget.deliveryCharge,
widget.couponId!, widget.couponId!,
widget.addressId, widget.addressId,
); );
@@ -133,18 +132,47 @@ class _CardCheckoutScreenState extends State<CardCheckoutScreen> {
child: SingleChildScrollView(child: Consumer<AddtocartProvider>( child: SingleChildScrollView(child: Consumer<AddtocartProvider>(
builder: (context, paymentProvider, child) { builder: (context, paymentProvider, child) {
return Container( return Container(
padding: EdgeInsets.all(16), padding: EdgeInsets.all(0),
height: 250, // height: 250,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row(
children: [
Text("Delivery Charge "),
Spacer(),
Text("${widget.deliveryCharge}",
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold))
],
),
Row(
children: [
Text("Product Amount "),
Spacer(),
Text("${widget.originalAmount}",
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold))
],
),
Divider(),
Row(
children: [
Text("Total Amount "),
Spacer(),
Text("${widget.originalAmount + widget.deliveryCharge}",
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold))
],
),
SizedBox(height: 30),
Text( Text(
"Select Payment Method", "Select Payment Method",
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
), ),
SizedBox(height: 20), SizedBox(height: 0),
// Online Payment Option
ListTile( ListTile(
leading: Icon(Icons.payment, color: Colors.blue), leading: Icon(Icons.payment, color: Colors.blue),
title: Text("Online Payment"), title: Text("Online Payment"),

View File

@@ -819,27 +819,28 @@ class _MycartState extends State<Mycart> {
label: 'Grand Total', label: 'Grand Total',
value: '${provider.grandPrice}', value: '${provider.grandPrice}',
isBold: true), isBold: true),
ListTile( // ListTile(
leading: Container( // leading: Container(
decoration: BoxDecoration( // decoration: BoxDecoration(
color: Colors.lightGreen.withOpacity(0.2), // color: Colors.lightGreen.withOpacity(0.2),
borderRadius: BorderRadius.all(Radius.circular(8))), // borderRadius: BorderRadius.all(Radius.circular(8))),
child: Padding( // child: Padding(
padding: const EdgeInsets.all(5.0), // padding: const EdgeInsets.all(5.0),
child: Icon(Icons.home_outlined, // child: Icon(Icons.home_outlined,
size: 15, color: Colors.green), // size: 15, color: Colors.green),
)), // )),
title: provider.isDeliverable // title: provider.isDeliverable
? Text('Delivering to : ${provider.pinCode}') // ? Text('Delivering to : ${provider.pinCode}')
: Text( // : Text(
'Out Of Stock ${provider.pinCode}', // 'Out Of Stock ${provider.pinCode}',
style: TextStyle(color: Colors.red), // style: TextStyle(color: Colors.red),
), // ),
trailing: Text('Change', style: TextStyle(color: Colors.green)), // trailing: Text('Change', style: TextStyle(color: Colors.green)),
onTap: () { // onTap: ()
_showBottomSheet(context); // {
}, // _showBottomSheet(context);
), // },
// ),
SizedBox(height: 10), SizedBox(height: 10),
Padding( Padding(
padding: EdgeInsets.only(left: 20, right: 20), padding: EdgeInsets.only(left: 20, right: 20),
@@ -858,19 +859,22 @@ class _MycartState extends State<Mycart> {
width: 1, height: 30, color: APPCOLOR.whiteFBFEFB), width: 1, height: 30, color: APPCOLOR.whiteFBFEFB),
InkWell( InkWell(
onTap: () { onTap: () {
if (provider.isDeliverable) { // if (provider.isDeliverable)
_showAddressBottomSheet(context); // {
} else { provider.selectedAddressId();
Fluttertoast.showToast( _showAddressBottomSheet(context);
msg: // }
"Delivery is not available for this pincode. Please try another pincode!", // else {
toastLength: Toast.LENGTH_SHORT, // Fluttertoast.showToast(
gravity: ToastGravity.BOTTOM, // msg:
backgroundColor: Colors.red, // "Delivery is not available for this pincode. Please try another pincode!",
textColor: Colors.white, // toastLength: Toast.LENGTH_SHORT,
fontSize: 14.0, // gravity: ToastGravity.BOTTOM,
); // backgroundColor: Colors.red,
} // textColor: Colors.white,
// fontSize: 14.0,
// );
// }
}, },
child: Row( child: Row(
children: [ children: [
@@ -1190,27 +1194,38 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
return ElevatedButton.icon( return ElevatedButton.icon(
onPressed: () { onPressed: () {
if (paymentProvider.selectedAddress.isNotEmpty) { if (paymentProvider.selectedAddress.isNotEmpty) {
Navigator.pop(context); if (paymentProvider.isDeliverable) {
Navigator.of(context).push(MaterialPageRoute( Navigator.pop(context);
builder: (context) { Navigator.of(context).push(MaterialPageRoute(
return CardCheckoutScreen( builder: (context) {
// amount: double.parse( return CardCheckoutScreen(
// paymentProvider.allitem.subtotal.toString()), deliveryCharge: paymentProvider.getdeliverycharge,
// currency: "INR", // currency: "INR",
originalAmount: paymentProvider.grandPrice, originalAmount: paymentProvider.grandPrice,
// 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,
couponId: paymentProvider.couponId, couponId: paymentProvider.couponId,
); );
}, },
)); ));
} else {
Fluttertoast.showToast(
msg:
"Delivery is not available for this address, Please change another address",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 14.0,
);
}
} else { } else {
Fluttertoast.showToast( Fluttertoast.showToast(
msg: "Please add a delivery address", msg: "Please add a delivery address",
@@ -1227,7 +1242,9 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
style: TextStyle(color: Colors.white, fontSize: 16), style: TextStyle(color: Colors.white, fontSize: 16),
), ),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: Colors.green, backgroundColor: paymentProvider.isDeliverable
? Colors.green
: Colors.grey,
minimumSize: Size(double.infinity, 50), minimumSize: Size(double.infinity, 50),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)), borderRadius: BorderRadius.circular(10)),
@@ -1251,6 +1268,9 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
itemCount: addressProvider.addresslist.length, itemCount: addressProvider.addresslist.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
if (addressProvider.selectedAddress.isEmpty) {
print("ldjkfhsgkhdfkgkfjgdfjk ");
}
var address = addressProvider.addresslist[index]; var address = addressProvider.addresslist[index];
return Card( return Card(
@@ -1263,6 +1283,8 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
groupValue: addressProvider.selectedAddress, groupValue: addressProvider.selectedAddress,
activeColor: Colors.green, activeColor: Colors.green,
onChanged: (value) { onChanged: (value) {
addressProvider.checkAddress(context, value);
addressProvider.selectAddress( addressProvider.selectAddress(
value.toString(), value.toString(),
address.phoneNumber, address.phoneNumber,

View File

@@ -85,9 +85,7 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
), ),
), ),
actions: [ actions: [],
],
), ),
body: Padding( body: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
@@ -458,7 +456,6 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
return discountPercentage.round(); return discountPercentage.round();
} }
Widget filterCategory() { Widget filterCategory() {
final activeIndexProvider = Provider.of<ProductProvider>(context); final activeIndexProvider = Provider.of<ProductProvider>(context);
@@ -494,8 +491,6 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
itemBuilder: (context, index) { itemBuilder: (context, index) {
var category = categories[index]; var category = categories[index];
return Padding( return Padding(
padding: const EdgeInsets.only(bottom: 8), padding: const EdgeInsets.only(bottom: 8),
child: InkWell( child: InkWell(
@@ -528,8 +523,8 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
child: SizedBox( child: SizedBox(
// height: 80, // height: 80,
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
if (category.name == "ALL") ...{ if (category.name == "ALL") ...{
if (provider.categoriesss.isNotEmpty) if (provider.categoriesss.isNotEmpty)
@@ -564,33 +559,17 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
), ),
) )
.toList(), .toList(),
child: Padding( child: Center(
padding: const EdgeInsets.symmetric( child: Container(
vertical: 10, child: AppNetworkImage(
horizontal: 10, height: 50,
), width: 60,
child: Row( imageUrl: provider
mainAxisAlignment: .selectedCategory?.image ??
MainAxisAlignment.spaceBetween, 'https://i.pinimg.com/originals/a5/f3/5f/a5f35fb23e942809da3df91b23718e8d.png',
children: [ backGroundColor: APPCOLOR.bgGrey,
SizedBox( radius: 10,
width: 20, ),
child: Text(
provider.selectedCategory?.name ??
"All",
maxLines: 1,
style: context.customMedium(
APPCOLOR.balck1A1A1A,
12,
),
),
),
Icon(
Icons.arrow_drop_down,
size: 20,
color: APPCOLOR.balck1A1A1A,
),
],
), ),
), ),
), ),
@@ -600,7 +579,7 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
Center( Center(
child: Container( child: Container(
child: AppNetworkImage( child: AppNetworkImage(
height: 30, height: 50,
width: 50, width: 50,
imageUrl: category.image ?? imageUrl: category.image ??
'https://i.pinimg.com/originals/a5/f3/5f/a5f35fb23e942809da3df91b23718e8d.png', 'https://i.pinimg.com/originals/a5/f3/5f/a5f35fb23e942809da3df91b23718e8d.png',
@@ -630,16 +609,16 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
], ],
), ),
}, },
SizedBox( // SizedBox(
width: 5, // width: 5,
), // ),
Container( // Container(
width: 2, // width: 2,
// height: 60, // height: 0,
color: activeIndexProvider.activeIndex == index // color: activeIndexProvider.activeIndex == index
? APPCOLOR.lightGreen // ? APPCOLOR.lightGreen
: Colors.transparent, // : Colors.transparent,
), // ),
], ],
), ),
), ),

View File

@@ -120,9 +120,6 @@ class _AddLocationAddressState extends State<AddLocationAddress> {
} }
} }
void _onMapTapped(LatLng tappedPoint) { void _onMapTapped(LatLng tappedPoint) {
setState(() { setState(() {
_selectedLocation = tappedPoint; _selectedLocation = tappedPoint;
@@ -335,8 +332,7 @@ class _AddLocationAddressState extends State<AddLocationAddress> {
SizedBox(height: 10), SizedBox(height: 10),
Consumer<AddressProvider>( Consumer<AddressProvider>(
builder: (context, addressProvider, child) builder: (context, addressProvider, child) {
{
return InkWell( return InkWell(
onTap: () async { onTap: () async {
if (_formKey.currentState!.validate()) { if (_formKey.currentState!.validate()) {
@@ -354,7 +350,8 @@ class _AddLocationAddressState extends State<AddLocationAddress> {
_RoadController.text, _RoadController.text,
_addressTypeController.text); _addressTypeController.text);
if (state) { if (state) {
context .read<AddtocartProvider>() context
.read<AddtocartProvider>()
.getAddress(context); .getAddress(context);
Fluttertoast.showToast( Fluttertoast.showToast(
msg: "Address Added!", msg: "Address Added!",

View File

@@ -9,9 +9,9 @@ import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class OrderDetailsScreen extends StatefulWidget { class OrderDetailsScreen extends StatefulWidget {
final Datum order; Datum order;
const OrderDetailsScreen({Key? key, required this.order}) : super(key: key); OrderDetailsScreen({Key? key, required this.order}) : super(key: key);
@override @override
_OrderDetailsScreenState createState() => _OrderDetailsScreenState(); _OrderDetailsScreenState createState() => _OrderDetailsScreenState();
@@ -30,48 +30,74 @@ class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
return formattedDateTime; return formattedDateTime;
} }
Future<void> _refresh() async {
Provider.of<OrderProvider>(context, listen: false).getMyOrder(context);
await Future.delayed(Duration(seconds: 1));
setState(() {
_fetchOrderDetails();
});
}
Future<void> _fetchOrderDetails() async {
// Get the updated order from Provider
final homeProvider = Provider.of<OrderProvider>(context, listen: false);
widget.order = homeProvider.orderList.firstWhere(
(o) => o.id == widget.order.id,
orElse: () => widget.order,
);
print("kdjhkjfh ${widget.order}");
setState(() {});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: Text('Order Details')), appBar: AppBar(title: Text('Order Details')),
body: Padding( body: RefreshIndicator(
padding: const EdgeInsets.all(2.0), onRefresh: _refresh,
child: Column( child: Padding(
crossAxisAlignment: CrossAxisAlignment.start, padding: const EdgeInsets.all(2.0),
children: [ child: Column(
Container( crossAxisAlignment: CrossAxisAlignment.start,
width: MediaQuery.of(context).size.width, children: [
child: Padding( Container(
padding: const EdgeInsets.all(16.0), width: MediaQuery.of(context).size.width,
child: Column( child: Padding(
crossAxisAlignment: CrossAxisAlignment.start, padding: const EdgeInsets.all(16.0),
children: [ child: Column(
Text(widget.order.orderNumber, crossAxisAlignment: CrossAxisAlignment.start,
style: TextStyle( children: [
fontSize: 16, fontWeight: FontWeight.bold)), Text(widget.order.orderNumber,
SizedBox(height: 5), style: TextStyle(
Text(widget.order.deliveryAddress!.addressLine ?? " ", fontSize: 16, fontWeight: FontWeight.bold)),
style: TextStyle( SizedBox(height: 5),
fontSize: 16, fontWeight: FontWeight.bold)), Text(widget.order.deliveryAddress!.addressLine ?? " ",
SizedBox(height: 5), style: TextStyle(
Text(convertUtcToIst(widget.order.createdAt.toString())), fontSize: 16, fontWeight: FontWeight.bold)),
SizedBox(height: 5), SizedBox(height: 5),
// Text( Text(
// "Status: ${_getStatusText(widget.order.orderStatus)}", convertUtcToIst(widget.order.createdAt.toString())),
// style: TextStyle( SizedBox(height: 5),
// color: Colors.blue, fontWeight: FontWeight.bold), // Text(
// ), // "Status: ${_getStatusText(widget.order.orderStatus)}",
// _itemsList(), // style: TextStyle(
], // color: Colors.blue, fontWeight: FontWeight.bold),
// ),
// _itemsList(),
],
),
),
), ),
), _itemsList(),
SizedBox(height: 20),
],
), ),
_itemsList(), ),
SizedBox(height: 20), ));
],
),
),
);
} }
/// Order Information /// Order Information
@@ -200,6 +226,8 @@ class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
itemBuilder: (context, index) { itemBuilder: (context, index) {
// final item = items[index]; // final item = items[index];
var orderitem = widget.order.orderItems![index]; var orderitem = widget.order.orderItems![index];
print("ckgjhkfghlfg ${orderitem.orderItemStatus}");
return Card( return Card(
margin: EdgeInsets.symmetric(vertical: 2), margin: EdgeInsets.symmetric(vertical: 2),
child: Column( child: Column(
@@ -231,7 +259,8 @@ class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
), ),
), ),
Gap(5), Gap(5),
if (orderitem.orderItemStatus != "PENDING") if (orderitem.orderItemStatus != "PENDING" &&
orderitem.orderItemStatus != "CANCELLED")
RichText( RichText(
text: TextSpan( text: TextSpan(
text: " ", text: " ",
@@ -255,6 +284,26 @@ class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
], ],
), ),
), ),
if (orderitem.orderItemStatus == "DELIVERED")
RichText(
text: TextSpan(
text: " ",
style: context.buttonTestStyle.copyWith(
color: context.appColor.blackColor,
),
children: [
TextSpan(
text: "Give Feedback",
style: context.buttonTestStyle.copyWith(
color: Colors.blue,
decoration: TextDecoration.underline,
),
recognizer: TapGestureRecognizer()
..onTap = () {},
),
],
),
),
], ],
), ),
), ),

View File

@@ -25,7 +25,8 @@ class _MyOrderScreenState extends State<MyOrderScreen> {
super.initState(); super.initState();
} }
String convertUtcToIst(String utcTime) { String convertUtcToIst(String utcTime)
{
DateTime utcDateTime = DateTime.parse(utcTime).toUtc(); DateTime utcDateTime = DateTime.parse(utcTime).toUtc();
DateTime istDateTime = DateTime istDateTime =
@@ -37,197 +38,219 @@ class _MyOrderScreenState extends State<MyOrderScreen> {
return formattedDateTime; return formattedDateTime;
} }
Future<void> _refresh() async {
await Future.delayed(Duration(seconds: 1));
setState(() {
Provider.of<OrderProvider>(context, listen: false).getMyOrder(context);
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
backgroundColor: Colors.white, backgroundColor: Colors.white,
centerTitle: true, centerTitle: true,
leading: Center( leading: Center(
child: SizedBox( child: SizedBox(
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,
height: 20, height: 20,
width: 20, width: 20,
)), )),
),
),
title: const Text(
"My Order",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
),
), ),
), ),
title: const Text( body: RefreshIndicator(
"My Order", onRefresh: _refresh,
style: TextStyle( child:
fontSize: 20, Consumer<OrderProvider>(builder: (context, orderProvider, child) {
fontWeight: FontWeight.w700, if (orderProvider.isloading) {
), return Center(child: CircularProgressIndicator());
), }
),
body: Consumer<OrderProvider>(builder: (context, orderProvider, child) {
if (orderProvider.isloading) {
return Center(child: CircularProgressIndicator());
}
if (orderProvider.orderList.isEmpty) { if (orderProvider.orderList.isEmpty) {
return Center( return Center(
child: DataNotFound( child: DataNotFound(
imagePath: 'assets/images/wishlist.jpg', imagePath: 'assets/images/wishlist.jpg',
message: "No Order Available! ", message: "No Order Available! ",
// width: 200.w, // width: 200.w,
// height: 200.h, // height: 200.h,
)); ));
} }
return Column( return Column(
children: [ children: [
Expanded( Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: orderProvider.orderList.length, itemCount: orderProvider.orderList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
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,
//context.push(MyRoutes.ORDERDETAILS); extra: order);
}, //context.push(MyRoutes.ORDERDETAILS);
child: Card( },
margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8), child: Card(
child: Padding( margin:
padding: const EdgeInsets.all(16.0), EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Column( child: Padding(
crossAxisAlignment: CrossAxisAlignment.start, padding: const EdgeInsets.all(16.0),
children: [ child: Column(
Row( crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Center( Row(
child: Container( children: [
width: 50, Center(
height: 50, child: Container(
decoration: BoxDecoration( width: 50,
color: APPCOLOR.bgGrey, height: 50,
borderRadius: BorderRadius.circular(15), 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: 48,
imageUrl: order.orderItems!.first
.productImage,
backGroundColor:
Colors.transparent,
),
],
),
),
), ),
child: Stack( SizedBox(width: 5),
alignment: Alignment.center, Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [ children: [
AppNetworkImage( Text(order.orderNumber,
height: MediaQuery.of(context) style: TextStyle(
.size fontWeight: FontWeight.bold)),
.height * Text(order.paymentStatus ?? "",
0.08, style:
width: 48, TextStyle(color: Colors.grey)),
imageUrl: order Text(
.orderItems!.first.productImage, order.totalItems.toString() +
backGroundColor: Colors.transparent, " items",
style:
TextStyle(color: Colors.grey)),
],
),
Spacer(),
// Container(
// padding: EdgeInsets.symmetric(
// horizontal: 5, vertical: 5),
// decoration: BoxDecoration(
// color: Colors.green.shade100,
// borderRadius: BorderRadius.circular(10),
// ),
// child: Text(order.orderStatus,
// style: TextStyle(color: Colors.green)),
// ),
],
),
SizedBox(height: 10),
Text(
convertUtcToIst(order.updatedAt.toString()),
style: TextStyle(color: Colors.grey)),
SizedBox(height: 5),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text("\$" + order.finalTotal,
style: TextStyle(
fontWeight: FontWeight.bold)),
Row(
children: [
// ElevatedButton(
// onPressed: () {},
// style: ElevatedButton.styleFrom(
// backgroundColor: Colors.white,
// side: BorderSide(color: Colors.green),
// shape: RoundedRectangleBorder(
// borderRadius:
// BorderRadius.circular(10),
// ),
// ),
// child: Row(
// children: [
// // Icon(Icons.message,
// // color: Colors.green),
// // SizedBox(width: 5),
// // Text('Message',
// // style: TextStyle(
// // color: Colors.green)),
// ],
// ),
// ),
SizedBox(width: 10),
ElevatedButton(
onPressed: () {
print("lkdhgkjdfgj");
_makePhoneCall(order
.stores!.first.vendor!.phone);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10),
),
),
child: Row(
children: [
Icon(Icons.call,
color: Colors.white),
SizedBox(width: 5),
Text('Call',
style: TextStyle(
color: Colors.white)),
],
),
), ),
], ],
), ),
),
),
SizedBox(width: 5),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(order.orderNumber,
style: TextStyle(
fontWeight: FontWeight.bold)),
Text(order.paymentStatus ?? "",
style: TextStyle(color: Colors.grey)),
Text(order.totalItems.toString() + " items",
style: TextStyle(color: Colors.grey)),
],
),
Spacer(),
// Container(
// padding: EdgeInsets.symmetric(
// horizontal: 5, vertical: 5),
// decoration: BoxDecoration(
// color: Colors.green.shade100,
// borderRadius: BorderRadius.circular(10),
// ),
// child: Text(order.orderStatus,
// style: TextStyle(color: Colors.green)),
// ),
],
),
SizedBox(height: 10),
Text(convertUtcToIst(order.updatedAt.toString()),
style: TextStyle(color: Colors.grey)),
SizedBox(height: 5),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("\$" + order.finalTotal,
style:
TextStyle(fontWeight: FontWeight.bold)),
Row(
children: [
// ElevatedButton(
// onPressed: () {},
// style: ElevatedButton.styleFrom(
// backgroundColor: Colors.white,
// side: BorderSide(color: Colors.green),
// shape: RoundedRectangleBorder(
// borderRadius:
// BorderRadius.circular(10),
// ),
// ),
// child: Row(
// children: [
// // Icon(Icons.message,
// // color: Colors.green),
// // SizedBox(width: 5),
// // Text('Message',
// // style: TextStyle(
// // color: Colors.green)),
// ],
// ),
// ),
SizedBox(width: 10),
ElevatedButton(
onPressed: () {
print("lkdhgkjdfgj");
_makePhoneCall(
order.stores!.first.vendor!.phone);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10),
),
),
child: Row(
children: [
Icon(Icons.call, color: Colors.white),
SizedBox(width: 5),
Text('Call',
style: TextStyle(
color: Colors.white)),
],
),
),
], ],
), ),
], ],
), ),
], ),
), ),
), );
), },
); ),
}, ),
), ],
), );
], }),
); ));
}),
);
} }
Future<void> _makePhoneCall(String number) async { Future<void> _makePhoneCall(String number) async {