resources changes

master
gitadmin 2 months ago
parent c664967fa2
commit ebe650103f

@ -1,9 +1,8 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:supplier_new/common/settings.dart'; import 'package:supplier_new/common/settings.dart';
import 'package:supplier_new/resources/drivers_model.dart'; import 'package:supplier_new/resources/drivers_model.dart';
import 'employees.dart';
class ResourcesDriverScreen extends StatefulWidget { class ResourcesDriverScreen extends StatefulWidget {
const ResourcesDriverScreen({super.key}); const ResourcesDriverScreen({super.key});
@ -13,21 +12,82 @@ class ResourcesDriverScreen extends StatefulWidget {
} }
class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> { class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> {
// ---------- screen state ----------
int selectedTab = 1; // default "Drivers" int selectedTab = 1; // default "Drivers"
String search = ''; String search = '';
bool isLoading = false; bool isLoading = false;
List<DriversModel> driversList = []; List<DriversModel> driversList = [];
// ---------- form (bottom sheet) ----------
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
// Text controllers
final _nameCtrl = TextEditingController();
final _mobileCtrl = TextEditingController();
final _altMobileCtrl = TextEditingController();
final _locationCtrl = TextEditingController();
// Unused in UI but kept if you later need them
final _commissionCtrl = TextEditingController();
final _joinDateCtrl = TextEditingController();
// Dropdown state
String? _status; // 'available' | 'on delivery' | 'offline'
final List<String> _statusOptions = const ['available', 'on delivery', 'offline'];
String? selectedLicense;
final List<String> licenseNumbers = const [
'DL-042019-9876543',
'DL-052020-1234567',
'DL-072021-7654321',
];
String? selectedExperience; // years as string
final List<String> yearOptions = List<String>.generate(41, (i) => '$i'); // 0..40
String? _required(String? v, {String field = "This field"}) {
if (v == null || v.trim().isEmpty) return "$field is required";
return null;
}
String? _validatePhone(String? v, {String label = "Phone"}) {
if (v == null || v.trim().isEmpty) return "$label is required";
if (v.trim().length != 10) return "$label must be 10 digits";
return null;
}
@override @override
void initState() { void initState() {
// TODO: implement initState
super.initState(); super.initState();
_fetchDrivers(); _fetchDrivers();
} }
@override
void dispose() {
_nameCtrl.dispose();
_mobileCtrl.dispose();
_altMobileCtrl.dispose();
_locationCtrl.dispose();
_commissionCtrl.dispose();
_joinDateCtrl.dispose();
super.dispose();
}
void _resetForm() {
_formKey.currentState?.reset();
_nameCtrl.clear();
_mobileCtrl.clear();
_altMobileCtrl.clear();
_locationCtrl.clear();
_commissionCtrl.clear();
_joinDateCtrl.clear();
selectedLicense = null;
selectedExperience = null;
_status = null;
}
Future<void> _fetchDrivers() async { Future<void> _fetchDrivers() async {
setState(() => isLoading = true); setState(() => isLoading = true);
try { try {
final response = await AppSettings.getDrivers(); final response = await AppSettings.getDrivers();
final data = (jsonDecode(response)['data'] as List) final data = (jsonDecode(response)['data'] as List)
@ -39,35 +99,283 @@ class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> {
isLoading = false; isLoading = false;
}); });
} catch (e) { } catch (e) {
debugPrint("⚠️ Error fetching orders: $e"); debugPrint("⚠️ Error fetching drivers: $e");
setState(() => isLoading = false); setState(() => isLoading = false);
} }
} }
// ---------- submit ----------
Future<void> _addDriver() async {
// run all validators, including the dropdowns
final ok = _formKey.currentState?.validate() ?? false;
if (!ok) {
setState(() {}); // ensure error texts render
return;
}
// Build payload (adjust keys to your API if needed)
final payload = <String, dynamic>{
"Name": _nameCtrl.text.trim(),
"license_number": selectedLicense ?? "",
"address": _locationCtrl.text.trim().isEmpty ? AppSettings.userAddress : _locationCtrl.text.trim(),
"supplier_name": AppSettings.userName,
"phone": _mobileCtrl.text.trim(),
"alternativeContactNumber": _altMobileCtrl.text.trim(),
"years_of_experience": selectedExperience ?? "",
"status": _status ?? "available",
};
try {
final bool created = await AppSettings.addDrivers(payload);
if (!mounted) return;
if (created) {
AppSettings.longSuccessToast("Driver created successfully");
Navigator.pop(context, true); // close sheet
_resetForm();
_fetchDrivers(); // refresh
} else {
AppSettings.longFailedToast("Driver creation failed");
}
} catch (e) {
debugPrint("⚠️ addDrivers error: $e");
if (!mounted) return;
AppSettings.longFailedToast("Something went wrong");
}
}
// ---------- bottom sheet ----------
void _openDriverFormSheet(BuildContext context) {
_resetForm(); // fresh form every time
showModalBottomSheet(
context: context,
isScrollControlled: true, // allow content to move for keyboard
backgroundColor: Colors.transparent, // style inner container
builder: (context) {
final bottomInset = MediaQuery.of(context).viewInsets.bottom;
return FractionallySizedBox(
heightFactor: 0.75, // fixed height (75% of screen)
child: Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
child: Padding(
padding: EdgeInsets.fromLTRB(20, 16, 20, 20 + bottomInset),
child: Form(
key: _formKey,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Handle + close (optional, simple close icon)
Row(
children: [
Expanded(
child: Center(
child: Container(
width: 36,
height: 4,
margin: const EdgeInsets.only(bottom: 12),
decoration: BoxDecoration(
color: const Color(0xFFE0E0E0),
borderRadius: BorderRadius.circular(2),
),
),
),
),
IconButton(
onPressed: () => Navigator.pop(context),
icon: const Icon(Icons.close),
),
],
),
_LabeledField(
label: "Driver Name *",
child: TextFormField(
controller: _nameCtrl,
validator: (v) => _required(v, field: "Driver Name"),
decoration: InputDecoration(
hintText: "Full Name",
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
border: const OutlineInputBorder(),
isDense: true,
),
textInputAction: TextInputAction.next,
),
),
_LabeledField(
label: "Driver License Number *",
child: DropdownButtonFormField<String>(
value: selectedLicense,
items: licenseNumbers
.map((t) => DropdownMenuItem(value: t, child: Text(t)))
.toList(),
onChanged: (v) => setState(() => selectedLicense = v),
validator: (v) => v == null || v.isEmpty ? "Driver License required" : null,
isExpanded: true,
alignment: Alignment.centerLeft,
hint: Text(
"Select License Number",
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),
),
),
),
_LabeledField(
label: "Years of Experience *",
child: DropdownButtonFormField<String>(
value: selectedExperience,
items: yearOptions
.map((t) => DropdownMenuItem(value: t, child: Text(t)))
.toList(),
onChanged: (v) => setState(() => selectedExperience = v),
validator: (v) => v == null || v.isEmpty ? "Experience is required" : null,
isExpanded: true,
alignment: Alignment.centerLeft,
hint: Text(
"Years",
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),
),
),
),
_LabeledField(
label: "Phone Number *",
child: TextFormField(
controller: _mobileCtrl,
validator: (v) => _validatePhone(v, label: "Phone Number"),
keyboardType: TextInputType.phone,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
LengthLimitingTextInputFormatter(10),
],
decoration: InputDecoration(
hintText: "Mobile Number",
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
border: const OutlineInputBorder(),
isDense: true,
),
textInputAction: TextInputAction.next,
),
),
final List<Map<String, dynamic>> drivers = [ _LabeledField(
{ label: "Alternate Phone Number",
'name': 'Ravi Kumar', child: TextFormField(
'status': 'available', controller: _altMobileCtrl,
'location': 'Gandipet', validator: (v) {
'deliveries': 134, if (v == null || v.trim().isEmpty) return null; // optional
'commission': '₹500/day', return _validatePhone(v, label: "Alternate Phone Number");
}, },
{ keyboardType: TextInputType.phone,
'name': 'Ravi Kumar', inputFormatters: [
'status': 'offline', FilteringTextInputFormatter.digitsOnly,
'location': 'Gandipet', LengthLimitingTextInputFormatter(10),
'deliveries': 134, ],
'commission': '₹500/day', decoration: InputDecoration(
hintText: "Mobile Number",
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
border: const OutlineInputBorder(),
isDense: true,
),
textInputAction: TextInputAction.next,
),
),
_LabeledField(
label: "Location *",
child: TextFormField(
controller: _locationCtrl,
validator: (v) => _required(v, field: "Location"),
decoration: InputDecoration(
hintText: "Area / locality",
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
border: const OutlineInputBorder(),
isDense: true,
),
textInputAction: TextInputAction.done,
),
),
_LabeledField(
label: "Status *",
child: DropdownButtonFormField<String>(
value: _status,
items: _statusOptions
.map((s) => DropdownMenuItem(value: s, child: Text(s)))
.toList(),
onChanged: (v) => setState(() => _status = v),
validator: (v) => v == null || v.isEmpty ? "Status is required" : null,
isExpanded: true,
alignment: Alignment.centerLeft,
hint: Text(
"Select status",
style: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
),
icon: const Icon(Icons.keyboard_arrow_down_rounded),
decoration: const InputDecoration(
border: OutlineInputBorder(),
isDense: false,
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 14),
),
),
),
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: _addDriver,
child: Text(
"Save",
style: fontTextStyle(14, Colors.white, FontWeight.w600),
),
),
),
],
),
),
),
),
),
);
}, },
]; );
}
// ---------- UI ----------
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: Colors.white, backgroundColor: Colors.white,
body: Column( body: Column(
children: [ children: [
// Top card
Container( Container(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
padding: const EdgeInsets.all(14), padding: const EdgeInsets.all(14),
@ -90,27 +398,20 @@ class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> {
), ),
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Image.asset('images/drivers.png', child: Image.asset('images/drivers.png', fit: BoxFit.contain),
fit: BoxFit.contain),
), ),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
Text('Total Drivers', Text('Total Drivers', style: fontTextStyle(12, const Color(0xFF2D2E30), FontWeight.w500)),
style: fontTextStyle(
12, const Color(0xFF2D2E30), FontWeight.w500)),
], ],
), ),
const Spacer(), const Spacer(),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Text('${driversList.length.toString()}', Text(driversList.length.toString(), style: fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500)),
style: fontTextStyle(
24, const Color(0xFF0D3771), FontWeight.w500)),
const SizedBox(height: 6), const SizedBox(height: 6),
Text('+1 since last month', Text('+1 since last month', style: fontTextStyle(10, const Color(0xFF646566), FontWeight.w400)),
style: fontTextStyle(
10, const Color(0xFF646566), FontWeight.w400)),
], ],
), ),
], ],
@ -123,11 +424,9 @@ class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> {
child: IntrinsicHeight( child: IntrinsicHeight(
child: Row( child: Row(
children: const [ children: const [
Expanded( Expanded(child: SmallMetricBox(title: 'On delivery', value: '2')),
child: SmallMetricBox(title: 'On delivery', value: '2')),
SizedBox(width: 8), SizedBox(width: 8),
Expanded( Expanded(child: SmallMetricBox(title: 'Available', value: '3')),
child: SmallMetricBox(title: 'Available', value: '3')),
SizedBox(width: 8), SizedBox(width: 8),
Expanded(child: SmallMetricBox(title: 'Offline', value: '1')), Expanded(child: SmallMetricBox(title: 'Offline', value: '1')),
], ],
@ -137,7 +436,7 @@ class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> {
const SizedBox(height: 12), const SizedBox(height: 12),
// Gray background with search and list // Search + list
Expanded( Expanded(
child: Container( child: Container(
color: const Color(0xFFF5F5F5), color: const Color(0xFFF5F5F5),
@ -149,29 +448,24 @@ class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> {
children: [ children: [
Expanded( Expanded(
child: Container( child: Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
horizontal: 12, vertical: 6),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(color: const Color(0xFF939495), width: 0.5),
color: const Color(0xFF939495), width: 0.5),
borderRadius: BorderRadius.circular(22), borderRadius: BorderRadius.circular(22),
), ),
child: Row( child: Row(
children: [ children: [
Image.asset('images/search.png', Image.asset('images/search.png', width: 18, height: 18),
width: 18, height: 18),
const SizedBox(width: 8), const SizedBox(width: 8),
Expanded( Expanded(
child: TextField( child: TextField(
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Search', hintText: 'Search',
hintStyle: fontTextStyle(12, hintStyle: fontTextStyle(12, const Color(0xFF939495), FontWeight.w400),
Color(0xFF939495), FontWeight.w400),
border: InputBorder.none, border: InputBorder.none,
isDense: true, isDense: true,
), ),
onChanged: (v) => onChanged: (v) => setState(() => search = v),
setState(() => search = v),
), ),
), ),
], ],
@ -179,18 +473,16 @@ class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> {
), ),
), ),
const SizedBox(width: 16), const SizedBox(width: 16),
Image.asset("images/icon_tune.png", Image.asset("images/icon_tune.png", width: 24, height: 24),
width: 24, height: 24),
const SizedBox(width: 16), const SizedBox(width: 16),
Image.asset("images/up_down arrow.png", Image.asset("images/up_down arrow.png", width: 24, height: 24),
width: 24, height: 24),
], ],
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
// Driver list
Expanded( Expanded(
child: ListView.separated( child: isLoading
? const Center(child: CircularProgressIndicator())
: ListView.separated(
itemCount: driversList.length, itemCount: driversList.length,
separatorBuilder: (_, __) => const SizedBox(height: 12), separatorBuilder: (_, __) => const SizedBox(height: 12),
itemBuilder: (context, idx) { itemBuilder: (context, idx) {
@ -199,7 +491,7 @@ class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> {
name: d.driver_name, name: d.driver_name,
status: d.status, status: d.status,
location: d.address, location: d.address,
deliveries: int.parse(d.deliveries), deliveries: int.tryParse(d.deliveries) ?? 0,
commission: d.commision, commission: d.commision,
); );
}, },
@ -213,21 +505,9 @@ class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> {
], ],
), ),
// Floating Action Button // FAB -> open fixed-height form sheet
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: () async{ onPressed: () => _openDriverFormSheet(context),
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => FleetEmployees(),
),
);
// If result indicates API reload
if (result == true) {
_fetchDrivers();
}
},
backgroundColor: Colors.black, backgroundColor: Colors.black,
shape: const CircleBorder(), shape: const CircleBorder(),
child: const Icon(Icons.add, color: Colors.white), child: const Icon(Icons.add, color: Colors.white),
@ -236,7 +516,8 @@ class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> {
} }
} }
// Metric Box widget // ---------- widgets ----------
class SmallMetricBox extends StatelessWidget { class SmallMetricBox extends StatelessWidget {
final String title; final String title;
final String value; final String value;
@ -255,20 +536,15 @@ class SmallMetricBox extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(title, Text(title, style: fontTextStyle(12, const Color(0xFF2D2E30), FontWeight.w500)),
style:
fontTextStyle(12, const Color(0xFF2D2E30), FontWeight.w500)),
const SizedBox(height: 4), const SizedBox(height: 4),
Text(value, Text(value, style: fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500)),
style:
fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500)),
], ],
), ),
); );
} }
} }
// Driver Card widget
class DriverCard extends StatelessWidget { class DriverCard extends StatelessWidget {
final String name; final String name;
final String status; final String status;
@ -287,6 +563,9 @@ class DriverCard extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final statusColor =
status == "available" ? Colors.green : (status == "on delivery" ? Colors.orange : Colors.grey);
return Container( return Container(
padding: const EdgeInsets.all(14), padding: const EdgeInsets.all(14),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -304,52 +583,33 @@ class DriverCard extends StatelessWidget {
Row( Row(
children: [ children: [
ClipOval( ClipOval(
child: Image.asset("images/profile_pic.png", child: Image.asset("images/profile_pic.png", height: 36, width: 36, fit: BoxFit.cover),
height: 36, width: 36, fit: BoxFit.cover),
), ),
const SizedBox(width: 10), const SizedBox(width: 10),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(name, Text(name, style: fontTextStyle(14, const Color(0xFF2D2E30), FontWeight.w500)),
style: fontTextStyle(
14, const Color(0xFF2D2E30), FontWeight.w500)),
const SizedBox(height: 4), const SizedBox(height: 4),
Container( Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
horizontal: 6, vertical: 2),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
border: Border.all( border: Border.all(color: statusColor),
color: status == "available"
? Colors.green
: Colors.grey,
),
),
child: Text(
status,
style: fontTextStyle(
10,
status == "available" ? Colors.green : Colors.grey,
FontWeight.w400,
),
), ),
child: Text(status, style: fontTextStyle(10, statusColor, FontWeight.w400)),
), ),
], ],
), ),
], ],
), ),
Container( Container(
padding: const EdgeInsets.all(8), // spacing around the icon padding: const EdgeInsets.all(8),
decoration: const BoxDecoration( decoration: const BoxDecoration(
color: Color(0xFFF5F6F6), // background color color: Color(0xFFF5F6F6),
shape: BoxShape.circle, // makes it perfectly round shape: BoxShape.circle,
),
child: Image.asset(
"images/phone_icon.png",
width: 20,
height: 20,
), ),
child: Image.asset("images/phone_icon.png", width: 20, height: 20),
), ),
], ],
), ),
@ -360,13 +620,8 @@ class DriverCard extends StatelessWidget {
Text.rich( Text.rich(
TextSpan( TextSpan(
children: [ children: [
TextSpan( TextSpan(text: "Location\n", style: fontTextStyle(8, const Color(0xFF939495), FontWeight.w500)),
text: "Location\n", style: fontTextStyle(8, Color(0xFF939495), FontWeight.w500, TextSpan(text: location, style: fontTextStyle(12, const Color(0xFF515253), FontWeight.w500)),
),
),
TextSpan(
text: location, style: fontTextStyle(12, const Color(0xFF515253), FontWeight.w500,),
),
], ],
), ),
textAlign: TextAlign.center, textAlign: TextAlign.center,
@ -374,64 +629,43 @@ class DriverCard extends StatelessWidget {
Text.rich( Text.rich(
TextSpan( TextSpan(
children: [ children: [
TextSpan( TextSpan(text: "Deliveries\n", style: fontTextStyle(8, const Color(0xFF939495), FontWeight.w400)),
text: "Deliveries\n", style: fontTextStyle(8, const Color(0xFF939495), FontWeight.w400, TextSpan(text: deliveries.toString(), style: fontTextStyle(12, const Color(0xFF515253), FontWeight.w500)),
),
),
TextSpan(
text: deliveries.toString(), style: fontTextStyle(12, const Color(0xFF515253), FontWeight.w500,),
),
], ],
), ),
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
// Commission
Text.rich( Text.rich(
TextSpan( TextSpan(
children: [ children: [
TextSpan( TextSpan(text: "Commission\n", style: fontTextStyle(8, const Color(0xFF939495), FontWeight.w400)),
text: "Commission\n", style: fontTextStyle(8, Color(0xFF939495), FontWeight.w400, TextSpan(text: commission, style: fontTextStyle(12, const Color(0xFF515253), FontWeight.w500)),
),
),
TextSpan(
text: commission, style: fontTextStyle(12, Color(0xFF515253), FontWeight.w500,),
),
], ],
), ),
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
], ],
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
// Buttons row
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
OutlinedButton( OutlinedButton(
style: OutlinedButton.styleFrom( style: OutlinedButton.styleFrom(
side: const BorderSide(color: Color(0xFF939495)), side: const BorderSide(color: Color(0xFF939495)),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
borderRadius: BorderRadius.circular(16)),
), ),
onPressed: () {}, onPressed: () {},
child: Text("View Schedule", child: Text("View Schedule", style: fontTextStyle(12, const Color(0xFF515253), FontWeight.w400)),
style: fontTextStyle(
12, Color(0xFF515253), FontWeight.w400)),
), ),
const SizedBox(width: 12), const SizedBox(width: 12),
ElevatedButton( ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF8270DB), backgroundColor: const Color(0xFF8270DB),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
borderRadius: BorderRadius.circular(16)),
), ),
onPressed: () {}, onPressed: () {},
child: Text("Assign", style: fontTextStyle(12, const Color(0xFFFFFFFF), FontWeight.w400)),
child: Text("Assign", style: fontTextStyle(12, Color(0xFFFFFFFF), FontWeight.w400)
),
), ),
], ],
) )
@ -440,3 +674,24 @@ class DriverCard extends StatelessWidget {
); );
} }
} }
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,
],
),
);
}
}

