|
|
@ -1,4 +1,14 @@
|
|
|
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:geolocator/geolocator.dart';
|
|
|
|
|
|
|
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
|
|
|
|
|
|
import 'package:google_maps_flutter_android/google_maps_flutter_android.dart';
|
|
|
|
|
|
|
|
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
|
|
|
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
|
|
|
|
import 'package:watermanagement_deliveryboy/model/getdeliveryboy_model.dart';
|
|
|
|
|
|
|
|
import 'package:watermanagement_deliveryboy/settings.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class Dashboard extends StatefulWidget {
|
|
|
|
class Dashboard extends StatefulWidget {
|
|
|
|
const Dashboard({Key? key}) : super(key: key);
|
|
|
|
const Dashboard({Key? key}) : super(key: key);
|
|
|
@ -7,22 +17,349 @@ class Dashboard extends StatefulWidget {
|
|
|
|
State<Dashboard> createState() => _DashboardState();
|
|
|
|
State<Dashboard> createState() => _DashboardState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _DashboardState extends State<Dashboard> {
|
|
|
|
class _DashboardState extends State<Dashboard> with TickerProviderStateMixin {
|
|
|
|
|
|
|
|
bool isSupplierDataLoading=false;
|
|
|
|
|
|
|
|
bool isSereverIssue = false;
|
|
|
|
|
|
|
|
bool isSereverIssueConnected = false;
|
|
|
|
|
|
|
|
bool isSereverIssuePending = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<GetDeliveryboyDetailsModel> connectedSuppliersList = [];
|
|
|
|
|
|
|
|
bool isLoading=false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> getConnectedSuppliersData() async {
|
|
|
|
|
|
|
|
isLoading = true;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
var response = await AppSettings.getdeliveryboybookings();
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
connectedSuppliersList =
|
|
|
|
|
|
|
|
((jsonDecode(response)['data']) as List).map((dynamic model) {
|
|
|
|
|
|
|
|
return GetDeliveryboyDetailsModel.fromJson(model);
|
|
|
|
|
|
|
|
}).toList();
|
|
|
|
|
|
|
|
isLoading = false;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
isLoading = false;
|
|
|
|
|
|
|
|
isSereverIssueConnected = true;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
void initState() {
|
|
|
|
return Scaffold(
|
|
|
|
// TODO: implement initState
|
|
|
|
body: Stack(
|
|
|
|
getConnectedSuppliersData();
|
|
|
|
children: <Widget>[
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Widget connectedTankers(){
|
|
|
|
|
|
|
|
if (connectedSuppliersList.length != 0) {
|
|
|
|
|
|
|
|
return ListView.builder(
|
|
|
|
|
|
|
|
padding: EdgeInsets.all(8),
|
|
|
|
|
|
|
|
itemCount: connectedSuppliersList.length,
|
|
|
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
|
|
|
return Card(
|
|
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
|
|
padding: EdgeInsets.all(8),
|
|
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
Container(
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
// width: MediaQuery.of(context).size.width * .75,
|
|
|
|
image: DecorationImage(image: AssetImage("images/logo.png"), fit: BoxFit.cover,),
|
|
|
|
child: Column(
|
|
|
|
|
|
|
|
mainAxisAlignment:
|
|
|
|
|
|
|
|
MainAxisAlignment.spaceBetween,
|
|
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Text('TankerName :',
|
|
|
|
|
|
|
|
style: labelTextStyle()),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
width: 5.0,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
connectedSuppliersList[index]
|
|
|
|
|
|
|
|
.tankerName
|
|
|
|
|
|
|
|
.toUpperCase(),
|
|
|
|
|
|
|
|
style: valuesTextStyle()),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Text('Bookingid :',
|
|
|
|
|
|
|
|
style: labelTextStyle()),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
width: 5.0,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
connectedSuppliersList [index]
|
|
|
|
|
|
|
|
.bookingid
|
|
|
|
|
|
|
|
.toString(),
|
|
|
|
|
|
|
|
style: valuesTextStyle()),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Text('SupplierId :',
|
|
|
|
|
|
|
|
style: labelTextStyle()),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
width: 5.0,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
Text(connectedSuppliersList[index].supplierId,
|
|
|
|
|
|
|
|
style: valuesTextStyle()),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Text('DateOfOrder :',
|
|
|
|
|
|
|
|
style: labelTextStyle()),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
width: 5.0,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Text(connectedSuppliersList[index].dateOfOrder,
|
|
|
|
|
|
|
|
style: valuesTextStyle()),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Text('Typeofwater :',
|
|
|
|
|
|
|
|
style: labelTextStyle()),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
width: 5.0,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Text(connectedSuppliersList[index].typeofwater,
|
|
|
|
|
|
|
|
style: valuesTextStyle()),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
|
|
|
crossAxisAlignment:
|
|
|
|
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Column(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
IconButton(
|
|
|
|
|
|
|
|
iconSize: 30,
|
|
|
|
|
|
|
|
icon: const Icon(
|
|
|
|
|
|
|
|
Icons.phone,
|
|
|
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
|
|
|
final Uri _phoneUri = Uri(
|
|
|
|
|
|
|
|
scheme: "tel",
|
|
|
|
|
|
|
|
path: connectedSuppliersList[index]
|
|
|
|
|
|
|
|
.delivery_agent_mobile);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
await launch(
|
|
|
|
|
|
|
|
_phoneUri.toString());
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
throw ("Cannot dial");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
'Call now',
|
|
|
|
|
|
|
|
style: iconBelowTextStyle(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
width: 30,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Column(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
IconButton(
|
|
|
|
|
|
|
|
iconSize: 30,
|
|
|
|
|
|
|
|
icon: const Icon(
|
|
|
|
|
|
|
|
Icons.start,
|
|
|
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
/* showTankerBookingDialog(
|
|
|
|
|
|
|
|
tankersList[index]);*/
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
'Start Trip',
|
|
|
|
|
|
|
|
style: iconBelowTextStyle(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
width: 30,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Column(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
IconButton(
|
|
|
|
|
|
|
|
iconSize: 30,
|
|
|
|
|
|
|
|
icon: const Icon(
|
|
|
|
|
|
|
|
Icons.download,
|
|
|
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Navigator.push(
|
|
|
|
|
|
|
|
context,
|
|
|
|
|
|
|
|
new MaterialPageRoute(
|
|
|
|
|
|
|
|
builder: (__) => new BookedTanerDetails(myObject:tankersList[index].tanker_name)));*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
'Download Water',
|
|
|
|
|
|
|
|
style: iconBelowTextStyle(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
/* Expanded(
|
|
|
|
|
|
|
|
child:TextButton(
|
|
|
|
|
|
|
|
child: const Text(
|
|
|
|
|
|
|
|
'Connect',
|
|
|
|
|
|
|
|
style: TextStyle(fontSize: 15,
|
|
|
|
|
|
|
|
decoration: TextDecoration.underline,color: primaryColor),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
)),*/
|
|
|
|
|
|
|
|
/* Expanded(
|
|
|
|
|
|
|
|
child: IconButton(
|
|
|
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
//showTankerUpdateDialog(tankersList[index]);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
icon: Icon(Icons.edit),
|
|
|
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
width: 5,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
|
|
child: IconButton(
|
|
|
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
|
|
|
showDialog(
|
|
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
builder: (BuildContext context) =>
|
|
|
|
|
|
|
|
AlertDialog(
|
|
|
|
|
|
|
|
title: const Text(
|
|
|
|
|
|
|
|
'Do you want to delete Tanker?',
|
|
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
|
|
|
fontSize: 20,
|
|
|
|
|
|
|
|
)),
|
|
|
|
|
|
|
|
actionsAlignment:
|
|
|
|
|
|
|
|
MainAxisAlignment.spaceBetween,
|
|
|
|
|
|
|
|
actions: [
|
|
|
|
|
|
|
|
TextButton(
|
|
|
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
|
|
|
bool deletePipelineStatus =
|
|
|
|
|
|
|
|
await AppSettings.deleteTanker(
|
|
|
|
|
|
|
|
tankersList[index]
|
|
|
|
|
|
|
|
.tanker_name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (deletePipelineStatus) {
|
|
|
|
|
|
|
|
getTankers();
|
|
|
|
|
|
|
|
AppSettings.longSuccessToast(
|
|
|
|
|
|
|
|
'Tanker deleted successfully');
|
|
|
|
|
|
|
|
Navigator.of(context).pop(true);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
AppSettings.longFailedToast(
|
|
|
|
|
|
|
|
'Tanker deletion failed');
|
|
|
|
|
|
|
|
Navigator.of(context).pop(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
child: const Text('Yes',
|
|
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
|
|
|
fontSize: 20,
|
|
|
|
|
|
|
|
)),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
TextButton(
|
|
|
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
Navigator.of(context).pop(true);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
child: const Text('No',
|
|
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
|
|
|
fontSize: 20,
|
|
|
|
|
|
|
|
)),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
icon: Icon(Icons.delete),
|
|
|
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)*/
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
return Center(
|
|
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
|
|
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
|
|
|
|
|
|
|
|
child: isSereverIssueConnected
|
|
|
|
|
|
|
|
? Column(
|
|
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Image(
|
|
|
|
|
|
|
|
image: AssetImage('images/serverissue.png'),
|
|
|
|
|
|
|
|
// height: MediaQuery.of(context).size.height * .10,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
height: 20,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
'There is an issue at server please try after some time',style:serverIssueTextStyle() ,),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: Column(
|
|
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Image(
|
|
|
|
|
|
|
|
image: AssetImage('images/no_data.png'),
|
|
|
|
|
|
|
|
// height: MediaQuery.of(context).size.height * .10,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
height: 20,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
'No Connected Tankers',style:serverIssueTextStyle() ,),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
|
|
return SafeArea(
|
|
|
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
|
|
|
appBar: AppSettings.appBar('Deliveryboy'),
|
|
|
|
|
|
|
|
body: isLoading?Center(
|
|
|
|
|
|
|
|
child: CircularProgressIndicator(
|
|
|
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
|
|
|
strokeWidth: 5.0,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
):connectedTankers(),
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|