source and service location changes

master
gitadmin 1 month ago
parent 033df91288
commit ac734007af

@ -498,8 +498,10 @@ class _FleetEmployeesState extends State<FleetEmployees> {
ElevatedButton( ElevatedButton(
onPressed: _addDriver, onPressed: _addDriver,
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF0D3771), backgroundColor: const Color(0xFF8270DB),
foregroundColor: Colors.white), foregroundColor: Colors.white,
minimumSize: const Size(343, 41), // Width & Height
padding: const EdgeInsets.fromLTRB(24, 12, 24, 12),),
child: const Text("Add Driver"), child: const Text("Add Driver"),
), ),
], ],

@ -487,14 +487,26 @@ class _AddTankerFormState extends State<AddTankerForm> {
onTap: _pickInsuranceDate, onTap: _pickInsuranceDate,
), ),
), ),
const SizedBox(height: 16), SizedBox(
ElevatedButton( child: ElevatedButton.icon(
onPressed: _addTanker, onPressed: _addTanker,
style: ElevatedButton.styleFrom( label: Text(
backgroundColor: const Color(0xFF0D3771), "Add Tanker",
foregroundColor: Colors.white), style: fontTextStyle(14, Colors.white, FontWeight.w600),
child: const Text("Add Tanker"), ),
), style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF8270DB),
foregroundColor: Colors.white,
minimumSize: const Size(343, 41), // Width & Height
padding: const EdgeInsets.fromLTRB(24, 12, 24, 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
elevation: 0, // Optional: flat style per modern UI
),
),
)
], ],
), ),
), ),

