Header Icons , Forex Search

This commit is contained in:
venbaittech 2025-05-21 14:21:52 +05:30
parent d99d9433ec
commit 3be2f695c6
2 changed files with 70 additions and 20 deletions

View File

@ -282,21 +282,43 @@ class ForexDataListState extends State<ForexDataList> {
});
}
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<ForexDataList> {
height: 40,
child: TextField(
controller: searchController,
onChanged: filterUsers,
onChanged: filterForex,
decoration: InputDecoration(
hintText: "Search ...",
hintStyle: TextStyle(
@ -490,7 +512,7 @@ class ForexDataListState extends State<ForexDataList> {
height: 35,
child: TextField(
controller: searchController,
onChanged: filterUsers,
onChanged: filterForex,
decoration: InputDecoration(
hintText: "Search ...",
hintStyle: TextStyle(
@ -571,10 +593,10 @@ class ForexDataListState extends State<ForexDataList> {
);
}
List<dynamic> users =
List<dynamic> 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<ForexDataList> {
.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<ForexDataList> {
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<ForexDataList> {
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(() {

View File

@ -295,7 +295,7 @@ class _CustomAppBarState extends State<CustomAppBar> {
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<CustomAppBar> {
layoutColor!,
// () => context.go('/ApprovalList'),
isSelected: selectedTab == TabSelection.myApprovals,
icon: Icons.assessment_outlined,
icon: Icons.verified_outlined,
),
// buildNavItem("My Approvals", _myApprovalsColor, () {