Announcement api integrated

This commit is contained in:
Vaibhav 2024-10-16 19:04:06 +05:30
parent 2f461768fb
commit 09193d7423
13 changed files with 384 additions and 1299 deletions

View File

@ -5,27 +5,59 @@ import '../utils/api_urls.dart';
class AnnouncementController extends GetxController { class AnnouncementController extends GetxController {
final ApiService _apiClient = ApiService(); final ApiService _apiClient = ApiService();
RxList<AnnouncementResponse> announcementsList = <AnnouncementResponse>[].obs; RxList<Announcements> announcementsList = <Announcements>[].obs;
RxBool isLoading = false.obs; RxBool isLoading = false.obs;
RxBool hasMoreData = true.obs; // To check if there are more pages to load
RxInt currentPage = 1.obs; // To track the current page
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
getAnnouncements(); getAnnouncements(); // Fetch announcements when the controller initializes
} }
Future<void> getAnnouncements() async { Future<void> getAnnouncements({int page = 1, int rowsPerPage = 5}) async {
isLoading.value = true; if (!hasMoreData.value) return; // Return if no more data is available
isLoading.value = true; // Set loading to true while fetching
try { try {
final response = await _apiClient.get(ApiUrls.announcementUrl); final response = await _apiClient.get(
isLoading.value = false; "${ApiUrls.announcementUrl}?page=$page&rowsPerPage=$rowsPerPage",
);
if (response.statusCode == 200) { if (response.statusCode == 200) {
final List<dynamic> data = response.data; final List<dynamic> data = response.data['announcements'];
announcementsList.value = data.map((item) => AnnouncementResponse.fromJson(item)).toList(); AnnouncementResponse res=AnnouncementResponse.fromJson(response.data);
// If the fetched data length is less than rowsPerPage, it means no more data
if (data.length < rowsPerPage) {
hasMoreData.value = false;
}
final newAnnouncements = data.map((item) => AnnouncementResponse.fromJson(item)).toList();
// If it's the first page, replace the list; else append to the existing list
if (page == 1) {
announcementsList.value =res.announcements??[];
} else {
announcementsList.addAll(res.announcements??[]);
}
// Update the current page
currentPage.value = page;
} else {
Get.snackbar('Error', 'Failed to fetch announcements: ${response.statusCode} - ${response.statusMessage}');
} }
} catch (e) { } catch (e) {
isLoading.value = false; Get.snackbar('Error', 'Failed to fetch announcements: $e');
Get.snackbar('Error', 'Failed to fetch announcements'); } finally {
isLoading.value = false; // Ensure loading is set to false in the finally block
}
}
void loadMoreAnnouncements() {
if (hasMoreData.value) {
getAnnouncements(page: currentPage.value + 1); // Load the next page
} }
} }
} }

View File

@ -1,43 +1,67 @@
class AnnouncementResponse { class AnnouncementResponse {
String? id; List<Announcements>? announcements;
String? uniqueId; int? totalAnnouncements;
AnnouncementResponse({this.announcements, this.totalAnnouncements});
AnnouncementResponse.fromJson(Map<String, dynamic> json) {
if (json['announcements'] != null) {
announcements = <Announcements>[];
json['announcements'].forEach((v) {
announcements!.add(new Announcements.fromJson(v));
});
}
totalAnnouncements = json['totalAnnouncements'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.announcements != null) {
data['announcements'] =
this.announcements!.map((v) => v.toJson()).toList();
}
data['totalAnnouncements'] = this.totalAnnouncements;
return data;
}
}
class Announcements {
String? sId;
List<String>? sentTo; List<String>? sentTo;
String? message; String? message;
DateTime? createdAt; String? createdAt;
DateTime? updatedAt; String? updatedAt;
int? v; String? uniqueId;
int? iV;
AnnouncementResponse({ Announcements(
this.id, {this.sId,
this.uniqueId,
this.sentTo, this.sentTo,
this.message, this.message,
this.createdAt, this.createdAt,
this.updatedAt, this.updatedAt,
this.v, this.uniqueId,
}); this.iV});
factory AnnouncementResponse.fromJson(Map<String, dynamic> json) { Announcements.fromJson(Map<String, dynamic> json) {
return AnnouncementResponse( sId = json['_id'];
id: json['_id'], sentTo = json['sentTo'].cast<String>();
uniqueId: json['uniqueId'], message = json['message'];
sentTo: json['sentTo'] != null ? List<String>.from(json['sentTo']) : null, createdAt = json['createdAt'];
message: json['message'], updatedAt = json['updatedAt'];
createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt']) : null, uniqueId = json['uniqueId'];
updatedAt: json['updatedAt'] != null ? DateTime.parse(json['updatedAt']) : null, iV = json['__v'];
v: json['__v'],
);
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { final Map<String, dynamic> data = new Map<String, dynamic>();
'_id': id, data['_id'] = this.sId;
'uniqueId': uniqueId, data['sentTo'] = this.sentTo;
'sentTo': sentTo, data['message'] = this.message;
'message': message, data['createdAt'] = this.createdAt;
'createdAt': createdAt?.toIso8601String(), data['updatedAt'] = this.updatedAt;
'updatedAt': updatedAt?.toIso8601String(), data['uniqueId'] = this.uniqueId;
'__v': v, data['__v'] = this.iV;
}; return data;
} }
} }

View File

