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 {
final ApiService _apiClient = ApiService();
RxList<AnnouncementResponse> announcementsList = <AnnouncementResponse>[].obs;
RxList<Announcements> announcementsList = <Announcements>[].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<void> getAnnouncements() async {
isLoading.value = true;
Future<void> 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<dynamic> data = response.data;
announcementsList.value = data.map((item) => AnnouncementResponse.fromJson(item)).toList();
final List<dynamic> 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
}
}
}
void loadMoreAnnouncements() {
if (hasMoreData.value) {
getAnnouncements(page: currentPage.value + 1); // Load the next page
}
}
}

View File

@ -1,43 +1,67 @@
class AnnouncementResponse {
String? id;
String? uniqueId;
List<String>? sentTo;
String? message;
DateTime? createdAt;
DateTime? updatedAt;
int? v;
List<Announcements>? 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<String, dynamic> json) {
return AnnouncementResponse(
id: json['_id'],
uniqueId: json['uniqueId'],
sentTo: json['sentTo'] != null ? List<String>.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<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() {
return {
'_id': id,
'uniqueId': uniqueId,
'sentTo': sentTo,
'message': message,
'createdAt': createdAt?.toIso8601String(),
'updatedAt': updatedAt?.toIso8601String(),
'__v': v,
};
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;
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<String, dynamic> json) {
sId = json['_id'];
sentTo = json['sentTo'].cast<String>();
message = json['message'];
createdAt = json['createdAt'];
updatedAt = json['updatedAt'];
uniqueId = json['uniqueId'];
iV = json['__v'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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;
}
}

View File

@ -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<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 {
final List<AnnouncementResponse> announcementList;
final List<Announcements> announcementList;
const MyListView({super.key, required this.announcementList});
@override
Widget build(BuildContext context) {
Map<String, List<AnnouncementResponse>> groupedAnnouncements = {};
Map<DateTime, List<Announcements>> 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<DateTime> 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<AnnouncementResponse> announcementsForDate = groupedAnnouncements[date]!;
DateTime date = sortedDates[index];
String formattedDate = DateFormat("dd MMM yyyy").format(date);
List<Announcements> 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 {
},
);
}
}
}

View File

