From 3be2f695c6fb61f0407227bbd4800976b6fa77f0 Mon Sep 17 00:00:00 2001 From: venbaittech Date: Wed, 21 May 2025 14:21:52 +0530 Subject: [PATCH] Header Icons , Forex Search --- lib/Screens/forex/forex_list.dart | 86 ++++++++++++++++++++++++------- lib/routes/custom_appBar.dart | 4 +- 2 files changed, 70 insertions(+), 20 deletions(-) diff --git a/lib/Screens/forex/forex_list.dart b/lib/Screens/forex/forex_list.dart index b6112cc..58dae9b 100644 --- a/lib/Screens/forex/forex_list.dart +++ b/lib/Screens/forex/forex_list.dart @@ -282,21 +282,43 @@ class ForexDataListState extends State { }); } - void filterUsers(String query) { + void filterForex1(String query) { print("allUsers before filtering: $query"); final lowerQuery = query.toLowerCase(); setState(() { - filteredForex = allForex.where((user) { - return (user['first_name']?.toLowerCase().contains(lowerQuery) ?? + filteredForex = allForex.where((forex) { + return (forex['country_code']?.toLowerCase().contains(lowerQuery) ?? false) || - (user['last_name']?.toLowerCase().contains(lowerQuery) ?? false) || - (user['email']?.toLowerCase().contains(lowerQuery) ?? false) || - (user['role_value']?.toLowerCase().contains(lowerQuery) ?? false); + (forex['country_name']?.toLowerCase().contains(lowerQuery) ?? + false) || + (forex['currency']?.toLowerCase().contains(lowerQuery) ?? false) || + (forex['perdiem_amount']?.toLowerCase().contains(lowerQuery) ?? + false); }).toList(); }); print("filteredPlans: $filteredForex"); } + void filterForex(String query) { + print("allForex before filtering: $query"); + final lowerQuery = query.toLowerCase(); + setState(() { + filteredForex = allForex.where((forex) { + final isActiveStatus = + forex['is_active'] == "1" ? "active" : "inactive"; + return (forex['country_code']?.toLowerCase().contains(lowerQuery) ?? + false) || + (forex['country_name']?.toLowerCase().contains(lowerQuery) ?? + false) || + (forex['currency']?.toLowerCase().contains(lowerQuery) ?? false) || + (forex['perdiem_amount']?.toLowerCase().contains(lowerQuery) ?? + false) || + (isActiveStatus.contains(lowerQuery)); + }).toList(); + }); + print("filteredForex: $filteredForex"); + } + @override Widget build(BuildContext context) { return ResponsiveBuilder(builder: (context, sizingInfo) { @@ -396,7 +418,7 @@ class ForexDataListState extends State { height: 40, child: TextField( controller: searchController, - onChanged: filterUsers, + onChanged: filterForex, decoration: InputDecoration( hintText: "Search ...", hintStyle: TextStyle( @@ -490,7 +512,7 @@ class ForexDataListState extends State { height: 35, child: TextField( controller: searchController, - onChanged: filterUsers, + onChanged: filterForex, decoration: InputDecoration( hintText: "Search ...", hintStyle: TextStyle( @@ -571,10 +593,10 @@ class ForexDataListState extends State { ); } - List users = + List forex = filteredForex.isNotEmpty ? filteredForex : allForex; - users.sort((a, b) { + forex.sort((a, b) { DateTime dateA = DateTime.parse(a['created_on']); DateTime dateB = DateTime.parse(b['created_on']); @@ -582,7 +604,7 @@ class ForexDataListState extends State { .compareTo(dateA); // Descending: newest first }); - List paginatedUser = users + List paginatedForex = forex .skip(currentPage * itemsPerPage) .take(itemsPerPage) .toList(); @@ -645,7 +667,7 @@ class ForexDataListState extends State { fontWeight: FontWeight.w600), )), ], - rows: paginatedUser.map((forex) { + rows: paginatedForex.map((forex) { String forexId = forex['forex_perdiem_id'] .toString(); // Get user ID bool isSelected = selectedUserId == forexId; @@ -958,16 +980,44 @@ class ForexDataListState extends State { children: [ Expanded( child: isDesktop - ? SingleChildScrollView( - scrollDirection: Axis.vertical, - child: table, // <-- your existing table - ) - : buildMobileCardView(paginatedUser), + ? (searchController.text.isNotEmpty && + filteredForex.isEmpty + ? Center( + child: Text( + "No matches found", + style: GoogleFonts.poppins( + fontSize: 14, + color: Colors.grey), + ), + ) + : SingleChildScrollView( + scrollDirection: Axis.vertical, + child: table, + )) + : (searchController.text.isNotEmpty && + filteredForex.isEmpty + ? Center( + child: Text( + "No matches found", + style: GoogleFonts.poppins( + fontSize: 14, + color: Colors.grey), + ), + ) + : buildMobileCardView(paginatedForex)), ), + // Expanded( + // child: isDesktop + // ? SingleChildScrollView( + // scrollDirection: Axis.vertical, + // child: table, // <-- your existing table + // ) + // : buildMobileCardView(paginatedUser), + // ), PaginationControls( currentPage: currentPage, itemsPerPage: itemsPerPage, - totalItems: users.length, + totalItems: forex.length, activeColor: layoutColor, // your theme color onPageChanged: (page) { setState(() { diff --git a/lib/routes/custom_appBar.dart b/lib/routes/custom_appBar.dart index e6c3da8..88b8ff6 100644 --- a/lib/routes/custom_appBar.dart +++ b/lib/routes/custom_appBar.dart @@ -295,7 +295,7 @@ class _CustomAppBarState extends State { layoutColor!, // () => context.go('/listPlan'), isSelected: selectedTab == TabSelection.myTrips, - icon: Icons.request_page_outlined, + icon: Icons.shopping_bag_outlined, ), // if (userDetails["role"] == "Travel Agent") // buildNavItem("My Trips", _myTravelRequestColor, @@ -319,7 +319,7 @@ class _CustomAppBarState extends State { layoutColor!, // () => context.go('/ApprovalList'), isSelected: selectedTab == TabSelection.myApprovals, - icon: Icons.assessment_outlined, + icon: Icons.verified_outlined, ), // buildNavItem("My Approvals", _myApprovalsColor, () {