download water functionality completed

dev
Sneha 1 year ago
parent ca2b402145
commit d88668eb27

@ -104,7 +104,7 @@ class _DashboardState extends State<Dashboard> {
},
child: Container(
padding: EdgeInsets.all(05),
margin: EdgeInsets.only(left:15, top:10, right: 0, bottom:0),
margin: EdgeInsets.only(left:15, top:15, right: 15, bottom:15),
//height: MediaQuery.of(context).size.height * .05,
//width: MediaQuery.of(context).size.width * .45,
decoration: BoxDecoration(
@ -116,7 +116,7 @@ class _DashboardState extends State<Dashboard> {
child: Column(
children: [
Container(
padding: EdgeInsets.fromLTRB(35, 10,0,0),
padding: EdgeInsets.fromLTRB(20, 10,10,10),
child: new SvgPicture.asset("assets/images/booking_request.svg")
),
Text('Booking Data',style: dashboardTextStyle(),),

@ -23,19 +23,41 @@ class _DelivryBookingDataState extends State<DelivryBookingData> with TickerProv
bool isSereverIssue = false;
bool isSereverIssueConnected = false;
bool isSereverIssuePending = false;
String dropdownTypeOfPayment = 'Cash';
String dueAmount = '';
var typeOfPaymentItems = [
'Cash',
'Online',
];
TextEditingController amountPaidController = TextEditingController();
List<GetDeliveryboyDetailsModel> connectedSuppliersList = [];
List<GetDeliveryboyDetailsModel> bookingDataList = [];
List<GetDeliveryboyDetailsModel> completedOrdersList = [];
List<GetDeliveryboyDetailsModel> activeOrdersList = [];
bool isLoading=false;
late TabController _controller;
Future<void> getConnectedSuppliersData() async {
final List<Tab> topTabs = <Tab>[
Tab(
child: Text('Active Orders',style: TextStyle(fontSize: 15),)
),
Tab(
child: Text('Completed Orders',style: TextStyle(fontSize: 15),)
),
];
Future<void> getBokkingsData() async {
isLoading = true;
try {
var response = await AppSettings.getdeliveryboybookings();
setState(() {
connectedSuppliersList =
bookingDataList =
((jsonDecode(response)['data']) as List).map((dynamic model) {
return GetDeliveryboyDetailsModel.fromJson(model);
}).toList();
activeOrdersList=bookingDataList.where((product) => product.orderStatus.toString().toLowerCase()!='delivered').toList();
completedOrdersList=bookingDataList.where((product) => product.orderStatus.toString().toLowerCase()=='delivered').toList();
isLoading = false;
});
@ -53,15 +75,204 @@ class _DelivryBookingDataState extends State<DelivryBookingData> with TickerProv
@override
void initState() {
// TODO: implement initState
getConnectedSuppliersData();
_controller = TabController(vsync: this, length:2);
getBokkingsData();
super.initState();
}
Widget connectedTankers(){
if (connectedSuppliersList.length != 0) {
showFinishOrderDialog(var obj) async {
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return AlertDialog(
title: Text('Finish Order'),
content: SingleChildScrollView(
child: ListBody(
children: [
Container(
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Text(obj.bookingid),
),
SizedBox(
height: 10,
),
Container(
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Text(obj.price),
),
SizedBox(
height: 10,
),
Container(
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
child: DropdownButtonFormField<String>(
// Initial Value
value: dropdownTypeOfPayment,
isExpanded: true,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.water,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Choose Type of Payment',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
hint: Text('Select Type of payment'),
// Down Arrow Icon
icon: const Icon(Icons.keyboard_arrow_down),
items: typeOfPaymentItems
.map<DropdownMenuItem<String>>(
(value) => new DropdownMenuItem<String>(
value: value,
child: new Text(value),
))
.toList(),
onChanged: (String? newValue) {
setState(() {
dropdownTypeOfPayment = newValue!;
});
},
),
),
SizedBox(
height: 10,
),
Container(
padding: const EdgeInsets.all(10),
child: TextFormField(
cursorColor: greyColor,
controller: amountPaidController,
textCapitalization: TextCapitalization.sentences,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.currency_rupee,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Amount Paid ',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
onChanged: (string) {
string = '${AppSettings.formNum(
string.replaceAll(',', ''),
)}';
amountPaidController.value = TextEditingValue(
text: string,
selection: TextSelection.collapsed(
offset: string.length,
),
);
setState(() {
if(amountPaidController.text.length>0){
dueAmount=(int.parse(obj.price)-int.parse(amountPaidController.text.replaceAll(',', ''))).toString();
}
else{
dueAmount=obj.price.toString();
}
});
},
),
),
Visibility(
visible: amountPaidController.text!='',
child: Container(
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Text("Due:$dueAmount"),
),)
]
)),
actions: <Widget>[
TextButton(
child: Text('No', style: textButtonStyle()),
onPressed: () {
Navigator.of(context).pop();
amountPaidController.clear();
},
),
TextButton(
child: Text('Finish Order', style: textButtonStyle()),
onPressed: () async {
if(amountPaidController.text!=''){
String x='';
x =amountPaidController.text. replaceAll(',', '');
if(int.parse(x)<=int.parse(obj.price)){
var payload = new Map<String, dynamic>();
payload["amount_paid"] = amountPaidController.text.toString();
payload["payment_mode"] = dropdownTypeOfPayment.toString().toLowerCase();
payload["orderStatus"] = 'delivered';
bool updateStatus = await AppSettings.deliveryboyFinishOrder(obj.bookingid,payload);
if(updateStatus){
AppSettings.longSuccessToast('Status updated');
Navigator.of(context).pop();
amountPaidController.clear();
getBokkingsData();
}
else{
AppSettings.longFailedToast('failed to update the status');
Navigator.of(context).pop();
amountPaidController.clear();
}
}
else{
AppSettings.longFailedToast('Please enter valid amount paid');
}
}
else{
AppSettings.longFailedToast('Please provide amount paid');
}
},
),
],
);
});
});
}
Widget activeOrders(){
if (activeOrdersList.length != 0) {
return ListView.builder(
padding: EdgeInsets.all(8),
itemCount: connectedSuppliersList.length,
itemCount: activeOrdersList.length,
itemBuilder: (BuildContext context, int index) {
return Card(
child: Padding(
@ -85,7 +296,7 @@ class _DelivryBookingDataState extends State<DelivryBookingData> with TickerProv
width: 5.0,
),
Text(
connectedSuppliersList[index]
activeOrdersList[index]
.tankerName
.toUpperCase(),
style: valuesTextStyle()),
@ -99,7 +310,7 @@ class _DelivryBookingDataState extends State<DelivryBookingData> with TickerProv
width: 5.0,
),
Text(
connectedSuppliersList [index]
activeOrdersList [index]
.bookingid
.toString(),
style: valuesTextStyle()),
@ -112,7 +323,7 @@ class _DelivryBookingDataState extends State<DelivryBookingData> with TickerProv
SizedBox(
width: 5.0,
),
Text(connectedSuppliersList[index].supplierId,
Text(activeOrdersList[index].supplierId,
style: valuesTextStyle()),
],
),
@ -123,7 +334,7 @@ class _DelivryBookingDataState extends State<DelivryBookingData> with TickerProv
SizedBox(
width: 5.0,
),
Text(connectedSuppliersList[index].dateOfOrder,
Text(activeOrdersList[index].dateOfOrder,
style: valuesTextStyle()),
],
),
@ -134,7 +345,7 @@ class _DelivryBookingDataState extends State<DelivryBookingData> with TickerProv
SizedBox(
width: 5.0,
),
Text(connectedSuppliersList[index].typeofwater,
Text(activeOrdersList[index].typeofwater,
style: valuesTextStyle()),
],
),
@ -154,7 +365,7 @@ class _DelivryBookingDataState extends State<DelivryBookingData> with TickerProv
onPressed: () async {
final Uri _phoneUri = Uri(
scheme: "tel",
path: connectedSuppliersList[index]
path: activeOrdersList[index]
.delivery_agent_mobile);
try {
await launch(
@ -201,21 +412,22 @@ class _DelivryBookingDataState extends State<DelivryBookingData> with TickerProv
iconSize: 30,
icon: Icon(
Icons.download,
color:connectedSuppliersList[index].isStart?Colors.grey: primaryColor,
color:activeOrdersList[index].tankerRunningStatus=='1'?Colors.red: Colors.green,
),
onPressed: () async{
if(connectedSuppliersList[index].isStart){
if(activeOrdersList[index].tankerRunningStatus!='0'){
var payload = new Map<String, dynamic>();
payload["action"] = 'stop';
payload["percentage"] = '';
var capacity = await AppSettings.startAndStop(connectedSuppliersList[index].bookingid,payload);
var capacity = await AppSettings.startAndStop(activeOrdersList[index].bookingid,payload);
print(capacity);
//var modelTanksViewList = jsonDecode(capacity)['data'];
setState(() {
connectedSuppliersList[index].isStart=false;
activeOrdersList[index].tankerRunningStatus='0';
activeOrdersList[index].stopTime=jsonDecode(capacity)['stop time'];
});
}
else{
@ -223,12 +435,14 @@ class _DelivryBookingDataState extends State<DelivryBookingData> with TickerProv
payload["action"] = 'start';
payload["percentage"] = '';
var capacity = await AppSettings.startAndStop(connectedSuppliersList[index].bookingid,payload);
var capacity = await AppSettings.startAndStop(activeOrdersList[index].bookingid,payload);
print(capacity);
//var modelTanksViewList = jsonDecode(capacity)['data'];
setState(() {
connectedSuppliersList[index].isStart=true;
activeOrdersList[index].tankerRunningStatus='1';
activeOrdersList[index].startTime=jsonDecode(capacity)['start time'];
});
}
@ -240,93 +454,59 @@ class _DelivryBookingDataState extends State<DelivryBookingData> with TickerProv
),
],
),
SizedBox(width: 10,),
],
)
),
SizedBox(height: 5,),
Row(children: [
Column(
children: [
Visibility(
visible:activeOrdersList[index].startTime!=''&&activeOrdersList[index].startTime!='null',
child:Row(
children: [
Text('Start Time:',style: labelTextStyle(),),
SizedBox(width: 5,),
Text(activeOrdersList[index].startTime,style: valuesTextStyle(),)
],
)),
SizedBox(height: 5,),
Visibility(
visible:activeOrdersList[index].stopTime!=''&&activeOrdersList[index].stopTime!='null',
child:Row(
children: [
Text('Stop Time:',style: labelTextStyle(),),
SizedBox(width: 5,),
Text(activeOrdersList[index].stopTime,style: valuesTextStyle(),)
],
))
],
),
SizedBox(width: 10,),
Visibility(
visible:activeOrdersList[index].stopTime!=''&&activeOrdersList[index].stopTime!='null',
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: primaryColor, // background
onPrimary: Colors.white, // foreground
),
onPressed: () {
showFinishOrderDialog(activeOrdersList[index]);
},
child: const Text('Finish')),)
],)
],
),
),
/* 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,
),
)*/
],
),
),
@ -370,18 +550,218 @@ class _DelivryBookingDataState extends State<DelivryBookingData> with TickerProv
}
}
modelBottomSheet(var obj){
showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
return SizedBox(
height: MediaQuery.of(context).size.height * .300,
child: Padding(
padding: EdgeInsets.all(10),
child: Row(
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Tanker Name :', style: labelTextStyle()),
Text('Capacity Of Tanker :', style: labelTextStyle()),
Text('Booking Id :', style: labelTextStyle()),
Text('Date Of Order :', style: labelTextStyle()),
Text('Type Of Water :', style: labelTextStyle()),
Text('Start Time :', style: labelTextStyle()),
Text('Stop Time :', style: labelTextStyle()),
Text('Initial Water Level :', style: labelTextStyle()),
Text('Final Water Level :', style: labelTextStyle()),
Text('Delivered Water :', style: labelTextStyle()),
Text('Actual Price :', style: labelTextStyle()),
Text('Amount Paid :', style: labelTextStyle()),
Text('Amount Due :', style: labelTextStyle()),
Text('Payment Mode :', style: labelTextStyle()),
],
),
Expanded(
child:Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(obj.tankerName,
style: valuesTextStyle()),
Text(obj.capacity+' Ltrs',
style: valuesTextStyle()),
Text(obj.bookingid,
style:TextStyle(fontSize: 12,fontWeight: FontWeight.bold,overflow: TextOverflow.ellipsis,)),
Text(obj.dateOfOrder,
style:TextStyle(fontSize: 12,fontWeight: FontWeight.bold,overflow: TextOverflow.ellipsis,)),
Text(obj.typeofwater,
style:TextStyle(fontSize: 12,fontWeight: FontWeight.bold,overflow: TextOverflow.ellipsis,)),
Text(obj.startTime,
style:TextStyle(fontSize: 12,fontWeight: FontWeight.bold,overflow: TextOverflow.ellipsis,)),
Text(obj.stopTime,
style:TextStyle(fontSize: 12,fontWeight: FontWeight.bold,overflow: TextOverflow.ellipsis,)),
Text(obj.initialWaterLevel+' Ltrs',
style:TextStyle(fontSize: 12,fontWeight: FontWeight.bold,overflow: TextOverflow.ellipsis,)),
Text(obj.finalWaterLevel+' Ltrs',
style:TextStyle(fontSize: 12,fontWeight: FontWeight.bold,overflow: TextOverflow.ellipsis,)),
Text(obj.deliverdWater+' Ltrs',
style:TextStyle(fontSize: 12,fontWeight: FontWeight.bold,overflow: TextOverflow.ellipsis,)),
Text(obj.price,
style:TextStyle(fontSize: 12,fontWeight: FontWeight.bold,overflow: TextOverflow.ellipsis,)),
Text(obj.amountPaid,
style:TextStyle(fontSize: 12,fontWeight: FontWeight.bold,overflow: TextOverflow.ellipsis,)),
Text(obj.amountDue,
style:TextStyle(fontSize: 12,fontWeight: FontWeight.bold,overflow: TextOverflow.ellipsis,)),
Text(obj.paymentMode,
style:TextStyle(fontSize: 12,fontWeight: FontWeight.bold,overflow: TextOverflow.ellipsis,)),
],
),
),
],
),
)
);
},
);
}
Widget completedOrders(){
if (completedOrdersList.length != 0) {
return ListView.builder(
padding: EdgeInsets.all(8),
itemCount: completedOrdersList.length,
itemBuilder: (BuildContext context, int index) {
return Card(
child: Padding(
padding: EdgeInsets.all(8),
child: Container(
child:Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Tanker Name :', style: labelTextStyle()),
Text('Booking Id :', style: labelTextStyle()),
Text('Date Of Order :', style: labelTextStyle()),
],
),
Expanded(
child:Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(completedOrdersList[index].tankerName,
style: valuesTextStyle()),
Text(completedOrdersList[index].bookingid,
style:TextStyle(fontSize: 12,fontWeight: FontWeight.bold,overflow: TextOverflow.ellipsis,)),
Text(completedOrdersList[index].dateOfOrder,
style:TextStyle(fontSize: 12,fontWeight: FontWeight.bold,overflow: TextOverflow.ellipsis,)),
],
),
),
Expanded(
child: TextButton(
onPressed: () {
modelBottomSheet(completedOrdersList[index]);
},
child: const Text(
'More Details',
style: TextStyle(
color: primaryColor,
fontSize: 15,
decoration: TextDecoration.underline,
),
),
),
)
],
)
)
),
);
});
}
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(
return Scaffold(
appBar: AppBar(
title: Text('Booking Data'),
backgroundColor: primaryColor,
bottom: TabBar(
controller: _controller,
tabs: topTabs,
indicatorColor: Colors.blue,
unselectedLabelColor: Colors.white60,
indicatorWeight: 2,
),),
/* body: */
body: TabBarView(controller: _controller, children: [
Container(
//color: Colors.lightBlueAccent,
child: isLoading?Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 5.0,
),
):connectedTankers(),
));
):activeOrders(),
),
Container(
//color: Colors.lightBlueAccent,
child: isLoading?Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 5.0,
),
):completedOrders(),
),
]),
);
}
}

