updated the code

dev
suresh 2 years ago
parent d1a27f9539
commit 45ed63be9c

@ -367,7 +367,7 @@ class _DashboardState extends State<Dashboard> {
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
Text('All Deliveryboys',style: TextStyle(color:primaryColor)), Text('Deliveryboys View',style: TextStyle(color:primaryColor)),
], ],
), ),
onTap: () { onTap: () {

@ -21,6 +21,8 @@ class _GetDeliveryboyDataState extends State<GetDeliveryboyData> {
TextEditingController deliveryboyPhoneController = TextEditingController(); TextEditingController deliveryboyPhoneController = TextEditingController();
TextEditingController deliveryboyAlterPhoneController = TextEditingController(); TextEditingController deliveryboyAlterPhoneController = TextEditingController();
TextEditingController deliveryboyAddress = TextEditingController(); TextEditingController deliveryboyAddress = TextEditingController();
TextEditingController deliveryboyStatus = TextEditingController();
bool isLoading=false; bool isLoading=false;
@ -43,7 +45,157 @@ class _GetDeliveryboyDataState extends State<GetDeliveryboyData> {
super.initState(); super.initState();
} }
showUpdateDeliveryDialog(var object) async {
// tankNameController
// blockNameController
// capacityController
deliveryboyNameController.text=object.deliveryboy_name??'';
deliveryboyPhoneController.text=object.deliveryboy_phone??'';
deliveryboyAlterPhoneController.text=object.deliveryboy_alternativeContactNumber??'';
deliveryboyAddress.text=object.deliveryboy_address??'';
deliveryboyStatus.text=object.deliveryboy_status??'';
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return AlertDialog(
title: const Text('Update Deliveryboy'),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Container(
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
child: TextFormField(
cursorColor: greyColor,
controller: deliveryboyNameController,
textCapitalization: TextCapitalization.characters,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.ac_unit_outlined,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Enter name',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
),
Container(
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
child: TextFormField(
cursorColor: greyColor,
controller: deliveryboyPhoneController,
keyboardType: TextInputType.number,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.phone,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Enter phone number',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
),
Container(
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
child: TextFormField(
cursorColor: greyColor,
controller: deliveryboyAlterPhoneController,
keyboardType: TextInputType.number,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.phone,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Enter Alternative phone number',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
),
],
),
),
actions: <Widget>[
TextButton(
child: Text('Cancel',style:textButtonStyle()),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: Text('Update',style:textButtonStyle()),
onPressed: () async{
if(deliveryboyNameController.text!=''&&deliveryboyPhoneController.text!=''&&deliveryboyAlterPhoneController.text!=''){
var payload = new Map<String, dynamic>();
payload["name"] = deliveryboyNameController.text.toString();
payload["phone"] = deliveryboyPhoneController.text.toString();
payload["alternativeContactNumber"] = deliveryboyAlterPhoneController.text.toString();
bool updateDeliveryboyStatus = await AppSettings.updateDeliveryboy(object.deliveryboy_phone,payload);
if(updateDeliveryboyStatus){
readJson();
AppSettings.longSuccessToast('Deliveryboy updated successfully');
Navigator.of(context).pop(true);
}
else{
AppSettings.longFailedToast('Deliveryboy update failed');
}
}
else{
AppSettings.longFailedToast('Fill the details');
}
},
),
],
);
});
},
);
}
Widget renderzUi(){ Widget renderzUi(){
if(modeldeliveryboyList.length!=0){ if(modeldeliveryboyList.length!=0){
@ -79,7 +231,8 @@ class _GetDeliveryboyDataState extends State<GetDeliveryboyData> {
Text('name :',style: labelTextStyle()), Text('name :',style: labelTextStyle()),
Text('phone :',style: labelTextStyle()), Text('phone :',style: labelTextStyle()),
Text('alternativeContactNumber :',style: labelTextStyle()), Text('alternativeContactNumber :',style: labelTextStyle()),
Text('address :',style: labelTextStyle()), // Text('address :',style: labelTextStyle()),
Text('status :',style: labelTextStyle()),
], ],
), ),
SizedBox(width: 5,), SizedBox(width: 5,),
@ -90,9 +243,11 @@ class _GetDeliveryboyDataState extends State<GetDeliveryboyData> {
Text(modeldeliveryboyList[index].deliveryboy_name,style: valuesTextStyle()), Text(modeldeliveryboyList[index].deliveryboy_name,style: valuesTextStyle()),
Text(modeldeliveryboyList[index].deliveryboy_phone,style: valuesTextStyle()), Text(modeldeliveryboyList[index].deliveryboy_phone,style: valuesTextStyle()),
Text(modeldeliveryboyList[index].deliveryboy_alternativeContactNumber,style: valuesTextStyle()), Text(modeldeliveryboyList[index].deliveryboy_alternativeContactNumber,style: valuesTextStyle()),
Text(modeldeliveryboyList[index].deliveryboy_address,style: valuesTextStyle(), /*Text(modeldeliveryboyList[index].deliveryboy_address,style: valuesTextStyle(),
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
maxLines: 1), maxLines: 1),*/
Text(modeldeliveryboyList[index].deliveryboy_status,style: valuesTextStyle()),
], ],
), ),
@ -106,14 +261,14 @@ class _GetDeliveryboyDataState extends State<GetDeliveryboyData> {
Expanded(child:IconButton( Expanded(child:IconButton(
icon: const Icon(Icons.edit,color: primaryColor,), icon: const Icon(Icons.edit,color: primaryColor,),
onPressed: () { onPressed: () {
// showTankerUpdateDialog(modeldeliveryboyList[index]); showUpdateDeliveryDialog(modeldeliveryboyList[index]);
}, },
),), ),),
Expanded(child:IconButton( Expanded(child:IconButton(
icon: const Icon(Icons.delete,color: primaryColor,), icon: const Icon(Icons.delete,color: primaryColor,),
onPressed: () async{ onPressed: () async{
/* showDialog( showDialog(
//if set to true allow to close popup by tapping out of the popup //if set to true allow to close popup by tapping out of the popup
//barrierDismissible: false, //barrierDismissible: false,
context: context, context: context,
@ -127,17 +282,17 @@ class _GetDeliveryboyDataState extends State<GetDeliveryboyData> {
actions: [ actions: [
TextButton( TextButton(
onPressed: ()async { onPressed: ()async {
bool deleteTankStatus = await AppSettings.deleteTanker(modelTanksViewList[index].tanker_name); bool deleteDeliveryboyStatus = await AppSettings.deleteDeliveryboy(modeldeliveryboyList[index].deliveryboy_phone);
if(deleteTankStatus){ if(deleteDeliveryboyStatus){
readJson(); readJson();
AppSettings.longSuccessToast('tank deleted successfully'); AppSettings.longSuccessToast('Deliveryboy deleted successfully');
Navigator.of(context).pop(true); Navigator.of(context).pop(true);
} }
else{ else{
AppSettings.longFailedToast('tank deletion failed'); AppSettings.longFailedToast('Deliveryboy deletion failed');
} }
}, },
child: const Text('Yes', child: const Text('Yes',
@ -160,7 +315,7 @@ class _GetDeliveryboyDataState extends State<GetDeliveryboyData> {
), ),
); );
*/
}, },
),) ),)

@ -6,6 +6,8 @@ class GetDeliveryboyDetailsModel {
String deliveryboy_phone = ''; String deliveryboy_phone = '';
String deliveryboy_alternativeContactNumber = ''; String deliveryboy_alternativeContactNumber = '';
String deliveryboy_address=''; String deliveryboy_address='';
String deliveryboy_status='';
Color cardColor=Colors.white; Color cardColor=Colors.white;
@ -18,6 +20,8 @@ class GetDeliveryboyDetailsModel {
rtvm.deliveryboy_phone = json['phone'] ?? ''; rtvm.deliveryboy_phone = json['phone'] ?? '';
rtvm.deliveryboy_alternativeContactNumber = json['alternativeContactNumber'] ?? ''; rtvm.deliveryboy_alternativeContactNumber = json['alternativeContactNumber'] ?? '';
rtvm.deliveryboy_address = json['address'] ??''; rtvm.deliveryboy_address = json['address'] ??'';
rtvm.deliveryboy_status = json['status'] ??'';
return rtvm; return rtvm;

@ -90,6 +90,10 @@ class AppSettings {
static String UpdateTankerUrl = host + 'updateTankers'; static String UpdateTankerUrl = host + 'updateTankers';
static String addDeliveryboyUrl = host + 'addDeliveryboys'; static String addDeliveryboyUrl = host + 'addDeliveryboys';
static String getAllDeliverboyUrl = host + 'getActiveDeliveryboys'; static String getAllDeliverboyUrl = host + 'getActiveDeliveryboys';
static String updateDeliveryboyUrl = host + 'updatedeliveryboy';
static String deleteDeliveryboyUrl = host + 'deletedeliveryboy';
@ -294,6 +298,10 @@ class AppSettings {
} }
static Future<bool> addTankers(payload) async { static Future<bool> addTankers(payload) async {
var response = await http.post(Uri.parse(addTankerUrl + '/' + supplierId), var response = await http.post(Uri.parse(addTankerUrl + '/' + supplierId),
body: json.encode(payload), headers: await buildRequestHeaders()); body: json.encode(payload), headers: await buildRequestHeaders());
@ -324,7 +332,6 @@ class AppSettings {
return false; return false;
} }
} }
static Future<String> getTankers() async { static Future<String> getTankers() async {
var uri = Uri.parse(getTankersDataUrl); var uri = Uri.parse(getTankersDataUrl);
uri = uri.replace(query: 'supplierId=$supplierId'); uri = uri.replace(query: 'supplierId=$supplierId');
@ -348,22 +355,21 @@ class AppSettings {
return ''; return '';
} }
} }
static Future<bool> updateTanker(tankerName, payload) async {
static Future<bool> deleteTanker(tankerName) async { var uri = Uri.parse(UpdateTankerUrl + '/' + supplierId);
var uri = Uri.parse(deleteTankerUrl + '/' + supplierId);
uri = uri.replace(query: 'tankerName=$tankerName'); uri = uri.replace(query: 'tankerName=$tankerName');
try { try {
var response = var response = await http.put(uri,
await http.put(uri, headers: await buildPutRequestHeaders()); body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) { if (response.statusCode == 200) {
return true; return true;
} else if (response.statusCode == 401) { } else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken(); bool status = await AppSettings.resetToken();
if (status) { if (status) {
response = response = await http.put(uri,
await http.put(uri, headers: await buildPutRequestHeaders()); body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) { if (response.statusCode == 200) {
return true; return true;
} else { } else {
@ -380,22 +386,21 @@ class AppSettings {
return false; return false;
} }
} }
static Future<bool> deleteTanker(tankerName) async {
static Future<bool> updateTanker(tankerName, payload) async { var uri = Uri.parse(deleteTankerUrl + '/' + supplierId);
var uri = Uri.parse(UpdateTankerUrl + '/' + supplierId);
uri = uri.replace(query: 'tankerName=$tankerName'); uri = uri.replace(query: 'tankerName=$tankerName');
try { try {
var response = await http.put(uri, var response =
body: json.encode(payload), headers: await buildRequestHeaders()); await http.put(uri, headers: await buildPutRequestHeaders());
if (response.statusCode == 200) { if (response.statusCode == 200) {
return true; return true;
} else if (response.statusCode == 401) { } else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken(); bool status = await AppSettings.resetToken();
if (status) { if (status) {
response = await http.put(uri, response =
body: json.encode(payload), headers: await buildRequestHeaders()); await http.put(uri, headers: await buildPutRequestHeaders());
if (response.statusCode == 200) { if (response.statusCode == 200) {
return true; return true;
} else { } else {
@ -444,8 +449,6 @@ class AppSettings {
return false; return false;
} }
} }
static Future<String> getAllDeliverboy() async { static Future<String> getAllDeliverboy() async {
var response = await http.get(Uri.parse(getAllDeliverboyUrl + '/' + supplierId), var response = await http.get(Uri.parse(getAllDeliverboyUrl + '/' + supplierId),
headers: await buildRequestHeaders()); headers: await buildRequestHeaders());
@ -476,7 +479,68 @@ class AppSettings {
return ""; return "";
} }
} }
static Future<bool> updateDeliveryboy(phone, payload) async {
var uri = Uri.parse(updateDeliveryboyUrl + '/' + supplierId);
uri = uri.replace(query: 'phone=$phone');
try {
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;
}
} catch (e) {
print(e);
return false;
}
}
static Future<bool> deleteDeliveryboy(phone) async {
var uri = Uri.parse(deleteDeliveryboyUrl + '/' + supplierId);
uri = uri.replace(query: 'phone=$phone');
try {
var response =
await http.put(uri, headers: await buildPutRequestHeaders());
if (response.statusCode == 200) {
return true;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response =
await http.put(uri, headers: await buildPutRequestHeaders());
if (response.statusCode == 200) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
} catch (e) {
print(e);
return false;
}
}

@ -265,8 +265,8 @@ class _TankersViewState extends State<TankersView> {
Visibility( Visibility(
visible: isDrinkingChecked, visible: isDrinkingChecked,
child: Container( child: Container(
height: 40, height: 37,
width:200, width:120,
child:TextFormField( child:TextFormField(
cursorColor: greyColor, cursorColor: greyColor,
controller: tankerDrinkingPriceController, controller: tankerDrinkingPriceController,
@ -329,8 +329,8 @@ class _TankersViewState extends State<TankersView> {
Visibility( Visibility(
visible: isBoreChecked, visible: isBoreChecked,
child: Container( child: Container(
height: 40, height: 37,
width:200, width:120,
child:TextFormField( child:TextFormField(
cursorColor: greyColor, cursorColor: greyColor,
controller: tankerBorePriceController, controller: tankerBorePriceController,

Loading…
Cancel
Save