|
|
|
|
@ -1,19 +1,15 @@
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
import 'package:supplier_new/common/settings.dart';
|
|
|
|
|
import 'package:supplier_new/resources/tankers_model.dart';
|
|
|
|
|
|
|
|
|
|
// Screens (single import each) – keep if you actually navigate to these
|
|
|
|
|
import 'fleet.dart';
|
|
|
|
|
import 'resources_drivers.dart';
|
|
|
|
|
import 'resources_sources.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:supplier_new/resources/resources_drivers.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:supplier_new/resources/resources_sources.dart';
|
|
|
|
|
|
|
|
|
|
import 'fleet.dart';void main() => runApp(const MaterialApp(home: ResourcesFleetScreen()));
|
|
|
|
|
void main() => runApp(const MaterialApp(home: ResourcesFleetScreen()));
|
|
|
|
|
|
|
|
|
|
class ResourcesFleetScreen extends StatefulWidget {
|
|
|
|
|
const ResourcesFleetScreen({super.key});
|
|
|
|
|
@ -25,13 +21,28 @@ class ResourcesFleetScreen extends StatefulWidget {
|
|
|
|
|
class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
final _formKey = GlobalKey<FormState>();
|
|
|
|
|
|
|
|
|
|
// Controllers
|
|
|
|
|
// Controllers (sheet)
|
|
|
|
|
final _nameCtrl = TextEditingController();
|
|
|
|
|
final _capacityCtrl = TextEditingController(); // hint-like
|
|
|
|
|
final _capacityCtrl = TextEditingController();
|
|
|
|
|
final _plateCtrl = TextEditingController();
|
|
|
|
|
final _mfgYearCtrl = TextEditingController();
|
|
|
|
|
final _insExpiryCtrl = TextEditingController();
|
|
|
|
|
|
|
|
|
|
// Dropdown selections (sheet)
|
|
|
|
|
String? selectedType;
|
|
|
|
|
String? selectedTypeOfWater;
|
|
|
|
|
|
|
|
|
|
// Dropdown options (adjust to your backend)
|
|
|
|
|
final List<String> tankerTypes = const [
|
|
|
|
|
"Standard Tanker",
|
|
|
|
|
"High-Capacity Tanker",
|
|
|
|
|
"Small Tanker",
|
|
|
|
|
];
|
|
|
|
|
final List<String> typeOfWater = const [
|
|
|
|
|
"Drinking water",
|
|
|
|
|
"Bore water",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
String? _required(String? v, {String field = "This field"}) {
|
|
|
|
|
if (v == null || v.trim().isEmpty) return "$field is required";
|
|
|
|
|
return null;
|
|
|
|
|
@ -39,19 +50,27 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
|
|
|
|
|
int selectedTab = 0;
|
|
|
|
|
String search = '';
|
|
|
|
|
bool isLoading = false;
|
|
|
|
|
bool isLoading = false;
|
|
|
|
|
List<TankersModel> tankersList = [];
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
// TODO: implement initState
|
|
|
|
|
super.initState();
|
|
|
|
|
_fetchTankers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_nameCtrl.dispose();
|
|
|
|
|
_capacityCtrl.dispose();
|
|
|
|
|
_plateCtrl.dispose();
|
|
|
|
|
_mfgYearCtrl.dispose();
|
|
|
|
|
_insExpiryCtrl.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _fetchTankers() async {
|
|
|
|
|
setState(() => isLoading = true);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
final response = await AppSettings.getTankers();
|
|
|
|
|
final data = (jsonDecode(response)['data'] as List)
|
|
|
|
|
@ -63,207 +82,275 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
debugPrint("⚠️ Error fetching orders: $e");
|
|
|
|
|
debugPrint("⚠️ Error fetching tankers: $e");
|
|
|
|
|
setState(() => isLoading = false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final List<Map<String, dynamic>> items = [
|
|
|
|
|
{
|
|
|
|
|
'title': 'Tanker Name',
|
|
|
|
|
'subtitle': 'Drinking water - 10,000 L',
|
|
|
|
|
'status': ['filled', 'available'],
|
|
|
|
|
'code': 'TS 07 J 3492',
|
|
|
|
|
'owner': 'Ramesh Krishna'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'title': 'Drinking Water - 15,000L',
|
|
|
|
|
'subtitle': 'Drinking water - 15,000 L',
|
|
|
|
|
'status': ['empty', 'available'],
|
|
|
|
|
'code': 'TS 07 J 3492',
|
|
|
|
|
'owner': 'Ramesh Krishna'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'title': 'Tanker Name',
|
|
|
|
|
'subtitle': 'Drinking water - 10,000 L',
|
|
|
|
|
'status': ['filled', 'in-use'],
|
|
|
|
|
'code': 'TS 07 J 3492',
|
|
|
|
|
'owner': 'Ramesh Krishna'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'title': 'Drinking Water - 15,000L',
|
|
|
|
|
'subtitle': 'Drinking water - 15,000 L',
|
|
|
|
|
'status': ['empty', 'in-use'],
|
|
|
|
|
'code': 'TS 07 J 3492',
|
|
|
|
|
'owner': 'Ramesh Krishna'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'title': 'Tanker Name',
|
|
|
|
|
'subtitle': 'Drinking water - 10,000 L',
|
|
|
|
|
'status': ['filled', 'maintenance'],
|
|
|
|
|
'code': 'TS 07 J 3492',
|
|
|
|
|
'owner': 'Ramesh Krishna'
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
Future<void> _pickInsuranceDate() async {
|
|
|
|
|
final picked = await showDatePicker(
|
|
|
|
|
context: context,
|
|
|
|
|
initialDate: DateTime.now(),
|
|
|
|
|
firstDate: DateTime(2000),
|
|
|
|
|
lastDate: DateTime(2100),
|
|
|
|
|
builder: (context, child) {
|
|
|
|
|
return Theme(
|
|
|
|
|
data: Theme.of(context).copyWith(
|
|
|
|
|
dialogBackgroundColor: Colors.white,
|
|
|
|
|
colorScheme: Theme.of(context).colorScheme.copyWith(
|
|
|
|
|
primary: const Color(0xFF8270DB),
|
|
|
|
|
surface: Colors.white,
|
|
|
|
|
onSurface: const Color(0xFF101214),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: child!,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
if (picked != null) {
|
|
|
|
|
final dd = picked.day.toString().padLeft(2, '0');
|
|
|
|
|
final mm = picked.month.toString().padLeft(2, '0');
|
|
|
|
|
final yyyy = picked.year.toString();
|
|
|
|
|
_insExpiryCtrl.text = "$dd-$mm-$yyyy";
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _resetForm() {
|
|
|
|
|
_formKey.currentState?.reset();
|
|
|
|
|
_nameCtrl.clear();
|
|
|
|
|
_capacityCtrl.clear();
|
|
|
|
|
_plateCtrl.clear();
|
|
|
|
|
_mfgYearCtrl.clear();
|
|
|
|
|
_insExpiryCtrl.clear();
|
|
|
|
|
selectedType = null;
|
|
|
|
|
selectedTypeOfWater = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _addTanker() async {
|
|
|
|
|
// Validate
|
|
|
|
|
final ok = _formKey.currentState?.validate() ?? false;
|
|
|
|
|
if (!ok) {
|
|
|
|
|
setState(() {}); // force rebuild to show errors
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build payload keys to match your backend
|
|
|
|
|
final payload = <String, dynamic>{
|
|
|
|
|
"tankerName": _nameCtrl.text.trim(),
|
|
|
|
|
"capacity": _capacityCtrl.text.trim(),
|
|
|
|
|
"typeofwater": selectedTypeOfWater ?? "",
|
|
|
|
|
"supplier_address": AppSettings.userAddress,
|
|
|
|
|
"supplier_name": AppSettings.userName,
|
|
|
|
|
"phoneNumber": AppSettings.phoneNumber,
|
|
|
|
|
"tanker_type": selectedType ?? "",
|
|
|
|
|
"license_plate": _plateCtrl.text.trim(),
|
|
|
|
|
"manufacturing_year": _mfgYearCtrl.text.trim(),
|
|
|
|
|
"insurance_exp_date": _insExpiryCtrl.text.trim(),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
final bool tankStatus = await AppSettings.addTankers(payload);
|
|
|
|
|
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
|
|
|
|
|
if (tankStatus) {
|
|
|
|
|
AppSettings.longSuccessToast("Tanker Created Successfully");
|
|
|
|
|
Navigator.pop(context, true); // close sheet
|
|
|
|
|
_resetForm();
|
|
|
|
|
_fetchTankers(); // refresh from server
|
|
|
|
|
} else {
|
|
|
|
|
AppSettings.longFailedToast("Tanker Creation failed");
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
debugPrint("⚠️ addTankers error: $e");
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
AppSettings.longFailedToast("Something went wrong");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void openTankerSimpleSheet(BuildContext context) {
|
|
|
|
|
_resetForm(); // open fresh
|
|
|
|
|
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
|
|
|
|
),
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
|
builder: (context) {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
left: 20,
|
|
|
|
|
right: 20,
|
|
|
|
|
top: 16,
|
|
|
|
|
bottom: MediaQuery.of(context).viewInsets.bottom + 20,
|
|
|
|
|
),
|
|
|
|
|
child: Form(
|
|
|
|
|
key: _formKey,
|
|
|
|
|
child: ListView(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
children: [
|
|
|
|
|
// Tanker Name
|
|
|
|
|
Text("Tanker Name *",
|
|
|
|
|
style: fontTextStyle(14, const Color(0xFF646566), FontWeight.w600)),
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
TextFormField(
|
|
|
|
|
controller: _nameCtrl,
|
|
|
|
|
validator: (v) => _required(v, field: "Tanker Name"),
|
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
|
hintText: "Enter Tanker Name",
|
|
|
|
|
border: OutlineInputBorder(),
|
|
|
|
|
isDense: true,
|
|
|
|
|
),
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
final viewInsets = MediaQuery.of(context).viewInsets.bottom;
|
|
|
|
|
|
|
|
|
|
return FractionallySizedBox(
|
|
|
|
|
heightFactor: 0.75,
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
|
|
|
|
),
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: EdgeInsets.fromLTRB(20, 16, 20, 20 + viewInsets),
|
|
|
|
|
child: Form(
|
|
|
|
|
key: _formKey,
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
children: [
|
|
|
|
|
_LabeledField(
|
|
|
|
|
label: "Tanker Name *",
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _nameCtrl,
|
|
|
|
|
validator: (v) => _required(v, field: "Tanker Name"),
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "Enter Tanker Name",
|
|
|
|
|
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
|
|
|
|
|
border: const OutlineInputBorder(),
|
|
|
|
|
isDense: true,
|
|
|
|
|
),
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// Capacity
|
|
|
|
|
Text("Tanker Capacity (in L) *",
|
|
|
|
|
style: fontTextStyle(14, const Color(0xFF646566), FontWeight.w600)),
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
TextFormField(
|
|
|
|
|
controller: _capacityCtrl,
|
|
|
|
|
validator: (v) => _required(v, field: "Tanker Capacity"),
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "10,000 L",
|
|
|
|
|
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
|
|
|
|
|
border: const OutlineInputBorder(),
|
|
|
|
|
isDense: true,
|
|
|
|
|
),
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
inputFormatters: [
|
|
|
|
|
FilteringTextInputFormatter.allow(RegExp(r'[0-9,]')),
|
|
|
|
|
],
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
_LabeledField(
|
|
|
|
|
label: "Tanker Capacity (in L) *",
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _capacityCtrl,
|
|
|
|
|
validator: (v) => _required(v, field: "Tanker Capacity"),
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "10,000",
|
|
|
|
|
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
|
|
|
|
|
border: const OutlineInputBorder(),
|
|
|
|
|
isDense: true,
|
|
|
|
|
),
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
inputFormatters: [
|
|
|
|
|
FilteringTextInputFormatter.allow(RegExp(r'[0-9,]')),
|
|
|
|
|
],
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// License Plate
|
|
|
|
|
Text("License Plate *",
|
|
|
|
|
style: fontTextStyle(14, const Color(0xFF646566), FontWeight.w600)),
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
TextFormField(
|
|
|
|
|
controller: _plateCtrl,
|
|
|
|
|
validator: (v) => _required(v, field: "License Plate"),
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "AB 05 H 4948",
|
|
|
|
|
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
|
|
|
|
|
border: const OutlineInputBorder(),
|
|
|
|
|
isDense: true,
|
|
|
|
|
),
|
|
|
|
|
textCapitalization: TextCapitalization.characters,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
_LabeledField(
|
|
|
|
|
label: "Tanker Type *",
|
|
|
|
|
child: DropdownButtonFormField<String>(
|
|
|
|
|
value: selectedType,
|
|
|
|
|
items: tankerTypes
|
|
|
|
|
.map((t) => DropdownMenuItem(value: t, child: Text(t)))
|
|
|
|
|
.toList(),
|
|
|
|
|
onChanged: (v) => setState(() => selectedType = v),
|
|
|
|
|
validator: (v) => v == null || v.isEmpty ? "Tanker Type is required" : null,
|
|
|
|
|
isExpanded: true,
|
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
|
hint: Text(
|
|
|
|
|
"Select Type",
|
|
|
|
|
style: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
|
|
|
|
|
),
|
|
|
|
|
icon: Image.asset('images/downarrow.png', width: 16, height: 16),
|
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
|
border: OutlineInputBorder(),
|
|
|
|
|
isDense: false,
|
|
|
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 14),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// Manufacturing Year (optional)
|
|
|
|
|
Text("Manufacturing Year (opt)",
|
|
|
|
|
style: fontTextStyle(14, const Color(0xFF646566), FontWeight.w600)),
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
TextFormField(
|
|
|
|
|
controller: _mfgYearCtrl,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "YYYY",
|
|
|
|
|
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
|
|
|
|
|
border: const OutlineInputBorder(),
|
|
|
|
|
isDense: true,
|
|
|
|
|
),
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
inputFormatters: [
|
|
|
|
|
FilteringTextInputFormatter.digitsOnly,
|
|
|
|
|
LengthLimitingTextInputFormatter(4),
|
|
|
|
|
],
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
_LabeledField(
|
|
|
|
|
label: "Type of water *",
|
|
|
|
|
child: DropdownButtonFormField<String>(
|
|
|
|
|
value: selectedTypeOfWater,
|
|
|
|
|
items: typeOfWater
|
|
|
|
|
.map((t) => DropdownMenuItem(value: t, child: Text(t)))
|
|
|
|
|
.toList(),
|
|
|
|
|
onChanged: (v) => setState(() => selectedTypeOfWater = v),
|
|
|
|
|
validator: (v) => v == null || v.isEmpty ? "Type of water is required" : null,
|
|
|
|
|
isExpanded: true,
|
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
|
hint: Text(
|
|
|
|
|
"Select type of water",
|
|
|
|
|
style: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
|
|
|
|
|
),
|
|
|
|
|
icon: Image.asset('images/downarrow.png', width: 16, height: 16),
|
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
|
border: OutlineInputBorder(),
|
|
|
|
|
isDense: false,
|
|
|
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 14),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// Insurance Expiry Date (optional)
|
|
|
|
|
Text("Insurance Expiry Date (opt)",
|
|
|
|
|
style: fontTextStyle(14, const Color(0xFF646566), FontWeight.w600)),
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
TextFormField(
|
|
|
|
|
controller: _insExpiryCtrl,
|
|
|
|
|
readOnly: true,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "DD-MM-YYYY",
|
|
|
|
|
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
|
|
|
|
|
border: const OutlineInputBorder(),
|
|
|
|
|
isDense: true,
|
|
|
|
|
suffixIcon: const Icon(Icons.calendar_today_outlined, size: 18),
|
|
|
|
|
),
|
|
|
|
|
onTap: () async {
|
|
|
|
|
final now = DateTime.now();
|
|
|
|
|
final picked = await showDatePicker(
|
|
|
|
|
context: context,
|
|
|
|
|
initialDate: now,
|
|
|
|
|
firstDate: DateTime(now.year - 30),
|
|
|
|
|
lastDate: DateTime(now.year + 30),
|
|
|
|
|
);
|
|
|
|
|
if (picked != null) {
|
|
|
|
|
final dd = picked.day.toString().padLeft(2, '0');
|
|
|
|
|
final mm = picked.month.toString().padLeft(2, '0');
|
|
|
|
|
final yyyy = picked.year.toString();
|
|
|
|
|
_insExpiryCtrl.text = "$dd-$mm-$yyyy";
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
|
_LabeledField(
|
|
|
|
|
label: "License Plate *",
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _plateCtrl,
|
|
|
|
|
validator: (v) => _required(v, field: "License Plate"),
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "AB 05 H 4948",
|
|
|
|
|
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
|
|
|
|
|
border: const OutlineInputBorder(),
|
|
|
|
|
isDense: true,
|
|
|
|
|
),
|
|
|
|
|
textCapitalization: TextCapitalization.characters,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// Save button
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: ElevatedButton(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
backgroundColor: const Color(0xFF8270DB),
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(24),
|
|
|
|
|
_LabeledField(
|
|
|
|
|
label: "Manufacturing Year (opt)",
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _mfgYearCtrl,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "YYYY",
|
|
|
|
|
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
|
|
|
|
|
border: const OutlineInputBorder(),
|
|
|
|
|
isDense: true,
|
|
|
|
|
),
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
inputFormatters: [
|
|
|
|
|
FilteringTextInputFormatter.digitsOnly,
|
|
|
|
|
LengthLimitingTextInputFormatter(4),
|
|
|
|
|
],
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
if (_formKey.currentState?.validate() != true) return;
|
|
|
|
|
|
|
|
|
|
// TODO: Replace with your save logic / API call
|
|
|
|
|
// Example:
|
|
|
|
|
// final ok = await saveTanker();
|
|
|
|
|
// if (ok) Navigator.pop(context, true);
|
|
|
|
|
|
|
|
|
|
Navigator.pop(context, true); // close sheet on success
|
|
|
|
|
},
|
|
|
|
|
child: Text(
|
|
|
|
|
"Save",
|
|
|
|
|
style: fontTextStyle(14, Colors.white, FontWeight.w600),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_LabeledField(
|
|
|
|
|
label: "Insurance Expiry Date (opt)",
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _insExpiryCtrl,
|
|
|
|
|
readOnly: true,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "DD-MM-YYYY",
|
|
|
|
|
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
|
|
|
|
|
border: const OutlineInputBorder(),
|
|
|
|
|
isDense: true,
|
|
|
|
|
suffixIcon: const Icon(Icons.calendar_today_outlined, size: 18),
|
|
|
|
|
),
|
|
|
|
|
onTap: _pickInsuranceDate,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: ElevatedButton(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
backgroundColor: const Color(0xFF8270DB),
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(24),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
onPressed: _addTanker,
|
|
|
|
|
child: Text(
|
|
|
|
|
"Save",
|
|
|
|
|
style: fontTextStyle(14, Colors.white, FontWeight.w600),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
@ -271,8 +358,6 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final filtered = tankersList.where((it) {
|
|
|
|
|
@ -285,6 +370,7 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
body: Column(
|
|
|
|
|
children: [
|
|
|
|
|
// Header section
|
|
|
|
|
Container(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
|
|
|
|
|
@ -297,7 +383,7 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
border: Border.all(color: Color(0xFF939495)),
|
|
|
|
|
border: Border.all(color: const Color(0xFF939495)),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
@ -309,56 +395,47 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
height: 40,
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
color: Color(0xFFF6F0FF),
|
|
|
|
|
borderRadius:
|
|
|
|
|
BorderRadius.all(Radius.circular(8)),
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(8)),
|
|
|
|
|
),
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
'images/truck.png',
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
),
|
|
|
|
|
child: Image.asset('images/truck.png', fit: BoxFit.contain),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
Text('Total Tankers', style: fontTextStyle(12, Color(0xFF2D2E30), FontWeight.w500, // or w500 if you want slightly bolder
|
|
|
|
|
),
|
|
|
|
|
Text('Total Tankers',
|
|
|
|
|
style: fontTextStyle(12, const Color(0xFF2D2E30), FontWeight.w500),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const Spacer(),
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [Text(tankersList.length.toString(), style: fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
tankersList.length.toString(),
|
|
|
|
|
style: fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
SizedBox(height: 6),
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
Text('+2 since last month',
|
|
|
|
|
style: fontTextStyle(10, Color(0xFF646566), FontWeight.w400,)),
|
|
|
|
|
style: fontTextStyle(10, const Color(0xFF646566), FontWeight.w400),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
|
|
|
|
|
IntrinsicHeight(
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: SmallMetricBox(title: 'Active', value: '2')),
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: SmallMetricBox(title: 'Inactive', value: '3')),
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: SmallMetricBox(
|
|
|
|
|
title: 'Under Maintenances', value: '1')),
|
|
|
|
|
children: const [
|
|
|
|
|
Expanded(child: SmallMetricBox(title: 'Active', value: '2')),
|
|
|
|
|
SizedBox(width: 8),
|
|
|
|
|
Expanded(child: SmallMetricBox(title: 'Inactive', value: '3')),
|
|
|
|
|
SizedBox(width: 8),
|
|
|
|
|
Expanded(child: SmallMetricBox(title: 'Under Maintenance', value: '1')),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -366,10 +443,10 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// -------- SECOND SECTION (gray background) ----------
|
|
|
|
|
// List section
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
color: const Color(0xFFF5F5F5), // Gray background
|
|
|
|
|
color: const Color(0xFFF5F5F5),
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
|
|
|
|
child: Column(
|
|
|
|
|
@ -379,13 +456,9 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 270,
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: 12, vertical: 6),
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: Color(0xFF939495), // 👈 border color
|
|
|
|
|
width: 0.5, // 👈 border width
|
|
|
|
|
),
|
|
|
|
|
border: Border.all(color: const Color(0xFF939495), width: 0.5),
|
|
|
|
|
borderRadius: BorderRadius.circular(22),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
@ -395,8 +468,9 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
height: 20,
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
image: DecorationImage(
|
|
|
|
|
image: AssetImage('images/search.png'),
|
|
|
|
|
fit: BoxFit.contain),
|
|
|
|
|
image: AssetImage('images/search.png'),
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
@ -404,15 +478,11 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
child: TextField(
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: 'Search',
|
|
|
|
|
hintStyle: fontTextStyle(
|
|
|
|
|
12,
|
|
|
|
|
const Color(0xFF939495),
|
|
|
|
|
FontWeight.w400),
|
|
|
|
|
hintStyle: fontTextStyle(12, const Color(0xFF939495), FontWeight.w400),
|
|
|
|
|
border: InputBorder.none,
|
|
|
|
|
isDense: true,
|
|
|
|
|
),
|
|
|
|
|
onChanged: (v) =>
|
|
|
|
|
setState(() => search = v),
|
|
|
|
|
onChanged: (v) => setState(() => search = v),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
@ -425,8 +495,9 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
height: 24,
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
image: DecorationImage(
|
|
|
|
|
image: AssetImage('images/icon_tune.png'),
|
|
|
|
|
fit: BoxFit.contain),
|
|
|
|
|
image: AssetImage('images/icon_tune.png'),
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 16),
|
|
|
|
|
@ -435,18 +506,18 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
height: 24,
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
image: DecorationImage(
|
|
|
|
|
image: AssetImage('images/up_down arrow.png'),
|
|
|
|
|
fit: BoxFit.contain),
|
|
|
|
|
image: AssetImage('images/up_down_arrow.png'),
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
|
|
|
|
|
// Cards List
|
|
|
|
|
Expanded(
|
|
|
|
|
child: ListView.separated(
|
|
|
|
|
child: isLoading
|
|
|
|
|
? const Center(child: CircularProgressIndicator())
|
|
|
|
|
: ListView.separated(
|
|
|
|
|
itemCount: filtered.length,
|
|
|
|
|
separatorBuilder: (_, __) => const SizedBox(height: 10),
|
|
|
|
|
itemBuilder: (context, idx) {
|
|
|
|
|
@ -470,24 +541,10 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
floatingActionButton: FloatingActionButton(
|
|
|
|
|
onPressed: () async{
|
|
|
|
|
openTankerSimpleSheet(context);
|
|
|
|
|
/*final result = await Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => FleetStep1Page(),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// If result indicates API reload
|
|
|
|
|
if (result == true) {
|
|
|
|
|
_fetchTankers();
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
onPressed: () => openTankerSimpleSheet(context),
|
|
|
|
|
backgroundColor: const Color(0xFF000000),
|
|
|
|
|
shape: const CircleBorder(), // ✅ ensures circle
|
|
|
|
|
child: const Icon(Icons.add,color: Colors.white,),
|
|
|
|
|
shape: const CircleBorder(),
|
|
|
|
|
child: const Icon(Icons.add, color: Colors.white),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
@ -506,22 +563,22 @@ class SmallMetricBox extends StatelessWidget {
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
border: Border.all(color: Color(0xFF939495)),
|
|
|
|
|
|
|
|
|
|
border: Border.all(color: const Color(0xFF939495)),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(title,
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
style:
|
|
|
|
|
fontTextStyle(12, const Color(0xFF2D2E30), FontWeight.w500)),
|
|
|
|
|
Text(value,
|
|
|
|
|
style:
|
|
|
|
|
fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500)),
|
|
|
|
|
Text(
|
|
|
|
|
title,
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
style: fontTextStyle(12, const Color(0xFF2D2E30), FontWeight.w500),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
value,
|
|
|
|
|
style: fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
@ -601,28 +658,23 @@ class TankCard extends StatelessWidget {
|
|
|
|
|
final chipTextColor = _chipTextColor(s);
|
|
|
|
|
return Container(
|
|
|
|
|
margin: const EdgeInsets.only(right: 6),
|
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: 8, vertical: 4),
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: _chipColor(s),
|
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
border: Border.all(color: chipTextColor, width: 1),
|
|
|
|
|
),
|
|
|
|
|
child: Text(
|
|
|
|
|
s, style:
|
|
|
|
|
fontTextStyle(10, chipTextColor, FontWeight.w400),
|
|
|
|
|
s,
|
|
|
|
|
style: fontTextStyle(10, chipTextColor, FontWeight.w400),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}).toList(),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
Text (title,
|
|
|
|
|
style: fontTextStyle(
|
|
|
|
|
14, const Color(0xFF343637), FontWeight.w600)),
|
|
|
|
|
Text(title, style: fontTextStyle(14, const Color(0xFF343637), FontWeight.w600)),
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
Text(subtitle+' - '+capacity+' L',
|
|
|
|
|
style: fontTextStyle(
|
|
|
|
|
10, const Color(0xFF343637), FontWeight.w600)),
|
|
|
|
|
Text("$subtitle - $capacity L", style: fontTextStyle(10, const Color(0xFF343637), FontWeight.w600)),
|
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
@ -633,20 +685,17 @@ class TankCard extends StatelessWidget {
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
|
image: DecorationImage(
|
|
|
|
|
image: (AppSettings.profilePictureUrl != '' &&
|
|
|
|
|
AppSettings.profilePictureUrl != 'null')
|
|
|
|
|
? NetworkImage(AppSettings.profilePictureUrl)
|
|
|
|
|
as ImageProvider
|
|
|
|
|
: const AssetImage("images/profile_pic.png"),
|
|
|
|
|
fit: BoxFit.cover),
|
|
|
|
|
image: (AppSettings.profilePictureUrl != '' && AppSettings.profilePictureUrl != 'null')
|
|
|
|
|
? NetworkImage(AppSettings.profilePictureUrl)
|
|
|
|
|
: const AssetImage("images/profile_pic.png") as ImageProvider,
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(owner,
|
|
|
|
|
style: fontTextStyle(
|
|
|
|
|
8, const Color(0xFF646566), FontWeight.w400)),
|
|
|
|
|
child: Text(owner, style: fontTextStyle(8, const Color(0xFF646566), FontWeight.w400)),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -656,9 +705,7 @@ class TankCard extends StatelessWidget {
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
Text(code,
|
|
|
|
|
style: fontTextStyle(
|
|
|
|
|
10, const Color(0xFF515253), FontWeight.w400)),
|
|
|
|
|
Text(code, style: fontTextStyle(10, const Color(0xFF515253), FontWeight.w400)),
|
|
|
|
|
const SizedBox(height: 28),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -667,3 +714,26 @@ class TankCard extends StatelessWidget {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ====== Labeled Field Wrapper ======
|
|
|
|
|
class _LabeledField extends StatelessWidget {
|
|
|
|
|
final String label;
|
|
|
|
|
final Widget child;
|
|
|
|
|
|
|
|
|
|
const _LabeledField({required this.label, required this.child});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: const EdgeInsets.only(bottom: 14.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(label, style: fontTextStyle(12, const Color(0xFF515253), FontWeight.w600)),
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
child,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|