@ -12,7 +12,17 @@ class GetDeliveryboyDetailsModel {
String address='';
String price='';
String customerId='';
bool isStart=false;
String startTime = '';
String stopTime = '';
String orderStatus = '';
String initialWaterLevel = '';
String finalWaterLevel = '';
String quantityDelivered = '';
String amountPaid = '';
String amountDue = '';
String paymentMode = '';
String deliverdWater = '';
var tankerRunningStatus ;
@ -37,11 +47,18 @@ class GetDeliveryboyDetailsModel {
rtvm.capacity = json['capacity'] ??'';
rtvm.address = json['address'] ??'';
rtvm.price = json['price'] ??'';
rtvm.orderStatus = json['orderStatus'] ??'';
rtvm.customerId = json['customerId'] ??'';
rtvm.startTime = json['start_time'] ??'';
rtvm.stopTime = json['stop_time'] ??'';
rtvm.initialWaterLevel = json['initial_water_level'] ??'';
rtvm.finalWaterLevel = json['final_water_level'] ??'';
rtvm.quantityDelivered = json['quantityDelivered'] ??'';
rtvm.amountPaid = json['amount_paid'] ??'';
rtvm.amountDue = json['amount_due'] ??'';
rtvm.paymentMode = json['payment_mode'] ??'';
rtvm.deliverdWater = json['quantityDelivered'] ??'';
rtvm.tankerRunningStatus = json['tankerRunningStatus'] ??'';
return rtvm;
}

@ -107,7 +107,7 @@ class AppSettings {
static String deliveryboyloginUrl = host + 'deliveryboylogin';
static String deliveryboybookingsUrl = host + 'getdeliveryboybookings';
static String deliveryboyStartAndStopUrl = host + 'deliveryboystartandstop';
static String deliveryboyFinishOrderUrl = host + 'amountpaidByCustomer';
static String verifyPhnUrl = host + 'phone';
static String updateProfileUrl = host + 'update/currentUser';
static String profilePicUrl = host + 'users/profile-picture';
@ -340,6 +340,31 @@ class AppSettings {
}
}
static Future<bool> deliveryboyFinishOrder(var bookingId,payload) async {
//var uri = Uri.parse(deliveryboyStartAndStopUrl);
var uri = Uri.parse(deliveryboyFinishOrderUrl + '/' + bookingId);
var response = await http.put(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return true;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.put(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
static Future<bool> resetToken() async {
var uri = Uri.parse(resetTokenUrl + '/' + customerId);

Loading…
Cancel
Save