Compare commits

..

4 Commits

@ -1,7 +1,7 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_svg/flutter_svg.dart';import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:watermanagement/models/connected_customers_model.dart';
@ -109,6 +109,7 @@ class _ConectedPendingCustomersState extends State<ConectedPendingCustomers> wit
getPendingSuppliersData();
super.initState();
}
Widget connectedCustomers(){
if(connectedCustomersList.length!=0){
@ -260,7 +261,6 @@ class _ConectedPendingCustomersState extends State<ConectedPendingCustomers> wit
Widget pendingCustomers(){
if(pendingSuppliersList.length!=0){
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [

@ -9,6 +9,7 @@ import 'package:watermanagement/login.dart';
import 'package:watermanagement/settings.dart';
import 'package:image_picker/image_picker.dart';
import 'package:watermanagement/tankersview.dart';
import 'dart:convert';
import 'dart:io';
import 'package:watermanagement/updateprofile.dart';
import 'booking_requests.dart';
@ -94,13 +95,15 @@ class _DashboardState extends State<Dashboard> {
final image = await _picker.pickImage(source: ImageSource.gallery);
if (image == null) return;
final imageTemp = File(image.path);
AppSettings.preLoaderDialog(context);
var res = await AppSettings.uploadImageHTTPNew(image);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
AppSettings.updatedImage = imageTemp;
AppSettings.profilePictureUrl = jsonDecode(res)['picture'];
});
uploadProfileApi(image.path);
AppSettings.saveProfile(image.path);
AppSettings.saveData('profile', jsonDecode(res)['picture'], 'STRING');
} on PlatformException catch (e) {
print('Failed to pick image: $e');
}
@ -111,13 +114,14 @@ class _DashboardState extends State<Dashboard> {
final image = await _picker.pickImage(source: ImageSource.camera);
if (image == null) return;
final imageTemp = File(image.path);
AppSettings.preLoaderDialog(context);
var res = await AppSettings.uploadImageHTTPNew(image);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
AppSettings.updatedImage = imageTemp;
AppSettings.profilePictureUrl = jsonDecode(res)['picture'];
});
uploadProfileApi(image.path);
AppSettings.saveProfile(image.path);
AppSettings.saveData('profile', jsonDecode(res)['picture'], 'STRING');
} on PlatformException catch (e) {
print('Failed to pick image: $e');
}
@ -428,15 +432,26 @@ class _DashboardState extends State<Dashboard> {
children: [
Expanded(child: GestureDetector(
Expanded(
child: GestureDetector(
child: Container(
width: MediaQuery.of(context).size.width * .20,
height: MediaQuery.of(context).size.height * .15,
width: (MediaQuery.of(context).size.width > 600)
? MediaQuery.of(context).size.width * .30
: MediaQuery.of(context).size.width * .60, // Adjusted width for tablet
height: (MediaQuery.of(context).size.width > 600)
? MediaQuery.of(context).size.height * .25
: MediaQuery.of(context).size.height * .50, // Adjusted height for tablet
decoration: BoxDecoration(
shape: BoxShape.circle,
shape: BoxShape.rectangle,
border: Border.all(width: 2, color: Colors.blueGrey),
image: DecorationImage(
image: (AppSettings.updatedImage != null) ? FileImage(AppSettings.updatedImage!) as ImageProvider : AssetImage("images/profile_pic.png"), // picked file
fit: BoxFit.cover)),
image: (AppSettings.profilePictureUrl != '' &&
AppSettings.profilePictureUrl != 'null')
? NetworkImage(AppSettings.profilePictureUrl) as ImageProvider
: AssetImage(" images/profile_pic.png"), // picked file
fit: BoxFit.fitWidth,
),
),
),
onTap: () {
showModalBottomSheet<void>(
@ -446,7 +461,8 @@ class _DashboardState extends State<Dashboard> {
height: 200,
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
GestureDetector(
child: Icon(
@ -460,8 +476,10 @@ class _DashboardState extends State<Dashboard> {
},
),
SizedBox(
width:
MediaQuery.of(context).size.width * .20,
width: MediaQuery.of(context)
.size
.width *
.20,
),
GestureDetector(
child: Icon(
@ -480,7 +498,10 @@ class _DashboardState extends State<Dashboard> {
);
});
},
),),
),
),
Text(
AppSettings.suppliername,

@ -92,7 +92,6 @@ class AppSettings {
static String latitude='';
static String longitude='';
static String supplierAddress = '';
static String profilepic = '';
static bool servicestatus = false;
static bool haspermission = false;
static late LocationPermission permission;
@ -124,7 +123,9 @@ class AppSettings {
static String acceptBookingRequestsUrl = host + 'ordernow';
static String acceptRequestUrl = host +"friend-request/accept";
static String rejectRequestUrl = host +"friend-request/reject";
static String profilePicUrl = host + 'upload-image';
static String profilePicUrl = host + 'supplier/profile-picture';
static String uploadPicUrl = host + 'uploads';
@ -136,6 +137,8 @@ class AppSettings {
static File? updatedImage;
static String profilePictureUrl = '';
static String image='';
static var api = {
'signIn': host + '/login',
@ -159,7 +162,15 @@ class AppSettings {
}
static Future<String> uploadImageHTTPNew(file) async {
var request = http.MultipartRequest('POST', Uri.parse(uploadPicUrl + '/' + supplierId));
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
var res = await request.send();
var response = await http.Response.fromStream(res);
return response.body;
}
////request headers with content type
static Future<Map<String, String>> buildRequestHeaders() async {
Map<String, String> _headers = new Map<String, String>();
@ -895,7 +906,6 @@ class AppSettings {
await saveData('email', input['simplydata']['email'][0]['email'], 'STRING');
await saveData('supplierId', input['simplydata']['supplierId'], 'STRING');
await saveData('supplieraddress', input['simplydata']['office_address'], 'STRING');
await saveData('profile', input['simplydata']['picture'], 'STRING');
await loadDataFromMemory();
}
@ -912,7 +922,6 @@ class AppSettings {
phoneNumber=await getData('phone', 'STRING');
supplierId=await getData('supplierId', 'STRING');
supplierAddress=await getData('supplieraddress', 'STRING');
profilepic=await getData('profile', 'STRING');
}
//assign saved values to variables

@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
import 'package:watermanagement/dashboard.dart';
import 'package:watermanagement/settings.dart';
import 'package:image_picker/image_picker.dart';
import 'dart:convert';
import 'dart:io';
import 'login.dart';
@ -52,17 +53,20 @@ class _UpdateprofileState extends State<UpdateProfile> {
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);
AppSettings.preLoaderDialog(context);
var res = await AppSettings.uploadImageHTTPNew(image);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
AppSettings.updatedImage = imageTemp;
AppSettings.profilePictureUrl = jsonDecode(res)['picture'];
});
//uploadProfileApi(AppSettings.updatedImage);
AppSettings.saveProfile(image.path);
AppSettings.saveData('profile', jsonDecode(res)['picture'], 'STRING');
} on PlatformException catch (e) {
print('Failed to pick image: $e');
}
@ -73,10 +77,14 @@ class _UpdateprofileState extends State<UpdateProfile> {
final image = await _picker.pickImage(source: ImageSource.camera);
if (image == null) return;
final imageTemp = File(image.path);
AppSettings.preLoaderDialog(context);
var res = await AppSettings.uploadImageHTTPNew(image);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
AppSettings.updatedImage = imageTemp;
AppSettings.profilePictureUrl = jsonDecode(res)['picture'];
});
AppSettings.saveData('profile', jsonDecode(res)['picture'], 'STRING');
// uploadProfileApi(AppSettings.updatedImage);
AppSettings.saveProfile(image.path);
@ -115,15 +123,17 @@ class _UpdateprofileState extends State<UpdateProfile> {
image: AssetImage('images/logo.png'),
height: MediaQuery.of(context).size.height * .10,
)),*/
Container(child: GestureDetector(
Container(child:
GestureDetector(
child: Container(
width: MediaQuery.of(context).size.width * .30,
height: MediaQuery.of(context).size.height * .20,
width: MediaQuery.of(context).size.width * .60,
height: MediaQuery.of(context).size.height * .15,
decoration: BoxDecoration(
shape: BoxShape.circle,
shape: BoxShape.rectangle,
border: Border.all(width: 2, color: Colors.blueGrey),
image: DecorationImage(
image: (AppSettings.updatedImage != null) ? FileImage(AppSettings.updatedImage!) as ImageProvider : AssetImage("images/profile_pic.png"), // picked file
fit: BoxFit.cover)),
image: (AppSettings.profilePictureUrl != ''&& AppSettings.profilePictureUrl != 'null') ? NetworkImage(AppSettings.profilePictureUrl) as ImageProvider : AssetImage("images/mobilebg.png"), // picked file
fit: BoxFit.fitWidth)),
),
onTap: () {
showModalBottomSheet<void>(
@ -139,7 +149,7 @@ class _UpdateprofileState extends State<UpdateProfile> {
child: Icon(
Icons.camera_alt_outlined,
size: 100,
color: greyColor,
color: primaryColor,
),
onTap: () async {
await takeImageFromCamera();
@ -154,7 +164,7 @@ class _UpdateprofileState extends State<UpdateProfile> {
child: Icon(
Icons.photo,
size: 100,
color: greyColor,
color: primaryColor,
),
onTap: () async {
await pickImageFromGallery();

Loading…
Cancel
Save