@ -7,7 +7,6 @@ import '../../controller/announcement_controller.dart';
import '../../models/announcement_response.dart'; import '../../models/announcement_response.dart';
import '../../widgets/comman_background.dart'; import '../../widgets/comman_background.dart';
import '../../widgets/common_appbar.dart'; import '../../widgets/common_appbar.dart';
import '../../widgets/common_elevated_button.dart';
class AnnouncementScreen extends StatelessWidget { class AnnouncementScreen extends StatelessWidget {
final AnnouncementController controller = Get.put(AnnouncementController()); final AnnouncementController controller = Get.put(AnnouncementController());
@ -38,51 +37,51 @@ class AnnouncementScreen extends StatelessWidget {
drawer: const MyDrawer(), drawer: const MyDrawer(),
body: Obx(() => controller.isLoading.value body: Obx(() => controller.isLoading.value
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())
: MyListView(announcementList: controller.announcementsList)), : NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification scrollInfo) {
// Load more announcements when reaching the bottom of the list
if (!controller.isLoading.value &&
scrollInfo.metrics.pixels == scrollInfo.metrics.maxScrollExtent) {
controller.loadMoreAnnouncements();
}
return true;
},
child: MyListView(announcementList: controller.announcementsList),
)),
), ),
); );
} }
} }
Widget buildProductButton(String productName) {
return Padding(
padding: const EdgeInsets.only(bottom: 15),
child: CommonElevatedButton(
borderRadius: 30,
width: double.infinity,
height: kToolbarHeight - 10,
text: productName,
backgroundColor: const Color(0xff004791),
onPressed: () {
debugPrint('$productName pressed');
},
),
);
}
class MyListView extends StatelessWidget { class MyListView extends StatelessWidget {
final List<AnnouncementResponse> announcementList; final List<Announcements> announcementList;
const MyListView({super.key, required this.announcementList}); const MyListView({super.key, required this.announcementList});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Map<String, List<AnnouncementResponse>> groupedAnnouncements = {}; Map<DateTime, List<Announcements>> groupedAnnouncements = {};
for (var announcement in announcementList) { for (var announcement in announcementList) {
String date = DateFormat("dd MMM yyyy").format(announcement.createdAt ?? DateTime.now()); DateTime date = DateUtils.dateOnly(
DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(announcement.createdAt!));
if (!groupedAnnouncements.containsKey(date)) { if (!groupedAnnouncements.containsKey(date)) {
groupedAnnouncements[date] = []; groupedAnnouncements[date] = [];
} }
groupedAnnouncements[date]!.add(announcement); groupedAnnouncements[date]!.add(announcement);
} }
// Sort the dates in descending order (latest first)
List<DateTime> sortedDates = groupedAnnouncements.keys.toList()
..sort((a, b) => b.compareTo(a));
return ListView.builder( return ListView.builder(
padding: const EdgeInsets.only(top: 15), padding: const EdgeInsets.only(top: 15),
itemCount: groupedAnnouncements.length, itemCount: sortedDates.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
String date = groupedAnnouncements.keys.elementAt(index); DateTime date = sortedDates[index];
List<AnnouncementResponse> announcementsForDate = groupedAnnouncements[date]!; String formattedDate = DateFormat("dd MMM yyyy").format(date);
List<Announcements> announcementsForDate = groupedAnnouncements[date]!;
return Padding( return Padding(
padding: const EdgeInsets.only(bottom: 10, left: 10, right: 10), padding: const EdgeInsets.only(bottom: 10, left: 10, right: 10),
@ -92,7 +91,7 @@ class MyListView extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.only(bottom: 8.0), padding: const EdgeInsets.only(bottom: 8.0),
child: Text( child: Text(
date, formattedDate,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
), ),
), ),

View File

@ -76,7 +76,7 @@ class _HomeScreenState extends State<HomeScreen> {
// SafeArea widget to ensure the content is placed within safe boundaries. // SafeArea widget to ensure the content is placed within safe boundaries.
SafeArea( SafeArea(
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(10.0),
// SingleChildScrollView allows scrolling if the content is larger than the screen. // SingleChildScrollView allows scrolling if the content is larger than the screen.
child: SingleChildScrollView( child: SingleChildScrollView(
@ -98,10 +98,10 @@ class _HomeScreenState extends State<HomeScreen> {
// HomeCard widget with the title and navigation to the Order Tracking screen. // HomeCard widget with the title and navigation to the Order Tracking screen.
HomeCard( HomeCard(
title: 'Order Tracking', title: 'Order Management',
onTap: () => Get.to( onTap: () => Get.to(
() => () =>
const OrderTrackingScreen(), // Navigates to OrderTrackingScreen using GetX. OrderManagementScreen(), // Navigates to OrderManagementScreen.
), ),
), ),
], ],
@ -114,13 +114,6 @@ class _HomeScreenState extends State<HomeScreen> {
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
HomeCard(
title: 'Order Management',
onTap: () => Get.to(
() =>
OrderManagementScreen(), // Navigates to OrderManagementScreen.
),
),
HomeCard( HomeCard(
title: 'Inventory Management', title: 'Inventory Management',
onTap: () => Get.to( onTap: () => Get.to(
@ -128,13 +121,9 @@ class _HomeScreenState extends State<HomeScreen> {
const InventoryManagementScreen(), // Navigates to InventoryManagementScreen. const InventoryManagementScreen(), // Navigates to InventoryManagementScreen.
), ),
), ),
// HomeCard( HomeCard(
// title: 'Shipping Management', title: 'Notifications',
// onTap: () => Get.to( onTap: () => Get.to(() => NotificationScreen()))
// () =>
// const ShippingManagementScreen(), // Navigates to ShippingManagementScreen.
// ),
// ),
], ],
), ),
@ -144,9 +133,6 @@ class _HomeScreenState extends State<HomeScreen> {
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
HomeCard(
title: 'Notifications',
onTap: () => Get.to(() => NotificationScreen())),
HomeCard( HomeCard(
title: 'Announcement', title: 'Announcement',
onTap: () => Get.to( onTap: () => Get.to(

View File

@ -74,7 +74,7 @@ class _InventoryManagementScreenState extends State<InventoryManagementScreen> {
SafeArea( SafeArea(
child: Column( child: Column(
children: [ children: [
SizedBox(height: Get.height * 0.02), SizedBox(height: Get.height * 0.01), // Reduced top spacing
Card( Card(
margin: const EdgeInsets.symmetric(horizontal: 18), margin: const EdgeInsets.symmetric(horizontal: 18),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
@ -109,7 +109,7 @@ class _InventoryManagementScreenState extends State<InventoryManagementScreen> {
), ),
), ),
SizedBox( SizedBox(
height: Get.height * 0.6, height: Get.height * 0.75, // Increased height here
child: FutureBuilder<InventoryManagementResponse>( child: FutureBuilder<InventoryManagementResponse>(
future: _productsFuture, future: _productsFuture,
builder: (context, snapshot) { builder: (context, snapshot) {

View File

@ -126,7 +126,7 @@ class _InventoryProductDetailScreenState
padding: padding:
const EdgeInsets.fromLTRB(8, 8, 8, 8), const EdgeInsets.fromLTRB(8, 8, 8, 8),
child: Text( child: Text(
"Descrition: ${widget.product.description}", "Product id: ${widget.product.sId}",
style: GoogleFonts.roboto( style: GoogleFonts.roboto(
fontSize: Get.width * 0.04, fontSize: Get.width * 0.04,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
@ -168,27 +168,14 @@ class _InventoryProductDetailScreenState
), ),
), ),
), ),
SizedBox( SizedBox(
width: Get.width, width: Get.width,
child: Padding( child: Padding(
padding: padding:
const EdgeInsets.fromLTRB(8, 8, 8, 0), const EdgeInsets.fromLTRB(8, 8, 8, 0),
child: Text( child: Text(
"Minimum Stock Level: 20", "Last Restock Date: ${widget.product.updatedAt}",
style: GoogleFonts.roboto(
fontSize: Get.width * 0.04,
fontWeight: FontWeight.w400,
),
),
),
),
SizedBox(
width: Get.width,
child: Padding(
padding:
const EdgeInsets.fromLTRB(8, 8, 8, 0),
child: Text(
"Last Restock Date: MM/DD/YYYY",
style: GoogleFonts.roboto( style: GoogleFonts.roboto(
fontSize: Get.width * 0.04, fontSize: Get.width * 0.04,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
@ -202,7 +189,7 @@ class _InventoryProductDetailScreenState
padding: padding:
const EdgeInsets.fromLTRB(8, 8, 8, 8), const EdgeInsets.fromLTRB(8, 8, 8, 8),
child: Text( child: Text(
"Supplier: ABC Supplier", "Supplier: ${widget.product.addedBy}",
style: GoogleFonts.roboto( style: GoogleFonts.roboto(
fontSize: Get.width * 0.04, fontSize: Get.width * 0.04,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,

View File

@ -1,13 +1,12 @@
import 'package:cheminova/models/place_order_list_model.dart'; import 'package:cheminova/models/place_order_list_model.dart';
import 'package:cheminova/screens/order_management/order_management_detail_screen.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:cheminova/widgets/my_drawer.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import '../../controller/cart_controller.dart'; import '../../controller/cart_controller.dart';
import '../../controller/get_order_placed_controller.dart'; import '../../controller/get_order_placed_controller.dart';
import '../../models/product_model1.dart'; import '../../models/product_model1.dart';
@ -23,9 +22,6 @@ class OrderManagementScreen extends StatefulWidget {
} }
class _OrderManagementScreenState extends State<OrderManagementScreen> { class _OrderManagementScreenState extends State<OrderManagementScreen> {
final _searchController = TextEditingController();
final List<String> _filterList = ["Order Status", "Date Range"];
final GetPlacedOrderController _getPlacedOrderController = final GetPlacedOrderController _getPlacedOrderController =
Get.put(GetPlacedOrderController()); Get.put(GetPlacedOrderController());
final CartController _cartController = Get.put(CartController()); final CartController _cartController = Get.put(CartController());
@ -45,8 +41,10 @@ class _OrderManagementScreenState extends State<OrderManagementScreen> {
Future<void> getOrder1() async { Future<void> getOrder1() async {
await _getPlacedOrderController.getOrders(); await _getPlacedOrderController.getOrders();
if (kDebugMode) {
print("Order fetched successfully"); print("Order fetched successfully");
} }
}
String capitalizeFirstLetter(String text) { String capitalizeFirstLetter(String text) {
if (text.isEmpty) return text; if (text.isEmpty) return text;
@ -97,26 +95,11 @@ class _OrderManagementScreenState extends State<OrderManagementScreen> {
children: [ children: [
Image.asset('assets/images/image_1.png', fit: BoxFit.cover), Image.asset('assets/images/image_1.png', fit: BoxFit.cover),
SafeArea( SafeArea(
child: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom),
child: RefreshIndicator(
key: _refreshIndicatorKey,
onRefresh: _onRefresh,
color: Colors.black,
backgroundColor: Colors.white,
child: Column( child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
InputField( SizedBox(height: Get.height * 0.02),
hintText: "Search Order", Expanded(
labelText: "Search Order", child: Card(
controller: _searchController,
),
SizedBox(height: Get.height * 0.035),
Card(
margin: const EdgeInsets.symmetric(horizontal: 18), margin: const EdgeInsets.symmetric(horizontal: 18),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(19), borderRadius: BorderRadius.circular(19),
@ -126,33 +109,27 @@ class _OrderManagementScreenState extends State<OrderManagementScreen> {
child: Padding( child: Padding(
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min,
children: [ children: [
Obx( Obx(
() => Container( () => Container(
height: Get.height * 0.05, height: Get.height * 0.05,
padding: const EdgeInsets.all(8), padding: const EdgeInsets.symmetric(horizontal: 12),
margin: const EdgeInsets.only(bottom: 8), margin: const EdgeInsets.only(bottom: 8),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: borderRadius: BorderRadius.circular(5),
BorderRadius.circular(5)), ),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>( child: DropdownButton<String>(
value: _getPlacedOrderController isExpanded: true,
.productStatus.value, value: _getPlacedOrderController.productStatus.value,
onChanged: (dynamic newValue) { onChanged: (newValue) {
if (newValue != null) { if (newValue != null) {
_getPlacedOrderController _getPlacedOrderController.updateProductStatus(newValue);
.updateProductStatus(newValue);
} }
}, },
items: <String>[ items: <String>['All', 'Delivered', 'Processing', 'Cancelled']
'All', .map<DropdownMenuItem<String>>((String value) {
'Delivered',
'Processing',
'Cancelled'
].map<DropdownMenuItem<String>>(
(String value) {
return DropdownMenuItem<String>( return DropdownMenuItem<String>(
value: value, value: value,
child: Text(value), child: Text(value),
@ -161,195 +138,61 @@ class _OrderManagementScreenState extends State<OrderManagementScreen> {
), ),
), ),
), ),
SizedBox( ),
height: Get.height * 0.6, Expanded(
child: RefreshIndicator(
key: _refreshIndicatorKey,
onRefresh: _onRefresh,
color: Colors.black,
backgroundColor: Colors.white,
child: Obx(() { child: Obx(() {
// Use a set to keep track of unique order IDs
final Set<String> uniqueOrderIds = {}; final Set<String> uniqueOrderIds = {};
final List<PlacedOrderList> uniqueOrders = final List<PlacedOrderList> uniqueOrders = [];
[];
final orders = _getPlacedOrderController final orders = _getPlacedOrderController.filterOrder.isNotEmpty
.filterOrder.isNotEmpty ? _getPlacedOrderController.filterOrder
? _getPlacedOrderController : _getPlacedOrderController.placedOrders;
.filterOrder
: _getPlacedOrderController
.placedOrders;
for (var order in orders) { for (var order in orders) {
if (uniqueOrderIds if (uniqueOrderIds.add(order.sId ?? '')) {
.add(order.sId ?? '')) {
uniqueOrders.add(order); uniqueOrders.add(order);
} }
} }
return ListView.builder( return ListView.builder(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
shrinkWrap: true,
itemCount: uniqueOrders.length, itemCount: uniqueOrders.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final order = uniqueOrders[index]; final order = uniqueOrders[index];
// Combine product names into a single string
final productNames = order.orderItem! final productNames = order.orderItem!
.map((item) => .map((item) => capitalizeFirstLetter(item.name ?? ''))
capitalizeFirstLetter(
item.name ?? ''))
.join(', '); .join(', ');
return Padding( return Card(
padding: const EdgeInsets.symmetric( margin: const EdgeInsets.symmetric(vertical: 8),
vertical: 8),
child: Card(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Padding(
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.uniqueId}")
],
),
),
Padding(
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.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, 8),
child: Row(
mainAxisAlignment:
MainAxisAlignment
.start,
children: [
Text("Status: ",
style: GoogleFonts.roboto(
fontSize: 14,
fontWeight:
FontWeight
.bold)),
Text(capitalizeFirstLetter(
"${order.status}"))
],
),
),
SizedBox(
width: Get.width * 0.4,
child: Padding( child: Padding(
padding: padding: const EdgeInsets.all(16),
const EdgeInsets.all( child: Column(
8.0), crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildInfoRow("Order ID:", "${order.uniqueId}"),
const SizedBox(height: 8),
_buildInfoRow("Product Names:", productNames),
const SizedBox(height: 8),
_buildInfoRow("Order Date:", formatDate("${order.createdAt}")),
const SizedBox(height: 8),
_buildInfoRow("Status:", capitalizeFirstLetter("${order.status}")),
const SizedBox(height: 16),
Center(
child: ElevatedButton( child: ElevatedButton(
onPressed: () => Get.to(() => onPressed: () => Get.to(() => OrderManagementDetailScreen(placedOrderList: uniqueOrders[index])),
OrderManagementDetailScreen( style: ElevatedButton.styleFrom(
placedOrderList: foregroundColor: Colors.white,
uniqueOrders[ backgroundColor: const Color(0xFF004791),
index])), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
style: ElevatedButton minimumSize: Size(Get.width * 0.4, 40),
.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)),
), ),
child: Text("View Details", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.w400)),
), ),
) )
], ],
@ -359,9 +202,6 @@ class _OrderManagementScreenState extends State<OrderManagementScreen> {
}, },
); );
}), }),
)
],
),
), ),
), ),
], ],
@ -369,6 +209,9 @@ class _OrderManagementScreenState extends State<OrderManagementScreen> {
), ),
), ),
), ),
SizedBox(height: Get.height * 0.02),
],
),
), ),
], ],
), ),
@ -389,245 +232,23 @@ class _OrderManagementScreenState extends State<OrderManagementScreen> {
], ],
); );
} }
}
// import 'package:cheminova/controller/get_place_order_service.dart'; Widget _buildInfoRow(String label, String value) {
// import 'package:cheminova/controller/place_order_controller.dart'; return Row(
// import 'package:cheminova/models/place_order_list_model.dart'; crossAxisAlignment: CrossAxisAlignment.start,
// import 'package:cheminova/screens/order_management/order_management_detail_screen.dart'; children: [
// import 'package:cheminova/widgets/input_field.dart'; Text(
// import 'package:cheminova/widgets/my_drawer.dart'; label,
// import 'package:flutter/material.dart'; style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.bold),
// import 'package:flutter_svg/svg.dart'; ),
// import 'package:get/get.dart'; const SizedBox(width: 4),
// import 'package:google_fonts/google_fonts.dart'; Expanded(
// import 'package:intl/intl.dart'; child: Text(
// value,
// import '../../controller/cart_controller.dart'; style: GoogleFonts.roboto(fontSize: 14),
// 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)),
// ),
// ),
// )
// ],
// ),
// ),
// );
// },
// );
// }),
// )
// ],
// ),
// ),
// ),
// ],
// ),
// ),
// ),
// ),
// ],
// ),
// );
// }
// }
//

View File

@ -9,7 +9,6 @@ import '../../widgets/my_drawer.dart';
import '../../widgets/product_card.dart'; import '../../widgets/product_card.dart';
import '../../controller/product_service.dart'; import '../../controller/product_service.dart';
// ProductCatalogScreen displays a catalog of products that users can browse and filter.
class ProductCatalogScreen extends StatefulWidget { class ProductCatalogScreen extends StatefulWidget {
const ProductCatalogScreen({super.key}); const ProductCatalogScreen({super.key});
@ -18,28 +17,29 @@ class ProductCatalogScreen extends StatefulWidget {
} }
class _ProductCatalogScreenState extends State<ProductCatalogScreen> { class _ProductCatalogScreenState extends State<ProductCatalogScreen> {
final ProductService _productService = ProductService(); // Service to fetch product data. final ProductService _productService = ProductService();
final ScrollController _scrollController = ScrollController(); // Controller for scroll events. final ScrollController _scrollController = ScrollController();
final CartController cartController = Get.put(CartController()); // Cart controller for managing cart state. final CartController cartController = Get.put(CartController());
List<Product> _products = []; // List to hold the fetched products. List<Product> _allProducts = []; // Store all fetched products
List<Map<String, dynamic>> _categories = []; // List to hold product categories. List<Product> _filteredProducts = []; // Store filtered products for display
List<Map<String, dynamic>> _categories = [];
int _currentPage = 1; // Tracks the current page of products being fetched. int _currentPage = 1;
bool _isLoading = false; // Indicates if data is being loaded. bool _isLoading = false;
bool _hasMoreData = true; // Indicates if more data can be fetched. bool _hasMoreData = true;
String? _selectedCategory; // Tracks the currently selected category for filtering. String? _selectedCategory;
String? _selectedPriceRange; // Placeholder for selected price range filtering. String? _selectedPriceRange;
String? _selectedAvailability; // Placeholder for selected availability filtering. String? _selectedAvailability;
String _searchQuery = ''; // New variable to store search query
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_fetchCategories(); // Fetch categories on initialization. _fetchCategories();
_fetchProducts(); // Fetch initial products. _fetchProducts();
// Add listener to fetch more products when reaching the bottom of the scroll view.
_scrollController.addListener(() { _scrollController.addListener(() {
if (_scrollController.position.pixels == if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent && _scrollController.position.maxScrollExtent &&
@ -49,76 +49,85 @@ class _ProductCatalogScreenState extends State<ProductCatalogScreen> {
}); });
} }
// Fetch products from the server.
Future<void> _fetchProducts() async { Future<void> _fetchProducts() async {
setState(() { setState(() {
_isLoading = true; // Set loading to true while fetching data. _isLoading = true;
}); });
final category = _selectedCategory == 'All' ? null : _selectedCategory; // Adjust category filter. final category = _selectedCategory == 'All' ? null : _selectedCategory;
// Get products using the product service.
final products = await _productService.getProduct( final products = await _productService.getProduct(
_currentPage, category: category); _currentPage, category: category);
setState(() { setState(() {
if (products != null) { if (products != null) {
_products.addAll(products); // Append fetched products to the list. _allProducts.addAll(products);
_hasMoreData = products.isNotEmpty; // Update the flag for more data availability. _hasMoreData = products.isNotEmpty;
} }
_isLoading = false; // Set loading to false after fetching data. _isLoading = false;
_applyFilters(); // Apply filters after fetching products
}); });
} }
// Fetch available product categories.
Future<void> _fetchCategories() async { Future<void> _fetchCategories() async {
final categories = await _productService.getCategory(); // Fetch categories. final categories = await _productService.getCategory();
if (categories != null) { if (categories != null) {
setState(() { setState(() {
_categories = categories; // Set the fetched categories. _categories = categories;
_categories.insert(1, {'categoryName': 'All'}); // Add 'All' category option. _categories.insert(1, {'categoryName': 'All'});
_selectedCategory = 'All'; // Default selected category. _selectedCategory = 'All';
}); });
} }
} }
// Handle category changes when the user selects a new category.
void _onCategoryChanged(String? newCategory) { void _onCategoryChanged(String? newCategory) {
if (newCategory != null) { if (newCategory != null) {
setState(() { setState(() {
_selectedCategory = newCategory; // Update selected category. _selectedCategory = newCategory;
_products.clear(); // Clear current product list for new fetch. _allProducts.clear();
_currentPage = 1; // Reset page counter. _filteredProducts.clear();
_currentPage = 1;
}); });
_fetchProducts(); // Fetch products for the selected category. _fetchProducts();
} }
} }
// Fetch additional products when scrolling to the bottom.
Future<void> _fetchMoreProducts() async { Future<void> _fetchMoreProducts() async {
if (!_isLoading && _hasMoreData) { // Ensure not already loading and more data is available. if (!_isLoading && _hasMoreData) {
setState(() { setState(() {
_isLoading = true; // Set loading to true while fetching more products. _isLoading = true;
_currentPage++; // Increment the page number for next fetch. _currentPage++;
}); });
await _fetchProducts(); // Fetch more products. await _fetchProducts();
} }
} }
// Clear all filters and reset the product list.
void _clearFilters() { void _clearFilters() {
setState(() { setState(() {
_selectedCategory = null; // Reset category filter. _selectedCategory = null;
_selectedPriceRange = null; // Reset price range filter. _selectedPriceRange = null;
_selectedAvailability = null; // Reset availability filter. _selectedAvailability = null;
_products.clear(); // Clear current product list. _searchQuery = '';
_currentPage = 1; // Reset page counter. _allProducts.clear();
_filteredProducts.clear();
_currentPage = 1;
});
_fetchProducts();
}
// New method to apply filters and search
void _applyFilters() {
setState(() {
_filteredProducts = _allProducts.where((product) {
final nameMatch = product.name.toLowerCase().contains(_searchQuery.toLowerCase());
final skuMatch = product.sku.toLowerCase().contains(_searchQuery.toLowerCase());
return nameMatch || skuMatch;
}).toList();
}); });
_fetchProducts(); // Fetch products without filters.
} }
@override @override
void dispose() { void dispose() {
_scrollController.dispose(); // Dispose of the scroll controller when done. _scrollController.dispose();
super.dispose(); super.dispose();
} }
@ -127,31 +136,29 @@ class _ProductCatalogScreenState extends State<ProductCatalogScreen> {
return Scaffold( return Scaffold(
extendBodyBehindAppBar: true, extendBodyBehindAppBar: true,
appBar: AppBar( appBar: AppBar(
backgroundColor: Colors.transparent, // Make the AppBar transparent. backgroundColor: Colors.transparent,
elevation: 0, // No shadow for the AppBar. elevation: 0,
leading: Builder( leading: Builder(
builder: (context) { builder: (context) {
return GestureDetector( return GestureDetector(
onTap: () => Scaffold.of(context).openDrawer(), // Open drawer on tap. onTap: () => Scaffold.of(context).openDrawer(),
child: Padding( child: Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: SvgPicture.asset( child: SvgPicture.asset(
'assets/svg/menu.svg', // Menu icon. 'assets/svg/menu.svg',
), ),
), ),
); );
}, },
), ),
actions: [ actions: [
// Cart icon with count indicator.
GestureDetector( GestureDetector(
onTap: () => Get.to(CartScreen()), // Navigate to cart on tap. onTap: () => Get.to(CartScreen()),
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Stack( child: Stack(
children: [ children: [
const Icon(Icons.shopping_cart, size: 30,), // Shopping cart icon. const Icon(Icons.shopping_cart, size: 30,),
// Cart count display
Positioned( Positioned(
right: 0, right: 0,
child: Obx(() => child: Obx(() =>
@ -163,14 +170,14 @@ class _ProductCatalogScreenState extends State<ProductCatalogScreen> {
shape: BoxShape.circle, shape: BoxShape.circle,
), ),
child: Text( child: Text(
'${cartController.cartCount.value}', // Display number of items in cart. '${cartController.cartCount.value}',
style: const TextStyle( style: const TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 12, fontSize: 12,
), ),
), ),
) )
: const SizedBox.shrink()), // Hide if cart is empty. : const SizedBox.shrink()),
), ),
], ],
), ),
@ -179,15 +186,14 @@ class _ProductCatalogScreenState extends State<ProductCatalogScreen> {
], ],
title: const Center( title: const Center(
child: Text( child: Text(
"Product Catalogue", // Title of the screen. "Product Catalogue",
), ),
), ),
), ),
drawer: const MyDrawer(), // Navigation drawer. drawer: const MyDrawer(),
body: Stack( body: Stack(
fit: StackFit.expand, fit: StackFit.expand,
children: [ children: [
// Background image for the screen.
Image.asset( Image.asset(
'assets/images/image_1.png', 'assets/images/image_1.png',
fit: BoxFit.cover, fit: BoxFit.cover,
@ -196,25 +202,30 @@ class _ProductCatalogScreenState extends State<ProductCatalogScreen> {
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
SizedBox(height: Get.height * 0.02), // Spacing. SizedBox(height: Get.height * 0.02),
// Search bar for products. // Updated search bar with onChanged callback
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 18.0), padding: const EdgeInsets.symmetric(horizontal: 18.0),
child: TextField( child: TextField(
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Search Products", // Placeholder for search. hintText: "Search Products",
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(15),
), ),
filled: true, filled: true,
fillColor: Colors.white.withOpacity(0.9), fillColor: Colors.white.withOpacity(0.9),
), ),
onChanged: (value) {
setState(() {
_searchQuery = value;
_applyFilters();
});
},
), ),
), ),
SizedBox(height: Get.height * 0.02), // Spacing. SizedBox(height: Get.height * 0.02),
// Card for filters and product listing.
Card( Card(
margin: const EdgeInsets.symmetric(horizontal: 18), margin: const EdgeInsets.symmetric(horizontal: 18),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
@ -227,22 +238,20 @@ class _ProductCatalogScreenState extends State<ProductCatalogScreen> {
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
// Filter section header.
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
"Filter", // Filter title. "Filter",
style: GoogleFonts.poppins( style: GoogleFonts.poppins(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 16, fontSize: 16,
), ),
), ),
// Button to clear filters.
TextButton( TextButton(
onPressed: _clearFilters, onPressed: _clearFilters,
child: Text( child: Text(
"Clear Filter", // Clear filters button text. "Clear Filter",
style: GoogleFonts.poppins( style: GoogleFonts.poppins(
color: Colors.red, color: Colors.red,
fontSize: 14, fontSize: 14,
@ -252,36 +261,33 @@ class _ProductCatalogScreenState extends State<ProductCatalogScreen> {
], ],
), ),
// Dropdowns for filtering options.
SizedBox( SizedBox(
height: Get.height * 0.05, height: Get.height * 0.05,
child: ListView.builder( child: ListView.builder(
shrinkWrap: true, shrinkWrap: true,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: 3, // Number of filters (categories, etc.). itemCount: 3,
itemBuilder: (context, index) => itemBuilder: (context, index) =>
_buildFilterDropdown(index), // Build filter dropdowns. _buildFilterDropdown(index),
), ),
), ),
// List of products. // Updated to use _filteredProducts
SizedBox( SizedBox(
height: Get.height * 0.6, height: Get.height * 0.6,
child: ListView.builder( child: ListView.builder(
controller: _scrollController, // Attach scroll controller. controller: _scrollController,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
itemCount: _products.length + (_isLoading ? 1 : 0), // Show loading indicator if more products are being fetched. itemCount: _filteredProducts.length + (_isLoading ? 1 : 0),
itemBuilder: (context, index) { itemBuilder: (context, index) {
if (index >= _products.length) { if (index >= _filteredProducts.length) {
print("Product length $_products");
return const Center( return const Center(
child: CircularProgressIndicator()); // Show loading indicator. child: CircularProgressIndicator());
} }
// Display each product card.
return Padding( return Padding(
padding: const EdgeInsets.symmetric(vertical: 8), padding: const EdgeInsets.symmetric(vertical: 8),
child: ProductCard( child: ProductCard(
productModel: _products[index], // Use ProductModel here. productModel: _filteredProducts[index],
), ),
); );
}, },
@ -300,7 +306,6 @@ class _ProductCatalogScreenState extends State<ProductCatalogScreen> {
); );
} }
// Build a dropdown for filtering based on the index.
Widget _buildFilterDropdown(int index) { Widget _buildFilterDropdown(int index) {
switch (index) { switch (index) {
case 0: case 0:
@ -313,14 +318,13 @@ class _ProductCatalogScreenState extends State<ProductCatalogScreen> {
child: Text(category['categoryName']), child: Text(category['categoryName']),
); );
}).toList(), }).toList(),
hint: "Category", // Dropdown hint for category selection. hint: "Category",
); );
default: default:
return const SizedBox(); // Return empty widget for unsupported indices. return const SizedBox();
} }
} }
// Build a styled dropdown widget.
Widget _buildStyledDropdown({ Widget _buildStyledDropdown({
required String? value, required String? value,
required ValueChanged<String?> onChanged, required ValueChanged<String?> onChanged,
@ -340,7 +344,7 @@ class _ProductCatalogScreenState extends State<ProductCatalogScreen> {
onChanged: onChanged, onChanged: onChanged,
items: items, items: items,
hint: Text(hint), hint: Text(hint),
icon: const Icon(Icons.arrow_drop_down), // Dropdown arrow icon. icon: const Icon(Icons.arrow_drop_down),
), ),
), ),
); );

View File

@ -1,183 +0,0 @@
import 'package:cheminova/screens/report/sales_data_screen.dart';
import 'package:cheminova/widgets/input_field.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
class ReportingAnalyticsScreen extends StatefulWidget {
const ReportingAnalyticsScreen({super.key});
@override
State<ReportingAnalyticsScreen> createState() =>
_ReportingAnalyticsScreenState();
}
class _ReportingAnalyticsScreenState extends State<ReportingAnalyticsScreen> {
final _searchController = TextEditingController();
final List<String> _filterList = [
"Report Type",
"Date Range",
];
@override
Widget build(BuildContext context) {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.transparent,
elevation: 0,
leading: GestureDetector(
onTap: () {},
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(
"Reporting & Analytics",
),
),
body: Stack(
fit: StackFit.expand,
children: [
Image.asset(
'assets/images/image_1.png',
fit: BoxFit.cover,
),
SafeArea(
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: ListView.builder(
padding: EdgeInsets.zero,
shrinkWrap: true,
itemCount: 2,
itemBuilder: (context, index) => 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: Text(
"Report Title: Sales Data Report",
style: GoogleFonts.roboto(
fontSize: 14,
fontWeight: FontWeight.w400,
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(
16, 8, 8, 8),
child: Text(
"Description: Overview of sales data",
style: GoogleFonts.roboto(
fontSize: 14,
fontWeight: FontWeight.w400,
),
),
),
SizedBox(
width: Get.width * 0.5,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
onPressed: () => Get.to(
() => const SalesDataScreen(),
),
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor:
const Color(0xFF004791),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10),
),
),
child: Text(
"Generate Report",
style: GoogleFonts.roboto(
fontSize: 14,
fontWeight: FontWeight.w400,
),
),
),
),
)
],
),
),
),
),
)
],
),
),
),
],
),
),
],
),
);
}
}

View File

@ -1,190 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
class SalesDataScreen extends StatefulWidget {
const SalesDataScreen({super.key});
@override
State<SalesDataScreen> createState() => _SalesDataScreenState();
}
class _SalesDataScreenState extends State<SalesDataScreen> {
final List<String> _filterList = [
"Order Status",
"Date Range",
];
@override
Widget build(BuildContext context) {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.transparent,
elevation: 0,
leading: GestureDetector(
onTap: () {},
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(
"Sales Data Report",
),
),
body: Stack(
fit: StackFit.expand,
children: [
Image.asset(
'assets/images/image_1.png',
fit: BoxFit.cover,
),
SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(height: Get.height * 0.02),
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.02),
SizedBox(
width: Get.width,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: Get.height * 0.4,
width: Get.width * 0.7,
decoration: BoxDecoration(
border: Border.all(
width: 4,
color: Colors.white,
),
borderRadius: BorderRadius.circular(15),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.asset(
"assets/images/chart.png",
fit: BoxFit.cover,
),
),
),
),
),
SizedBox(height: Get.height * 0.02),
SizedBox(
width: Get.width,
child: Card(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding:
const EdgeInsets.fromLTRB(16, 8, 8, 0),
child: Text(
"Report Title: Sales Data Report",
style: GoogleFonts.roboto(
fontSize: 14,
fontWeight: FontWeight.w400,
),
),
),
Padding(
padding:
const EdgeInsets.fromLTRB(16, 8, 8, 8),
child: Text(
"Description: Overview of sales data",
style: GoogleFonts.roboto(
fontSize: 14,
fontWeight: FontWeight.w400,
),
),
),
SizedBox(
width: Get.width * 0.5,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
onPressed: (){},
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor:
const Color(0xFF004791),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10),
),
),
child: Text(
"Generate Report",
style: GoogleFonts.roboto(
fontSize: 14,
fontWeight: FontWeight.w400,
),
),
),
),
)
],
),
),
),
],
),
),
),
],
),
),
],
),
);
}
}

