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