@ -1,19 +1,15 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:supplier_new/common/settings.dart'; import 'package:supplier_new/common/settings.dart';
import 'package:supplier_new/resources/tankers_model.dart'; import 'package:supplier_new/resources/tankers_model.dart';
// Screens (single import each) keep if you actually navigate to these
import 'fleet.dart'; import 'fleet.dart';
import 'resources_drivers.dart'; import 'resources_drivers.dart';
import 'resources_sources.dart'; import 'resources_sources.dart';
import 'package:supplier_new/resources/resources_drivers.dart'; void main() => runApp(const MaterialApp(home: ResourcesFleetScreen()));
import 'package:supplier_new/resources/resources_sources.dart';
import 'fleet.dart';void main() => runApp(const MaterialApp(home: ResourcesFleetScreen()));
class ResourcesFleetScreen extends StatefulWidget { class ResourcesFleetScreen extends StatefulWidget {
const ResourcesFleetScreen({super.key}); const ResourcesFleetScreen({super.key});
@ -25,13 +21,28 @@ class ResourcesFleetScreen extends StatefulWidget {
class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> { class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
final _formKey = GlobalKey<FormState>(); final _formKey = GlobalKey<FormState>();
// Controllers // Controllers (sheet)
final _nameCtrl = TextEditingController(); final _nameCtrl = TextEditingController();
final _capacityCtrl = TextEditingController(); // hint-like final _capacityCtrl = TextEditingController();
final _plateCtrl = TextEditingController(); final _plateCtrl = TextEditingController();
final _mfgYearCtrl = TextEditingController(); final _mfgYearCtrl = TextEditingController();
final _insExpiryCtrl = 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"}) { String? _required(String? v, {String field = "This field"}) {
if (v == null || v.trim().isEmpty) return "$field is required"; if (v == null || v.trim().isEmpty) return "$field is required";
return null; return null;
@ -44,14 +55,22 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
@override @override
void initState() { void initState() {
// TODO: implement initState
super.initState(); super.initState();
_fetchTankers(); _fetchTankers();
} }
@override
void dispose() {
_nameCtrl.dispose();
_capacityCtrl.dispose();
_plateCtrl.dispose();
_mfgYearCtrl.dispose();
_insExpiryCtrl.dispose();
super.dispose();
}
Future<void> _fetchTankers() async { Future<void> _fetchTankers() async {
setState(() => isLoading = true); setState(() => isLoading = true);
try { try {
final response = await AppSettings.getTankers(); final response = await AppSettings.getTankers();
final data = (jsonDecode(response)['data'] as List) final data = (jsonDecode(response)['data'] as List)
@ -63,95 +82,140 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
isLoading = false; isLoading = false;
}); });
} catch (e) { } catch (e) {
debugPrint("⚠️ Error fetching orders: $e"); debugPrint("⚠️ Error fetching tankers: $e");
setState(() => isLoading = false); setState(() => isLoading = false);
} }
} }
final List<Map<String, dynamic>> items = [ Future<void> _pickInsuranceDate() async {
{ final picked = await showDatePicker(
'title': 'Tanker Name', context: context,
'subtitle': 'Drinking water - 10,000 L', initialDate: DateTime.now(),
'status': ['filled', 'available'], firstDate: DateTime(2000),
'code': 'TS 07 J 3492', lastDate: DateTime(2100),
'owner': 'Ramesh Krishna' builder: (context, child) {
}, return Theme(
{ data: Theme.of(context).copyWith(
'title': 'Drinking Water - 15,000L', dialogBackgroundColor: Colors.white,
'subtitle': 'Drinking water - 15,000 L', colorScheme: Theme.of(context).colorScheme.copyWith(
'status': ['empty', 'available'], primary: const Color(0xFF8270DB),
'code': 'TS 07 J 3492', surface: Colors.white,
'owner': 'Ramesh Krishna' onSurface: const Color(0xFF101214),
}, ),
{ ),
'title': 'Tanker Name', child: child!,
'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'
}, },
]; );
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) { void openTankerSimpleSheet(BuildContext context) {
_resetForm(); // open fresh
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
backgroundColor: Colors.white, backgroundColor: Colors.transparent,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
builder: (context) { builder: (context) {
return Padding( final viewInsets = MediaQuery.of(context).viewInsets.bottom;
padding: EdgeInsets.only(
left: 20, return FractionallySizedBox(
right: 20, heightFactor: 0.75,
top: 16, child: Container(
bottom: MediaQuery.of(context).viewInsets.bottom + 20, 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( child: Form(
key: _formKey, key: _formKey,
child: ListView( child: SingleChildScrollView(
shrinkWrap: true, child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
// Tanker Name _LabeledField(
Text("Tanker Name *", label: "Tanker Name *",
style: fontTextStyle(14, const Color(0xFF646566), FontWeight.w600)), child: TextFormField(
const SizedBox(height: 6),
TextFormField(
controller: _nameCtrl, controller: _nameCtrl,
validator: (v) => _required(v, field: "Tanker Name"), validator: (v) => _required(v, field: "Tanker Name"),
decoration: const InputDecoration( decoration: InputDecoration(
hintText: "Enter Tanker Name", hintText: "Enter Tanker Name",
border: OutlineInputBorder(), hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
border: const OutlineInputBorder(),
isDense: true, isDense: true,
), ),
textInputAction: TextInputAction.next, textInputAction: TextInputAction.next,
), ),
const SizedBox(height: 14), ),
// Capacity _LabeledField(
Text("Tanker Capacity (in L) *", label: "Tanker Capacity (in L) *",
style: fontTextStyle(14, const Color(0xFF646566), FontWeight.w600)), child: TextFormField(
const SizedBox(height: 6),
TextFormField(
controller: _capacityCtrl, controller: _capacityCtrl,
validator: (v) => _required(v, field: "Tanker Capacity"), validator: (v) => _required(v, field: "Tanker Capacity"),
decoration: InputDecoration( decoration: InputDecoration(
hintText: "10,000 L", hintText: "10,000",
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400), hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
isDense: true, isDense: true,
@ -162,13 +226,59 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
], ],
textInputAction: TextInputAction.next, textInputAction: TextInputAction.next,
), ),
const SizedBox(height: 14), ),
// License Plate _LabeledField(
Text("License Plate *", label: "Tanker Type *",
style: fontTextStyle(14, const Color(0xFF646566), FontWeight.w600)), child: DropdownButtonFormField<String>(
const SizedBox(height: 6), value: selectedType,
TextFormField( 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),
),
),
),
_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),
),
),
),
_LabeledField(
label: "License Plate *",
child: TextFormField(
controller: _plateCtrl, controller: _plateCtrl,
validator: (v) => _required(v, field: "License Plate"), validator: (v) => _required(v, field: "License Plate"),
decoration: InputDecoration( decoration: InputDecoration(
@ -180,13 +290,11 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
textCapitalization: TextCapitalization.characters, textCapitalization: TextCapitalization.characters,
textInputAction: TextInputAction.next, textInputAction: TextInputAction.next,
), ),
const SizedBox(height: 14), ),
// Manufacturing Year (optional) _LabeledField(
Text("Manufacturing Year (opt)", label: "Manufacturing Year (opt)",
style: fontTextStyle(14, const Color(0xFF646566), FontWeight.w600)), child: TextFormField(
const SizedBox(height: 6),
TextFormField(
controller: _mfgYearCtrl, controller: _mfgYearCtrl,
decoration: InputDecoration( decoration: InputDecoration(
hintText: "YYYY", hintText: "YYYY",
@ -201,13 +309,11 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
], ],
textInputAction: TextInputAction.next, textInputAction: TextInputAction.next,
), ),
const SizedBox(height: 14), ),
// Insurance Expiry Date (optional) _LabeledField(
Text("Insurance Expiry Date (opt)", label: "Insurance Expiry Date (opt)",
style: fontTextStyle(14, const Color(0xFF646566), FontWeight.w600)), child: TextFormField(
const SizedBox(height: 6),
TextFormField(
controller: _insExpiryCtrl, controller: _insExpiryCtrl,
readOnly: true, readOnly: true,
decoration: InputDecoration( decoration: InputDecoration(
@ -217,25 +323,12 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
isDense: true, isDense: true,
suffixIcon: const Icon(Icons.calendar_today_outlined, size: 18), suffixIcon: const Icon(Icons.calendar_today_outlined, size: 18),
), ),
onTap: () async { onTap: _pickInsuranceDate,
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), const SizedBox(height: 20),
// Save button
SizedBox( SizedBox(
width: double.infinity, width: double.infinity,
child: ElevatedButton( child: ElevatedButton(
@ -247,16 +340,7 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
borderRadius: BorderRadius.circular(24), borderRadius: BorderRadius.circular(24),
), ),
), ),
onPressed: () async { onPressed: _addTanker,
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( child: Text(
"Save", "Save",
style: fontTextStyle(14, Colors.white, FontWeight.w600), style: fontTextStyle(14, Colors.white, FontWeight.w600),
@ -266,13 +350,14 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
], ],
), ),
), ),
),
),
),
); );
}, },
); );
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final filtered = tankersList.where((it) { final filtered = tankersList.where((it) {
@ -285,6 +370,7 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
backgroundColor: Colors.white, backgroundColor: Colors.white,
body: Column( body: Column(
children: [ children: [
// Header section
Container( Container(
color: Colors.white, color: Colors.white,
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12), padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
@ -297,7 +383,7 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
border: Border.all(color: Color(0xFF939495)), border: Border.all(color: const Color(0xFF939495)),
), ),
child: Row( child: Row(
children: [ children: [
@ -309,56 +395,47 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
height: 40, height: 40,
decoration: const BoxDecoration( decoration: const BoxDecoration(
color: Color(0xFFF6F0FF), color: Color(0xFFF6F0FF),
borderRadius: borderRadius: BorderRadius.all(Radius.circular(8)),
BorderRadius.all(Radius.circular(8)),
), ),
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Image.asset( child: Image.asset('images/truck.png', fit: BoxFit.contain),
'images/truck.png',
fit: BoxFit.contain,
),
), ),
), ),
const SizedBox(height: 8), 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(), const Spacer(),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min, 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),
), ),
const SizedBox(height: 6),
SizedBox(height: 6),
Text('+2 since last month', Text('+2 since last month',
style: fontTextStyle(10, Color(0xFF646566), FontWeight.w400,)), style: fontTextStyle(10, const Color(0xFF646566), FontWeight.w400),
),
], ],
), ),
], ],
), ),
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
IntrinsicHeight( IntrinsicHeight(
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: const [
Expanded( Expanded(child: SmallMetricBox(title: 'Active', value: '2')),
child: SmallMetricBox(title: 'Active', value: '2')), SizedBox(width: 8),
const SizedBox(width: 8), Expanded(child: SmallMetricBox(title: 'Inactive', value: '3')),
Expanded( SizedBox(width: 8),
child: SmallMetricBox(title: 'Inactive', value: '3')), Expanded(child: SmallMetricBox(title: 'Under Maintenance', value: '1')),
const SizedBox(width: 8),
Expanded(
child: SmallMetricBox(
title: 'Under Maintenances', value: '1')),
], ],
), ),
), ),
@ -366,10 +443,10 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
), ),
), ),
// -------- SECOND SECTION (gray background) ---------- // List section
Expanded( Expanded(
child: Container( child: Container(
color: const Color(0xFFF5F5F5), // Gray background color: const Color(0xFFF5F5F5),
child: Padding( child: Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0), padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
child: Column( child: Column(
@ -379,13 +456,9 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
SizedBox( SizedBox(
width: 270, width: 270,
child: Container( child: Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
horizontal: 12, vertical: 6),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(color: const Color(0xFF939495), width: 0.5),
color: Color(0xFF939495), // 👈 border color
width: 0.5, // 👈 border width
),
borderRadius: BorderRadius.circular(22), borderRadius: BorderRadius.circular(22),
), ),
child: Row( child: Row(
@ -396,7 +469,8 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
decoration: const BoxDecoration( decoration: const BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: AssetImage('images/search.png'), image: AssetImage('images/search.png'),
fit: BoxFit.contain), fit: BoxFit.contain,
),
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
@ -404,15 +478,11 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
child: TextField( child: TextField(
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Search', hintText: 'Search',
hintStyle: fontTextStyle( hintStyle: fontTextStyle(12, const Color(0xFF939495), FontWeight.w400),
12,
const Color(0xFF939495),
FontWeight.w400),
border: InputBorder.none, border: InputBorder.none,
isDense: true, isDense: true,
), ),
onChanged: (v) => onChanged: (v) => setState(() => search = v),
setState(() => search = v),
), ),
), ),
], ],
@ -426,7 +496,8 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
decoration: const BoxDecoration( decoration: const BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: AssetImage('images/icon_tune.png'), image: AssetImage('images/icon_tune.png'),
fit: BoxFit.contain), fit: BoxFit.contain,
),
), ),
), ),
const SizedBox(width: 16), const SizedBox(width: 16),
@ -435,18 +506,18 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
height: 24, height: 24,
decoration: const BoxDecoration( decoration: const BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: AssetImage('images/up_down arrow.png'), image: AssetImage('images/up_down_arrow.png'),
fit: BoxFit.contain), fit: BoxFit.contain,
),
), ),
), ),
], ],
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
// Cards List
Expanded( Expanded(
child: ListView.separated( child: isLoading
? const Center(child: CircularProgressIndicator())
: ListView.separated(
itemCount: filtered.length, itemCount: filtered.length,
separatorBuilder: (_, __) => const SizedBox(height: 10), separatorBuilder: (_, __) => const SizedBox(height: 10),
itemBuilder: (context, idx) { itemBuilder: (context, idx) {
@ -470,24 +541,10 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
], ],
), ),
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: () async{ onPressed: () => openTankerSimpleSheet(context),
openTankerSimpleSheet(context);
/*final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => FleetStep1Page(),
),
);
// If result indicates API reload
if (result == true) {
_fetchTankers();
}*/
},
backgroundColor: const Color(0xFF000000), backgroundColor: const Color(0xFF000000),
shape: const CircleBorder(), // ensures circle shape: const CircleBorder(),
child: const Icon(Icons.add,color: Colors.white,), child: const Icon(Icons.add, color: Colors.white),
), ),
); );
} }
@ -506,22 +563,22 @@ class SmallMetricBox extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
border: Border.all(color: Color(0xFF939495)), border: Border.all(color: const Color(0xFF939495)),
color: Colors.white, color: Colors.white,
), ),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(title, Text(
title,
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: style: fontTextStyle(12, const Color(0xFF2D2E30), FontWeight.w500),
fontTextStyle(12, const Color(0xFF2D2E30), FontWeight.w500)), ),
Text(value, Text(
style: value,
fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500)), style: fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500),
),
], ],
), ),
); );
@ -601,28 +658,23 @@ class TankCard extends StatelessWidget {
final chipTextColor = _chipTextColor(s); final chipTextColor = _chipTextColor(s);
return Container( return Container(
margin: const EdgeInsets.only(right: 6), margin: const EdgeInsets.only(right: 6),
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
horizontal: 8, vertical: 4),
decoration: BoxDecoration( decoration: BoxDecoration(
color: _chipColor(s), color: _chipColor(s),
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
border: Border.all(color: chipTextColor, width: 1), border: Border.all(color: chipTextColor, width: 1),
), ),
child: Text( child: Text(
s, style: s,
fontTextStyle(10, chipTextColor, FontWeight.w400), style: fontTextStyle(10, chipTextColor, FontWeight.w400),
), ),
); );
}).toList(), }).toList(),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
Text (title, Text(title, style: fontTextStyle(14, const Color(0xFF343637), FontWeight.w600)),
style: fontTextStyle(
14, const Color(0xFF343637), FontWeight.w600)),
const SizedBox(height: 6), const SizedBox(height: 6),
Text(subtitle+' - '+capacity+' L', Text("$subtitle - $capacity L", style: fontTextStyle(10, const Color(0xFF343637), FontWeight.w600)),
style: fontTextStyle(
10, const Color(0xFF343637), FontWeight.w600)),
const SizedBox(height: 10), const SizedBox(height: 10),
Row( Row(
children: [ children: [
@ -633,20 +685,17 @@ class TankCard extends StatelessWidget {
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
image: DecorationImage( image: DecorationImage(
image: (AppSettings.profilePictureUrl != '' && image: (AppSettings.profilePictureUrl != '' && AppSettings.profilePictureUrl != 'null')
AppSettings.profilePictureUrl != 'null')
? NetworkImage(AppSettings.profilePictureUrl) ? NetworkImage(AppSettings.profilePictureUrl)
as ImageProvider : const AssetImage("images/profile_pic.png") as ImageProvider,
: const AssetImage("images/profile_pic.png"), fit: BoxFit.cover,
fit: BoxFit.cover), ),
), ),
), ),
), ),
const SizedBox(width: 6), const SizedBox(width: 6),
Expanded( Expanded(
child: Text(owner, child: Text(owner, style: fontTextStyle(8, const Color(0xFF646566), FontWeight.w400)),
style: fontTextStyle(
8, const Color(0xFF646566), FontWeight.w400)),
), ),
], ],
), ),
@ -656,9 +705,7 @@ class TankCard extends StatelessWidget {
Column( Column(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Text(code, Text(code, style: fontTextStyle(10, const Color(0xFF515253), FontWeight.w400)),
style: fontTextStyle(
10, const Color(0xFF515253), FontWeight.w400)),
const SizedBox(height: 28), 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,
],
),
);
}
}