@ -1,5 +1,7 @@
import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:supplier_new/common/settings.dart'; import 'package:supplier_new/common/settings.dart';
import '../resources/source_loctaions_model.dart';
void main() => runApp(const MaterialApp(home: ServiceLocation())); void main() => runApp(const MaterialApp(home: ServiceLocation()));
@ -16,6 +18,49 @@ class _ServiceLocationState extends State<ServiceLocation> {
final TextEditingController _radiusController = final TextEditingController _radiusController =
TextEditingController(text: "10"); TextEditingController(text: "10");
bool _customizeEachSource = false; bool _customizeEachSource = false;
bool isLoading = false;
int currentStep = 3;
List<SourceLocationsModel> sourceLocationsList = [];
final List<String> _services = [
"24/7 Emergency services",
"Scheduled water deliveries",
"Bulk water deliveries",
"Long-term water delivery plans",
"Industrial/Commercial water deliveries"
];
final Set<String> _selectedServices = {};
final Map<int, bool> _expandedMap = {};
@override
void initState() {
super.initState();
_fetchSources();
}
Future<void> _fetchSources() async {
setState(() => isLoading = true);
try {
final response = await AppSettings.getSourceLoctaions();
final data = (jsonDecode(response)['data'] as List)
.map((e) => SourceLocationsModel.fromJson(e))
.toList();
if (!mounted) return;
setState(() {
sourceLocationsList = data;
isLoading = false;
for (var i = 0; i < data.length; i++) {
_expandedMap[i] = false;
}
});
} catch (e) {
debugPrint("⚠️ Error fetching source locations: $e");
setState(() => isLoading = false);
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -25,323 +70,325 @@ class _ServiceLocationState extends State<ServiceLocation> {
backgroundColor: Colors.white, backgroundColor: Colors.white,
surfaceTintColor: Colors.transparent, surfaceTintColor: Colors.transparent,
elevation: 0, elevation: 0,
scrolledUnderElevation: 0,
title: const Text("Complete Profile"), title: const Text("Complete Profile"),
actions: [
IconButton(
splashRadius: 20,
icon: const Image(
image: AssetImage('images/calendar_appbar.png'),
width: 22,
height: 22,
),
onPressed: () {},
),
IconButton(
splashRadius: 20,
icon: Image.asset('images/notification_appbar.png',
width: 22, height: 22),
onPressed: () {},
),
],
), ),
body: SafeArea( body: SafeArea(
child: Form( child: isLoading
key: _formKey, ? const Center(child: CircularProgressIndicator())
child: ListView( : Form(
padding: const EdgeInsets.fromLTRB(20, 10, 20, 24), key: _formKey,
children: [ child: ListView(
// Step indicator padding: const EdgeInsets.fromLTRB(20, 10, 20, 24),
Text("Step 3/5", children: [
style: Text("Step $currentStep/5",
fontTextStyle(16, const Color(0xFFC3C4C4), FontWeight.w500)), style: fontTextStyle(16, Color(0xFFC3C4C4), FontWeight.w500)),
const SizedBox(height: 16), const SizedBox(height: 16),
Row( Row(
children: List.generate(5, (index) { children: List.generate(5, (index) {
final isFilled = index < 3; final isFilled = index < currentStep;
return Expanded( return Expanded(
child: Container( child: Container(
margin: const EdgeInsets.symmetric(horizontal: 2), margin: const EdgeInsets.symmetric(horizontal: 2),
height: 5, height: 5,
decoration: BoxDecoration( decoration: BoxDecoration(
color: isFilled color: isFilled
? const Color(0xFF0D3771) ? const Color(0xFF0D3771)
: const Color(0xFFE6E6E6), : const Color(0xFFE6E6E6),
borderRadius: BorderRadius.circular(2), borderRadius: BorderRadius.circular(2),
), ),
),
);
}),
), ),
);
}),
),
const SizedBox(height: 16), const SizedBox(height: 16),
Text("SOURCE LOCATION",
style:
fontTextStyle(20, const Color(0xFF515253), FontWeight.w600)),
const SizedBox(height: 8),
Align(
alignment: Alignment.centerLeft,
child: Image.asset('images/marker-pin.png', width: 24, height: 24),
),
const SizedBox(height: 12),
Text(
"Define where you want to provide delivery services",
style:
fontTextStyle(14, const Color(0xFF939495), FontWeight.w500),
),
const SizedBox(height: 6),
// Radio Buttons Text("SERVICE LOCATIONS",
RadioListTile<String>( style: fontTextStyle(20, Color(0xFF515253), FontWeight.w600)),
value: 'business', const SizedBox(height: 16),
groupValue: _deliveryFrom, Align(
onChanged: (value) => alignment: Alignment.centerLeft,
setState(() => _deliveryFrom = value ?? 'business'), child: Image.asset('images/marker-pin.png',
title: Text("From Business Location", width: 24, height: 24),
style: fontTextStyle(
14, const Color(0xFF2D2E30), FontWeight.w500)),
dense: true,
contentPadding: EdgeInsets.zero,
visualDensity:
const VisualDensity(horizontal: 0, vertical: -3),
),
RadioListTile<String>(
value: 'source',
groupValue: _deliveryFrom,
onChanged: (value) =>
setState(() => _deliveryFrom = value ?? 'source'),
title: Text("From Source Locations",
style: fontTextStyle(
14, const Color(0xFF2D2E30), FontWeight.w500)),
dense: true,
contentPadding: EdgeInsets.zero,
visualDensity:
const VisualDensity(horizontal: 0, vertical: -3),
),
const SizedBox(height: 12),
// Business Location Section
Visibility(
visible: _deliveryFrom == 'business',
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Delivery Radius (in Kms) *",
style: fontTextStyle(
14, const Color(0xFF2D2E30), FontWeight.w500)),
const SizedBox(height: 6),
TextFormField(
controller: _radiusController,
keyboardType: TextInputType.number,
decoration: InputDecoration(
hintText: "Enter radius in kms",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 12),
),
), ),
const SizedBox(height: 16),
const SizedBox(height: 12), Text(
Container( "Define where you want to provide delivery services",
width: double.infinity, style: fontTextStyle(14, Color(0xFF939495), FontWeight.w500),
height: 160,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('images/google_maps.png'),
fit: BoxFit.contain,
),
),
), ),
], const SizedBox(height: 16),
),
),
// Source Location Customization Section RadioListTile<String>(
Visibility( value: 'business',
visible: _deliveryFrom == 'source', groupValue: _deliveryFrom,
child: Column( onChanged: (value) =>
crossAxisAlignment: CrossAxisAlignment.start, setState(() => _deliveryFrom = value ?? 'business'),
children: [ title: Text("From Business Location",
const SizedBox(height: 12), style: fontTextStyle(12, Color(0xFF2D2E30), FontWeight.w400)),
dense: true,
// 🔹 Checkbox toggle contentPadding: EdgeInsets.zero,
Row( visualDensity:
children: [ const VisualDensity(horizontal: 0, vertical: -3),
Checkbox( ),
value: _customizeEachSource, RadioListTile<String>(
onChanged: (val) => value: 'source',
setState(() => _customizeEachSource = val ?? false), groupValue: _deliveryFrom,
), onChanged: (value) =>
const SizedBox(width: 6), setState(() => _deliveryFrom = value ?? 'source'),
Expanded( title: Text("From Source Locations",
child: Text( style: fontTextStyle(12, Color(0xFF2D2E30), FontWeight.w400)),
"Customize for each source location", dense: true,
style: fontTextStyle( contentPadding: EdgeInsets.zero,
14, const Color(0xFF2D2E30), FontWeight.w500), visualDensity:
), const VisualDensity(horizontal: 0, vertical: -3),
),
],
), ),
const SizedBox(height: 12), const SizedBox(height: 16),
// 🔹 Only the list hides/shows
Visibility( Visibility(
visible: _customizeEachSource, visible: _deliveryFrom == 'business',
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
_SectionHeaderBar(title: "SOURCE LOCATION #1"), Text("Delivery Radius (in Kms) *",
const SizedBox(height: 12), style: fontTextStyle(12, Color(0xFF2F3036), FontWeight.w600)),
Text( const SizedBox(height: 16),
"Delivery Radius (in Kms) *",
style: fontTextStyle(
14, const Color(0xFF2D2E30), FontWeight.w500),
),
const SizedBox(height: 6),
TextFormField( TextFormField(
controller: TextEditingController(text: "10"), controller: _radiusController,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Enter radius in kms", hintText: "Enter radius in kms",
hintStyle: fontTextStyle(14, Color(0xFF939495), FontWeight.w400),
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
contentPadding: contentPadding: const EdgeInsets.symmetric(
const EdgeInsets.symmetric(horizontal: 12, vertical: 12), horizontal: 12, vertical: 12),
), ),
), ),
const SizedBox(height: 12), const SizedBox(height: 16),
_SectionHeaderBar(title: "SOURCE LOCATION #2"), Container(
const SizedBox(height: 12), width: double.infinity,
Text( height: 160,
"Delivery Radius (in Kms) *", decoration: const BoxDecoration(
style: fontTextStyle( image: DecorationImage(
14, const Color(0xFF2D2E30), FontWeight.w500), image: AssetImage('images/google_maps.png'),
fit: BoxFit.contain,
),
),
), ),
const SizedBox(height: 6), ],
),
),
// Source Location Customization Section
Visibility(
visible: _deliveryFrom == 'source',
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Delivery Radius (in Kms) *",
style: fontTextStyle(12, Color(0xFF2F3036), FontWeight.w600)),
const SizedBox(height: 16),
TextFormField( TextFormField(
controller: TextEditingController(text: "8"), controller: _radiusController,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Enter radius in kms", hintText: "Enter radius in kms",
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
contentPadding: contentPadding: const EdgeInsets.symmetric(
const EdgeInsets.symmetric(horizontal: 12, vertical: 12), horizontal: 12, vertical: 12),
), ),
), ),
const SizedBox(height: 16),
Row(
children: [
Checkbox(
value: _customizeEachSource,
onChanged: (val) => setState(
() => _customizeEachSource = val ?? false),
materialTapTargetSize:
MaterialTapTargetSize.shrinkWrap,
visualDensity: const VisualDensity(
horizontal: -4, vertical: -4),
),
const SizedBox(width: 6),
Expanded(
child: Text(
"Customize for each source location",
style: fontTextStyle(12, Color(0xFF2D2E30), FontWeight.w400),
),
),
],
),
const SizedBox(height: 12), const SizedBox(height: 12),
// 🔹 Show all source locations when checkbox checked
if (_customizeEachSource)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: sourceLocationsList.isEmpty
? [
const Text("No source locations available"),
]
: List.generate(sourceLocationsList.length, (index) {
final d = sourceLocationsList[index];
return StatefulBuilder(
builder: (context, setInner) {
// Always read from map dynamically (not fixed final variable)
final isExpanded = _expandedMap[index] ?? false;
return Container(
margin: const EdgeInsets.only(bottom: 8),
decoration: BoxDecoration(
color: const Color(0xFFF7F7F7),
border: Border.all(color: const Color(0xFFE5E5E5)),
borderRadius: BorderRadius.circular(12),
),
child: Column(
children: [
ListTile(
dense: true,
contentPadding: EdgeInsets.zero,
minVerticalPadding: 0,
visualDensity: const VisualDensity(vertical: -4, horizontal: 0),
title: Text(
d.source_name ?? 'Unnamed location',
style: fontTextStyle(14, const Color(0xFF2D2E30), FontWeight.w600),
),
trailing: IconButton(
icon: Image.asset(
isExpanded
? 'images/arrow-up.png'
: 'images/downarrow.png',
width: 18,
height: 18,
),
onPressed: () {
setInner(() {
_expandedMap[index] = !isExpanded;
});
},
),
),
if (isExpanded)
Container(
margin: const EdgeInsets.only(left: 10, right: 10, bottom: 6),
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: const Color(0xFFE5E5E5)),
),
child: Text(
"Address: ${d.address ?? 'N/A'}",
style: fontTextStyle(12, const Color(0xFF646566), FontWeight.w400),
),
),
],
),
);
},
);
}),
),
const SizedBox(height: 16),
Container(
width: double.infinity,
height: 160,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('images/google_maps.png'),
fit: BoxFit.contain,
),
),
),
], ],
), ),
), ),
// 🔹 Map always visible const SizedBox(height: 24),
Container( Text("Types of Services",
style: fontTextStyle(16, Color(0xFF2D2E30), FontWeight.w600)),
const SizedBox(height: 12),
Text(
"Define what type of services you would wish to provide",
style: fontTextStyle(14, Color(0xFF939495), FontWeight.w500)),
const SizedBox(height: 16),
..._services
.map((service) => _serviceItem(service))
.toList(),
const SizedBox(height: 24),
SizedBox(
width: double.infinity, width: double.infinity,
height: 160, child: ElevatedButton(
decoration: const BoxDecoration( style: ElevatedButton.styleFrom(
image: DecorationImage( backgroundColor: const Color(0xFF8270DB),
image: AssetImage('images/google_maps.png'), foregroundColor: Colors.white,
fit: BoxFit.contain, padding: const EdgeInsets.symmetric(vertical: 14),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24)),
), ),
onPressed: () {
final selected = _selectedServices.isEmpty
? "No services selected"
: _selectedServices.join(", ");
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
"Saved successfully for ${_deliveryFrom == 'business' ? 'Business Location' : 'Source Locations'}\nSelected: $selected"),
),
);
},
child: Text("Save & Continue",
style: fontTextStyle(14, Color(0xFFFFFFFF), FontWeight.w400)),
), ),
), ),
], ],
), ),
), ),
const SizedBox(height: 24),
Text("Types of Services",
style: fontTextStyle(
16, const Color(0xFF2D2E30), FontWeight.w600)),
const SizedBox(height: 12),
Text("Define what type of services you would wish to provide",
style:
fontTextStyle(14, const Color(0xFF939495), FontWeight.w500)),
const SizedBox(height: 20),
_serviceItem("24/7 Emergency services"),
_serviceItem("Scheduled water deliveries"),
_serviceItem("Bulk water deliveries"),
_serviceItem("Long-term water delivery plans"),
_serviceItem("Industrial/Commercial water deliveries"),
const SizedBox(height: 24),
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: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
"Saved successfully for ${_deliveryFrom == 'business' ? 'Business Location' : 'Source Locations'}"),
),
);
},
child: Text("Save & Continue",
style: fontTextStyle(14, Colors.white, FontWeight.w400)),
),
),
],
),
),
), ),
); );
} }
Widget _serviceItem(String label) => Padding( // Service item
padding: const EdgeInsets.only(bottom: 12), Widget _serviceItem(String label) {
child: Row( final bool selected = _selectedServices.contains(label);
children: [ return GestureDetector(
const Icon(Icons.check_box_outline_blank, onTap: () {
size: 20, color: Color(0xFF939495)), setState(() {
const SizedBox(width: 8), if (selected) {
Text(label, _selectedServices.remove(label);
style: } else {
fontTextStyle(12, const Color(0xFF2D2E30), FontWeight.w400)), _selectedServices.add(label);
], }
), });
); },
} child: Container(
margin: const EdgeInsets.only(bottom: 8),
class _SectionHeaderBar extends StatelessWidget { child: Row(
final String title; children: [
Icon(
const _SectionHeaderBar({required this.title, super.key}); selected ? Icons.check_box : Icons.check_box_outline_blank,
color: selected ? Color(0xFF8270DB) : Color(0xFF939495),
@override size: 20,
Widget build(BuildContext context) { ),
return Container( const SizedBox(width: 8),
decoration: BoxDecoration( Expanded(
color: const Color(0xFFEEEEEE), child: Text(label, style: fontTextStyle(12, Color(0xFF2D2E30), FontWeight.w400),
border: Border.all(color: const Color(0xFFE5E7EB), width: 1), ),
borderRadius: BorderRadius.circular(12), ),
boxShadow: [ ],
BoxShadow( ),
color: Colors.black.withOpacity(0.04),
blurRadius: 6,
offset: const Offset(0, 2),
),
],
), ),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
child: Text(title,
style:
fontTextStyle(10, const Color(0xFF2D2E30), FontWeight.w600)),
); );
} }
} }

