|
|
|
|
@ -1,9 +1,12 @@
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
import 'package:image_picker/image_picker.dart';
|
|
|
|
|
import 'package:supplier_new/common/settings.dart';
|
|
|
|
|
import 'package:supplier_new/resources/tanker_details.dart';
|
|
|
|
|
import 'package:supplier_new/resources/tankers_model.dart';
|
|
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
|
|
|
|
|
|
class FirstCharUppercaseFormatter extends TextInputFormatter {
|
|
|
|
|
const FirstCharUppercaseFormatter();
|
|
|
|
|
@ -93,6 +96,67 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
"Capacity"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
final ImagePicker _picker = ImagePicker();
|
|
|
|
|
|
|
|
|
|
List<XFile> tankerImages = [];
|
|
|
|
|
|
|
|
|
|
final int maxImages = 5;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> pickTankerImages(Function modalSetState) async {
|
|
|
|
|
|
|
|
|
|
if(tankerImages.length>=5){
|
|
|
|
|
|
|
|
|
|
AppSettings.longFailedToast("Maximum 5 images allowed");
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final images =
|
|
|
|
|
await _picker.pickMultiImage(imageQuality:70);
|
|
|
|
|
|
|
|
|
|
if(images!=null){
|
|
|
|
|
|
|
|
|
|
int remaining = 5 - tankerImages.length;
|
|
|
|
|
|
|
|
|
|
tankerImages.addAll(
|
|
|
|
|
images.take(remaining)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
modalSetState((){});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> pickFromCamera(Function modalSetState) async {
|
|
|
|
|
|
|
|
|
|
if(tankerImages.length>=5){
|
|
|
|
|
|
|
|
|
|
AppSettings.longFailedToast("Maximum 5 images allowed");
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final image =
|
|
|
|
|
await _picker.pickImage(
|
|
|
|
|
source:ImageSource.camera,
|
|
|
|
|
imageQuality:70,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if(image!=null){
|
|
|
|
|
|
|
|
|
|
tankerImages.add(image);
|
|
|
|
|
|
|
|
|
|
modalSetState((){});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
@ -392,7 +456,612 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> uploadTankerImages(
|
|
|
|
|
String tankerId
|
|
|
|
|
) async {
|
|
|
|
|
|
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
|
|
|
|
|
|
'POST',
|
|
|
|
|
|
|
|
|
|
Uri.parse(
|
|
|
|
|
AppSettings.host +
|
|
|
|
|
"uploads_tanker_images/$tankerId"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
request.headers.addAll(
|
|
|
|
|
await AppSettings.buildRequestHeaders()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
for(var img in tankerImages){
|
|
|
|
|
|
|
|
|
|
request.files.add(
|
|
|
|
|
|
|
|
|
|
await http.MultipartFile.fromPath(
|
|
|
|
|
|
|
|
|
|
'files',
|
|
|
|
|
|
|
|
|
|
img.path
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var response =
|
|
|
|
|
await request.send();
|
|
|
|
|
|
|
|
|
|
if(response.statusCode != 200){
|
|
|
|
|
|
|
|
|
|
throw Exception(
|
|
|
|
|
"Upload failed"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _addTankerNew() async {
|
|
|
|
|
|
|
|
|
|
/// FORM VALIDATION
|
|
|
|
|
final ok = _formKey.currentState?.validate() ?? false;
|
|
|
|
|
|
|
|
|
|
if (!ok) {
|
|
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
AppSettings.preLoaderDialog(context);
|
|
|
|
|
|
|
|
|
|
/// STEP 1 → CREATE TANKER
|
|
|
|
|
final payload = {
|
|
|
|
|
|
|
|
|
|
"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(),
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
final response =
|
|
|
|
|
await AppSettings.addTankersWithResponse(payload);
|
|
|
|
|
|
|
|
|
|
if(response == null){
|
|
|
|
|
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
|
|
|
|
|
AppSettings.longFailedToast(
|
|
|
|
|
"Tanker creation failed"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// IMPORTANT → GET TANKER ID
|
|
|
|
|
String tankerId =
|
|
|
|
|
response["tankerId"] ??
|
|
|
|
|
response["_id"] ??
|
|
|
|
|
"";
|
|
|
|
|
|
|
|
|
|
/// STEP 2 → UPLOAD IMAGES
|
|
|
|
|
if(tankerImages.isNotEmpty){
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
await uploadTankerImages(tankerId);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch(e){
|
|
|
|
|
|
|
|
|
|
debugPrint(
|
|
|
|
|
"Image upload failed $e"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
AppSettings.longFailedToast(
|
|
|
|
|
"Tanker created but images failed"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
|
|
|
|
|
AppSettings.longSuccessToast(
|
|
|
|
|
"Tanker Created Successfully"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Navigator.pop(context,true);
|
|
|
|
|
|
|
|
|
|
_resetForm();
|
|
|
|
|
|
|
|
|
|
_fetchTankers();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (e) {
|
|
|
|
|
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
|
|
|
|
|
debugPrint(
|
|
|
|
|
"⚠️ addTanker error $e"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
|
|
|
|
|
AppSettings.longFailedToast(
|
|
|
|
|
"Something went wrong"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> openTankerSimpleSheet(BuildContext context) async {
|
|
|
|
|
|
|
|
|
|
await showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
|
|
|
|
|
|
builder: (context) {
|
|
|
|
|
|
|
|
|
|
return StatefulBuilder(
|
|
|
|
|
|
|
|
|
|
builder: (context, modalSetState) {
|
|
|
|
|
|
|
|
|
|
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: [
|
|
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 86,
|
|
|
|
|
height: 4,
|
|
|
|
|
margin: const EdgeInsets.only(bottom: 12),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: const Color(0xFFE0E0E0),
|
|
|
|
|
borderRadius: BorderRadius.circular(2),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_LabeledField(
|
|
|
|
|
label: "Tanker Name *",
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _nameCtrl,
|
|
|
|
|
validator: (v) => _required(v, field: "Tanker Name"),
|
|
|
|
|
textCapitalization: TextCapitalization.characters,
|
|
|
|
|
inputFormatters: const [
|
|
|
|
|
FirstCharUppercaseFormatter(), // << live first-letter caps
|
|
|
|
|
],
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "Enter Tanker Name",
|
|
|
|
|
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
|
|
|
|
|
border: const OutlineInputBorder(),
|
|
|
|
|
isDense: true,
|
|
|
|
|
),
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_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,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_LabeledField(
|
|
|
|
|
label: "Tanker Type *",
|
|
|
|
|
child: DropdownButtonFormField<String>(
|
|
|
|
|
value: selectedType,
|
|
|
|
|
dropdownColor: Colors.white,
|
|
|
|
|
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,
|
|
|
|
|
dropdownColor: Colors.white,
|
|
|
|
|
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,
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_LabeledField(
|
|
|
|
|
label: " Age of vehicle (opt)",
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _mfgYearCtrl,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "12",
|
|
|
|
|
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
|
|
|
|
|
border: const OutlineInputBorder(),
|
|
|
|
|
isDense: true,
|
|
|
|
|
),
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
inputFormatters: [
|
|
|
|
|
FilteringTextInputFormatter.digitsOnly,
|
|
|
|
|
LengthLimitingTextInputFormatter(4),
|
|
|
|
|
],
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_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,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_LabeledField(
|
|
|
|
|
label: "Tanker Images (Max 5)",
|
|
|
|
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
|
|
/// IMAGE GRID
|
|
|
|
|
if(tankerImages.isNotEmpty)
|
|
|
|
|
|
|
|
|
|
GridView.builder(
|
|
|
|
|
|
|
|
|
|
shrinkWrap:true,
|
|
|
|
|
|
|
|
|
|
physics:NeverScrollableScrollPhysics(),
|
|
|
|
|
|
|
|
|
|
itemCount:tankerImages.length,
|
|
|
|
|
|
|
|
|
|
gridDelegate:
|
|
|
|
|
const SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
|
|
|
|
|
|
crossAxisCount:3,
|
|
|
|
|
|
|
|
|
|
crossAxisSpacing:8,
|
|
|
|
|
|
|
|
|
|
mainAxisSpacing:8,
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
itemBuilder:(context,index){
|
|
|
|
|
|
|
|
|
|
return Stack(
|
|
|
|
|
|
|
|
|
|
children:[
|
|
|
|
|
|
|
|
|
|
ClipRRect(
|
|
|
|
|
|
|
|
|
|
borderRadius:BorderRadius.circular(8),
|
|
|
|
|
|
|
|
|
|
child:Image.file(
|
|
|
|
|
|
|
|
|
|
File(tankerImages[index].path),
|
|
|
|
|
|
|
|
|
|
width:double.infinity,
|
|
|
|
|
|
|
|
|
|
height:double.infinity,
|
|
|
|
|
|
|
|
|
|
fit:BoxFit.cover,
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
Positioned(
|
|
|
|
|
|
|
|
|
|
right:4,
|
|
|
|
|
|
|
|
|
|
top:4,
|
|
|
|
|
|
|
|
|
|
child:GestureDetector(
|
|
|
|
|
|
|
|
|
|
onTap:(){
|
|
|
|
|
|
|
|
|
|
tankerImages.removeAt(index);
|
|
|
|
|
|
|
|
|
|
modalSetState((){}); /// FIXED
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
child:Container(
|
|
|
|
|
|
|
|
|
|
decoration:const BoxDecoration(
|
|
|
|
|
|
|
|
|
|
color:Colors.red,
|
|
|
|
|
|
|
|
|
|
shape:BoxShape.circle,
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
child:const Icon(
|
|
|
|
|
|
|
|
|
|
Icons.close,
|
|
|
|
|
|
|
|
|
|
color:Colors.white,
|
|
|
|
|
|
|
|
|
|
size:18,
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
const SizedBox(height:10),
|
|
|
|
|
|
|
|
|
|
/// BUTTONS
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
|
|
children:[
|
|
|
|
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
|
|
|
|
child:OutlinedButton.icon(
|
|
|
|
|
|
|
|
|
|
onPressed:(){
|
|
|
|
|
|
|
|
|
|
pickTankerImages(modalSetState); /// FIXED
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
icon:Icon(Icons.photo),
|
|
|
|
|
|
|
|
|
|
label:Text("Gallery"),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
const SizedBox(width:10),
|
|
|
|
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
|
|
|
|
child:OutlinedButton.icon(
|
|
|
|
|
|
|
|
|
|
onPressed:(){
|
|
|
|
|
|
|
|
|
|
pickFromCamera(modalSetState); /// FIXED
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
icon:Icon(Icons.camera_alt),
|
|
|
|
|
|
|
|
|
|
label:Text("Camera"),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
const SizedBox(height:5),
|
|
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
|
|
"${tankerImages.length}/5 images selected",
|
|
|
|
|
|
|
|
|
|
style: fontTextStyle(
|
|
|
|
|
12,
|
|
|
|
|
Colors.grey,
|
|
|
|
|
FontWeight.w400
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
/// SAVE BUTTON (UNCHANGED)
|
|
|
|
|
|
|
|
|
|
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:_addTankerNew,
|
|
|
|
|
|
|
|
|
|
child:Text(
|
|
|
|
|
|
|
|
|
|
"Save",
|
|
|
|
|
|
|
|
|
|
style:fontTextStyle(
|
|
|
|
|
14,
|
|
|
|
|
Colors.white,
|
|
|
|
|
FontWeight.w600
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*Future<void> openTankerSimpleSheet1(BuildContext context) async {
|
|
|
|
|
await showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
@ -571,6 +1240,120 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
onTap: _pickInsuranceDate,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
_LabeledField(
|
|
|
|
|
label: "Tanker Images (Max 5)",
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
|
|
/// Grid Images
|
|
|
|
|
if(tankerImages.isNotEmpty)
|
|
|
|
|
GridView.builder(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
|
itemCount: tankerImages.length,
|
|
|
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
|
crossAxisCount: 3,
|
|
|
|
|
crossAxisSpacing: 8,
|
|
|
|
|
mainAxisSpacing: 8,
|
|
|
|
|
),
|
|
|
|
|
itemBuilder: (context,index){
|
|
|
|
|
|
|
|
|
|
return Stack(
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
|
|
ClipRRect(
|
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
child: Image.file(
|
|
|
|
|
File(tankerImages[index].path),
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: double.infinity,
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
Positioned(
|
|
|
|
|
right: 4,
|
|
|
|
|
top: 4,
|
|
|
|
|
child: GestureDetector(
|
|
|
|
|
|
|
|
|
|
onTap: (){
|
|
|
|
|
|
|
|
|
|
tankerImages.removeAt(index);
|
|
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
|
),
|
|
|
|
|
child: Icon(
|
|
|
|
|
Icons.close,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
size: 18,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
const SizedBox(height:10),
|
|
|
|
|
|
|
|
|
|
/// Add Buttons
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
|
|
Expanded(
|
|
|
|
|
child: OutlinedButton.icon(
|
|
|
|
|
|
|
|
|
|
onPressed: pickTankerImages,
|
|
|
|
|
|
|
|
|
|
icon: Icon(Icons.photo),
|
|
|
|
|
|
|
|
|
|
label: Text("Gallery"),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
const SizedBox(width:10),
|
|
|
|
|
|
|
|
|
|
Expanded(
|
|
|
|
|
child: OutlinedButton.icon(
|
|
|
|
|
|
|
|
|
|
onPressed: pickFromCamera,
|
|
|
|
|
|
|
|
|
|
icon: Icon(Icons.camera_alt),
|
|
|
|
|
|
|
|
|
|
label: Text("Camera"),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
const SizedBox(height:5),
|
|
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
"${tankerImages.length}/5 images selected",
|
|
|
|
|
style: fontTextStyle(
|
|
|
|
|
12,
|
|
|
|
|
Colors.grey,
|
|
|
|
|
FontWeight.w400
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
|
|
|
|
|
|
@ -601,7 +1384,7 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|