|
|
|
|
@ -57,9 +57,8 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
|
|
|
|
|
// Dropdown options (adjust to your backend)
|
|
|
|
|
final List<String> tankerTypes = const [
|
|
|
|
|
"Standard Tanker",
|
|
|
|
|
"High-Capacity Tanker",
|
|
|
|
|
"Small Tanker",
|
|
|
|
|
"Without Pump",
|
|
|
|
|
"With Pump",
|
|
|
|
|
];
|
|
|
|
|
final List<String> typeOfWater = const [
|
|
|
|
|
"Drinking water",
|
|
|
|
|
@ -79,6 +78,21 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
int inactiveCount = 0;
|
|
|
|
|
int maintenanceCount = 0;
|
|
|
|
|
|
|
|
|
|
String? selectedFilter;
|
|
|
|
|
String selectedSort = "name";
|
|
|
|
|
|
|
|
|
|
List<String> filterOptions = [
|
|
|
|
|
"All",
|
|
|
|
|
"Active",
|
|
|
|
|
"Inactive",
|
|
|
|
|
"Maintenance"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
List<String> sortOptions = [
|
|
|
|
|
"Name",
|
|
|
|
|
"Capacity"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
@ -95,6 +109,169 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _showFilterMenu(BuildContext context, Offset position) async {
|
|
|
|
|
|
|
|
|
|
await showMenu<String>(
|
|
|
|
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
|
|
|
|
position: RelativeRect.fromLTRB(
|
|
|
|
|
position.dx,
|
|
|
|
|
position.dy,
|
|
|
|
|
position.dx + 200,
|
|
|
|
|
position.dy + 200),
|
|
|
|
|
|
|
|
|
|
items: [
|
|
|
|
|
|
|
|
|
|
PopupMenuItem<String>(
|
|
|
|
|
enabled: false,
|
|
|
|
|
child: Text(
|
|
|
|
|
"Filter",
|
|
|
|
|
style: fontTextStyle(
|
|
|
|
|
12,
|
|
|
|
|
Color(0XFF2D2E30),
|
|
|
|
|
FontWeight.w600),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
...filterOptions.map((option){
|
|
|
|
|
|
|
|
|
|
return PopupMenuItem<String>(
|
|
|
|
|
|
|
|
|
|
child: RadioListTile<String>(
|
|
|
|
|
|
|
|
|
|
value: option,
|
|
|
|
|
|
|
|
|
|
groupValue:
|
|
|
|
|
selectedFilter ?? "All",
|
|
|
|
|
|
|
|
|
|
activeColor:
|
|
|
|
|
Color(0XFF1D7AFC),
|
|
|
|
|
|
|
|
|
|
onChanged:(value){
|
|
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
|
|
selectedFilter =
|
|
|
|
|
value=="All"
|
|
|
|
|
? null
|
|
|
|
|
: value;
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
title: Text(
|
|
|
|
|
option,
|
|
|
|
|
style: fontTextStyle(
|
|
|
|
|
12,
|
|
|
|
|
Color(0XFF2D2E30),
|
|
|
|
|
FontWeight.w400),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
dense:true,
|
|
|
|
|
|
|
|
|
|
visualDensity:
|
|
|
|
|
VisualDensity(
|
|
|
|
|
horizontal:-4,
|
|
|
|
|
vertical:-4),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}).toList()
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _showSortMenu(BuildContext context, Offset position) async {
|
|
|
|
|
|
|
|
|
|
await showMenu<String>(
|
|
|
|
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
|
|
|
|
position: RelativeRect.fromLTRB(
|
|
|
|
|
position.dx,
|
|
|
|
|
position.dy,
|
|
|
|
|
position.dx + 200,
|
|
|
|
|
position.dy + 200),
|
|
|
|
|
|
|
|
|
|
items: [
|
|
|
|
|
|
|
|
|
|
PopupMenuItem<String>(
|
|
|
|
|
enabled:false,
|
|
|
|
|
child: Text(
|
|
|
|
|
"Sort",
|
|
|
|
|
style: fontTextStyle(
|
|
|
|
|
12,
|
|
|
|
|
Color(0XFF2D2E30),
|
|
|
|
|
FontWeight.w600),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
...sortOptions.map((option){
|
|
|
|
|
|
|
|
|
|
return PopupMenuItem<String>(
|
|
|
|
|
|
|
|
|
|
child: RadioListTile<String>(
|
|
|
|
|
|
|
|
|
|
value: option,
|
|
|
|
|
|
|
|
|
|
groupValue: selectedSort,
|
|
|
|
|
|
|
|
|
|
activeColor:
|
|
|
|
|
Color(0XFF1D7AFC),
|
|
|
|
|
|
|
|
|
|
onChanged:(value){
|
|
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
|
|
selectedSort =
|
|
|
|
|
value.toString();
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
title: Text(
|
|
|
|
|
option,
|
|
|
|
|
style: fontTextStyle(
|
|
|
|
|
12,
|
|
|
|
|
Color(0XFF2D2E30),
|
|
|
|
|
FontWeight.w400),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
dense:true,
|
|
|
|
|
|
|
|
|
|
visualDensity:
|
|
|
|
|
VisualDensity(
|
|
|
|
|
horizontal:-4,
|
|
|
|
|
vertical:-4),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}).toList()
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _fetchTankers() async {
|
|
|
|
|
setState(() => isLoading = true);
|
|
|
|
|
try {
|
|
|
|
|
@ -261,7 +438,7 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _nameCtrl,
|
|
|
|
|
validator: (v) => _required(v, field: "Tanker Name"),
|
|
|
|
|
textCapitalization: TextCapitalization.none,
|
|
|
|
|
textCapitalization: TextCapitalization.characters,
|
|
|
|
|
inputFormatters: const [
|
|
|
|
|
FirstCharUppercaseFormatter(), // << live first-letter caps
|
|
|
|
|
],
|
|
|
|
|
@ -361,11 +538,11 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_LabeledField(
|
|
|
|
|
label: "Manufacturing Year (opt)",
|
|
|
|
|
label: " Age of vehicle (opt)",
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _mfgYearCtrl,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "YYYY",
|
|
|
|
|
hintText: "12",
|
|
|
|
|
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
|
|
|
|
|
border: const OutlineInputBorder(),
|
|
|
|
|
isDense: true,
|
|
|
|
|
@ -426,14 +603,54 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final filtered = tankersList.where((it) {
|
|
|
|
|
List<TankersModel> filtered = tankersList.where((it) {
|
|
|
|
|
|
|
|
|
|
final q = search.trim().toLowerCase();
|
|
|
|
|
if (q.isEmpty) return true;
|
|
|
|
|
return it.tanker_name.toLowerCase().contains(q);
|
|
|
|
|
|
|
|
|
|
bool matchesSearch =
|
|
|
|
|
q.isEmpty || it.tanker_name.toLowerCase().contains(q);
|
|
|
|
|
|
|
|
|
|
bool matchesFilter = true;
|
|
|
|
|
|
|
|
|
|
if(selectedFilter=="Active"){
|
|
|
|
|
matchesFilter =
|
|
|
|
|
it.availability.contains('available') ||
|
|
|
|
|
it.availability.contains('in-use') ||
|
|
|
|
|
it.availability.contains('empty');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(selectedFilter=="Inactive"){
|
|
|
|
|
matchesFilter =
|
|
|
|
|
it.availability.contains('inactive');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(selectedFilter=="Maintenance"){
|
|
|
|
|
matchesFilter =
|
|
|
|
|
it.availability.contains('undermaintanence');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return matchesSearch && matchesFilter;
|
|
|
|
|
|
|
|
|
|
}).toList();
|
|
|
|
|
|
|
|
|
|
if(selectedSort=="Name"){
|
|
|
|
|
filtered.sort((a,b)=>
|
|
|
|
|
a.tanker_name.compareTo(b.tanker_name));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(selectedSort=="Capacity"){
|
|
|
|
|
filtered.sort((a,b)=>
|
|
|
|
|
int.parse(a.capacity.replaceAll(",",""))
|
|
|
|
|
.compareTo(
|
|
|
|
|
int.parse(b.capacity.replaceAll(",",""))
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
body: Column(
|
|
|
|
|
@ -477,20 +694,36 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const Spacer(),
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
tankersList.length.toString(),
|
|
|
|
|
style: fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500),
|
|
|
|
|
),
|
|
|
|
|
/*const SizedBox(height: 6),
|
|
|
|
|
Text('+2 since last month',
|
|
|
|
|
style: fontTextStyle(10, const Color(0xFF646566), FontWeight.w400),
|
|
|
|
|
),*/
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
tankersList.length.toString(),
|
|
|
|
|
style: fontTextStyle(
|
|
|
|
|
24,
|
|
|
|
|
const Color(0xFF0D3771),
|
|
|
|
|
FontWeight.w500),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
tankersList.isEmpty
|
|
|
|
|
? Text(
|
|
|
|
|
'You have not added any tankers please click + button to add new Tanker.',
|
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
|
softWrap: true,
|
|
|
|
|
style: fontTextStyle(
|
|
|
|
|
10,
|
|
|
|
|
const Color(0xFF646566),
|
|
|
|
|
FontWeight.w400),
|
|
|
|
|
)
|
|
|
|
|
: const SizedBox(),
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -558,26 +791,50 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 16),
|
|
|
|
|
Container(
|
|
|
|
|
width: 24,
|
|
|
|
|
height: 24,
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
image: DecorationImage(
|
|
|
|
|
image: AssetImage('images/icon_tune.png'),
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
GestureDetector(
|
|
|
|
|
|
|
|
|
|
onTapDown:(TapDownDetails details){
|
|
|
|
|
|
|
|
|
|
_showFilterMenu(
|
|
|
|
|
context,
|
|
|
|
|
details.globalPosition);
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 24,
|
|
|
|
|
height: 24,
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
image: DecorationImage(
|
|
|
|
|
image: AssetImage('images/icon_tune.png'),
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 16),
|
|
|
|
|
Container(
|
|
|
|
|
width: 24,
|
|
|
|
|
height: 24,
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
image: DecorationImage(
|
|
|
|
|
image: AssetImage('images/up_down_arrow.png'),
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
GestureDetector(
|
|
|
|
|
|
|
|
|
|
onTapDown:(TapDownDetails details){
|
|
|
|
|
|
|
|
|
|
_showSortMenu(
|
|
|
|
|
context,
|
|
|
|
|
details.globalPosition);
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 24,
|
|
|
|
|
height: 24,
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
image: DecorationImage(
|
|
|
|
|
image: AssetImage('images/up_down_arrow.png'),
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
|