1)get all Place Order api integration done
2) single Place order api integration done 3) Refresh inidicator added 4)Caps Functionality added
This commit is contained in:
parent
e1d96ee34e
commit
174d7afa99
@ -1,40 +1,63 @@
|
||||
import 'package:cheminova/controller/get_place_order_service.dart';
|
||||
import 'package:cheminova/controller/product_service.dart';
|
||||
import 'package:cheminova/models/oder_place_model.dart';
|
||||
import 'package:cheminova/models/product_model1.dart';
|
||||
import 'package:cheminova/controller/get_single_placed_order_service.dart';
|
||||
import 'package:cheminova/controller/place_order_controller.dart';
|
||||
import 'package:cheminova/models/place_order_list_model.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../models/oder_place_model.dart';
|
||||
import '../models/product_model1.dart';
|
||||
import '../utils/log_service.dart';
|
||||
import 'get_place_order_service.dart';
|
||||
|
||||
class GetPlacedOrderController extends GetxController {
|
||||
final GetOrderPlacedServcie _getOrderPlacedServcie = GetOrderPlacedServcie();
|
||||
var products = <PlacedOrderModel>[].obs;
|
||||
final GetOrderPlacedService _getOrderPlacedService = GetOrderPlacedService();
|
||||
final OrderPlacedController _orderPlacedController = Get.put(OrderPlacedController());
|
||||
final GetSingleOrderPlacedService _getSingleOrderPlacedService = GetSingleOrderPlacedService();
|
||||
var placedOrders = <PlacedOrderList>[].obs;
|
||||
var products = <Product>[].obs;
|
||||
|
||||
int _currentPage = 1;
|
||||
bool isLoading = false;
|
||||
var isLoading = false.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
getOrders(); // Fetch the orders immediately on initialization
|
||||
}
|
||||
|
||||
Future<void> getOrder(String id) async {
|
||||
if (isLoading) return;
|
||||
isLoading = true;
|
||||
Future<void> getOrders() async {
|
||||
|
||||
final fetchedOrders = await _getOrderPlacedService.getPlacedOrders();
|
||||
|
||||
if (fetchedOrders != null && fetchedOrders.isNotEmpty) {
|
||||
placedOrders.addAll(fetchedOrders);
|
||||
//logger.w("Fetched orders: $fetchedOrders");
|
||||
|
||||
} else {
|
||||
//logger.w("No orders fetched");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> searchOrder() async {
|
||||
try {
|
||||
|
||||
final fetchedProducts = await _getOrderPlacedServcie.getPlacedOrder();
|
||||
|
||||
|
||||
if (fetchedProducts != null) {
|
||||
|
||||
products.addAll(fetchedProducts);
|
||||
isLoading.value = true;
|
||||
final order = await _getSingleOrderPlacedService.getSinglePlacedOrder(placedOrders[0].id);
|
||||
if (order != null) {
|
||||
placedOrders.clear(); // Clear existing orders if needed
|
||||
placedOrders.add(order);
|
||||
} else {
|
||||
// Handle order not found case
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error fetching products: $e");
|
||||
// Handle exceptions
|
||||
} finally {
|
||||
isLoading = false;
|
||||
update();
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Optional: Reset the pagination if needed
|
||||
void resetPagination() {
|
||||
_getOrderPlacedService.resetPagination();
|
||||
placedOrders.clear(); // Clear existing data
|
||||
getOrders(); // Fetch fresh data
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +1,122 @@
|
||||
import 'package:cheminova/models/oder_place_model.dart';
|
||||
|
||||
import 'package:cheminova/models/place_order_list_model.dart';
|
||||
import '../models/oder_place_model.dart';
|
||||
import '../utils/common_api_service.dart';
|
||||
import '../utils/show_snackbar.dart';
|
||||
|
||||
class GetOrderPlacedServcie{
|
||||
Future<List<PlacedOrderModel>?> getPlacedOrder() async {
|
||||
class GetOrderPlacedService {
|
||||
int _currentPage = 1; // Initialize with the first page
|
||||
//int _limit = 100; // Start with a fixed limit, can be adjusted
|
||||
final List<PlacedOrderList> _allOrders = []; // To store all fetched orders
|
||||
bool _hasMoreOrders = true; // To check if there are more orders to fetch
|
||||
|
||||
Future<List<PlacedOrderList>?> getPlacedOrders() async {
|
||||
try {
|
||||
String url;
|
||||
while (_hasMoreOrders) {
|
||||
// Construct the API URL with pagination parameters
|
||||
String url = "/api/get-placed-order-pd?page=$_currentPage";
|
||||
|
||||
url = "/api/get-placed-order-pd?id=66cc7869f02b935094127a27";
|
||||
|
||||
final response = await commonApiService<List<PlacedOrderModel>>(
|
||||
final response = await commonApiService<List<PlacedOrderList>>(
|
||||
method: "GET",
|
||||
url: url,
|
||||
fromJson: (json) {
|
||||
if (json['plcaedOrders'] != null) {
|
||||
final List<PlacedOrderModel> products = (json['plcaedOrders'] as List)
|
||||
.map((productJson) => PlacedOrderModel.fromJson(productJson as Map<String, dynamic>))
|
||||
final List<PlacedOrderList> orders = (json['plcaedOrders'] as List)
|
||||
.map((orderJson) => PlacedOrderList.fromJson(orderJson as Map<String, dynamic>))
|
||||
.toList();
|
||||
return products;
|
||||
|
||||
if (orders.isNotEmpty) {
|
||||
_allOrders.addAll(orders);
|
||||
_currentPage++;
|
||||
// _limit += orders.length; // Adjust limit based on the number of fetched orders
|
||||
} else {
|
||||
_hasMoreOrders = false; // Stop fetching if no more orders are returned
|
||||
}
|
||||
|
||||
return orders;
|
||||
} else {
|
||||
_hasMoreOrders = false; // Stop if there are no orders at all
|
||||
return [];
|
||||
}
|
||||
},
|
||||
);
|
||||
return response;
|
||||
|
||||
if (response == null || response.isEmpty) {
|
||||
_hasMoreOrders = false; // Stop fetching if the response is empty
|
||||
}
|
||||
}
|
||||
|
||||
return _allOrders;
|
||||
} catch (e) {
|
||||
showSnackbar(e.toString());
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Optional: Reset the pagination and orders when needed
|
||||
void resetPagination() {
|
||||
_currentPage = 1;
|
||||
//_limit = 100; // Reset the limit to the initial value
|
||||
_allOrders.clear(); // Clear the list of orders
|
||||
_hasMoreOrders = true; // Reset the flag to allow fetching again
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// import 'package:cheminova/models/place_order_list_model.dart';
|
||||
//
|
||||
// import '../models/oder_place_model.dart';
|
||||
// import '../utils/common_api_service.dart';
|
||||
// import '../utils/show_snackbar.dart';
|
||||
//
|
||||
// class GetOrderPlacedService {
|
||||
// int _currentPage = 1; // Initialize with the first page
|
||||
// int _limit = 10; // Fixed limit, you can change this as needed
|
||||
// final List<PlacedOrderList> _allOrders = [];
|
||||
// int? totalOrders ;
|
||||
// Future<List<PlacedOrderList>?> getPlacedOrders() async {
|
||||
// try {
|
||||
// // Construct the API URL with pagination parameters
|
||||
// String url = "/api/get-placed-order-pd?page=$_currentPage&limit=$_limit";
|
||||
//
|
||||
// final response = await commonApiService<List<PlacedOrderList>>(
|
||||
// method: "GET",
|
||||
// url: url,
|
||||
// fromJson: (json) {
|
||||
// if (json['plcaedOrders'] != null) {
|
||||
// final List<PlacedOrderList> orders = (json['plcaedOrders'] as List)
|
||||
// .map((orderJson) => PlacedOrderList.fromJson(orderJson as Map<String, dynamic>))
|
||||
// .toList();
|
||||
// // Automatically increase the page number for the next request
|
||||
// if (orders.isNotEmpty) {
|
||||
// _currentPage++;
|
||||
// _limit+= orders.length;
|
||||
//
|
||||
// }
|
||||
// return orders;
|
||||
// } else {
|
||||
// return [];
|
||||
// }
|
||||
// },
|
||||
// );
|
||||
//
|
||||
// return response;
|
||||
// } catch (e) {
|
||||
// showSnackbar(e.toString());
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Optional: Reset the pagination when needed
|
||||
// void resetPagination() {
|
||||
// _currentPage = 1;
|
||||
// _limit = 100;
|
||||
// }
|
||||
// }
|
||||
|
30
lib/controller/get_single_placed_order_service.dart
Normal file
30
lib/controller/get_single_placed_order_service.dart
Normal file
@ -0,0 +1,30 @@
|
||||
import 'package:cheminova/models/place_order_list_model.dart'; // Import your model
|
||||
import '../utils/common_api_service.dart';
|
||||
import '../utils/show_snackbar.dart';
|
||||
|
||||
class GetSingleOrderPlacedService {
|
||||
Future<PlacedOrderList?> getSinglePlacedOrder(String orderId) async {
|
||||
try {
|
||||
// Construct the API URL for the single placed order
|
||||
String url = "/api/get-single-placed-order-pd/$orderId";
|
||||
|
||||
final response = await commonApiService<PlacedOrderList>(
|
||||
method: "GET",
|
||||
url: url,
|
||||
fromJson: (json) {
|
||||
if (json['singleOrder'] != null) {
|
||||
// Convert the JSON response to a PlacedOrderList model
|
||||
return PlacedOrderList.fromJson(json['singleOrder'] as Map<String, dynamic>);
|
||||
} else {
|
||||
throw Exception("Order not found"); // Throw an exception if not found
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return response;
|
||||
} catch (e) {
|
||||
showSnackbar(e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -12,9 +12,9 @@ class OrderPlacedService {
|
||||
|
||||
Future<void> placeOrder(PlacedOrderModel orderDetails, String token) async {
|
||||
//try {
|
||||
logger.w("orderjson ${jsonEncode(orderDetails.toJson())}");
|
||||
// logger.w("orderjson ${jsonEncode(orderDetails.toJson())}");
|
||||
final response = await dio.post(
|
||||
'https://cheminova-api-2.onrender.com/api/order-place', // Ensure this is your correct endpoint
|
||||
'https://api.cnapp.co.in/api/order-place', // Ensure this is your correct endpoint
|
||||
data: jsonEncode(orderDetails.toJson()),
|
||||
options: Options(
|
||||
headers: {
|
||||
@ -23,7 +23,7 @@ class OrderPlacedService {
|
||||
},
|
||||
),
|
||||
);
|
||||
logger.w("Status code,${response.statusCode}");
|
||||
//logger.w("Status code,${response.statusCode}");
|
||||
if (response.statusCode != 201) {
|
||||
|
||||
throw Exception('Failed to place order');
|
||||
|
@ -139,45 +139,3 @@ class OrderItem {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// class Brand {
|
||||
// String id;
|
||||
// String brandName;
|
||||
//
|
||||
// Brand({
|
||||
// required this.id,
|
||||
// required this.brandName,
|
||||
// });
|
||||
//
|
||||
// factory Brand.fromJson(Map<String, dynamic> json) => Brand(
|
||||
// id: json["_id"],
|
||||
// brandName: json["brandName"],
|
||||
// );
|
||||
//
|
||||
// Map<String, dynamic> toJson() => {
|
||||
// "_id": id,
|
||||
// "brandName": brandName,
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// class Category {
|
||||
// String id;
|
||||
// String categoryName;
|
||||
//
|
||||
// Category({
|
||||
// required this.id,
|
||||
// required this.categoryName,
|
||||
// });
|
||||
//
|
||||
// factory Category.fromJson(Map<String, dynamic> json) => Category(
|
||||
// id: json["_id"],
|
||||
// categoryName: json["categoryName"],
|
||||
// );
|
||||
//
|
||||
// Map<String, dynamic> toJson() => {
|
||||
// "_id": id,
|
||||
// "categoryName": categoryName,
|
||||
// };
|
||||
// }
|
||||
|
@ -1,130 +1,51 @@
|
||||
// import 'brand_model.dart';
|
||||
// import 'category_model.dart';
|
||||
//
|
||||
// class OrderItem {
|
||||
// final String id;
|
||||
// final String sku;
|
||||
// final String name;
|
||||
// final Category category;
|
||||
// final Brand brand;
|
||||
// final double price;
|
||||
// final double gst;
|
||||
// final int hsnCode;
|
||||
// final String description;
|
||||
// final String productStatus;
|
||||
// final String addedBy;
|
||||
// final List<String> image;
|
||||
// final DateTime createdAt;
|
||||
// final DateTime updatedAt;
|
||||
// final int count;
|
||||
//
|
||||
// OrderItem({
|
||||
// required this.id,
|
||||
// required this.sku,
|
||||
// required this.name,
|
||||
// required this.category,
|
||||
// required this.brand,
|
||||
// required this.price,
|
||||
// required this.gst,
|
||||
// required this.hsnCode,
|
||||
// required this.description,
|
||||
// required this.productStatus,
|
||||
// required this.addedBy,
|
||||
// required this.image,
|
||||
// required this.createdAt,
|
||||
// required this.updatedAt,
|
||||
// required this.count,
|
||||
// });
|
||||
//
|
||||
// factory OrderItem.fromJson(Map<String, dynamic> json) {
|
||||
// return OrderItem(
|
||||
// id: json['_id'],
|
||||
// sku: json['SKU'],
|
||||
// name: json['name'],
|
||||
// category: Category.fromJson(json['category']),
|
||||
// brand: Brand.fromJson(json['brand']),
|
||||
// price: json['price'].toDouble(),
|
||||
// gst: json['GST'].toDouble(),
|
||||
// hsnCode: json['HSN_Code'],
|
||||
// description: json['description'],
|
||||
// productStatus: json['product_Status'],
|
||||
// addedBy: json['addedBy'],
|
||||
// image: List<String>.from(json['image'] ?? []),
|
||||
// createdAt: DateTime.parse(json['createdAt']),
|
||||
// updatedAt: DateTime.parse(json['updatedAt']),
|
||||
// count: json['count'],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// return {
|
||||
// '_id': id,
|
||||
// 'SKU': sku,
|
||||
// 'name': name,
|
||||
// 'category': category,
|
||||
// 'brand': brand,
|
||||
// 'price': price,
|
||||
// 'GST': gst,
|
||||
// 'HSN_Code': hsnCode,
|
||||
// 'description': description,
|
||||
// 'product_Status': productStatus,
|
||||
// 'addedBy': addedBy,
|
||||
// 'image': image,
|
||||
// 'createdAt': createdAt.toIso8601String(),
|
||||
// 'updatedAt': updatedAt.toIso8601String(),
|
||||
// 'count': count,
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //
|
||||
// class Category {
|
||||
// final String id;
|
||||
// final String categoryName;
|
||||
//
|
||||
// Category({
|
||||
// required this.id,
|
||||
// required this.categoryName,
|
||||
// });
|
||||
//
|
||||
// factory Category.fromJson(Map<String, dynamic> json) {
|
||||
// return Category(
|
||||
// id: json['_id'],
|
||||
// categoryName: json['categoryName'],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class Brand {
|
||||
// final String id;
|
||||
// final String brandName;
|
||||
//
|
||||
// Brand({
|
||||
// required this.id,
|
||||
// required this.brandName,
|
||||
// });
|
||||
//
|
||||
// factory Brand.fromJson(Map<String, dynamic> json) {
|
||||
// return Brand(
|
||||
// id: json['_id'],
|
||||
// brandName: json['brandName'],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// //
|
||||
// // class AddedBy {
|
||||
// // final String id;
|
||||
// // final String name;
|
||||
// //
|
||||
// // AddedBy({
|
||||
// // required this.id,
|
||||
// // required this.name,
|
||||
// // });
|
||||
// //
|
||||
// // factory AddedBy.fromJson(Map<String, dynamic> json) {
|
||||
// // return AddedBy(
|
||||
// // id: json['_id'],
|
||||
// // name: json['name'],
|
||||
// // );
|
||||
// // }
|
||||
// // }
|
||||
class PlaceOrderItem1 {
|
||||
final String sku;
|
||||
String? id;
|
||||
List<String>? image;
|
||||
final String name;
|
||||
final String categoryName;
|
||||
final String brandName;
|
||||
final double price;
|
||||
final int quantity;
|
||||
|
||||
PlaceOrderItem1({
|
||||
required this.sku,
|
||||
this.id,
|
||||
this.image,
|
||||
required this.name,
|
||||
required this.categoryName,
|
||||
required this.brandName,
|
||||
required this.price,
|
||||
required this.quantity,
|
||||
});
|
||||
|
||||
factory PlaceOrderItem1.fromJson(Map<String, dynamic> json) {
|
||||
return PlaceOrderItem1(
|
||||
id: json['id'],
|
||||
sku: json['SKU'],
|
||||
name: json['name'],
|
||||
categoryName: json['categoryName'],
|
||||
brandName: json['brandName'],
|
||||
price: json['price'].toDouble(),
|
||||
quantity: json['quantity'], image: null,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'SKU': sku,
|
||||
'name': name,
|
||||
'categoryName': categoryName,
|
||||
'brandName': brandName,
|
||||
'price': price,
|
||||
'quantity': quantity,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OrderItem(sku: $sku, name: $name, categoryName: $categoryName, '
|
||||
'brandName: $brandName, price: $price, quantity: $quantity)';
|
||||
}
|
||||
}
|
||||
|
||||
|
136
lib/models/place_order_list_model.dart
Normal file
136
lib/models/place_order_list_model.dart
Normal file
@ -0,0 +1,136 @@
|
||||
class PlacedOrderList {
|
||||
final String id;
|
||||
final String paymentMode;
|
||||
final String shipTo;
|
||||
final String billTo;
|
||||
final List<OrderItem1> orderItem;
|
||||
final double subtotal;
|
||||
final double gstTotal;
|
||||
final double grandTotal;
|
||||
final String status;
|
||||
final String addedBy;
|
||||
final bool isCancelled;
|
||||
final bool isDelivered;
|
||||
final String deliveredDate;
|
||||
final String uniqueId;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
|
||||
PlacedOrderList({
|
||||
required this.id,
|
||||
required this.paymentMode,
|
||||
required this.shipTo,
|
||||
required this.billTo,
|
||||
required this.orderItem,
|
||||
required this.subtotal,
|
||||
required this.gstTotal,
|
||||
required this.grandTotal,
|
||||
required this.status,
|
||||
required this.addedBy,
|
||||
required this.isCancelled,
|
||||
required this.isDelivered,
|
||||
required this.deliveredDate,
|
||||
required this.uniqueId,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
});
|
||||
|
||||
factory PlacedOrderList.fromJson(Map<String, dynamic> json) {
|
||||
return PlacedOrderList(
|
||||
id: json['_id'],
|
||||
paymentMode: json['paymentMode'],
|
||||
shipTo: json['shipTo'],
|
||||
billTo: json['billTo'],
|
||||
orderItem: (json['orderItem'] as List)
|
||||
.map((item) => OrderItem1.fromJson(item))
|
||||
.toList(),
|
||||
subtotal: json['subtotal'].toDouble(),
|
||||
gstTotal: json['gstTotal'].toDouble(),
|
||||
grandTotal: json['grandTotal'].toDouble(),
|
||||
status: json['status'],
|
||||
addedBy: json['addedBy'],
|
||||
isCancelled: json['iscancelled'],
|
||||
isDelivered: json['isDelivered'],
|
||||
deliveredDate: json['DeliveredDate'],
|
||||
uniqueId: json['uniqueId'],
|
||||
createdAt: DateTime.parse(json['createdAt']),
|
||||
updatedAt: DateTime.parse(json['updatedAt']),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'_id': id,
|
||||
'paymentMode': paymentMode,
|
||||
'shipTo': shipTo,
|
||||
'billTo': billTo,
|
||||
'orderItem': orderItem.map((item) => item.toJson()).toList(),
|
||||
'subtotal': subtotal,
|
||||
'gstTotal': gstTotal,
|
||||
'grandTotal': grandTotal,
|
||||
'status': status,
|
||||
'addedBy': addedBy,
|
||||
'iscancelled': isCancelled,
|
||||
'isDelivered': isDelivered,
|
||||
'DeliveredDate': deliveredDate,
|
||||
'uniqueId': uniqueId,
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
'updatedAt': updatedAt.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PlacedOrderList(id: $id, paymentMode: $paymentMode, shipTo: $shipTo, billTo: $billTo, '
|
||||
'orderItem: $orderItem, subtotal: $subtotal, gstTotal: $gstTotal, grandTotal: $grandTotal, '
|
||||
'status: $status, addedBy: $addedBy, isCancelled: $isCancelled, isDelivered: $isDelivered, '
|
||||
'deliveredDate: $deliveredDate, uniqueId: $uniqueId, createdAt: $createdAt, updatedAt: $updatedAt)';
|
||||
}
|
||||
}
|
||||
|
||||
class OrderItem1 {
|
||||
final String sku;
|
||||
final String name;
|
||||
final String categoryName;
|
||||
final String brandName;
|
||||
final double price;
|
||||
final int quantity;
|
||||
|
||||
OrderItem1({
|
||||
required this.sku,
|
||||
required this.name,
|
||||
required this.categoryName,
|
||||
required this.brandName,
|
||||
required this.price,
|
||||
required this.quantity,
|
||||
});
|
||||
|
||||
factory OrderItem1.fromJson(Map<String, dynamic> json) {
|
||||
return OrderItem1(
|
||||
sku: json['SKU'],
|
||||
name: json['name'],
|
||||
categoryName: json['categoryName'],
|
||||
brandName: json['brandName'],
|
||||
price: json['price'].toDouble(),
|
||||
quantity: json['quantity'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'SKU': sku,
|
||||
'name': name,
|
||||
'categoryName': categoryName,
|
||||
'brandName': brandName,
|
||||
'price': price,
|
||||
'quantity': quantity,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OrderItem(sku: $sku, name: $name, categoryName: $categoryName, '
|
||||
'brandName: $brandName, price: $price, quantity: $quantity)';
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ class CheckoutScreen extends StatefulWidget {
|
||||
final Product? productModel;
|
||||
|
||||
PlacedOrderModel? placeOrder;
|
||||
|
||||
CheckoutScreen({super.key, this.productModel, this.placeOrder});
|
||||
List<Product>? selectedProducts;
|
||||
CheckoutScreen({super.key, this.productModel, this.placeOrder,this.selectedProducts});
|
||||
|
||||
@override
|
||||
State<CheckoutScreen> createState() => _CheckoutScreenState();
|
||||
@ -157,7 +157,7 @@ class _CheckoutScreenState extends State<CheckoutScreen> {
|
||||
await _orderPlacedController.placeOrder();
|
||||
|
||||
if (_orderPlacedController.isLoading.value) {
|
||||
showSnackbar("OderPlaced Successfully");
|
||||
showSnackbar("Order Placed Successfully");
|
||||
Get.to(() => OrderConfermationScreen(
|
||||
placedOrder: _orderPlacedController.placedOrder1.value,
|
||||
));
|
||||
@ -292,7 +292,7 @@ class _CheckoutScreenState extends State<CheckoutScreen> {
|
||||
SizedBox(
|
||||
height: Get.height * 0.035,
|
||||
child: RadioListTile(
|
||||
title: const Text("cheque"),
|
||||
title: const Text("Cheque"),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
value: "cheque",
|
||||
groupValue: _groupValue,
|
||||
@ -302,7 +302,7 @@ class _CheckoutScreenState extends State<CheckoutScreen> {
|
||||
SizedBox(
|
||||
height: Get.height * 0.035,
|
||||
child: RadioListTile(
|
||||
title: const Text("online-transfer"),
|
||||
title: const Text("Online transfer"),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
value: "online-transfer",
|
||||
groupValue: _groupValue,
|
||||
@ -311,7 +311,7 @@ class _CheckoutScreenState extends State<CheckoutScreen> {
|
||||
),
|
||||
SizedBox(
|
||||
child: RadioListTile(
|
||||
title: const Text("credit"),
|
||||
title: const Text("Credit"),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
value: "credit",
|
||||
groupValue: _groupValue,
|
||||
@ -371,28 +371,27 @@ class _CheckoutScreenState extends State<CheckoutScreen> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('Subtotal:'),
|
||||
Text('Subtotal',style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Text('₹${_cartController.subtotal.value.toStringAsFixed(2)}'),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('GST:'),
|
||||
Text('GST',style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Text('₹${_cartController.gstTotal.value.toStringAsFixed(2)}'),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('Grand Total:'),
|
||||
Text('Total Amount',style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Text('₹${_cartController.grandTotal.value.toStringAsFixed(2)}'),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -38,11 +38,11 @@ class _OrderConfermationScreenState extends State<OrderConfermationScreen> {
|
||||
// ),
|
||||
// ];
|
||||
|
||||
void _getOrder(){
|
||||
final details = _getPlacedOrderController.getOrder(_cartController.cartList[0].id);
|
||||
showSnackbar("Get Placed Order Sucessfully");
|
||||
print("dffgfg,$details");
|
||||
}
|
||||
// void _getOrder(){
|
||||
// final details = _getPlacedOrderController.getOrder();
|
||||
// showSnackbar("Get Placed Order Sucessfully");
|
||||
// print("dffgfg,$details");
|
||||
// }
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final orderItems = _placedController.placedOrder1;
|
||||
@ -128,7 +128,7 @@ class _OrderConfermationScreenState extends State<OrderConfermationScreen> {
|
||||
'Order Summary',
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
@ -160,21 +160,21 @@ class _OrderConfermationScreenState extends State<OrderConfermationScreen> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('Subtotal:'),
|
||||
Text('Subtotal',style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Text('₹${_cartController.subtotal.value.toStringAsFixed(2)}'),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('GST:'),
|
||||
Text('GST',style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Text('₹${_cartController.gstTotal.value.toStringAsFixed(2)}'),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('Grand Total:'),
|
||||
Text('Total Amount',style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Text('₹${_cartController.grandTotal.value.toStringAsFixed(2)}'),
|
||||
],
|
||||
),
|
||||
@ -219,18 +219,8 @@ class _OrderConfermationScreenState extends State<OrderConfermationScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Text(
|
||||
// "Contact: +91 9123456789",
|
||||
// style: GoogleFonts.roboto(
|
||||
// fontSize: Get.width * 0.04,
|
||||
// fontWeight: FontWeight.w400,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
|
||||
]),
|
||||
),
|
||||
),
|
||||
Card(
|
||||
@ -240,7 +230,7 @@ class _OrderConfermationScreenState extends State<OrderConfermationScreen> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
"Estimated Delivery Date: 20 Sep 2024",
|
||||
"Estimated Delivery Date: ${widget.placedOrder!.orderItems[0].createdAt}",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.w400,
|
||||
@ -254,25 +244,7 @@ class _OrderConfermationScreenState extends State<OrderConfermationScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: [
|
||||
// ElevatedButton(
|
||||
// onPressed:_getOrder,
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// foregroundColor: Colors.white,
|
||||
// backgroundColor: const Color(0xFF00784C),
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: Get.width * 0.20,
|
||||
// vertical: Get.height * 0.02),
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(10),
|
||||
// ),
|
||||
// ),
|
||||
// child: const Text("Confirm Order"),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:cheminova/models/place_order_list_model.dart';
|
||||
import 'package:cheminova/models/product_model.dart';
|
||||
import 'package:cheminova/screens/order_management/order_status_update_screen.dart';
|
||||
import 'package:cheminova/widgets/product_card.dart';
|
||||
@ -10,8 +11,9 @@ import '../../controller/cart_controller.dart';
|
||||
import '../../models/product_model1.dart';
|
||||
|
||||
class OrderFullfilmentScreen extends StatefulWidget {
|
||||
final Product? productModel;
|
||||
const OrderFullfilmentScreen({super.key,required this.productModel});
|
||||
//final Product? productModel;
|
||||
PlacedOrderList? placedOrderList;
|
||||
OrderFullfilmentScreen({super.key,this.placedOrderList});
|
||||
|
||||
@override
|
||||
State<OrderFullfilmentScreen> createState() => _OrderFullfilmentScreenState();
|
||||
@ -148,7 +150,7 @@ class _OrderFullfilmentScreenState extends State<OrderFullfilmentScreen> {
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: 10,
|
||||
itemBuilder: (context, index) => ProductCard(
|
||||
productModel:widget.productModel,
|
||||
placedOrderList:widget.placedOrderList,
|
||||
isCheckout: true,
|
||||
),
|
||||
),
|
||||
|
@ -1,3 +1,7 @@
|
||||
import 'package:cheminova/controller/get_order_placed_controller.dart';
|
||||
import 'package:cheminova/models/oder_place_model.dart';
|
||||
import 'package:cheminova/models/order_item_model.dart';
|
||||
import 'package:cheminova/models/place_order_list_model.dart';
|
||||
import 'package:cheminova/models/product_model.dart';
|
||||
import 'package:cheminova/screens/order_management/order_fullfilment_screen.dart';
|
||||
import 'package:cheminova/widgets/product_card.dart';
|
||||
@ -6,13 +10,16 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../controller/cart_controller.dart';
|
||||
import '../../models/product_model1.dart';
|
||||
|
||||
class OrderManagementDetailScreen extends StatefulWidget {
|
||||
final Product? productModel;
|
||||
const OrderManagementDetailScreen({super.key,required this.productModel});
|
||||
//final Product? productModel;
|
||||
PlacedOrderList? placedOrderList;
|
||||
PlacedOrderModel? placedOrderModel;
|
||||
OrderManagementDetailScreen({super.key,this.placedOrderList,this.placedOrderModel});
|
||||
|
||||
@override
|
||||
State<OrderManagementDetailScreen> createState() =>
|
||||
@ -23,16 +30,44 @@ class OrderManagementDetailScreen extends StatefulWidget {
|
||||
class _OrderManagementDetailScreenState
|
||||
extends State<OrderManagementDetailScreen> {
|
||||
final CartController _cartController = Get.put(CartController());
|
||||
// final List<ProductModel> _checkoutList = [
|
||||
// ProductModel(
|
||||
// id: "1",
|
||||
// image: 'assets/images/image_1.png',
|
||||
// name: "Product 1",
|
||||
// category: ProductCategory.food,
|
||||
// description: 'Product 1 description',
|
||||
// price: 100,
|
||||
// ),
|
||||
// ];
|
||||
final GetPlacedOrderController _getPlacedOrderController = Get.put(GetPlacedOrderController());
|
||||
String formatDate(String apiDate) {
|
||||
|
||||
DateTime parsedDate = DateTime.parse(apiDate);
|
||||
|
||||
String formattedDate = DateFormat('dd-MMM-yyyy').format(parsedDate);
|
||||
|
||||
return formattedDate;
|
||||
}
|
||||
String capitalizeFirstLetter(String text) {
|
||||
if (text.isEmpty) return text;
|
||||
return text[0].toUpperCase() + text.substring(1).toLowerCase();
|
||||
}
|
||||
|
||||
Future<void> adduni()async {
|
||||
final Set<String> uniqueOrderIds = {};
|
||||
final List<PlacedOrderList> uniqueOrders = [];
|
||||
|
||||
for (var order in _getPlacedOrderController.placedOrders) {
|
||||
if (uniqueOrderIds.add(order.id)) {
|
||||
uniqueOrders.add(order);
|
||||
}
|
||||
}
|
||||
final order = uniqueOrders[0];
|
||||
|
||||
// Combine product names into a single string
|
||||
final productNames = order.orderItem
|
||||
.map((item) => (item.name))
|
||||
.join(', ');
|
||||
final categotyName = order.orderItem
|
||||
.map((item) => (item.categoryName))
|
||||
.join(', ');
|
||||
final quantity = order.orderItem
|
||||
.map((item) => (item.quantity))
|
||||
.join(', ');
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -102,8 +137,8 @@ class _OrderManagementDetailScreenState
|
||||
child: Text(
|
||||
"Order Summary",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: Get.width * 0.05,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -113,13 +148,19 @@ class _OrderManagementDetailScreenState
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Text(
|
||||
"Order ID: 123456",
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Order ID:",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(widget.placedOrderList!.id),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
@ -127,26 +168,38 @@ class _OrderManagementDetailScreenState
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Text(
|
||||
"Order Date: MM/DD/YYYY",
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Order Date: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(formatDate("${widget.placedOrderList!.createdAt}")),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
"Total Price: ₹ Total",
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Total Amount: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("₹ ${widget.placedOrderList!.grandTotal}"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -160,11 +213,52 @@ class _OrderManagementDetailScreenState
|
||||
padding: EdgeInsets.all(Get.width * 0.02),
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: 10,
|
||||
itemBuilder: (context, index) => ProductCard(
|
||||
productModel: widget.productModel,
|
||||
isCheckout: true,
|
||||
itemCount: widget.placedOrderList?.orderItem.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
final orderItem = widget.placedOrderList!.orderItem[index];
|
||||
return orderItem != null
|
||||
? Card(
|
||||
margin: const EdgeInsets.symmetric(vertical: 5.0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
"assets/images/product.png", // Add the image URL here
|
||||
height: 50,
|
||||
width: 50,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
capitalizeFirstLetter(orderItem.name),
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Quantity: ${orderItem.quantity}",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.03,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -192,28 +286,33 @@ class _OrderManagementDetailScreenState
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
||||
child: Text(
|
||||
"Address: Hyderabad",
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Address: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
"Contact: +91 9123456789",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("${widget.placedOrderList!.shipTo}")
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// SizedBox(
|
||||
// width: Get.width,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Text(
|
||||
// "Contact: +91 9123456789",
|
||||
// style: GoogleFonts.roboto(
|
||||
// fontSize: Get.width * 0.04,
|
||||
// fontWeight: FontWeight.w400,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -223,13 +322,18 @@ class _OrderManagementDetailScreenState
|
||||
width: Get.width,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Text(
|
||||
"Status: Processing/ Shipped/ Delivered",
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Status: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(capitalizeFirstLetter("${widget.placedOrderList!.status}")),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -238,31 +342,31 @@ class _OrderManagementDetailScreenState
|
||||
),
|
||||
),
|
||||
SizedBox(height: Get.height * 0.04),
|
||||
SizedBox(
|
||||
width: Get.width * 0.9,
|
||||
height: Get.height * 0.06,
|
||||
child: ElevatedButton(
|
||||
onPressed: () => Get.to(
|
||||
() => OrderFullfilmentScreen(
|
||||
productModel:widget.productModel ,
|
||||
),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: Colors.white,
|
||||
backgroundColor: const Color(0xFF00784C),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
"Fulfill Order",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: Get.width * 0.04,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// SizedBox(
|
||||
// width: Get.width * 0.9,
|
||||
// height: Get.height * 0.06,
|
||||
// child: ElevatedButton(
|
||||
// onPressed: () => Get.to(
|
||||
// () => OrderFullfilmentScreen(
|
||||
// placedOrderList:widget.placedOrderList ,
|
||||
// ),
|
||||
// ),
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// foregroundColor: Colors.white,
|
||||
// backgroundColor: const Color(0xFF00784C),
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(10),
|
||||
// ),
|
||||
// ),
|
||||
// child: Text(
|
||||
// "Fulfill Order",
|
||||
// style: GoogleFonts.roboto(
|
||||
// fontSize: Get.width * 0.04,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:cheminova/models/place_order_list_model.dart';
|
||||
import 'package:cheminova/screens/order_management/order_management_detail_screen.dart';
|
||||
import 'package:cheminova/widgets/input_field.dart';
|
||||
import 'package:cheminova/widgets/my_drawer.dart';
|
||||
@ -5,12 +6,16 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../controller/cart_controller.dart';
|
||||
import '../../controller/get_order_placed_controller.dart';
|
||||
import '../../models/product_model1.dart';
|
||||
|
||||
|
||||
class OrderManagementScreen extends StatefulWidget {
|
||||
Product? productModel;
|
||||
OrderManagementScreen({super.key,this.productModel});
|
||||
final Product? productModel;
|
||||
PlacedOrderList? placeOrder;
|
||||
OrderManagementScreen({super.key, this.productModel, this.placeOrder});
|
||||
|
||||
@override
|
||||
State<OrderManagementScreen> createState() => _OrderManagementScreenState();
|
||||
@ -18,10 +23,39 @@ class OrderManagementScreen extends StatefulWidget {
|
||||
|
||||
class _OrderManagementScreenState extends State<OrderManagementScreen> {
|
||||
final _searchController = TextEditingController();
|
||||
final List<String> _filterList = [
|
||||
"Order Status",
|
||||
"Date Range",
|
||||
];
|
||||
final List<String> _filterList = ["Order Status", "Date Range"];
|
||||
|
||||
final GetPlacedOrderController _getPlacedOrderController = Get.put(GetPlacedOrderController());
|
||||
final CartController _cartController = Get.put(CartController());
|
||||
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
|
||||
GlobalKey<RefreshIndicatorState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
getOrder1();
|
||||
}
|
||||
|
||||
Future<void> _onRefresh() async {
|
||||
await getOrder1();
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
}
|
||||
|
||||
Future<void> getOrder1() async {
|
||||
await _getPlacedOrderController.getOrders();
|
||||
print("Order fetched successfully");
|
||||
}
|
||||
|
||||
String capitalizeFirstLetter(String text) {
|
||||
if (text.isEmpty) return text;
|
||||
return text[0].toUpperCase() + text.substring(1).toLowerCase();
|
||||
}
|
||||
|
||||
String formatDate(String apiDate) {
|
||||
DateTime parsedDate = DateTime.parse(apiDate);
|
||||
String formattedDate = DateFormat('dd-MMM-yyyy').format(parsedDate);
|
||||
return formattedDate;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -37,9 +71,7 @@ class _OrderManagementScreenState extends State<OrderManagementScreen> {
|
||||
onTap: () => Scaffold.of(context).openDrawer(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: SvgPicture.asset(
|
||||
'assets/svg/menu.svg',
|
||||
),
|
||||
child: SvgPicture.asset('assets/svg/menu.svg'),
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -49,29 +81,26 @@ class _OrderManagementScreenState extends State<OrderManagementScreen> {
|
||||
onTap: () => Get.back(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: SvgPicture.asset(
|
||||
'assets/svg/back_arrow.svg',
|
||||
),
|
||||
child: SvgPicture.asset('assets/svg/back_arrow.svg'),
|
||||
),
|
||||
),
|
||||
],
|
||||
title: const Text(
|
||||
"Order Management",
|
||||
),
|
||||
title: const Text("Order Management"),
|
||||
),
|
||||
drawer: const MyDrawer(),
|
||||
body: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/image_1.png',
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
Image.asset('assets/images/image_1.png', fit: BoxFit.cover),
|
||||
SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||
child: RefreshIndicator(
|
||||
key: _refreshIndicatorKey,
|
||||
onRefresh: _onRefresh,
|
||||
color: Colors.black,
|
||||
backgroundColor: Colors.white,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
@ -101,15 +130,11 @@ class _OrderManagementScreenState extends State<OrderManagementScreen> {
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: _filterList.length,
|
||||
itemBuilder: (context, index) => Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 4),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Chip(
|
||||
label: Text(
|
||||
_filterList[index],
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -117,60 +142,96 @@ class _OrderManagementScreenState extends State<OrderManagementScreen> {
|
||||
),
|
||||
SizedBox(
|
||||
height: Get.height * 0.6,
|
||||
child: ListView.builder(
|
||||
child: Obx(() {
|
||||
// Use a set to keep track of unique order IDs
|
||||
final Set<String> uniqueOrderIds = {};
|
||||
final List<PlacedOrderList> uniqueOrders = [];
|
||||
|
||||
for (var order in _getPlacedOrderController.placedOrders) {
|
||||
if (uniqueOrderIds.add(order.id)) {
|
||||
uniqueOrders.add(order);
|
||||
}
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
shrinkWrap: true,
|
||||
itemCount: 2,
|
||||
itemBuilder: (context, index) => Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 8),
|
||||
itemCount: uniqueOrders.length,
|
||||
itemBuilder: (context, index) {
|
||||
final order = uniqueOrders[index];
|
||||
|
||||
// Combine product names into a single string
|
||||
final productNames = order.orderItem
|
||||
.map((item) => capitalizeFirstLetter(item.name))
|
||||
.join(', ');
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: Card(
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
16, 8, 8, 0),
|
||||
child: Text(
|
||||
"Order ID: 123456",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 8, 0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Order ID: ", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.bold)),
|
||||
Text("${order.id}")
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
16, 8, 8, 0),
|
||||
child: Text(
|
||||
"Product Name: XYZ",
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 8, 0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start, // Aligns the Column to the top of the Text
|
||||
children: [
|
||||
Text(
|
||||
"Product Names: ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start, // Aligns text to the right within the Column
|
||||
children: [
|
||||
const SizedBox(height: 4), // Adds a small space between the label and the product names
|
||||
for (int i = 0; i < productNames.split(",").length; i++)
|
||||
Text(
|
||||
'${i + 1}. ${productNames.split(",")[i].trim()}', // Adds index and trims whitespace
|
||||
textAlign: TextAlign.left, // Aligns text to the right
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 8, 0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Order Date: ", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.bold)),
|
||||
Text(formatDate("${order.createdAt}"))
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
16, 8, 8, 0),
|
||||
child: Text(
|
||||
"Order Date: MM/DD/YYYY",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
16, 8, 8, 8),
|
||||
child: Text(
|
||||
"Status: Processing/shipped/delivered",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 8, 8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Status: ", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.bold)),
|
||||
Text(capitalizeFirstLetter("${order.status}"))
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
@ -178,36 +239,25 @@ class _OrderManagementScreenState extends State<OrderManagementScreen> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ElevatedButton(
|
||||
onPressed: () => Get.to(
|
||||
() =>
|
||||
OrderManagementDetailScreen(
|
||||
productModel:widget.productModel,
|
||||
),
|
||||
),
|
||||
onPressed: () => Get.to(() => OrderManagementDetailScreen(
|
||||
placedOrderList: uniqueOrders[index])),
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: Colors.white,
|
||||
backgroundColor:
|
||||
const Color(0xFF004791),
|
||||
backgroundColor: const Color(0xFF004791),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
"View Details",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
),
|
||||
child: Text("View Details", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.w400)),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
)
|
||||
],
|
||||
),
|
||||
@ -218,8 +268,259 @@ class _OrderManagementScreenState extends State<OrderManagementScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// import 'package:cheminova/controller/get_place_order_service.dart';
|
||||
// import 'package:cheminova/controller/place_order_controller.dart';
|
||||
// import 'package:cheminova/models/place_order_list_model.dart';
|
||||
// import 'package:cheminova/screens/order_management/order_management_detail_screen.dart';
|
||||
// import 'package:cheminova/widgets/input_field.dart';
|
||||
// import 'package:cheminova/widgets/my_drawer.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_svg/svg.dart';
|
||||
// import 'package:get/get.dart';
|
||||
// import 'package:google_fonts/google_fonts.dart';
|
||||
// import 'package:intl/intl.dart';
|
||||
//
|
||||
// import '../../controller/cart_controller.dart';
|
||||
// import '../../controller/get_order_placed_controller.dart';
|
||||
// import '../../models/product_model1.dart';
|
||||
// import '../../models/oder_place_model.dart';
|
||||
// import '../../utils/show_snackbar.dart'; // Ensure this import is correct
|
||||
//
|
||||
// class OrderManagementScreen extends StatefulWidget {
|
||||
// final Product? productModel;
|
||||
// PlacedOrderList? placeOrder;
|
||||
// OrderManagementScreen({super.key, this.productModel, this.placeOrder});
|
||||
//
|
||||
// @override
|
||||
// State<OrderManagementScreen> createState() => _OrderManagementScreenState();
|
||||
// }
|
||||
//
|
||||
// class _OrderManagementScreenState extends State<OrderManagementScreen> {
|
||||
// final _searchController = TextEditingController();
|
||||
// final List<String> _filterList = ["Order Status", "Date Range"];
|
||||
//
|
||||
// final GetPlacedOrderController _getPlacedOrderController = Get.put(GetPlacedOrderController());
|
||||
// final CartController _cartController = Get.put(CartController());
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// getOrder1();
|
||||
// }
|
||||
//
|
||||
// Future<void> getOrder1() async {
|
||||
// await _getPlacedOrderController.getOrders();
|
||||
// print("Order fetched successfully");
|
||||
// }
|
||||
//
|
||||
// String capitalizeFirstLetter(String text) {
|
||||
// if (text.isEmpty) return text;
|
||||
// return text[0].toUpperCase() + text.substring(1).toLowerCase();
|
||||
// }
|
||||
//
|
||||
// String formatDate(String apiDate) {
|
||||
// DateTime parsedDate = DateTime.parse(apiDate);
|
||||
// String formattedDate = DateFormat('dd-MMM-yyyy hh:mm:ss a').format(parsedDate);
|
||||
// return formattedDate;
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Scaffold(
|
||||
// extendBodyBehindAppBar: true,
|
||||
// appBar: AppBar(
|
||||
// centerTitle: true,
|
||||
// backgroundColor: Colors.transparent,
|
||||
// elevation: 0,
|
||||
// leading: Builder(
|
||||
// builder: (context) {
|
||||
// return GestureDetector(
|
||||
// onTap: () => Scaffold.of(context).openDrawer(),
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(16.0),
|
||||
// child: SvgPicture.asset('assets/svg/menu.svg'),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// actions: [
|
||||
// GestureDetector(
|
||||
// onTap: () => Get.back(),
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: SvgPicture.asset('assets/svg/back_arrow.svg'),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// title: const Text("Order Management"),
|
||||
// ),
|
||||
// drawer: const MyDrawer(),
|
||||
// body: Stack(
|
||||
// fit: StackFit.expand,
|
||||
// children: [
|
||||
// Image.asset('assets/images/image_1.png', fit: BoxFit.cover),
|
||||
// SafeArea(
|
||||
// child: SingleChildScrollView(
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||
// child: Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
// children: [
|
||||
// InputField(
|
||||
// hintText: "Search Order",
|
||||
// labelText: "Search Order",
|
||||
// controller: _searchController,
|
||||
// ),
|
||||
// SizedBox(height: Get.height * 0.035),
|
||||
// Card(
|
||||
// margin: const EdgeInsets.symmetric(horizontal: 18),
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(19),
|
||||
// side: const BorderSide(color: Color(0xFFFDFDFD)),
|
||||
// ),
|
||||
// color: const Color(0xFFB4D1E5).withOpacity(0.9),
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(12.0),
|
||||
// child: Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// SizedBox(
|
||||
// height: Get.height * 0.05,
|
||||
// child: ListView.builder(
|
||||
// shrinkWrap: true,
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// itemCount: _filterList.length,
|
||||
// itemBuilder: (context, index) => Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
// child: Chip(
|
||||
// label: Text(
|
||||
// _filterList[index],
|
||||
// style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.w500),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: Get.height * 0.6,
|
||||
// child: Obx(() {
|
||||
// return ListView.builder(
|
||||
// padding: EdgeInsets.zero,
|
||||
// shrinkWrap: true,
|
||||
// itemCount: _getPlacedOrderController.placedOrders.length,
|
||||
// itemBuilder: (context, index) {
|
||||
// final order = _getPlacedOrderController.placedOrders[index];
|
||||
//
|
||||
// // Combine product names into a single string
|
||||
// final productNames = order.orderItem
|
||||
// .map((item) => capitalizeFirstLetter(item.name))
|
||||
// .join(', ');
|
||||
//
|
||||
// return Padding(
|
||||
// padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
// child: Card(
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.fromLTRB(16, 8, 8, 0),
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Text("Order ID: ", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.bold)),
|
||||
// Text("${order.id}")
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.fromLTRB(16, 8, 8, 0),
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Text("Product Names: ", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.bold)),
|
||||
// Expanded(
|
||||
// child: Text(productNames,
|
||||
// style: GoogleFonts.roboto(
|
||||
// fontSize: 14,
|
||||
// )),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.fromLTRB(16, 8, 8, 0),
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Text("Order Date: ", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.bold)),
|
||||
// Text(formatDate("${order.createdAt}"))
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.fromLTRB(16, 8, 8, 8),
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Text("Status: ", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.bold)),
|
||||
// Text(capitalizeFirstLetter("${order.status}"))
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// width: Get.width * 0.4,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: ElevatedButton(
|
||||
// onPressed: () => Get.to(() => OrderManagementDetailScreen(
|
||||
// placedOrderList: _getPlacedOrderController.placedOrders[index])),
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// foregroundColor: Colors.white,
|
||||
// backgroundColor: const Color(0xFF004791),
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(10)),
|
||||
// ),
|
||||
// child: Text("View Details", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.w400)),
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// }),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
|
@ -62,10 +62,12 @@ class _CartScreenState extends State<CartScreen> {
|
||||
),
|
||||
),
|
||||
],
|
||||
title: const Text(
|
||||
title: Center(
|
||||
child: const Text(
|
||||
"Cart",
|
||||
),
|
||||
),
|
||||
),
|
||||
drawer: const MyDrawer(),
|
||||
body: Stack(
|
||||
fit: StackFit.expand,
|
||||
@ -114,11 +116,12 @@ class _CartScreenState extends State<CartScreen> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Subtotal Price: ",
|
||||
"Subtotal ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 15,
|
||||
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold
|
||||
),
|
||||
),
|
||||
Text("₹ ${_cartController.subtotal.value}"),
|
||||
@ -136,11 +139,13 @@ class _CartScreenState extends State<CartScreen> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"gstTotal Price: ",
|
||||
"GST ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 15,
|
||||
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold
|
||||
|
||||
),
|
||||
),
|
||||
Text("₹ ${_cartController.gstTotal.value}"),
|
||||
@ -153,11 +158,12 @@ class _CartScreenState extends State<CartScreen> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"grandTotal Price:",
|
||||
"Total Amount ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 15,
|
||||
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold
|
||||
),
|
||||
),
|
||||
Text(" ₹ ${_cartController.grandTotal.value}"),
|
||||
|
@ -169,10 +169,12 @@ class _ProductCatalogScreenState extends State<ProductCatalogScreen> {
|
||||
),
|
||||
),
|
||||
],
|
||||
title: const Text(
|
||||
title: Center(
|
||||
child: const Text(
|
||||
"Product Catalogue",
|
||||
),
|
||||
),
|
||||
),
|
||||
drawer: const MyDrawer(),
|
||||
body: Stack(
|
||||
fit: StackFit.expand,
|
||||
@ -216,7 +218,7 @@ class _ProductCatalogScreenState extends State<ProductCatalogScreen> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Filters",
|
||||
"Filter",
|
||||
style: GoogleFonts.poppins(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
@ -225,7 +227,7 @@ class _ProductCatalogScreenState extends State<ProductCatalogScreen> {
|
||||
TextButton(
|
||||
onPressed: _clearFilters,
|
||||
child: Text(
|
||||
"Clear Filters",
|
||||
"Clear Filter",
|
||||
style: GoogleFonts.poppins(
|
||||
color: Colors.red,
|
||||
fontSize: 14,
|
||||
|
@ -24,6 +24,10 @@ class ProductDetailScreen extends StatefulWidget {
|
||||
|
||||
class _ProductDetailScreenState extends State<ProductDetailScreen> {
|
||||
final CartController _cartController = Get.put(CartController());
|
||||
String capitalizeFirstLetter(String text) {
|
||||
if (text.isEmpty) return text;
|
||||
return text[0].toUpperCase() + text.substring(1).toLowerCase();
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -92,7 +96,7 @@ class _ProductDetailScreenState extends State<ProductDetailScreen> {
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
height: Get.height * 0.4,
|
||||
width: Get.width * 0.7,
|
||||
width: Get.width * 0.8,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 4,
|
||||
@ -112,48 +116,71 @@ class _ProductDetailScreenState extends State<ProductDetailScreen> {
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(
|
||||
widget.productModel!.name,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("Product Name ",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 16),),
|
||||
Text(
|
||||
capitalizeFirstLetter(widget.productModel!.name),
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
// fontWeight: FontWeight.w600,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("Price ",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold),),
|
||||
Text(
|
||||
"₹ ${widget.productModel!.price.toString()}",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
//fontWeight: FontWeight.w800,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(
|
||||
widget.productModel!.category!.categoryName,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("Category ",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 16),),
|
||||
Text(
|
||||
capitalizeFirstLetter(widget.productModel!.category!.categoryName),
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.white,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(
|
||||
widget.productModel!.description,
|
||||
child: Row(
|
||||
children: [
|
||||
Text("Description",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 16)),
|
||||
Text(
|
||||
capitalizeFirstLetter(widget.productModel!.description),
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.white,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -167,7 +194,7 @@ class _ProductDetailScreenState extends State<ProductDetailScreen> {
|
||||
onPressed: () {
|
||||
// Pass the product data to the CartScreen
|
||||
_cartController.addToCart(widget.productModel!);
|
||||
showSnackbar("Product Added to cart");
|
||||
showSnackbar("Product successfully added to your cart");
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: Colors.white,
|
||||
|
@ -1 +1,3 @@
|
||||
String baseUrl = "https://cheminova-api-2.onrender.com";
|
||||
//String baseUrl = "https://cheminova-api-2.onrender.com";
|
||||
|
||||
String baseUrl = "https://api.cnapp.co.in";
|
@ -1,5 +1,7 @@
|
||||
import 'package:cheminova/controller/cart_controller.dart';
|
||||
import 'package:cheminova/models/oder_place_model.dart';
|
||||
import 'package:cheminova/models/order_item_model.dart';
|
||||
import 'package:cheminova/models/place_order_list_model.dart';
|
||||
import 'package:cheminova/models/product_model.dart';
|
||||
import 'package:cheminova/screens/product/product_detail_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -13,17 +15,22 @@ import '../utils/show_snackbar.dart';
|
||||
class ProductCard extends StatefulWidget {
|
||||
final Product? productModel;
|
||||
PlacedOrderModel? placedOrder;
|
||||
PlacedOrderList? placedOrderList;
|
||||
PlaceOrderItem1? placeorderItem;
|
||||
ProductModel? product;
|
||||
final bool isInCart;
|
||||
final bool isCheckout;
|
||||
final bool isConfirmation;
|
||||
int? quantity;
|
||||
|
||||
ProductCard({
|
||||
super.key,
|
||||
this.product,
|
||||
this.quantity=1,
|
||||
this.quantity = 1,
|
||||
this.productModel,
|
||||
this.placedOrder,
|
||||
this.placedOrderList,
|
||||
this.placeorderItem,
|
||||
this.isInCart = false,
|
||||
this.isCheckout = false,
|
||||
this.isConfirmation = false,
|
||||
@ -33,25 +40,26 @@ class ProductCard extends StatefulWidget {
|
||||
State<ProductCard> createState() => _ProductCardState();
|
||||
}
|
||||
|
||||
|
||||
class _ProductCardState extends State<ProductCard> {
|
||||
@override
|
||||
String capitalizeFirstLetter(String text) {
|
||||
if (text.isEmpty) return text;
|
||||
return text[0].toUpperCase() + text.substring(1).toLowerCase();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final CartController _cartController = Get.put(CartController());
|
||||
bool showQuantity = widget.isInCart || widget.isCheckout || widget.isConfirmation;
|
||||
bool isProductInCart = _cartController.cartList.contains(widget.productModel);
|
||||
|
||||
bool isProductInCart = _cartController.cartList.any((p) => p.id == widget.productModel!.id);
|
||||
|
||||
int currentQuantity = isProductInCart
|
||||
? _cartController.cartList.firstWhere((p) => p.id == widget.productModel!.id).quantity
|
||||
: widget.productModel!.quantity;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => widget.isInCart || widget.isCheckout
|
||||
? null
|
||||
: Get.to(() =>
|
||||
ProductDetailScreen(productModel: widget.productModel)),
|
||||
: Get.to(() => ProductDetailScreen(productModel: widget.productModel)),
|
||||
child: Card(
|
||||
child: Row(
|
||||
children: [
|
||||
@ -65,7 +73,6 @@ class _ProductCardState extends State<ProductCard> {
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage("assets/images/product.png"),
|
||||
// Image.asset(productModel!['image']).image,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
@ -79,21 +86,21 @@ class _ProductCardState extends State<ProductCard> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.productModel!.name,
|
||||
capitalizeFirstLetter(widget.productModel!.name),
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.productModel!.category!.categoryName,
|
||||
capitalizeFirstLetter(widget.productModel!.category!.categoryName),
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"₹ ${ widget.productModel!.price.toString()}",
|
||||
"₹ ${widget.productModel!.price.toString()}",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w700,
|
||||
@ -122,8 +129,7 @@ class _ProductCardState extends State<ProductCard> {
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceAround,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 24,
|
||||
@ -132,20 +138,16 @@ class _ProductCardState extends State<ProductCard> {
|
||||
onPressed: () {
|
||||
_cartController.decreaseQuantity(widget.productModel!);
|
||||
setState(() {
|
||||
// Update the local quantity to reflect the change
|
||||
currentQuantity = _cartController
|
||||
.cartList
|
||||
.firstWhere((p) =>
|
||||
p.id ==
|
||||
widget.productModel!.id)
|
||||
.firstWhere((p) => p.id == widget.productModel!.id)
|
||||
.quantity;
|
||||
});
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(8.0),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
@ -171,20 +173,16 @@ class _ProductCardState extends State<ProductCard> {
|
||||
onPressed: () {
|
||||
_cartController.increaseQuantity(widget.productModel!);
|
||||
setState(() {
|
||||
// Update the local quantity to reflect the change
|
||||
currentQuantity = _cartController
|
||||
.cartList
|
||||
.firstWhere((p) =>
|
||||
p.id ==
|
||||
widget.productModel!.id)
|
||||
.firstWhere((p) => p.id == widget.productModel!.id)
|
||||
.quantity;
|
||||
});
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(8.0),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
@ -199,13 +197,14 @@ class _ProductCardState extends State<ProductCard> {
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.0,),
|
||||
SizedBox(
|
||||
width: 20.0,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_cartController.removeFromCart(widget.productModel!);
|
||||
showSnackbar("Product removed successfully!");
|
||||
showSnackbar("Product has been removed successfully!");
|
||||
setState(() {
|
||||
// Update the local quantity
|
||||
currentQuantity = 1;
|
||||
});
|
||||
},
|
||||
@ -222,14 +221,16 @@ class _ProductCardState extends State<ProductCard> {
|
||||
showSnackbar("Product already added to cart");
|
||||
} else {
|
||||
_cartController.addToCart(widget.productModel!);
|
||||
showSnackbar("Product added to cart successfully");
|
||||
showSnackbar("Product successfully added to your cart");
|
||||
// setState(() {
|
||||
// currentQuantity = widget.productModel!.quantity;
|
||||
// });
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: Colors.white,
|
||||
backgroundColor: const Color(0xFF00784C),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 18, vertical: 8),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 8),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
|
@ -176,6 +176,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.2"
|
||||
intl:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: intl
|
||||
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.19.0"
|
||||
leak_tracker:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -43,6 +43,7 @@ dependencies:
|
||||
shared_preferences: ^2.2.3
|
||||
logger: ^2.4.0
|
||||
get_storage: ^2.1.1
|
||||
intl: ^0.19.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
Loading…
Reference in New Issue
Block a user