updated the code

dev
suresh 2 years ago
parent 90a9f5919a
commit 299dafd5a1

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

@ -0,0 +1,189 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:watermanagement/addtankers.dart';
import 'package:watermanagement/models/connected_customers_model.dart';
import 'package:watermanagement/models/pending_suppliers_model.dart';
import 'package:watermanagement/settings.dart';
import 'models/tankersview_model.dart';
class ConectedCustomers extends StatefulWidget {
@override
State<ConectedCustomers> createState() => _ConectedCustomersState();
}
class _ConectedCustomersState extends State<ConectedCustomers> {
TextEditingController conectedCustomerNameController = TextEditingController();
TextEditingController conectedCustomerPhoneController = TextEditingController();
TextEditingController conectedCustomerBuildingName = TextEditingController();
TextEditingController conectedCustomerAddress = TextEditingController();
bool isPendingDataLoading=false;
List<ConnectedCustomersModel> connectedCustomersList = [];
bool isSereverIssuePending = false;
bool isLoading=false;
Future<void> getConectedCustomersData() async {
isPendingDataLoading = true;
try {
var response = await AppSettings.getConnectedCustomers();
setState(() {
connectedCustomersList =
((jsonDecode(response)['data']) as List).map((dynamic model) {
return ConnectedCustomersModel.fromJson(model);
}).toList();
isPendingDataLoading = false;
});
} catch (e) {
setState(() {
isPendingDataLoading = false;
isSereverIssuePending = true;
});
}
}
@override
void initState() {
isLoading=true;
getConectedCustomersData();
super.initState();
}
Widget renderzUi(){
if(connectedCustomersList.length!=0){
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(child:ListView.builder(
padding: EdgeInsets.all(0),
itemCount: connectedCustomersList.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('phone:',
style: labelTextStyle()),
SizedBox(height: 10,),
Text('buildingname:',
style: labelTextStyle()),
SizedBox(height: 10,),
Text('address:',
style: labelTextStyle()),
],
),
SizedBox(width: 10,),
Expanded(child:Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
connectedCustomersList[index]
.customer_name
.toUpperCase(),
style: valuesTextStyle()),
SizedBox(height: 10,),
Text(
connectedCustomersList[index]
.customer_phone_number
.toUpperCase(),
style: valuesTextStyle()),
SizedBox(height: 10,),
Text(
connectedCustomersList[index]
.customer_building_name
.toUpperCase(),
style: valuesTextStyle()),
SizedBox(height: 10,),
Text(
connectedCustomersList[index]
.customer_address
.toUpperCase(),
style: valuesTextStyle())
],
),)
],
)
),
],
),
),
);
}) ),
]);
}
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('Connected Customers'),
body: isPendingDataLoading?Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 5.0,
),
):renderzUi(),
));
}
}

@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:watermanagement/adddeliveryboy.dart'; import 'package:watermanagement/adddeliveryboy.dart';
import 'package:watermanagement/addtankers.dart'; import 'package:watermanagement/addtankers.dart';
import 'package:watermanagement/conected_customers.dart';
import 'package:watermanagement/getdeliveryboydata.dart'; import 'package:watermanagement/getdeliveryboydata.dart';
import 'package:watermanagement/login.dart'; import 'package:watermanagement/login.dart';
import 'package:watermanagement/place_picker.dart'; import 'package:watermanagement/place_picker.dart';
@ -12,6 +13,8 @@ import 'package:image_picker/image_picker.dart';
import 'package:watermanagement/tankersview.dart'; import 'package:watermanagement/tankersview.dart';
import 'dart:io'; import 'dart:io';
import 'package:watermanagement/updateprofile.dart';
class Dashboard extends StatefulWidget { class Dashboard extends StatefulWidget {
const Dashboard({super.key}); const Dashboard({super.key});
@ -96,7 +99,7 @@ class _DashboardState extends State<Dashboard> {
//color: Colors.red, //color: Colors.red,
child: FittedBox( child: FittedBox(
child:Image( child:Image(
image: const AssetImage('images/appbg.png'), image: const AssetImage('images/appbgsuplier.png'),
), ),
fit: BoxFit.fill, fit: BoxFit.fill,
@ -308,10 +311,10 @@ class _DashboardState extends State<Dashboard> {
), ),
onTap: () { onTap: () {
/* Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => UpdateProfile()), MaterialPageRoute(builder: (context) => UpdateProfile()),
);*/ );
}, },
), ),
@ -422,6 +425,29 @@ class _DashboardState extends State<Dashboard> {
}, },
), ),
Divider(
color: Colors.grey,
),
ListTile(
title: Row(
children: const [
Image(image: const AssetImage('images/ic_launcher.png'),height: 25,width: 25,fit: BoxFit.fill),
const SizedBox(
width: 10,
),
Text('Conected Customers', style: TextStyle(color:primaryColor)),
],
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ConectedCustomers()),
);
},
),
Divider( Divider(
color: Colors.grey, color: Colors.grey,
), ),