@ -1,13 +1,15 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io' show Platform;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:supplier_new/common/settings.dart'; import 'package:supplier_new/common/settings.dart';
import 'package:supplier_new/resources/source_location.dart';
import 'package:supplier_new/resources/source_loctaions_model.dart'; import 'package:supplier_new/resources/source_loctaions_model.dart';
import 'fleet.dart';
import 'resources_drivers.dart';
import 'resources_sources.dart';
// If you use the PlacePicker flow in the button below, make sure you have
// the needed imports in your project (google_maps_flutter, place_picker, etc).
// import 'package:google_maps_flutter/google_maps_flutter.dart';
// import 'package:place_picker/place_picker.dart';
// import 'package:location/location.dart';
void main() => runApp(const MaterialApp(home: ResourcesSourceScreen())); void main() => runApp(const MaterialApp(home: ResourcesSourceScreen()));
@ -24,16 +26,57 @@ class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> {
bool isLoading = false; bool isLoading = false;
List<SourceLocationsModel> sourceLocationsList = []; List<SourceLocationsModel> sourceLocationsList = [];
// ---------- Form state (bottom sheet) ----------
final _formKey = GlobalKey<FormState>();
final _locationNameController = TextEditingController();
final _mobileCtrl = TextEditingController();
bool addBusinessAsSource = false; // toggle if you want to hide map input
String? selectedWaterType;
final List<String> waterTypes = const ['Drinking water', 'Bore water', 'Both'];
// Optional: values used by your map flow
// final location = Location(); // from 'location' package
// PickResult? selectedPlace;
double? lat;
double? lng;
String? address;
String? _required(String? v, {String field = "This field"}) {
if (v == null || v.trim().isEmpty) return "$field is required";
return null;
}
String? _validatePhone(String? v, {String label = "Phone"}) {
if (v == null || v.trim().isEmpty) return "$label is required";
if (v.trim().length != 10) return "$label must be 10 digits";
return null;
}
@override @override
void initState() { void initState() {
// TODO: implement initState
super.initState(); super.initState();
_fetchDrivers(); _fetchSources();
} }
Future<void> _fetchDrivers() async { @override
setState(() => isLoading = true); void dispose() {
_locationNameController.dispose();
_mobileCtrl.dispose();
super.dispose();
}
void _resetForm() {
_formKey.currentState?.reset();
_locationNameController.clear();
_mobileCtrl.clear();
selectedWaterType = null;
// keep address/lat/lng as last-picked unless you want to clear:
// address = null; lat = null; lng = null;
}
Future<void> _fetchSources() async {
setState(() => isLoading = true);
try { try {
final response = await AppSettings.getSourceLoctaions(); final response = await AppSettings.getSourceLoctaions();
final data = (jsonDecode(response)['data'] as List) final data = (jsonDecode(response)['data'] as List)
@ -45,34 +88,299 @@ class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> {
isLoading = false; isLoading = false;
}); });
} catch (e) { } catch (e) {
debugPrint("⚠️ Error fetching orders: $e"); debugPrint("⚠️ Error fetching source locations: $e");
setState(() => isLoading = false); setState(() => isLoading = false);
} }
} }
final List<Map<String, dynamic>> items = [ Future<void> _addSourceLocation() async {
{ final ok = _formKey.currentState?.validate() ?? false;
'title': 'Gandipet Water Supply',
'subtitle': 'Road No.34, Blah', if (addBusinessAsSource) {
// Use supplier's address as the source location
address = AppSettings.userAddress;
lat = AppSettings.supplierLatitude;
lng = AppSettings.supplierLongitude;
setState(() {});
}
if (!ok || selectedWaterType == null || selectedWaterType!.isEmpty) {
if (selectedWaterType == null) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Please select Water Type")),
);
}
setState(() {}); // ensure errors render
return;
}
final payload = <String, dynamic>{
"location_name": _locationNameController.text.trim(),
"phone": _mobileCtrl.text.trim(),
"water_type": selectedWaterType,
"status": 'active', // or whatever string your backend expects
"address": address,
"city": '',
"state": '',
"zip": '',
"latitude": lat,
"longitude": lng,
};
try {
final bool ok = await AppSettings.addSourceLocations(payload);
if (!mounted) return;
if (ok) {
AppSettings.longSuccessToast("Source location added successfully");
Navigator.pop(context, true); // close the sheet
_resetForm();
_fetchSources(); // refresh list
} else {
AppSettings.longFailedToast("Source location creation failed");
}
} catch (e) {
debugPrint("⚠️ addSourceLocations error: $e");
if (!mounted) return;
AppSettings.longFailedToast("Something went wrong");
}
}
void _openSourceFormSheet(BuildContext context) {
_resetForm(); // fresh form each time you open
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) {
final kbInset = MediaQuery.of(context).viewInsets.bottom;
return FractionallySizedBox(
heightFactor: 0.75, // fixed height
child: Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
child: Padding(
padding: EdgeInsets.fromLTRB(20, 16, 20, 20 + kbInset),
child: Form(
key: _formKey,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_LabeledField(
label: "Location Name *",
child: TextFormField(
controller: _locationNameController,
validator: (v) => _required(v, field: "Location Name"),
decoration: InputDecoration(
hintText: "Location Name",
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
border: const OutlineInputBorder(),
isDense: true,
),
textInputAction: TextInputAction.next,
),
),
_LabeledField(
label: "Mobile Number *",
child: TextFormField(
controller: _mobileCtrl,
validator: (v) => _validatePhone(v, label: "Mobile Number"),
keyboardType: TextInputType.phone,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
LengthLimitingTextInputFormatter(10),
],
decoration: InputDecoration(
hintText: "Mobile Number",
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
border: const OutlineInputBorder(),
isDense: true,
),
textInputAction: TextInputAction.next,
),
),
Visibility(
visible: !addBusinessAsSource,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(
width: double.infinity,
child: OutlinedButton.icon(
onPressed: () {
// Your PlacePicker flow goes here (kept commented for reference)
/*
location.serviceEnabled().then((value) {
if (value) {
initRenderer();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return PlacePicker(
resizeToAvoidBottomInset: false,
hintText: "Find a place ...",
searchingText: "Please wait ...",
selectText: "Select place",
outsideOfPickAreaText: "Place not in area",
initialPosition: kInitialPosition,
useCurrentLocation: true,
selectInitialPosition: true,
usePinPointingSearch: true,
usePlaceDetailSearch: true,
zoomGesturesEnabled: true,
zoomControlsEnabled: true,
onMapCreated: (GoogleMapController controller) {},
onPlacePicked: (PickResult result) {
setState(() {
selectedPlace = result;
lat = selectedPlace!.geometry!.location.lat;
lng = selectedPlace!.geometry!.location.lng;
if (selectedPlace!.types!.length == 1) {
address = selectedPlace!.formattedAddress!;
} else {
address = '${selectedPlace!.name!}, ${selectedPlace!.formattedAddress!}';
}
Navigator.of(context).pop();
});
}, },
{ onMapTypeChanged: (MapType mapType) {},
'title': 'Gandipet Water Supply', apiKey: Platform.isAndroid ? APIKeys.androidApiKey : APIKeys.iosApiKey,
'subtitle': 'Road No.34, Blah', forceAndroidLocationManager: true,
);
}, },
{ ),
'title': 'Gandipet Water Supply', );
'subtitle': 'Road No.34, Blah', } else {
showGeneralDialog(
context: context,
pageBuilder: (context, x, y) {
return Scaffold(
backgroundColor: Colors.grey.withOpacity(.5),
body: Center(
child: Container(
width: double.infinity,
height: 150,
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Card(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
"Please enable the location",
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
}, },
{ child: const Text("Cancel"),
'title': 'Gandipet Water Supply', ),
'subtitle': 'Road No.34, Blah', ],
),
),
),
),
),
);
}, },
{ );
'title': 'Gandipet Water Supply', }
'subtitle': 'Road No.34, Blah', });
*/
}, },
]; icon: Image.asset('images/Add_icon.png', width: 16, height: 16),
label: Text(
"Add Location on map",
style: fontTextStyle(14, const Color(0xFF646566), FontWeight.w600),
),
),
),
const SizedBox(height: 12),
],
),
),
_LabeledField(
label: "Water Type *",
child: DropdownButtonFormField<String>(
value: selectedWaterType,
items: waterTypes
.map((w) => DropdownMenuItem(value: w, child: Text(w)))
.toList(),
onChanged: (v) => setState(() => selectedWaterType = v),
validator: (v) => v == null || v.isEmpty ? "Water Type is required" : null,
isExpanded: true,
alignment: Alignment.centerLeft,
hint: Text(
"Select Water 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),
),
),
),
const SizedBox(height: 20),
// Actions
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(
width: double.infinity,
child: OutlinedButton.icon(
onPressed: _addSourceLocation,
icon: Image.asset('images/Add_icon.png', width: 16, height: 16),
label: Text(
"Add Location",
style: fontTextStyle(14, const Color(0xFF646566), FontWeight.w600),
),
),
),
const SizedBox(height: 12),
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: _addSourceLocation,
child: Text(
"Save",
style: fontTextStyle(14, Colors.white, FontWeight.w600),
),
),
),
],
),
],
),
),
),
),
),
);
},
);
}
// ---------- UI ----------
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final filtered = sourceLocationsList.where((it) { final filtered = sourceLocationsList.where((it) {
@ -84,7 +392,6 @@ class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> {
return Scaffold( return Scaffold(
backgroundColor: Colors.white, backgroundColor: Colors.white,
body: Column( body: Column(
children: [ children: [
// Top card section // Top card section
@ -117,10 +424,7 @@ class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> {
), ),
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Image.asset( child: Image.asset('images/drivers.png', fit: BoxFit.contain),
'images/drivers.png',
fit: BoxFit.contain,
),
), ),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
@ -136,7 +440,7 @@ class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Text(
'${sourceLocationsList.length.toString()}', sourceLocationsList.length.toString(),
style: fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500), style: fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500),
), ),
const SizedBox(height: 6), const SizedBox(height: 6),
@ -147,17 +451,15 @@ class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> {
], ],
), ),
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
// Metrics boxes
IntrinsicHeight( IntrinsicHeight(
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: const [
Expanded(child: SmallMetricBox(title: 'Drinking water', value: '2')), Expanded(child: SmallMetricBox(title: 'Drinking water', value: '2')),
const SizedBox(width: 8), SizedBox(width: 8),
Expanded(child: SmallMetricBox(title: 'Bore water', value: '3')), Expanded(child: SmallMetricBox(title: 'Bore water', value: '3')),
const SizedBox(width: 8), SizedBox(width: 8),
Expanded(child: SmallMetricBox(title: 'Both', value: '1')), Expanded(child: SmallMetricBox(title: 'Both', value: '1')),
], ],
), ),
@ -166,7 +468,7 @@ class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> {
), ),
), ),
// SECOND SECTION (gray background) // List section
Expanded( Expanded(
child: Container( child: Container(
color: const Color(0xFFF5F5F5), color: const Color(0xFFF5F5F5),
@ -174,7 +476,6 @@ class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> {
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0), padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
child: Column( child: Column(
children: [ children: [
// Search row
Row( Row(
children: [ children: [
SizedBox( SizedBox(
@ -182,23 +483,12 @@ class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> {
child: Container( child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(color: const Color(0xFF939495), width: 0.5),
color: const Color(0xFF939495),
width: 0.5,
),
borderRadius: BorderRadius.circular(22), borderRadius: BorderRadius.circular(22),
), ),
child: Row( child: Row(
children: [ children: [
Container( Image.asset('images/search.png', width: 20, height: 20),
width: 20,
height: 20,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('images/search.png'),
fit: BoxFit.contain),
),
),
const SizedBox(width: 8), const SizedBox(width: 8),
Expanded( Expanded(
child: TextField( child: TextField(
@ -216,33 +506,16 @@ class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> {
), ),
), ),
const SizedBox(width: 16), const SizedBox(width: 16),
Container( Image.asset('images/icon_tune.png', width: 24, height: 24),
width: 24,
height: 24,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('images/icon_tune.png'),
fit: BoxFit.contain),
),
),
const SizedBox(width: 16), const SizedBox(width: 16),
Container( Image.asset('images/up_down arrow.png', width: 24, height: 24),
width: 24,
height: 24,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('images/up_down arrow.png'),
fit: BoxFit.contain),
),
),
], ],
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
// Cards List
Expanded( Expanded(
child: ListView.separated( child: isLoading
? const Center(child: CircularProgressIndicator())
: ListView.separated(
itemCount: filtered.length, itemCount: filtered.length,
separatorBuilder: (_, __) => const SizedBox(height: 10), separatorBuilder: (_, __) => const SizedBox(height: 10),
itemBuilder: (context, idx) { itemBuilder: (context, idx) {
@ -261,19 +534,8 @@ class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> {
), ),
], ],
), ),
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: () { onPressed: () => _openSourceFormSheet(context),
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const HeroMode(
enabled: false,
child: SourceLocation(),
),
),
);
},
backgroundColor: const Color(0xFF000000), backgroundColor: const Color(0xFF000000),
shape: const CircleBorder(), shape: const CircleBorder(),
child: const Icon(Icons.add, color: Colors.white), child: const Icon(Icons.add, color: Colors.white),
@ -302,19 +564,23 @@ class SmallMetricBox extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(title, Text(
title,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: fontTextStyle(12, const Color(0xFF2D2E30), FontWeight.w500)), style: fontTextStyle(12, const Color(0xFF2D2E30), FontWeight.w500),
Text(value, ),
style: fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500)), Text(
value,
style: fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500),
),
], ],
), ),
); );
} }
} }
// ====== TankCard (with phone icon inside) ====== // ====== TankCard ======
class TankCard extends StatelessWidget { class TankCard extends StatelessWidget {
final String title; final String title;
final String subtitle; final String subtitle;
@ -336,33 +602,48 @@ class TankCard extends StatelessWidget {
), ),
child: Row( child: Row(
children: [ children: [
// Title and subtitle
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(title, Text(title, style: fontTextStyle(14, const Color(0xFF343637), FontWeight.w600)),
style: fontTextStyle(14, const Color(0xFF343637), FontWeight.w600)),
const SizedBox(height: 6), const SizedBox(height: 6),
Text(subtitle, Text(subtitle, style: fontTextStyle(10, const Color(0xFF515253), FontWeight.w600)),
style: fontTextStyle(10, const Color(0xFF515253), FontWeight.w600)),
], ],
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
// Phone icon inside card
Container( Container(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
decoration: const BoxDecoration( decoration: const BoxDecoration(
color: Color(0xFFF5F6F6), color: Color(0xFFF5F6F6),
shape: BoxShape.circle, shape: BoxShape.circle,
), ),
child: Image.asset( child: Image.asset("images/phone_icon.png", width: 20, height: 20),
"images/phone_icon.png",
width: 20,
height: 20,
), ),
],
), ),
);
}
}
// ====== 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,
], ],
), ),
); );

@ -490,6 +490,7 @@ class _SourceLocationState extends State<SourceLocation> {
// // SnackBar(content: Text("Saved ${_drivers.length} driver(s). Proceeding…")), // // SnackBar(content: Text("Saved ${_drivers.length} driver(s). Proceeding…")),
// // ); // // );
}, },
child: Text( child: Text(
"Continue", "Continue",
style: fontTextStyle(14, Colors.white, FontWeight.w400), style: fontTextStyle(14, Colors.white, FontWeight.w400),

Loading…
Cancel
Save