diff --git a/lib/resources/resources_drivers.dart b/lib/resources/resources_drivers.dart index 8273452..6011648 100644 --- a/lib/resources/resources_drivers.dart +++ b/lib/resources/resources_drivers.dart @@ -51,7 +51,7 @@ class _ResourcesDriverScreenState extends State { String search = ''; bool isLoading = false; List driversList = []; - + String selectedStatus = "all"; // ---------- form (bottom sheet) ---------- final GlobalKey _formKey = GlobalKey(); @@ -1319,6 +1319,27 @@ class _ResourcesDriverScreenState extends State { bool matchesFilter = true; +// Top metric click filter + if(selectedStatus != "all"){ + + if(selectedStatus == "delivery"){ + matchesFilter = + it.status.toLowerCase().trim() == "on delivery"; + } + + if(selectedStatus == "available"){ + matchesFilter = + it.status.toLowerCase().trim() == "available"; + } + + if(selectedStatus == "offline"){ + matchesFilter = + it.status.toLowerCase().trim() == "offline"; + } + + } + +// Menu filter if(selectedFilter!=null){ matchesFilter = @@ -1408,29 +1429,58 @@ class _ResourcesDriverScreenState extends State { child: IntrinsicHeight( child: Row( children: [ + Expanded( - child: SmallMetricBox( - title: 'On delivery', - value: onDeliveryCount.toString(), + child: GestureDetector( + onTap: (){ + setState(() { + selectedStatus = "delivery"; + selectedFilter = null; + }); + }, + child: SmallMetricBox( + title: 'On delivery', + value: onDeliveryCount.toString(), + ), ), ), + const SizedBox(width: 8), + Expanded( - child: SmallMetricBox( - title: 'Available', - value: availableCount.toString(), + child: GestureDetector( + onTap: (){ + setState(() { + selectedStatus = "available"; + selectedFilter = null; + }); + }, + child: SmallMetricBox( + title: 'Available', + value: availableCount.toString(), + ), ), ), + const SizedBox(width: 8), + Expanded( - child: SmallMetricBox( - title: 'Offline', - value: offlineCount.toString(), + child: GestureDetector( + onTap: (){ + setState(() { + selectedStatus = "offline"; + selectedFilter = null; + }); + }, + child: SmallMetricBox( + title: 'Offline', + value: offlineCount.toString(), + ), ), ), + ], ), - ), ), diff --git a/lib/resources/resources_fleet.dart b/lib/resources/resources_fleet.dart index f9cae21..fb3b84e 100644 --- a/lib/resources/resources_fleet.dart +++ b/lib/resources/resources_fleet.dart @@ -1553,6 +1553,7 @@ class _ResourcesFleetScreenState extends State { onTap: (){ setState(() { selectedFilter = "Maintenance"; + }); }, child: SmallMetricBox( diff --git a/lib/resources/resources_sources.dart b/lib/resources/resources_sources.dart index 7995198..9e8db2b 100644 --- a/lib/resources/resources_sources.dart +++ b/lib/resources/resources_sources.dart @@ -88,6 +88,7 @@ class _ResourcesSourceScreenState extends State { int selectedTab = 2; String search = ''; bool isLoading = false; + String selectedWaterFilter = "all"; List sourceLocationsList = []; // ---------- Form state (bottom sheet) ---------- @@ -716,6 +717,16 @@ class _ResourcesSourceScreenState extends State { bool matchesFilter = true; +// Top metric filter + if(selectedWaterFilter != "all"){ + + matchesFilter = + it.water_type.toLowerCase().trim() == + selectedWaterFilter; + + } + +// Menu filter if(selectedFilter!=null){ matchesFilter = @@ -813,29 +824,58 @@ class _ResourcesSourceScreenState extends State { child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ + Expanded( - child: SmallMetricBox( - title: 'Drinking water', - value: drinkingCount.toString(), + child: GestureDetector( + onTap: (){ + setState(() { + selectedWaterFilter = "drinking water"; + selectedFilter = null; + }); + }, + child: SmallMetricBox( + title: 'Drinking water', + value: drinkingCount.toString(), + ), ), ), + const SizedBox(width: 8), + Expanded( - child: SmallMetricBox( - title: 'Bore water', - value: boreCount.toString(), + child: GestureDetector( + onTap: (){ + setState(() { + selectedWaterFilter = "bore water"; + selectedFilter = null; + }); + }, + child: SmallMetricBox( + title: 'Bore water', + value: boreCount.toString(), + ), ), ), + const SizedBox(width: 8), + Expanded( - child: SmallMetricBox( - title: 'Both', - value: bothCount.toString(), + child: GestureDetector( + onTap: (){ + setState(() { + selectedWaterFilter = "both"; + selectedFilter = null; + }); + }, + child: SmallMetricBox( + title: 'Both', + value: bothCount.toString(), + ), ), ), + ], ), - ), ], ),