@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:watermanagement/settings.dart';
class ConnectedCustomersModel {
String customer_name = '';
String customer_phone_number='';
String customer_building_name='';
String customer_address='';
String customer_id='';
Color text_color=Colors.black;
ConnectedCustomersModel();
factory ConnectedCustomersModel.fromJson(Map<String, dynamic> json){
ConnectedCustomersModel rtvm = new ConnectedCustomersModel();
rtvm.customer_name = json['username'] ?? '';
rtvm.customer_phone_number = json['phone'] ?? '';
rtvm.customer_building_name = json['buildingName'] ?? '';
rtvm.customer_address = json['profile']['address1'] ?? '';
rtvm.customer_id = json['customerId'] ?? '';
return rtvm;
}
}

@ -136,13 +136,14 @@ class _PendingCustomersState extends State<PendingCustomers> {
TextButton( TextButton(
child: Text( child: Text(
'Connect', 'Accept',
style: TextStyle(fontSize: 15, style: TextStyle(fontSize: 15,
color:primaryColor/*FilteredList[index].text_color*/ ), color:primaryColor/*FilteredList[index].text_color*/ ),
), ),
onPressed: () async{ onPressed: () async{
var payload = new Map<String, dynamic>(); var payload = new Map<String, dynamic>();
payload["supplierId"] =AppSettings.supplierId; payload["supplierId"] =AppSettings.supplierId;
payload["customerId"] = pendingSuppliersList[index].customer_id;
bool requestStatus = await AppSettings.acceptRequest(payload); bool requestStatus = await AppSettings.acceptRequest(payload);
if(requestStatus){ if(requestStatus){

@ -84,6 +84,7 @@ class AppSettings {
static String signUpUrl = host+'suppliers'; static String signUpUrl = host+'suppliers';
static String verifyPhnUrl = host+'supplierphone'; static String verifyPhnUrl = host+'supplierphone';
static String resetTokenUrl = host+'reset_token'; static String resetTokenUrl = host+'reset_token';
static String updateProfileUrl = host + 'update/currentSupplier';
static String addTankerUrl = host + 'addTankers'; static String addTankerUrl = host + 'addTankers';
static String getTankersDataUrl = host + 'getTankers'; static String getTankersDataUrl = host + 'getTankers';
static String deleteTankerUrl = host + 'deleteTanker'; static String deleteTankerUrl = host + 'deleteTanker';
@ -93,7 +94,12 @@ class AppSettings {
static String updateDeliveryboyUrl = host + 'updatedeliveryboy'; static String updateDeliveryboyUrl = host + 'updatedeliveryboy';
static String deleteDeliveryboyUrl = host + 'deletedeliveryboy'; static String deleteDeliveryboyUrl = host + 'deletedeliveryboy';
static String pendingCustomersUrl = host + 'pendingCustomers'; static String pendingCustomersUrl = host + 'pendingCustomers';
static String acceptRequestUrl = host + 'friend-request/{id}/accept'; static String connectedCustomersUrl = host + 'connectedCustomers';
String a="";
String b="";
static String acceptRequestUrl = host +"friend-request/"+ supplierId+"/accept";
@ -303,7 +309,29 @@ class AppSettings {
static Future<bool> updateProfile(payload) async {
try {
var response = await http.put(
Uri.parse(updateProfileUrl + '/' + supplierId),
body: json.encode(payload),
headers: await buildRequestHeaders());
if (response.statusCode == 200) {
var _response = json.decode(response.body);
suppliername = _response['suppliername'];
phoneNumber = _response['phone'];
email = _response['emails'][0]['email'];
return true;
} else {
return false;
}
} catch (e) {
print(e);
return false;
}
}
static Future<bool> addTankers(payload) async { static Future<bool> addTankers(payload) async {
@ -577,6 +605,36 @@ class AppSettings {
return ""; return "";
} }
} }
static Future<String> getConnectedCustomers() async {
var response = await http.get(Uri.parse(connectedCustomersUrl + '/' + supplierId),
headers: await buildRequestHeaders());
if (response.statusCode == 200) {
try {
var _response = json.decode(response.body);
print(_response);
return response.body;
} catch (e) {
// display error toast
return '';
}
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.get(Uri.parse(connectedCustomersUrl + '/' + supplierId),
headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else {
return "";
}
} else {
return "";
}
} else {
return "";
}
}
static Future<bool> acceptRequest( payload) async { static Future<bool> acceptRequest( payload) async {

@ -0,0 +1,298 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:watermanagement/dashboard.dart';
import 'package:watermanagement/settings.dart';
import 'package:image_picker/image_picker.dart';
import 'dart:io';
import 'login.dart';
class UpdateProfile extends StatefulWidget {
const UpdateProfile({Key? key}) : super(key: key);
@override
State<UpdateProfile> createState() => _UpdateprofileState();
}
class _UpdateprofileState extends State<UpdateProfile> {
bool isPwdObscureText=true;
bool isConfirmPwdObscureText=true;
TextEditingController nameController = TextEditingController();
TextEditingController mobileNumberController = TextEditingController();
TextEditingController emailController = TextEditingController();
@override
void initState() {
isPwdObscureText=true;
isConfirmPwdObscureText=true;
nameController.text=AppSettings.suppliername;
mobileNumberController.text=AppSettings.phoneNumber;
emailController.text=AppSettings.email;
super.initState();
}
final ImagePicker _picker = ImagePicker();
Future pickImageFromGallery() async {
try {
final image = await _picker.pickImage(source: ImageSource.gallery);
if (image == null) return;
final imageTemp = File(image.path);
setState(() {
AppSettings.updatedImage = imageTemp;
});
//uploadProfileApi(AppSettings.updatedImage);
AppSettings.saveProfile(image.path);
} on PlatformException catch (e) {
print('Failed to pick image: $e');
}
}
Future takeImageFromCamera() async {
try {
final image = await _picker.pickImage(source: ImageSource.camera);
if (image == null) return;
final imageTemp = File(image.path);
setState(() {
AppSettings.updatedImage = imageTemp;
});
// uploadProfileApi(AppSettings.updatedImage);
AppSettings.saveProfile(image.path);
} on PlatformException catch (e) {
print('Failed to pick image: $e');
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar:AppSettings.appBar('Edit Profile'),
body: Stack(children: <Widget>[
Container(
decoration: const BoxDecoration(
/* image: DecorationImage(
image: AssetImage("images/backgroundimage.png"),
fit: BoxFit.cover,
),*/
),
),
GestureDetector(
onTap: () {
FocusScope.of(context).requestFocus(new FocusNode());
},
child: SafeArea(
child: SingleChildScrollView(
child: Column(
children: <Widget>[
SizedBox(
height: 40,
),
/*Container(
child: Image(
image: AssetImage('images/logo.png'),
height: MediaQuery.of(context).size.height * .10,
)),*/
Container(child: GestureDetector(
child: Container(
width: MediaQuery.of(context).size.width * .30,
height: MediaQuery.of(context).size.height * .20,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: (AppSettings.updatedImage != null) ? FileImage(AppSettings.updatedImage!) as ImageProvider : AssetImage("images/profile_pic.png"), // picked file
fit: BoxFit.cover)),
),
onTap: () {
showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
return SizedBox(
height: 200,
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
GestureDetector(
child: Icon(
Icons.camera_alt_outlined,
size: 100,
color: greyColor,
),
onTap: () async {
await takeImageFromCamera();
Navigator.pop(context);
},
),
SizedBox(
width:
MediaQuery.of(context).size.width * .20,
),
GestureDetector(
child: Icon(
Icons.photo,
size: 100,
color: greyColor,
),
onTap: () async {
await pickImageFromGallery();
Navigator.pop(context);
},
),
],
),
),
);
});
},
),),
SizedBox(
height: 10,
),
Container(
padding: const EdgeInsets.all(10),
child: TextFormField(
cursorColor: greyColor,
controller: nameController,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.person,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Username',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
),//name
const SizedBox(
height: 15,
),
Container(
padding: const EdgeInsets.all(10),
child: TextFormField(
cursorColor: greyColor,
controller: emailController,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.email,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Enter email ID',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
), //email
SizedBox(
height: 10,
),
Container(
padding: const EdgeInsets.all(10),
child: TextFormField(
cursorColor: greyColor,
controller: mobileNumberController,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.phone_android,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Enter Mobile Number',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
), //mobile
SizedBox(
height: 10,
),
SizedBox(
height: 10,
),
Container(
width: 400,
height: 55,
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: primaryColor, // background
onPrimary: Colors.white, // foreground
),
onPressed: () async{
var payload = new Map<String, dynamic>();
payload["suppliername"] = nameController.text.toString();
payload["phone"] = mobileNumberController.text.toString();
payload["emails"] = [{"email":emailController.text.toString()}];
bool signUpStatus = await AppSettings.updateProfile(payload);
try{
if (signUpStatus) {
Navigator.pop(context);
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Dashboard()),
);
AppSettings.longSuccessToast("profile updated");
} else {
AppSettings.longFailedToast("profile not updated");
}
}
catch(exception){
print(exception);
AppSettings.longFailedToast("Please enter valid details");
}
},
child: Text('Update'),
)
),
],
),
)),
),
]));
}
}
Loading…
Cancel
Save