import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:watermanagement/addtankers.dart'; import 'package:watermanagement/models/pending_suppliers_model.dart'; import 'package:watermanagement/settings.dart'; import 'models/tankersview_model.dart'; class PendingCustomers extends StatefulWidget { @override State createState() => _PendingCustomersState(); } class _PendingCustomersState extends State { TextEditingController tankerNameController = TextEditingController(); TextEditingController tankerPhoneController = TextEditingController(); TextEditingController tankerAlterPhoneController = TextEditingController(); bool isPendingDataLoading=false; List pendingSuppliersList = []; bool isSereverIssuePending = false; bool isLoading=false; Future getPendingSuppliersData() async { isPendingDataLoading = true; try { var response = await AppSettings.getPendingSuppliers(); setState(() { pendingSuppliersList = ((jsonDecode(response)['data']) as List).map((dynamic model) { return PendingSuppliersModel.fromJson(model); }).toList(); isPendingDataLoading = false; }); } catch (e) { setState(() { isPendingDataLoading = false; isSereverIssuePending = true; }); } } @override void initState() { isLoading=true; getPendingSuppliersData(); super.initState(); } Widget renderzUi(){ if(pendingSuppliersList.length!=0){ return Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Expanded(child:ListView.builder( padding: EdgeInsets.all(0), itemCount: pendingSuppliersList.length, itemBuilder: (BuildContext context, int index) { return Card( child: Padding( padding:EdgeInsets.all(8) , child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( width: MediaQuery.of(context).size.width * .50, child: Row( children: [ Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('username :', style: labelTextStyle()), SizedBox(height: 10,), Text('contactNumber:', style: labelTextStyle()), SizedBox(height: 10,), Text('address1:', style: labelTextStyle()), ], ), SizedBox(width: 10,), Expanded(child:Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( pendingSuppliersList[index] .customer_name .toUpperCase(), style: valuesTextStyle()), SizedBox(height: 10,), Text( pendingSuppliersList[index] .customer_phone_number .toUpperCase(), style: valuesTextStyle()), SizedBox(height: 10,), Text( pendingSuppliersList[index] .customer_address .toUpperCase(), style: valuesTextStyle()) ], ),) ], ) ), TextButton( child: Text( 'Connect', style: TextStyle(fontSize: 15, color:primaryColor/*FilteredList[index].text_color*/ ), ), onPressed: () async{ /* var payload = new Map(); payload["customerId"] =AppSettings.customerId; payload["supplierId"] = FilteredList[index].supplier_id; bool requestStatus = await AppSettings.connectRequest(payload); if(requestStatus){ AppSettings.longSuccessToast("Request Sent Successfully"); await getAllSuppliersData(); await getConnectedSuppliersData(); await getPendingSuppliersData(); } else{ }*/ }, ), TextButton( child: Text( 'Reject', style: TextStyle(fontSize: 15, color:primaryColor/*FilteredList[index].text_color*/ ), ), onPressed: () async{ /* var payload = new Map(); payload["customerId"] =AppSettings.customerId; payload["supplierId"] = FilteredList[index].supplier_id; bool requestStatus = await AppSettings.connectRequest(payload); if(requestStatus){ AppSettings.longSuccessToast("Request Sent Successfully"); await getAllSuppliersData(); await getConnectedSuppliersData(); await getPendingSuppliersData(); } else{ }*/ }, ), ], ), ), ); }) ), ]); } else{ return Center( child: Padding( padding: EdgeInsets.fromLTRB(0, 40, 0, 0), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox(height: MediaQuery.of(context).size.height * .25,), Text('No Data Found'), SizedBox( height: 20, ), ], ), ) ); } } @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( appBar: AppSettings.appBar('Pending Customers'), body: isLoading?Center( child: CircularProgressIndicator( color: primaryColor, strokeWidth: 5.0, ), ):renderzUi(), )); } }