@ -76,7 +76,7 @@ class _HomeScreenState extends State<HomeScreen> {
// 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<HomeScreen> {
// 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<HomeScreen> {
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<HomeScreen> {
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<HomeScreen> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
HomeCard(
title: 'Notifications',
onTap: () => Get.to(() => NotificationScreen())),
HomeCard(
title: 'Announcement',
onTap: () => Get.to(

View File

@ -19,7 +19,7 @@ class _InventoryManagementScreenState extends State<InventoryManagementScreen> {
late Future<InventoryManagementResponse> _productsFuture;
final InventoryManagementController _controller =
Get.put(InventoryManagementController());
Get.put(InventoryManagementController());
final List<String> _filterList = [
"Category",
@ -74,7 +74,7 @@ class _InventoryManagementScreenState extends State<InventoryManagementScreen> {
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<InventoryManagementScreen> {
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<InventoryManagementScreen> {
),
),
SizedBox(
height: Get.height * 0.6,
height: Get.height * 0.75, // Increased height here
child: FutureBuilder<InventoryManagementResponse>(
future: _productsFuture,
builder: (context, snapshot) {
@ -149,4 +149,4 @@ class _InventoryManagementScreenState extends State<InventoryManagementScreen> {
),
);
}
}
}

View File

@ -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,

View File

@ -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<OrderManagementScreen> {
final _searchController = TextEditingController();
final List<String> _filterList = ["Order Status", "Date Range"];
final GetPlacedOrderController _getPlacedOrderController =
Get.put(GetPlacedOrderController());
Get.put(GetPlacedOrderController());
final CartController _cartController = Get.put(CartController());
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
GlobalKey<RefreshIndicatorState>();
GlobalKey<RefreshIndicatorState>();
@override
void initState() {
@ -45,7 +41,9 @@ class _OrderManagementScreenState extends State<OrderManagementScreen> {
Future<void> 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<OrderManagementScreen> {
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<String>(
value: _getPlacedOrderController
.productStatus.value,
onChanged: (dynamic newValue) {
if (newValue != null) {
_getPlacedOrderController
.updateProductStatus(newValue);
}
},
items: <String>[
'All',
'Delivered',
'Processing',
'Cancelled'
].map<DropdownMenuItem<String>>(
(String value) {
return DropdownMenuItem<String>(
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<String>(
isExpanded: true,
value: _getPlacedOrderController.productStatus.value,
onChanged: (newValue) {
if (newValue != null) {
_getPlacedOrderController.updateProductStatus(newValue);
}
},
items: <String>['All', 'Delivered', 'Processing', 'Cancelled']
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
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<String> uniqueOrderIds = {};
final List<PlacedOrderList> 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<String> uniqueOrderIds = {};
final List<PlacedOrderList> 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<OrderManagementScreen> {
],
);
}
}
// import 'package:cheminova/controller/get_place_order_service.dart';
// import 'package:cheminova/controller/place_order_controller.dart';
// import 'package:cheminova/models/place_order_list_model.dart';
// import 'package:cheminova/screens/order_management/order_management_detail_screen.dart';
// import 'package:cheminova/widgets/input_field.dart';
// import 'package:cheminova/widgets/my_drawer.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_svg/svg.dart';
// import 'package:get/get.dart';
// import 'package:google_fonts/google_fonts.dart';
// import 'package:intl/intl.dart';
//
// import '../../controller/cart_controller.dart';
// import '../../controller/get_order_placed_controller.dart';
// import '../../models/product_model1.dart';
// import '../../models/oder_place_model.dart';
// import '../../utils/show_snackbar.dart'; // Ensure this import is correct
//
// class OrderManagementScreen extends StatefulWidget {
// final Product? productModel;
// PlacedOrderList? placeOrder;
// OrderManagementScreen({super.key, this.productModel, this.placeOrder});
//
// @override
// State<OrderManagementScreen> createState() => _OrderManagementScreenState();
// }
//
// class _OrderManagementScreenState extends State<OrderManagementScreen> {
// final _searchController = TextEditingController();
// final List<String> _filterList = ["Order Status", "Date Range"];
//
// final GetPlacedOrderController _getPlacedOrderController = Get.put(GetPlacedOrderController());
// final CartController _cartController = Get.put(CartController());
//
// @override
// void initState() {
// super.initState();
// getOrder1();
// }
//
// Future<void> getOrder1() async {
// await _getPlacedOrderController.getOrders();
// print("Order fetched successfully");
// }
//
// String capitalizeFirstLetter(String text) {
// if (text.isEmpty) return text;
// return text[0].toUpperCase() + text.substring(1).toLowerCase();
// }
//
// String formatDate(String apiDate) {
// DateTime parsedDate = DateTime.parse(apiDate);
// String formattedDate = DateFormat('dd-MMM-yyyy hh:mm:ss a').format(parsedDate);
// return formattedDate;
// }
//
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// extendBodyBehindAppBar: true,
// appBar: AppBar(
// centerTitle: true,
// backgroundColor: Colors.transparent,
// elevation: 0,
// leading: Builder(
// builder: (context) {
// return GestureDetector(
// onTap: () => Scaffold.of(context).openDrawer(),
// child: Padding(
// padding: const EdgeInsets.all(16.0),
// child: SvgPicture.asset('assets/svg/menu.svg'),
// ),
// );
// },
// ),
// actions: [
// GestureDetector(
// onTap: () => Get.back(),
// child: Padding(
// padding: const EdgeInsets.all(8.0),
// child: SvgPicture.asset('assets/svg/back_arrow.svg'),
// ),
// ),
// ],
// title: const Text("Order Management"),
// ),
// drawer: const MyDrawer(),
// body: Stack(
// fit: StackFit.expand,
// children: [
// Image.asset('assets/images/image_1.png', fit: BoxFit.cover),
// SafeArea(
// child: SingleChildScrollView(
// child: Padding(
// padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
// child: Column(
// mainAxisSize: MainAxisSize.min,
// mainAxisAlignment: MainAxisAlignment.start,
// children: [
// InputField(
// hintText: "Search Order",
// labelText: "Search Order",
// controller: _searchController,
// ),
// SizedBox(height: Get.height * 0.035),
// Card(
// margin: const EdgeInsets.symmetric(horizontal: 18),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(19),
// side: const BorderSide(color: Color(0xFFFDFDFD)),
// ),
// color: const Color(0xFFB4D1E5).withOpacity(0.9),
// child: Padding(
// padding: const EdgeInsets.all(12.0),
// child: Column(
// mainAxisSize: MainAxisSize.min,
// children: [
// SizedBox(
// height: Get.height * 0.05,
// child: ListView.builder(
// shrinkWrap: true,
// scrollDirection: Axis.horizontal,
// itemCount: _filterList.length,
// itemBuilder: (context, index) => Padding(
// padding: const EdgeInsets.symmetric(horizontal: 4),
// child: Chip(
// label: Text(
// _filterList[index],
// style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.w500),
// ),
// ),
// ),
// ),
// ),
// SizedBox(
// height: Get.height * 0.6,
// child: Obx(() {
// return ListView.builder(
// padding: EdgeInsets.zero,
// shrinkWrap: true,
// itemCount: _getPlacedOrderController.placedOrders.length,
// itemBuilder: (context, index) {
// final order = _getPlacedOrderController.placedOrders[index];
//
// // Combine product names into a single string
// final productNames = order.orderItem
// .map((item) => capitalizeFirstLetter(item.name))
// .join(', ');
//
// return Padding(
// padding: const EdgeInsets.symmetric(vertical: 8),
// child: Card(
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Padding(
// padding: const EdgeInsets.fromLTRB(16, 8, 8, 0),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text("Order ID: ", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.bold)),
// Text("${order.id}")
// ],
// ),
// ),
// Padding(
// padding: const EdgeInsets.fromLTRB(16, 8, 8, 0),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text("Product Names: ", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.bold)),
// Expanded(
// child: Text(productNames,
// style: GoogleFonts.roboto(
// fontSize: 14,
// )),
// ),
// ],
// ),
// ),
// Padding(
// padding: const EdgeInsets.fromLTRB(16, 8, 8, 0),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text("Order Date: ", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.bold)),
// Text(formatDate("${order.createdAt}"))
// ],
// ),
// ),
// Padding(
// padding: const EdgeInsets.fromLTRB(16, 8, 8, 8),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text("Status: ", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.bold)),
// Text(capitalizeFirstLetter("${order.status}"))
// ],
// ),
// ),
// SizedBox(
// width: Get.width * 0.4,
// child: Padding(
// padding: const EdgeInsets.all(8.0),
// child: ElevatedButton(
// onPressed: () => Get.to(() => OrderManagementDetailScreen(
// placedOrderList: _getPlacedOrderController.placedOrders[index])),
// style: ElevatedButton.styleFrom(
// foregroundColor: Colors.white,
// backgroundColor: const Color(0xFF004791),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(10)),
// ),
// child: Text("View Details", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.w400)),
// ),
// ),
// )
// ],
// ),
// ),
// );
// },
// );
// }),
// )
// ],
// ),
// ),
// ),
// ],
// ),
// ),
// ),
// ),
// ],
// ),
// );
// }
// }
//
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),
),
),
],
);
}
}

View File

@ -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<ProductCatalogScreen> {
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<Product> _products = []; // List to hold the fetched products.
List<Map<String, dynamic>> _categories = []; // List to hold product categories.
List<Product> _allProducts = []; // Store all fetched products
List<Product> _filteredProducts = []; // Store filtered products for display
List<Map<String, dynamic>> _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<ProductCatalogScreen> {
});
}
// Fetch products from the server.
Future<void> _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<void> _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<void> _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<ProductCatalogScreen> {
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<ProductCatalogScreen> {
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<ProductCatalogScreen> {
],
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<ProductCatalogScreen> {
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<ProductCatalogScreen> {
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<ProductCatalogScreen> {
],
),
// 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<ProductCatalogScreen> {
);
}
// 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<ProductCatalogScreen> {
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<String?> onChanged,
@ -340,9 +344,9 @@ class _ProductCatalogScreenState extends State<ProductCatalogScreen> {
onChanged: onChanged,
items: items,
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();
});
super.initState();
}
checkLogin() async {
@ -34,8 +33,6 @@ class _SplashScreenState extends State<SplashScreen> {
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -91,33 +88,27 @@ class _SplashScreenState extends State<SplashScreen> {
),
),
),
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),
),
),
],
),
);
}
}
}

View File

@ -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';
}