@ -162,8 +162,7 @@ class _SourceLocationState extends State<SourceLocation> {
Center( Center(
child: Text( child: Text(
"Add Source Location", "Add Source Location",
style: fontTextStyle( style: fontTextStyle(16, Color(0xFF2D2E30), FontWeight.w600),
16, const Color(0xFF2D2E30), FontWeight.w600),
), ),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
@ -304,7 +303,7 @@ class _SourceLocationState extends State<SourceLocation> {
), ),
), ),
), ),
const SizedBox(height: 12), const SizedBox(height: 16),
], ],
), ),
), ),
@ -401,8 +400,7 @@ class _SourceLocationState extends State<SourceLocation> {
padding: const EdgeInsets.fromLTRB(20, 10, 20, 24), padding: const EdgeInsets.fromLTRB(20, 10, 20, 24),
children: [ children: [
Text("Step $currentStep/5", Text("Step $currentStep/5",
style: fontTextStyle( style: fontTextStyle(16, Color(0xFFC3C4C4), FontWeight.w500)),
16, const Color(0xFFC3C4C4), FontWeight.w500)),
const SizedBox(height: 16), const SizedBox(height: 16),
Row( Row(
children: List.generate(5, (index) { children: List.generate(5, (index) {
@ -420,18 +418,16 @@ class _SourceLocationState extends State<SourceLocation> {
}), }),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
Text("SOURCE LOCATION", Text("SOURCE LOCATIONS",
style: fontTextStyle( style: fontTextStyle(20, Color(0xFF515253), FontWeight.w600)),
20, const Color(0xFF515253), FontWeight.w600)), const SizedBox(height: 6),
const SizedBox(height: 16),
Align( Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Image.asset('images/truck.png', width: 24, height: 24), child: Image.asset('images/truck.png', width: 24, height: 24),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
Text("Add your source location", Text("Add your source location",
style: fontTextStyle( style: fontTextStyle(14, Color(0xFF939495), FontWeight.w500)),
14, const Color(0xFF939495), FontWeight.w500)),
const SizedBox(height: 16), const SizedBox(height: 16),
// List of saved locations // List of saved locations
@ -496,10 +492,7 @@ class _SourceLocationState extends State<SourceLocation> {
), ),
child: Text( child: Text(
"Address: ${d.address ?? 'N/A'}", "Address: ${d.address ?? 'N/A'}",
style: fontTextStyle( style: fontTextStyle(12, Color(0xFF646566), FontWeight.w400),
12,
const Color(0xFF646566),
FontWeight.w400),
), ),
), ),
], ],
@ -518,7 +511,7 @@ class _SourceLocationState extends State<SourceLocation> {
14, const Color(0xFF646566), FontWeight.w600), 14, const Color(0xFF646566), FontWeight.w600),
), ),
), ),
const SizedBox(height: 12), const SizedBox(height: 16),
ElevatedButton( ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF8270DB), backgroundColor: const Color(0xFF8270DB),
@ -532,7 +525,7 @@ class _SourceLocationState extends State<SourceLocation> {
}, },
child: Text("Continue", child: Text("Continue",
style: fontTextStyle( style: fontTextStyle(
14, Colors.white, FontWeight.w400)), 14, Color(0xFFFFFFFF), FontWeight.w600)),
), ),
], ],
), ),

Loading…
Cancel
Save