diff --git a/lib/controller/announcement_controller.dart b/lib/controller/announcement_controller.dart index ed30ae4..c89ffe8 100644 --- a/lib/controller/announcement_controller.dart +++ b/lib/controller/announcement_controller.dart @@ -5,27 +5,59 @@ import '../utils/api_urls.dart'; class AnnouncementController extends GetxController { final ApiService _apiClient = ApiService(); - RxList announcementsList = [].obs; + RxList announcementsList = [].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 void onInit() { super.onInit(); - getAnnouncements(); + getAnnouncements(); // Fetch announcements when the controller initializes } - Future getAnnouncements() async { - isLoading.value = true; + Future getAnnouncements({int page = 1, int rowsPerPage = 5}) async { + if (!hasMoreData.value) return; // Return if no more data is available + + isLoading.value = true; // Set loading to true while fetching try { - final response = await _apiClient.get(ApiUrls.announcementUrl); - isLoading.value = false; + final response = await _apiClient.get( + "${ApiUrls.announcementUrl}?page=$page&rowsPerPage=$rowsPerPage", + ); + if (response.statusCode == 200) { - final List data = response.data; - announcementsList.value = data.map((item) => AnnouncementResponse.fromJson(item)).toList(); + final List data = response.data['announcements']; + 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) { - isLoading.value = false; - Get.snackbar('Error', 'Failed to fetch announcements'); + Get.snackbar('Error', 'Failed to fetch announcements: $e'); + } finally { + isLoading.value = false; // Ensure loading is set to false in the finally block } } -} \ No newline at end of file + + void loadMoreAnnouncements() { + if (hasMoreData.value) { + getAnnouncements(page: currentPage.value + 1); // Load the next page + } + } +} diff --git a/lib/models/announcement_response.dart b/lib/models/announcement_response.dart index 1598777..1d25b78 100644 --- a/lib/models/announcement_response.dart +++ b/lib/models/announcement_response.dart @@ -1,43 +1,67 @@ class AnnouncementResponse { - String? id; - String? uniqueId; - List? sentTo; - String? message; - DateTime? createdAt; - DateTime? updatedAt; - int? v; + List? announcements; + int? totalAnnouncements; - AnnouncementResponse({ - this.id, - this.uniqueId, - this.sentTo, - this.message, - this.createdAt, - this.updatedAt, - this.v, - }); + AnnouncementResponse({this.announcements, this.totalAnnouncements}); - factory AnnouncementResponse.fromJson(Map json) { - return AnnouncementResponse( - id: json['_id'], - uniqueId: json['uniqueId'], - sentTo: json['sentTo'] != null ? List.from(json['sentTo']) : null, - message: json['message'], - createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt']) : null, - updatedAt: json['updatedAt'] != null ? DateTime.parse(json['updatedAt']) : null, - v: json['__v'], - ); + AnnouncementResponse.fromJson(Map json) { + if (json['announcements'] != null) { + announcements = []; + json['announcements'].forEach((v) { + announcements!.add(new Announcements.fromJson(v)); + }); + } + totalAnnouncements = json['totalAnnouncements']; } Map toJson() { - return { - '_id': id, - 'uniqueId': uniqueId, - 'sentTo': sentTo, - 'message': message, - 'createdAt': createdAt?.toIso8601String(), - 'updatedAt': updatedAt?.toIso8601String(), - '__v': v, - }; + final Map data = new Map(); + if (this.announcements != null) { + data['announcements'] = + this.announcements!.map((v) => v.toJson()).toList(); + } + data['totalAnnouncements'] = this.totalAnnouncements; + return data; } -} \ No newline at end of file +} + +class Announcements { + String? sId; + List? sentTo; + String? message; + String? createdAt; + String? updatedAt; + String? uniqueId; + int? iV; + + Announcements( + {this.sId, + this.sentTo, + this.message, + this.createdAt, + this.updatedAt, + this.uniqueId, + this.iV}); + + Announcements.fromJson(Map json) { + sId = json['_id']; + sentTo = json['sentTo'].cast(); + message = json['message']; + createdAt = json['createdAt']; + updatedAt = json['updatedAt']; + uniqueId = json['uniqueId']; + iV = json['__v']; + } + + Map toJson() { + final Map data = new Map(); + data['_id'] = this.sId; + data['sentTo'] = this.sentTo; + data['message'] = this.message; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['uniqueId'] = this.uniqueId; + data['__v'] = this.iV; + return data; + } +} diff --git a/lib/screens/announment/announment_screen.dart b/lib/screens/announment/announment_screen.dart index a5b2c59..b74d397 100644 --- a/lib/screens/announment/announment_screen.dart +++ b/lib/screens/announment/announment_screen.dart @@ -7,7 +7,6 @@ import '../../controller/announcement_controller.dart'; import '../../models/announcement_response.dart'; import '../../widgets/comman_background.dart'; import '../../widgets/common_appbar.dart'; -import '../../widgets/common_elevated_button.dart'; class AnnouncementScreen extends StatelessWidget { final AnnouncementController controller = Get.put(AnnouncementController()); @@ -38,51 +37,51 @@ class AnnouncementScreen extends StatelessWidget { drawer: const MyDrawer(), body: Obx(() => controller.isLoading.value ? const Center(child: CircularProgressIndicator()) - : MyListView(announcementList: controller.announcementsList)), + : NotificationListener( + 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 { - final List announcementList; + final List announcementList; const MyListView({super.key, required this.announcementList}); @override Widget build(BuildContext context) { - Map> groupedAnnouncements = {}; + Map> groupedAnnouncements = {}; 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)) { groupedAnnouncements[date] = []; } groupedAnnouncements[date]!.add(announcement); } + // Sort the dates in descending order (latest first) + List sortedDates = groupedAnnouncements.keys.toList() + ..sort((a, b) => b.compareTo(a)); + return ListView.builder( padding: const EdgeInsets.only(top: 15), - itemCount: groupedAnnouncements.length, + itemCount: sortedDates.length, itemBuilder: (context, index) { - String date = groupedAnnouncements.keys.elementAt(index); - List announcementsForDate = groupedAnnouncements[date]!; + DateTime date = sortedDates[index]; + String formattedDate = DateFormat("dd MMM yyyy").format(date); + List announcementsForDate = groupedAnnouncements[date]!; return Padding( padding: const EdgeInsets.only(bottom: 10, left: 10, right: 10), @@ -92,7 +91,7 @@ class MyListView extends StatelessWidget { Padding( padding: const EdgeInsets.only(bottom: 8.0), child: Text( - date, + formattedDate, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), ), @@ -128,4 +127,4 @@ class MyListView extends StatelessWidget { }, ); } -} \ No newline at end of file +} diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index 361588d..54ef839 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -76,7 +76,7 @@ class _HomeScreenState extends State { // SafeArea widget to ensure the content is placed within safe boundaries. SafeArea( 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. child: SingleChildScrollView( @@ -98,10 +98,10 @@ class _HomeScreenState extends State { // HomeCard widget with the title and navigation to the Order Tracking screen. HomeCard( - title: 'Order Tracking', + title: 'Order Management', onTap: () => Get.to( - () => - const OrderTrackingScreen(), // Navigates to OrderTrackingScreen using GetX. + () => + OrderManagementScreen(), // Navigates to OrderManagementScreen. ), ), ], @@ -114,13 +114,6 @@ class _HomeScreenState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - HomeCard( - title: 'Order Management', - onTap: () => Get.to( - () => - OrderManagementScreen(), // Navigates to OrderManagementScreen. - ), - ), HomeCard( title: 'Inventory Management', onTap: () => Get.to( @@ -128,13 +121,9 @@ class _HomeScreenState extends State { const InventoryManagementScreen(), // Navigates to InventoryManagementScreen. ), ), - // HomeCard( - // title: 'Shipping Management', - // onTap: () => Get.to( - // () => - // const ShippingManagementScreen(), // Navigates to ShippingManagementScreen. - // ), - // ), + HomeCard( + title: 'Notifications', + onTap: () => Get.to(() => NotificationScreen())) ], ), @@ -144,9 +133,6 @@ class _HomeScreenState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - HomeCard( - title: 'Notifications', - onTap: () => Get.to(() => NotificationScreen())), HomeCard( title: 'Announcement', onTap: () => Get.to( diff --git a/lib/screens/inventory/inventory_management_screen.dart b/lib/screens/inventory/inventory_management_screen.dart index 60c5372..9e9d08d 100644 --- a/lib/screens/inventory/inventory_management_screen.dart +++ b/lib/screens/inventory/inventory_management_screen.dart @@ -19,7 +19,7 @@ class _InventoryManagementScreenState extends State { late Future _productsFuture; final InventoryManagementController _controller = - Get.put(InventoryManagementController()); + Get.put(InventoryManagementController()); final List _filterList = [ "Category", @@ -74,7 +74,7 @@ class _InventoryManagementScreenState extends State { SafeArea( child: Column( children: [ - SizedBox(height: Get.height * 0.02), + SizedBox(height: Get.height * 0.01), // Reduced top spacing Card( margin: const EdgeInsets.symmetric(horizontal: 18), shape: RoundedRectangleBorder( @@ -95,7 +95,7 @@ class _InventoryManagementScreenState extends State { itemCount: _filterList.length, itemBuilder: (context, index) => Padding( padding: - const EdgeInsets.symmetric(horizontal: 4), + const EdgeInsets.symmetric(horizontal: 4), child: Chip( label: Text( _filterList[index], @@ -109,7 +109,7 @@ class _InventoryManagementScreenState extends State { ), ), SizedBox( - height: Get.height * 0.6, + height: Get.height * 0.75, // Increased height here child: FutureBuilder( future: _productsFuture, builder: (context, snapshot) { @@ -149,4 +149,4 @@ class _InventoryManagementScreenState extends State { ), ); } -} +} \ No newline at end of file diff --git a/lib/screens/inventory/inventory_product_detail_screen.dart b/lib/screens/inventory/inventory_product_detail_screen.dart index bee9af9..c0d7870 100644 --- a/lib/screens/inventory/inventory_product_detail_screen.dart +++ b/lib/screens/inventory/inventory_product_detail_screen.dart @@ -126,7 +126,7 @@ class _InventoryProductDetailScreenState padding: const EdgeInsets.fromLTRB(8, 8, 8, 8), child: Text( - "Descrition: ${widget.product.description}", + "Product id: ${widget.product.sId}", style: GoogleFonts.roboto( fontSize: Get.width * 0.04, fontWeight: FontWeight.w400, @@ -168,27 +168,14 @@ class _InventoryProductDetailScreenState ), ), ), + SizedBox( width: Get.width, child: Padding( padding: const EdgeInsets.fromLTRB(8, 8, 8, 0), child: Text( - "Minimum Stock Level: 20", - 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", + "Last Restock Date: ${widget.product.updatedAt}", style: GoogleFonts.roboto( fontSize: Get.width * 0.04, fontWeight: FontWeight.w400, @@ -202,7 +189,7 @@ class _InventoryProductDetailScreenState padding: const EdgeInsets.fromLTRB(8, 8, 8, 8), child: Text( - "Supplier: ABC Supplier", + "Supplier: ${widget.product.addedBy}", style: GoogleFonts.roboto( fontSize: Get.width * 0.04, fontWeight: FontWeight.w400, diff --git a/lib/screens/order_management/order_management_screen.dart b/lib/screens/order_management/order_management_screen.dart index 3cf62b8..1fa02ec 100644 --- a/lib/screens/order_management/order_management_screen.dart +++ b/lib/screens/order_management/order_management_screen.dart @@ -1,13 +1,12 @@ 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/foundation.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'; @@ -23,14 +22,11 @@ class OrderManagementScreen extends StatefulWidget { } class _OrderManagementScreenState extends State { - final _searchController = TextEditingController(); - final List _filterList = ["Order Status", "Date Range"]; - final GetPlacedOrderController _getPlacedOrderController = - Get.put(GetPlacedOrderController()); + Get.put(GetPlacedOrderController()); final CartController _cartController = Get.put(CartController()); final GlobalKey _refreshIndicatorKey = - GlobalKey(); + GlobalKey(); @override void initState() { @@ -45,7 +41,9 @@ class _OrderManagementScreenState extends State { Future getOrder1() async { await _getPlacedOrderController.getOrders(); - print("Order fetched successfully"); + if (kDebugMode) { + print("Order fetched successfully"); + } } String capitalizeFirstLetter(String text) { @@ -97,284 +95,129 @@ class _OrderManagementScreenState extends State { 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: RefreshIndicator( - key: _refreshIndicatorKey, - onRefresh: _onRefresh, - color: Colors.black, - backgroundColor: Colors.white, - 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: [ - Obx( + child: Column( + children: [ + SizedBox(height: Get.height * 0.02), + Expanded( + child: 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( + children: [ + Obx( () => Container( - height: Get.height * 0.05, - padding: const EdgeInsets.all(8), - margin: const EdgeInsets.only(bottom: 8), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: - BorderRadius.circular(5)), - child: DropdownButton( - value: _getPlacedOrderController - .productStatus.value, - onChanged: (dynamic newValue) { - if (newValue != null) { - _getPlacedOrderController - .updateProductStatus(newValue); - } - }, - items: [ - 'All', - 'Delivered', - 'Processing', - 'Cancelled' - ].map>( - (String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }).toList(), - ), + height: Get.height * 0.05, + padding: const EdgeInsets.symmetric(horizontal: 12), + margin: const EdgeInsets.only(bottom: 8), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(5), + ), + child: DropdownButtonHideUnderline( + child: DropdownButton( + isExpanded: true, + value: _getPlacedOrderController.productStatus.value, + onChanged: (newValue) { + if (newValue != null) { + _getPlacedOrderController.updateProductStatus(newValue); + } + }, + items: ['All', 'Delivered', 'Processing', 'Cancelled'] + .map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), ), ), - SizedBox( - height: Get.height * 0.6, - child: Obx(() { - // Use a set to keep track of unique order IDs - final Set uniqueOrderIds = {}; - final List uniqueOrders = - []; - - final orders = _getPlacedOrderController - .filterOrder.isNotEmpty - ? _getPlacedOrderController - .filterOrder - : _getPlacedOrderController - .placedOrders; - - for (var order in orders) { - if (uniqueOrderIds - .add(order.sId ?? '')) { - uniqueOrders.add(order); - } - } - - return ListView.builder( - padding: EdgeInsets.zero, - shrinkWrap: true, - 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, - 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( - padding: - const EdgeInsets.all( - 8.0), - child: ElevatedButton( - onPressed: () => Get.to(() => - OrderManagementDetailScreen( - placedOrderList: - uniqueOrders[ - 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)), - ), - ), - ) - ], - ), - ), - ); - }, - ); - }), - ) - ], + ), ), - ), + Expanded( + child: RefreshIndicator( + key: _refreshIndicatorKey, + onRefresh: _onRefresh, + color: Colors.black, + backgroundColor: Colors.white, + child: Obx(() { + final Set uniqueOrderIds = {}; + final List uniqueOrders = []; + + final orders = _getPlacedOrderController.filterOrder.isNotEmpty + ? _getPlacedOrderController.filterOrder + : _getPlacedOrderController.placedOrders; + + for (var order in orders) { + if (uniqueOrderIds.add(order.sId ?? '')) { + uniqueOrders.add(order); + } + } + + return ListView.builder( + padding: EdgeInsets.zero, + itemCount: uniqueOrders.length, + itemBuilder: (context, index) { + final order = uniqueOrders[index]; + final productNames = order.orderItem! + .map((item) => capitalizeFirstLetter(item.name ?? '')) + .join(', '); + + return Card( + margin: const EdgeInsets.symmetric(vertical: 8), + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + 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( + onPressed: () => Get.to(() => OrderManagementDetailScreen(placedOrderList: uniqueOrders[index])), + style: ElevatedButton.styleFrom( + foregroundColor: Colors.white, + backgroundColor: const Color(0xFF004791), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + minimumSize: Size(Get.width * 0.4, 40), + ), + child: Text("View Details", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.w400)), + ), + ) + ], + ), + ), + ); + }, + ); + }), + ), + ), + ], ), - ], + ), ), ), - ), + SizedBox(height: Get.height * 0.02), + ], ), ), ], ), ), Obx( - () { + () { if (_getPlacedOrderController.isLoading.value) { return Container( color: Colors.black.withOpacity(0.5), @@ -389,245 +232,23 @@ class _OrderManagementScreenState extends State { ], ); } -} -// 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 createState() => _OrderManagementScreenState(); -// } -// -// class _OrderManagementScreenState extends State { -// final _searchController = TextEditingController(); -// final List _filterList = ["Order Status", "Date Range"]; -// -// final GetPlacedOrderController _getPlacedOrderController = Get.put(GetPlacedOrderController()); -// final CartController _cartController = Get.put(CartController()); -// -// @override -// void initState() { -// super.initState(); -// getOrder1(); -// } -// -// Future 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)), -// ), -// ), -// ) -// ], -// ), -// ), -// ); -// }, -// ); -// }), -// ) -// ], -// ), -// ), -// ), -// ], -// ), -// ), -// ), -// ), -// ], -// ), -// ); -// } -// } -// + Widget _buildInfoRow(String label, String value) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + label, + style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.bold), + ), + const SizedBox(width: 4), + Expanded( + child: Text( + value, + style: GoogleFonts.roboto(fontSize: 14), + ), + ), + ], + ); + } +} \ No newline at end of file diff --git a/lib/screens/product/product_catalog_screen.dart b/lib/screens/product/product_catalog_screen.dart index 50631a9..76e2847 100644 --- a/lib/screens/product/product_catalog_screen.dart +++ b/lib/screens/product/product_catalog_screen.dart @@ -9,7 +9,6 @@ import '../../widgets/my_drawer.dart'; import '../../widgets/product_card.dart'; import '../../controller/product_service.dart'; -// ProductCatalogScreen displays a catalog of products that users can browse and filter. class ProductCatalogScreen extends StatefulWidget { const ProductCatalogScreen({super.key}); @@ -18,28 +17,29 @@ class ProductCatalogScreen extends StatefulWidget { } class _ProductCatalogScreenState extends State { - final ProductService _productService = ProductService(); // Service to fetch product data. - final ScrollController _scrollController = ScrollController(); // Controller for scroll events. - final CartController cartController = Get.put(CartController()); // Cart controller for managing cart state. + final ProductService _productService = ProductService(); + final ScrollController _scrollController = ScrollController(); + final CartController cartController = Get.put(CartController()); - List _products = []; // List to hold the fetched products. - List> _categories = []; // List to hold product categories. + List _allProducts = []; // Store all fetched products + List _filteredProducts = []; // Store filtered products for display + List> _categories = []; - int _currentPage = 1; // Tracks the current page of products being fetched. - bool _isLoading = false; // Indicates if data is being loaded. - bool _hasMoreData = true; // Indicates if more data can be fetched. + int _currentPage = 1; + bool _isLoading = false; + bool _hasMoreData = true; - String? _selectedCategory; // Tracks the currently selected category for filtering. - String? _selectedPriceRange; // Placeholder for selected price range filtering. - String? _selectedAvailability; // Placeholder for selected availability filtering. + String? _selectedCategory; + String? _selectedPriceRange; + String? _selectedAvailability; + String _searchQuery = ''; // New variable to store search query @override void initState() { super.initState(); - _fetchCategories(); // Fetch categories on initialization. - _fetchProducts(); // Fetch initial products. + _fetchCategories(); + _fetchProducts(); - // Add listener to fetch more products when reaching the bottom of the scroll view. _scrollController.addListener(() { if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent && @@ -49,76 +49,85 @@ class _ProductCatalogScreenState extends State { }); } - // Fetch products from the server. Future _fetchProducts() async { 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( _currentPage, category: category); setState(() { if (products != null) { - _products.addAll(products); // Append fetched products to the list. - _hasMoreData = products.isNotEmpty; // Update the flag for more data availability. + _allProducts.addAll(products); + _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 _fetchCategories() async { - final categories = await _productService.getCategory(); // Fetch categories. + final categories = await _productService.getCategory(); if (categories != null) { setState(() { - _categories = categories; // Set the fetched categories. - _categories.insert(1, {'categoryName': 'All'}); // Add 'All' category option. - _selectedCategory = 'All'; // Default selected category. + _categories = categories; + _categories.insert(1, {'categoryName': 'All'}); + _selectedCategory = 'All'; }); } } - // Handle category changes when the user selects a new category. void _onCategoryChanged(String? newCategory) { if (newCategory != null) { setState(() { - _selectedCategory = newCategory; // Update selected category. - _products.clear(); // Clear current product list for new fetch. - _currentPage = 1; // Reset page counter. + _selectedCategory = newCategory; + _allProducts.clear(); + _filteredProducts.clear(); + _currentPage = 1; }); - _fetchProducts(); // Fetch products for the selected category. + _fetchProducts(); } } - // Fetch additional products when scrolling to the bottom. Future _fetchMoreProducts() async { - if (!_isLoading && _hasMoreData) { // Ensure not already loading and more data is available. + if (!_isLoading && _hasMoreData) { setState(() { - _isLoading = true; // Set loading to true while fetching more products. - _currentPage++; // Increment the page number for next fetch. + _isLoading = true; + _currentPage++; }); - await _fetchProducts(); // Fetch more products. + await _fetchProducts(); } } - // Clear all filters and reset the product list. void _clearFilters() { setState(() { - _selectedCategory = null; // Reset category filter. - _selectedPriceRange = null; // Reset price range filter. - _selectedAvailability = null; // Reset availability filter. - _products.clear(); // Clear current product list. - _currentPage = 1; // Reset page counter. + _selectedCategory = null; + _selectedPriceRange = null; + _selectedAvailability = null; + _searchQuery = ''; + _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 void dispose() { - _scrollController.dispose(); // Dispose of the scroll controller when done. + _scrollController.dispose(); super.dispose(); } @@ -127,31 +136,29 @@ class _ProductCatalogScreenState extends State { return Scaffold( extendBodyBehindAppBar: true, appBar: AppBar( - backgroundColor: Colors.transparent, // Make the AppBar transparent. - elevation: 0, // No shadow for the AppBar. + backgroundColor: Colors.transparent, + elevation: 0, leading: Builder( builder: (context) { return GestureDetector( - onTap: () => Scaffold.of(context).openDrawer(), // Open drawer on tap. + onTap: () => Scaffold.of(context).openDrawer(), child: Padding( padding: const EdgeInsets.all(16.0), child: SvgPicture.asset( - 'assets/svg/menu.svg', // Menu icon. + 'assets/svg/menu.svg', ), ), ); }, ), actions: [ - // Cart icon with count indicator. GestureDetector( - onTap: () => Get.to(CartScreen()), // Navigate to cart on tap. + onTap: () => Get.to(CartScreen()), child: Padding( padding: const EdgeInsets.all(8.0), child: Stack( children: [ - const Icon(Icons.shopping_cart, size: 30,), // Shopping cart icon. - // Cart count display + const Icon(Icons.shopping_cart, size: 30,), Positioned( right: 0, child: Obx(() => @@ -163,14 +170,14 @@ class _ProductCatalogScreenState extends State { shape: BoxShape.circle, ), child: Text( - '${cartController.cartCount.value}', // Display number of items in cart. + '${cartController.cartCount.value}', style: const TextStyle( color: Colors.white, fontSize: 12, ), ), ) - : const SizedBox.shrink()), // Hide if cart is empty. + : const SizedBox.shrink()), ), ], ), @@ -179,15 +186,14 @@ class _ProductCatalogScreenState extends State { ], title: const Center( child: Text( - "Product Catalogue", // Title of the screen. + "Product Catalogue", ), ), ), - drawer: const MyDrawer(), // Navigation drawer. + drawer: const MyDrawer(), body: Stack( fit: StackFit.expand, children: [ - // Background image for the screen. Image.asset( 'assets/images/image_1.png', fit: BoxFit.cover, @@ -196,25 +202,30 @@ class _ProductCatalogScreenState extends State { child: SingleChildScrollView( child: Column( 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: const EdgeInsets.symmetric(horizontal: 18.0), child: TextField( decoration: InputDecoration( - hintText: "Search Products", // Placeholder for search. + hintText: "Search Products", border: OutlineInputBorder( borderRadius: BorderRadius.circular(15), ), filled: true, 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( margin: const EdgeInsets.symmetric(horizontal: 18), shape: RoundedRectangleBorder( @@ -227,22 +238,20 @@ class _ProductCatalogScreenState extends State { child: Column( mainAxisSize: MainAxisSize.min, children: [ - // Filter section header. Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - "Filter", // Filter title. + "Filter", style: GoogleFonts.poppins( fontWeight: FontWeight.bold, fontSize: 16, ), ), - // Button to clear filters. TextButton( onPressed: _clearFilters, child: Text( - "Clear Filter", // Clear filters button text. + "Clear Filter", style: GoogleFonts.poppins( color: Colors.red, fontSize: 14, @@ -252,36 +261,33 @@ class _ProductCatalogScreenState extends State { ], ), - // Dropdowns for filtering options. SizedBox( height: Get.height * 0.05, child: ListView.builder( shrinkWrap: true, scrollDirection: Axis.horizontal, - itemCount: 3, // Number of filters (categories, etc.). + itemCount: 3, itemBuilder: (context, index) => - _buildFilterDropdown(index), // Build filter dropdowns. + _buildFilterDropdown(index), ), ), - // List of products. + // Updated to use _filteredProducts SizedBox( height: Get.height * 0.6, child: ListView.builder( - controller: _scrollController, // Attach scroll controller. + controller: _scrollController, 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) { - if (index >= _products.length) { - print("Product length $_products"); + if (index >= _filteredProducts.length) { return const Center( - child: CircularProgressIndicator()); // Show loading indicator. + child: CircularProgressIndicator()); } - // Display each product card. return Padding( padding: const EdgeInsets.symmetric(vertical: 8), child: ProductCard( - productModel: _products[index], // Use ProductModel here. + productModel: _filteredProducts[index], ), ); }, @@ -300,7 +306,6 @@ class _ProductCatalogScreenState extends State { ); } - // Build a dropdown for filtering based on the index. Widget _buildFilterDropdown(int index) { switch (index) { case 0: @@ -313,14 +318,13 @@ class _ProductCatalogScreenState extends State { child: Text(category['categoryName']), ); }).toList(), - hint: "Category", // Dropdown hint for category selection. + hint: "Category", ); default: - return const SizedBox(); // Return empty widget for unsupported indices. + return const SizedBox(); } } - // Build a styled dropdown widget. Widget _buildStyledDropdown({ required String? value, required ValueChanged onChanged, @@ -340,9 +344,9 @@ class _ProductCatalogScreenState extends State { onChanged: onChanged, items: items, hint: Text(hint), - icon: const Icon(Icons.arrow_drop_down), // Dropdown arrow icon. + icon: const Icon(Icons.arrow_drop_down), ), ), ); } -} +} \ No newline at end of file diff --git a/lib/screens/report/reporting_analytics_screen.dart b/lib/screens/report/reporting_analytics_screen.dart deleted file mode 100644 index 831377f..0000000 --- a/lib/screens/report/reporting_analytics_screen.dart +++ /dev/null @@ -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 createState() => - _ReportingAnalyticsScreenState(); -} - -class _ReportingAnalyticsScreenState extends State { - final _searchController = TextEditingController(); - final List _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, - ), - ), - ), - ), - ) - ], - ), - ), - ), - ), - ) - ], - ), - ), - ), - ], - ), - ), - ], - ), - ); - } -} diff --git a/lib/screens/report/sales_data_screen.dart b/lib/screens/report/sales_data_screen.dart deleted file mode 100644 index a6bc496..0000000 --- a/lib/screens/report/sales_data_screen.dart +++ /dev/null @@ -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 createState() => _SalesDataScreenState(); -} - -class _SalesDataScreenState extends State { - final List _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, - ), - ), - ), - ), - ) - ], - ), - ), - ), - ], - ), - ), - ), - ], - ), - ), - ], - ), - ); - } -} diff --git a/lib/screens/retail/retail_distributer_on_boarding_screen.dart b/lib/screens/retail/retail_distributer_on_boarding_screen.dart deleted file mode 100644 index 19e0e3d..0000000 --- a/lib/screens/retail/retail_distributer_on_boarding_screen.dart +++ /dev/null @@ -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 createState() => - _RetailDistributerOnBoardingScreenState(); -} - -class _RetailDistributerOnBoardingScreenState - extends State { - final List _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, - ), - ), - ), - ), - ) - ], - ), - ), - ), - ), - ) - ], - ), - ), - ), - ], - ), - ), - ], - ), - ); - } -} diff --git a/lib/screens/splash_screen.dart b/lib/screens/splash_screen.dart index 97d47ff..7705b35 100644 --- a/lib/screens/splash_screen.dart +++ b/lib/screens/splash_screen.dart @@ -21,7 +21,6 @@ class _SplashScreenState extends State { checkLogin(); }); super.initState(); - } checkLogin() async { @@ -34,8 +33,6 @@ class _SplashScreenState extends State { } } - - @override Widget build(BuildContext context) { return Scaffold( @@ -91,33 +88,27 @@ class _SplashScreenState extends State { ), ), ), - Container( - margin: EdgeInsets.only(bottom: Get.height * 0.03), - child: Text( - 'Powered By', - style: GoogleFonts.getFont( - 'Roboto', - fontWeight: FontWeight.w500, - fontSize: Get.textScaleFactor * 12, - color: const Color(0xFF000000), - ), + Text( + 'Powered By', + style: GoogleFonts.getFont( + 'Roboto', + fontWeight: FontWeight.w500, + fontSize: Get.textScaleFactor * 12, + color: const Color(0xFF000000), ), ), - SizedBox( - height: Get.height * 0.03, - child: Text( - 'codeology.solutions', - style: GoogleFonts.getFont( - 'Roboto', - fontWeight: FontWeight.w500, - fontSize: Get.textScaleFactor * 14, - height: 1.8, - color: const Color(0xFF000000), - ), + SizedBox(height: Get.height * 0.005), // Reduced spacing + Text( + 'codeology.solutions', + style: GoogleFonts.getFont( + 'Roboto', + fontWeight: FontWeight.w500, + fontSize: Get.textScaleFactor * 14, + color: const Color(0xFF000000), ), ), ], ), ); } -} +} \ No newline at end of file diff --git a/lib/utils/api_urls.dart b/lib/utils/api_urls.dart index 0916956..535c9e1 100644 --- a/lib/utils/api_urls.dart +++ b/lib/utils/api_urls.dart @@ -1,5 +1,4 @@ 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 loginUrl = '/api/v1/user/login/'; 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 placedOrderUrl ='${baseUrl}/api/order-place'; 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'; }