View File

@ -1,185 +0,0 @@
import 'package:cheminova/screens/retail/retail_distributer_detail_screen.dart';
import 'package:cheminova/widgets/input_field.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
class RetailDistributerOnBoardingScreen extends StatefulWidget {
const RetailDistributerOnBoardingScreen({super.key});
@override
State<RetailDistributerOnBoardingScreen> createState() =>
_RetailDistributerOnBoardingScreenState();
}
class _RetailDistributerOnBoardingScreenState
extends State<RetailDistributerOnBoardingScreen> {
final List<String> _filterList = [
"Verification Status",
"Date Range",
];
final _searchController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.transparent,
elevation: 0,
leading: GestureDetector(
onTap: () {},
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(
"Retail Distributer On Boarding",
),
),
body: Stack(
fit: StackFit.expand,
children: [
Image.asset(
'assets/images/image_1.png',
fit: BoxFit.cover,
),
SafeArea(
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: ListView.builder(
padding: EdgeInsets.zero,
shrinkWrap: true,
itemCount: 2,
itemBuilder: (context, index) => 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: Text(
"Report Title: Sales Data Report",
style: GoogleFonts.roboto(
fontSize: 14,
fontWeight: FontWeight.w400,
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(
16, 8, 8, 8),
child: Text(
"Description: Overview of sales data",
style: GoogleFonts.roboto(
fontSize: 14,
fontWeight: FontWeight.w400,
),
),
),
SizedBox(
width: Get.width * 0.5,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
onPressed: () => Get.to(
() =>
const RetailDistributerDetailScreen(),
),
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor:
const Color(0xFF004791),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10),
),
),
child: Text(
"View Retailer Details",
style: GoogleFonts.roboto(
fontSize: 14,
fontWeight: FontWeight.w400,
),
),
),
),
)
],
),
),
),
),
)
],
),
),
),
],
),
),
],
),
);
}
}

