allocate deliveryboy functionaliy

dev
Sneha 2 years ago
parent 12dab14b6b
commit b963a37fe0

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:watermanagement/settings.dart';
import 'models/booking_requests_model.dart';
import 'models/getdeliveryboy_model.dart';
class BookingRequets extends StatefulWidget {
const BookingRequets({Key? key}) : super(key: key);
@ -14,8 +15,10 @@ class BookingRequets extends StatefulWidget {
class _BookingRequetsState extends State<BookingRequets> {
List<BookingRequestsModel> BookingRequestsList = [];
List<GetDeliveryboyDetailsModel> modeldeliveryboyList = [];
bool isSereverIssuePending = false;
bool isDataLoading = false;
var dropdownAllDeliveryBoys;
Future<void> getBookingRequestsData() async {
isDataLoading = true;
@ -37,11 +40,22 @@ class _BookingRequetsState extends State<BookingRequets> {
});
}
}
Future<void> getAllDeliveryBoys() async {
var response1= await AppSettings.getAllDeliverboy();
print(response1);
setState(() {
modeldeliveryboyList =
((jsonDecode(response1)['data']) as List).map((dynamic model) {
return GetDeliveryboyDetailsModel.fromJson(model);
}).toList();
dropdownAllDeliveryBoys=modeldeliveryboyList[0];
});
}
@override
void initState() {
isDataLoading = true;
getBookingRequestsData();
getAllDeliveryBoys();
super.initState();
}
@ -225,6 +239,74 @@ class _BookingRequetsState extends State<BookingRequets> {
color:
primaryColor /*FilteredList[index].text_color*/),
),
onPressed: () async {
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return AlertDialog(
title: const Text('Assign'),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Container(
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
child: DropdownButtonFormField<GetDeliveryboyDetailsModel>(
// Initial Value
value: dropdownAllDeliveryBoys,
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: 'Select delivery boy',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
hint: Text('Select delivery boy'),
// Down Arrow Icon
icon: const Icon(Icons.keyboard_arrow_down),
items: modeldeliveryboyList
.map<DropdownMenuItem<GetDeliveryboyDetailsModel>>(
(value) => new DropdownMenuItem<GetDeliveryboyDetailsModel>(
value: value,
child: new Text(value.deliveryboy_name),
))
.toList(),
onChanged: (GetDeliveryboyDetailsModel? newValue) {
setState(() {
dropdownAllDeliveryBoys = newValue;
});
},
),
),
],
),
),
actions: <Widget>[
TextButton(
child: Text('cancel', style: textButtonStyle()),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: Text('Accept', style: textButtonStyle()),
onPressed: () async{
var payload = new Map<String, dynamic>();
payload["supplierName"] =
@ -243,9 +325,9 @@ class _BookingRequetsState extends State<BookingRequets> {
payload["action"] = "accept";
payload["price"] =
BookingRequestsList[index].price;
payload["delivery_agent"] = '';
payload["agent_mobile"] = '';
payload["agent_alternative_mobile"] = '';
payload["delivery_agent"] = dropdownAllDeliveryBoys.deliveryboy_name;
payload["agent_mobile"] = dropdownAllDeliveryBoys.deliveryboy_phone;
payload["agent_alternative_mobile"] = dropdownAllDeliveryBoys.deliveryboy_alternativeContactNumber;
bool requestStatus =
await AppSettings.acceptBookingRequests(
@ -253,6 +335,7 @@ class _BookingRequetsState extends State<BookingRequets> {
payload);
if (requestStatus) {
Navigator.of(context).pop();
AppSettings.longSuccessToast(
"Booking Accepted");
await getBookingRequestsData();
@ -261,6 +344,17 @@ class _BookingRequetsState extends State<BookingRequets> {
//await getPendingSuppliersData();
} else {}
},
),
],
);
});
},
);
},
),
TextButton(

@ -318,7 +318,7 @@ class _ConectedPendingCustomersState extends State<ConectedPendingCustomers> wit
bool requestStatus = await AppSettings.rejectRequest(payload);
if(requestStatus){
AppSettings.longSuccessToast("Request Sent Successfully");
AppSettings.longSuccessToast("Rejected request Successfully");
await getPendingSuppliersData();
}

@ -66,6 +66,5 @@ flutter:
uses-material-design: true
assets:
- images/
- json/
- assets/images/

Loading…
Cancel
Save