updated the code

dev
suresh 2 years ago
parent d1a27f9539
commit 45ed63be9c

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

@ -21,6 +21,8 @@ class _GetDeliveryboyDataState extends State<GetDeliveryboyData> {
TextEditingController deliveryboyPhoneController = TextEditingController();
TextEditingController deliveryboyAlterPhoneController = TextEditingController();
TextEditingController deliveryboyAddress = TextEditingController();
TextEditingController deliveryboyStatus = TextEditingController();
bool isLoading=false;
@ -43,7 +45,157 @@ class _GetDeliveryboyDataState extends State<GetDeliveryboyData> {
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(){
if(modeldeliveryboyList.length!=0){
@ -79,7 +231,8 @@ class _GetDeliveryboyDataState extends State<GetDeliveryboyData> {
Text('name :',style: labelTextStyle()),
Text('phone :',style: labelTextStyle()),
Text('alternativeContactNumber :',style: labelTextStyle()),
Text('address :',style: labelTextStyle()),
// Text('address :',style: labelTextStyle()),
Text('status :',style: labelTextStyle()),
],
),
SizedBox(width: 5,),
@ -90,9 +243,11 @@ class _GetDeliveryboyDataState extends State<GetDeliveryboyData> {
Text(modeldeliveryboyList[index].deliveryboy_name,style: valuesTextStyle()),
Text(modeldeliveryboyList[index].deliveryboy_phone,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,
maxLines: 1),
maxLines: 1),*/
Text(modeldeliveryboyList[index].deliveryboy_status,style: valuesTextStyle()),
],
),
@ -106,14 +261,14 @@ class _GetDeliveryboyDataState extends State<GetDeliveryboyData> {
Expanded(child:IconButton(
icon: const Icon(Icons.edit,color: primaryColor,),
onPressed: () {
// showTankerUpdateDialog(modeldeliveryboyList[index]);
showUpdateDeliveryDialog(modeldeliveryboyList[index]);
},
),),
Expanded(child:IconButton(
icon: const Icon(Icons.delete,color: primaryColor,),
onPressed: () async{
/* showDialog(
showDialog(
//if set to true allow to close popup by tapping out of the popup
//barrierDismissible: false,
context: context,
@ -127,17 +282,17 @@ class _GetDeliveryboyDataState extends State<GetDeliveryboyData> {
actions: [
TextButton(
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();
AppSettings.longSuccessToast('tank deleted successfully');
AppSettings.longSuccessToast('Deliveryboy deleted successfully');
Navigator.of(context).pop(true);
}
else{
AppSettings.longFailedToast('tank deletion failed');
AppSettings.longFailedToast('Deliveryboy deletion failed');
}
},
child: const Text('Yes',
@ -160,7 +315,7 @@ class _GetDeliveryboyDataState extends State<GetDeliveryboyData> {
),
);
*/
},
),)

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

@ -90,6 +90,10 @@ class AppSettings {
static String UpdateTankerUrl = host + 'updateTankers';
static String addDeliveryboyUrl = host + 'addDeliveryboys';
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 {
var response = await http.post(Uri.parse(addTankerUrl + '/' + supplierId),
body: json.encode(payload), headers: await buildRequestHeaders());
@ -324,7 +332,6 @@ class AppSettings {
return false;
}
}
static Future<String> getTankers() async {
var uri = Uri.parse(getTankersDataUrl);
uri = uri.replace(query: 'supplierId=$supplierId');
@ -348,22 +355,21 @@ class AppSettings {
return '';
}
}
static Future<bool> deleteTanker(tankerName) async {
var uri = Uri.parse(deleteTankerUrl + '/' + supplierId);
static Future<bool> updateTanker(tankerName, payload) async {
var uri = Uri.parse(UpdateTankerUrl + '/' + supplierId);
uri = uri.replace(query: 'tankerName=$tankerName');
try {
var response =
await http.put(uri, headers: await buildPutRequestHeaders());
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, headers: await buildPutRequestHeaders());
response = await http.put(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return true;
} else {
@ -380,22 +386,21 @@ class AppSettings {
return false;
}
}
static Future<bool> updateTanker(tankerName, payload) async {
var uri = Uri.parse(UpdateTankerUrl + '/' + supplierId);
static Future<bool> deleteTanker(tankerName) async {
var uri = Uri.parse(deleteTankerUrl + '/' + supplierId);
uri = uri.replace(query: 'tankerName=$tankerName');
try {
var response = await http.put(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
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,
body: json.encode(payload), headers: await buildRequestHeaders());
response =
await http.put(uri, headers: await buildPutRequestHeaders());
if (response.statusCode == 200) {
return true;
} else {
@ -444,8 +449,6 @@ class AppSettings {
return false;
}
}
static Future<String> getAllDeliverboy() async {
var response = await http.get(Uri.parse(getAllDeliverboyUrl + '/' + supplierId),
headers: await buildRequestHeaders());
@ -476,7 +479,68 @@ class AppSettings {
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(
visible: isDrinkingChecked,
child: Container(
height: 40,
width:200,
height: 37,
width:120,
child:TextFormField(
cursorColor: greyColor,
controller: tankerDrinkingPriceController,
@ -329,8 +329,8 @@ class _TankersViewState extends State<TankersView> {
Visibility(
visible: isBoreChecked,
child: Container(
height: 40,
width:200,
height: 37,
width:120,
child:TextFormField(
cursorColor: greyColor,
controller: tankerBorePriceController,

Loading…
Cancel
Save