View File

@ -21,7 +21,6 @@ class _SplashScreenState extends State<SplashScreen> {
checkLogin(); checkLogin();
}); });
super.initState(); super.initState();
} }
checkLogin() async { checkLogin() async {
@ -34,8 +33,6 @@ class _SplashScreenState extends State<SplashScreen> {
} }
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -91,9 +88,7 @@ class _SplashScreenState extends State<SplashScreen> {
), ),
), ),
), ),
Container( Text(
margin: EdgeInsets.only(bottom: Get.height * 0.03),
child: Text(
'Powered By', 'Powered By',
style: GoogleFonts.getFont( style: GoogleFonts.getFont(
'Roboto', 'Roboto',
@ -102,20 +97,16 @@ class _SplashScreenState extends State<SplashScreen> {
color: const Color(0xFF000000), color: const Color(0xFF000000),
), ),
), ),
), SizedBox(height: Get.height * 0.005), // Reduced spacing
SizedBox( Text(
height: Get.height * 0.03,
child: Text(
'codeology.solutions', 'codeology.solutions',
style: GoogleFonts.getFont( style: GoogleFonts.getFont(
'Roboto', 'Roboto',
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
fontSize: Get.textScaleFactor * 14, fontSize: Get.textScaleFactor * 14,
height: 1.8,
color: const Color(0xFF000000), color: const Color(0xFF000000),
), ),
), ),
),
], ],
), ),
); );

View File

@ -1,5 +1,4 @@
class ApiUrls { class ApiUrls {
// static const String baseUrl = 'https://cheminova-api-2.onrender.com/api/';
static const String baseUrl = 'https://api.cnapp.co.in'; static const String baseUrl = 'https://api.cnapp.co.in';
static const String loginUrl = '/api/v1/user/login/'; static const String loginUrl = '/api/v1/user/login/';
static const String profileUrl = '/api/rd-get-me'; static const String profileUrl = '/api/rd-get-me';
@ -15,6 +14,6 @@ class ApiUrls {
static const String getSinglePlacedOrderUrl ='/api/get-single-placed-order-pd'; static const String getSinglePlacedOrderUrl ='/api/get-single-placed-order-pd';
static const String placedOrderUrl ='${baseUrl}/api/order-place'; static const String placedOrderUrl ='${baseUrl}/api/order-place';
static const String inventoryManangementOrdersStock ='${baseUrl}/api/stock'; static const String inventoryManangementOrdersStock ='${baseUrl}/api/stock';
static const String announcementUrl ='${baseUrl}/api/announcement/RDs'; static const String announcementUrl ='${baseUrl}/api/announcement/RDs?page%3D1=rowsPerPage=5';
} }