drawer upload profile picture completed

dev
Sneha 1 year ago
parent 77a7051c41
commit 903f044073

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 KiB

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 738 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

@ -1,14 +1,14 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:healthcare_user/settings.dart'; import 'package:healthcare_user/settings.dart';
class BMICalculator extends StatefulWidget { class BMIHistory extends StatefulWidget {
const BMICalculator({Key? key}) : super(key: key); const BMIHistory({Key? key}) : super(key: key);
@override @override
State<BMICalculator> createState() => _BMICalculatorState(); State<BMIHistory> createState() => _BMIHistoryState();
} }
class _BMICalculatorState extends State<BMICalculator> { class _BMIHistoryState extends State<BMIHistory> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(

@ -9,10 +9,12 @@ import 'package:healthcare_user/prescriptions.dart';
import 'package:healthcare_user/reports.dart'; import 'package:healthcare_user/reports.dart';
import 'package:healthcare_user/seekopinion.dart'; import 'package:healthcare_user/seekopinion.dart';
import 'package:healthcare_user/settings.dart'; import 'package:healthcare_user/settings.dart';
import 'package:healthcare_user/updateprofile.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:carousel_slider/carousel_slider.dart'; import 'package:carousel_slider/carousel_slider.dart';
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'login.dart'; import 'login.dart';
import 'dart:io';
class Dashboard extends StatefulWidget { class Dashboard extends StatefulWidget {
const Dashboard({super.key}); const Dashboard({super.key});
@ -177,6 +179,45 @@ class _DashboardState extends State<Dashboard> {
devicedetection(); devicedetection();
} }
Future<void> uploadProfileApi(image) async {
var payload = new Map<String, dynamic>();
payload["formData"] = image.toString();
var response1 = await AppSettings.updateProfilePicture(payload);
print(response1);
}
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(image.path);
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(image.path);
AppSettings.saveProfile(image.path);
} on PlatformException catch (e) {
print('Failed to pick image: $e');
}
}
showLogoutAlertDialog(context) { showLogoutAlertDialog(context) {
return showDialog( return showDialog(
context: context, context: context,
@ -275,11 +316,60 @@ class _DashboardState extends State<Dashboard> {
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
image: DecorationImage( image: DecorationImage(
image: AssetImage( image: (AppSettings.updatedImage !=
null)
? FileImage(
AppSettings.updatedImage!)
as ImageProvider
: AssetImage(
"images/profile_pic.png"), // picked file "images/profile_pic.png"), // picked file
fit: BoxFit.cover)), fit: BoxFit.cover)),
), ),
onTap: () {}, 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);
},
),
],
),
),
);
});
},
), ),
), ),
Text( Text(
@ -303,7 +393,7 @@ class _DashboardState extends State<Dashboard> {
title: Row( title: Row(
children: const [ children: const [
Image( Image(
image: const AssetImage('images/01.png'), image: const AssetImage('images/editprofile.png'),
height: 25, height: 25,
width: 25, width: 25,
fit: BoxFit.fill), fit: BoxFit.fill),
@ -316,7 +406,13 @@ class _DashboardState extends State<Dashboard> {
Text('Edit Profile', style: TextStyle(color: primaryColor)), Text('Edit Profile', style: TextStyle(color: primaryColor)),
], ],
), ),
onTap: () {}, onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const UpdateProfile()),
);
},
), ),
Divider( Divider(
color: Colors.grey, color: Colors.grey,
@ -325,7 +421,7 @@ class _DashboardState extends State<Dashboard> {
title: Row( title: Row(
children: const [ children: const [
Image( Image(
image: const AssetImage('images/01.png'), image: const AssetImage('images/myhealth.png'),
height: 25, height: 25,
width: 25, width: 25,
fit: BoxFit.fill), fit: BoxFit.fill),
@ -353,7 +449,7 @@ class _DashboardState extends State<Dashboard> {
title: Row( title: Row(
children: const [ children: const [
Image( Image(
image: const AssetImage('images/01.png'), image: const AssetImage('images/reportmyself.png'),
height: 25, height: 25,
width: 25, width: 25,
fit: BoxFit.fill), fit: BoxFit.fill),
@ -375,7 +471,7 @@ class _DashboardState extends State<Dashboard> {
title: Row( title: Row(
children: const [ children: const [
Image( Image(
image: const AssetImage('images/01.png'), image: const AssetImage('images/myconnections.png'),
height: 25, height: 25,
width: 25, width: 25,
fit: BoxFit.fill), fit: BoxFit.fill),
@ -397,7 +493,7 @@ class _DashboardState extends State<Dashboard> {
title: Row( title: Row(
children: const [ children: const [
Image( Image(
image: const AssetImage('images/01.png'), image: const AssetImage('images/mymedicinetimings.png'),
height: 25, height: 25,
width: 25, width: 25,
fit: BoxFit.fill), fit: BoxFit.fill),
@ -419,7 +515,7 @@ class _DashboardState extends State<Dashboard> {
title: Row( title: Row(
children: const [ children: const [
Image( Image(
image: const AssetImage('images/01.png'), image: const AssetImage('images/updatepin.png'),
height: 25, height: 25,
width: 25, width: 25,
fit: BoxFit.fill), fit: BoxFit.fill),
@ -441,7 +537,7 @@ class _DashboardState extends State<Dashboard> {
title: Row( title: Row(
children: const [ children: const [
Image( Image(
image: const AssetImage('images/01.png'), image: const AssetImage('images/updatemobilenumber.png'),
height: 25, height: 25,
width: 25, width: 25,
fit: BoxFit.fill), fit: BoxFit.fill),
@ -463,7 +559,7 @@ class _DashboardState extends State<Dashboard> {
title: Row( title: Row(
children: const [ children: const [
Image( Image(
image: const AssetImage('images/01.png'), image: const AssetImage('images/updatemylocation.png'),
height: 25, height: 25,
width: 25, width: 25,
fit: BoxFit.fill), fit: BoxFit.fill),
@ -485,7 +581,7 @@ class _DashboardState extends State<Dashboard> {
title: Row( title: Row(
children: const [ children: const [
Image( Image(
image: const AssetImage('images/01.png'), image: const AssetImage('images/logout.png'),
height: 25, height: 25,
width: 25, width: 25,
fit: BoxFit.fill), fit: BoxFit.fill),

@ -218,13 +218,13 @@ class _LoginState extends State<Login> {
MaterialPageRoute( MaterialPageRoute(
builder: (context) => const Dashboard()), builder: (context) => const Dashboard()),
); );
// AppSettings.longSuccessToast("Logged in Successfully"); AppSettings.longSuccessToast("Logged in Successfully");
mobileNumberController.text=''; mobileNumberController.text='';
passwordController.text=''; passwordController.text='';
} else { } else {
Navigator.of(context,rootNavigator: true).pop(); Navigator.of(context,rootNavigator: true).pop();
//AppSettings.longFailedToast("Please enter valid details"); AppSettings.longFailedToast("Please enter valid details");
} }
} }
catch(exception){ catch(exception){
@ -234,14 +234,14 @@ class _LoginState extends State<Login> {
} }
else{ else{
Navigator.of(context,rootNavigator: true).pop(); Navigator.of(context,rootNavigator: true).pop();
// AppSettings.longFailedToast("Please Check internet"); AppSettings.longFailedToast("Please Check internet");
} }
} }
else{ else{
//AppSettings.longFailedToast("Please enter valid details"); AppSettings.longFailedToast("Please enter valid details");
} }
}, },

@ -1,7 +1,9 @@
import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:healthcare_user/settings.dart'; import 'package:healthcare_user/settings.dart';
import 'bmicalculator.dart'; import 'bmi_history.dart';
class MyHealth extends StatefulWidget { class MyHealth extends StatefulWidget {
const MyHealth({Key? key}) : super(key: key); const MyHealth({Key? key}) : super(key: key);
@ -11,11 +13,10 @@ class MyHealth extends StatefulWidget {
} }
class _MyHealthState extends State<MyHealth> { class _MyHealthState extends State<MyHealth> {
TextEditingController heightController = TextEditingController(); TextEditingController heightController = TextEditingController();
TextEditingController weightController = TextEditingController(); TextEditingController weightController = TextEditingController();
TextEditingController ageController = TextEditingController(); TextEditingController ageController = TextEditingController();
String bmiValue = '';
var heightUnitItems = [ var heightUnitItems = [
'feet', 'feet',
'cm', 'cm',
@ -37,7 +38,10 @@ class _MyHealthState extends State<MyHealth> {
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return AlertDialog( return AlertDialog(
title: Center( title: Center(
child: Text('Body Mass Index',style: TextStyle(color: primaryColor),), child: Text(
'Body Mass Index',
style: TextStyle(color: primaryColor),
),
), ),
content: SingleChildScrollView( content: SingleChildScrollView(
child: ListBody( child: ListBody(
@ -70,7 +74,8 @@ class _MyHealthState extends State<MyHealth> {
//height: 60, //height: 60,
child: Row( child: Row(
children: [ children: [
Expanded(child: TextFormField( Expanded(
child: TextFormField(
cursorColor: greyColor, cursorColor: greyColor,
controller: heightController, controller: heightController,
textCapitalization: TextCapitalization.characters, textCapitalization: TextCapitalization.characters,
@ -92,9 +97,11 @@ class _MyHealthState extends State<MyHealth> {
color: greyColor, //<-- SEE HERE color: greyColor, //<-- SEE HERE
), ),
), ),
),), ),
),
SizedBox(width: 5), SizedBox(width: 5),
Expanded(child: DropdownButtonFormField( Expanded(
child: DropdownButtonFormField(
// Initial Value // Initial Value
value: heightUnits, value: heightUnits,
isExpanded: true, isExpanded: true,
@ -125,10 +132,13 @@ class _MyHealthState extends State<MyHealth> {
items: heightUnitItems.map((String items) { items: heightUnitItems.map((String items) {
return DropdownMenuItem( return DropdownMenuItem(
value: items, value: items,
child: Text(items, style: TextStyle( child: Text(
items,
style: TextStyle(
fontSize: 16, fontSize: 16,
),textAlign: TextAlign.center,) ),
); textAlign: TextAlign.center,
));
}).toList(), }).toList(),
// After selecting the desired option,it will // After selecting the desired option,it will
// change button value to selected value // change button value to selected value
@ -137,7 +147,8 @@ class _MyHealthState extends State<MyHealth> {
heightUnits = newValue!; heightUnits = newValue!;
}); });
}, },
),) ),
)
], ],
), ),
), ),
@ -147,7 +158,8 @@ class _MyHealthState extends State<MyHealth> {
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
child: Row( child: Row(
children: [ children: [
Expanded(child: TextFormField( Expanded(
child: TextFormField(
cursorColor: greyColor, cursorColor: greyColor,
controller: weightController, controller: weightController,
textCapitalization: TextCapitalization.characters, textCapitalization: TextCapitalization.characters,
@ -169,9 +181,11 @@ class _MyHealthState extends State<MyHealth> {
color: greyColor, //<-- SEE HERE color: greyColor, //<-- SEE HERE
), ),
), ),
),), ),
),
SizedBox(width: 5), SizedBox(width: 5),
Expanded(child: DropdownButtonFormField( Expanded(
child: DropdownButtonFormField(
// Initial Value // Initial Value
value: weightUnits, value: weightUnits,
isExpanded: true, isExpanded: true,
@ -202,10 +216,13 @@ class _MyHealthState extends State<MyHealth> {
items: weightUnitItems.map((String items) { items: weightUnitItems.map((String items) {
return DropdownMenuItem( return DropdownMenuItem(
value: items, value: items,
child: Text(items, style: TextStyle( child: Text(
items,
style: TextStyle(
fontSize: 16, fontSize: 16,
),textAlign: TextAlign.center,) ),
); textAlign: TextAlign.center,
));
}).toList(), }).toList(),
// After selecting the desired option,it will // After selecting the desired option,it will
// change button value to selected value // change button value to selected value
@ -214,10 +231,40 @@ class _MyHealthState extends State<MyHealth> {
weightUnits = newValue!; weightUnits = newValue!;
}); });
}, },
),) ),
)
], ],
), ),
), ),
SizedBox(height: 10),
TextButton(
child: Text('Calculate BMI', style: textButtonStyle()),
onPressed: () async {
if (ageController.text != '' &&
heightController.text != '' &&
weightController.text != '') {
var payload = new Map<String, dynamic>();
payload["age"] =
int.parse(ageController.text.toString());
payload["height"] = heightController.text.toString();
payload["weight"] = weightController.text.toString();
payload["heightUnit"] = heightUnits.toString();
payload["weightUnit"] = weightUnits.toString();
var value = await AppSettings.calculateBmi(payload);
var valueResponse = jsonDecode(value);
print(valueResponse);
setState(() {
bmiValue = valueResponse['userDetails']['bmivalue']
.toString();
});
}
},
),
SizedBox(height: 10),
Container(
child: Text('Your Bmi value: $bmiValue'),
),
], ],
), ),
), ),
@ -229,9 +276,9 @@ class _MyHealthState extends State<MyHealth> {
}, },
), ),
TextButton( TextButton(
child: Text('Calculate BMI', style: textButtonStyle()), child: Text('Save', style: textButtonStyle()),
onPressed: () async { onPressed: () async {
Navigator.of(context).pop();
}, },
), ),
], ],
@ -241,9 +288,6 @@ class _MyHealthState extends State<MyHealth> {
); );
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -258,19 +302,36 @@ class _MyHealthState extends State<MyHealth> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text('Body Mass Index'), Text('Body Mass Index'),
IconButton(onPressed: (){ IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => BMIHistory()),
);
},
icon: Icon(
Icons.history,
color: greyColor,
),
),
IconButton(
onPressed: () {
/* Navigator.push( /* Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => BMICalculator()), builder: (context) => BMICalculator()),
);*/ );*/
showBMIAdddialog(); showBMIAdddialog();
},
}, icon: Icon(Icons.add,color: greyColor,),) icon: Icon(
], Icons.add,
color: greyColor,
), ),
) )
],
), ),
)),
Card( Card(
child: Padding( child: Padding(
padding: EdgeInsets.all(3), padding: EdgeInsets.all(3),
@ -278,11 +339,16 @@ class _MyHealthState extends State<MyHealth> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text('Blood Pressure'), Text('Blood Pressure'),
IconButton(onPressed: (){}, icon: Icon(Icons.add,color: greyColor,),) IconButton(
], onPressed: () {},
icon: Icon(
Icons.add,
color: greyColor,
), ),
) )
],
), ),
)),
Card( Card(
child: Padding( child: Padding(
padding: EdgeInsets.all(3), padding: EdgeInsets.all(3),
@ -290,11 +356,16 @@ class _MyHealthState extends State<MyHealth> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text('Diabetes'), Text('Diabetes'),
IconButton(onPressed: (){}, icon: Icon(Icons.add,color: greyColor,),) IconButton(
], onPressed: () {},
icon: Icon(
Icons.add,
color: greyColor,
), ),
) )
],
), ),
)),
Card( Card(
child: Padding( child: Padding(
padding: EdgeInsets.all(3), padding: EdgeInsets.all(3),
@ -302,11 +373,16 @@ class _MyHealthState extends State<MyHealth> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text('Cholesterol'), Text('Cholesterol'),
IconButton(onPressed: (){}, icon: Icon(Icons.add,color: greyColor,),) IconButton(
], onPressed: () {},
icon: Icon(
Icons.add,
color: greyColor,
), ),
) )
],
), ),
)),
Card( Card(
child: Padding( child: Padding(
padding: EdgeInsets.all(3), padding: EdgeInsets.all(3),
@ -314,14 +390,16 @@ class _MyHealthState extends State<MyHealth> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text('Habbits'), Text('Habbits'),
IconButton(onPressed: (){ IconButton(
onPressed: () {},
icon: Icon(
}, icon: Icon(Icons.add,color: greyColor,),) Icons.add,
], color: greyColor,
), ),
) )
],
), ),
)),
Card( Card(
child: Padding( child: Padding(
padding: EdgeInsets.all(3), padding: EdgeInsets.all(3),
@ -329,12 +407,16 @@ class _MyHealthState extends State<MyHealth> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text('Allergies'), Text('Allergies'),
IconButton(onPressed: (){}, icon: Icon(Icons.add,color: greyColor,),) IconButton(
], onPressed: () {},
icon: Icon(
Icons.add,
color: greyColor,
), ),
) )
) ],
),
))
], ],
), ),
), ),

@ -175,6 +175,8 @@ class _OtpScreenState extends State<OtpScreen> {
bool phoneVerified = await AppSettings.phoneVerification(payload); bool phoneVerified = await AppSettings.phoneVerification(payload);
if(phoneVerified){ if(phoneVerified){
Navigator.of(context,rootNavigator: true).pop(); Navigator.of(context,rootNavigator: true).pop();
AppSettings.longSuccessToast(
"Phone verified successfully");
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
@ -183,12 +185,16 @@ class _OtpScreenState extends State<OtpScreen> {
} }
else{ else{
Navigator.of(context,rootNavigator: true).pop(); Navigator.of(context,rootNavigator: true).pop();
AppSettings.longFailedToast(
"please enter valid pin");
} }
} }
else{ else{
Navigator.of(context,rootNavigator: true).pop(); Navigator.of(context,rootNavigator: true).pop();
AppSettings.longFailedToast(
"Please check your internet");
} }

@ -10,7 +10,7 @@ import 'package:intl/intl.dart';
import 'package:flutter_styled_toast/flutter_styled_toast.dart'; import 'package:flutter_styled_toast/flutter_styled_toast.dart';
import 'dart:async'; import 'dart:async';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
import 'package:dio/dio.dart'; import 'package:fluttertoast/fluttertoast.dart';
const Color primaryColor = Color(0XFF1786A3); const Color primaryColor = Color(0XFF1786A3);
const Color greyColor = Color(0XFF8F8E8E); const Color greyColor = Color(0XFF8F8E8E);
@ -134,6 +134,10 @@ class AppSettings {
static String sendSmsUrl = host + 'sendSms'; static String sendSmsUrl = host + 'sendSms';
static String phoneVerificationUrl = host + 'phone'; static String phoneVerificationUrl = host + 'phone';
static String verifyPhnUrl = host + 'phone'; static String verifyPhnUrl = host + 'phone';
static String resetTokenUrl = host + 'reset_token';
static String bmiCaluculateUrl = host + 'insertBMI';
static String profilePicUrl = host + 'users/profile-picture';
@ -314,6 +318,53 @@ class AppSettings {
} }
} }
static Future<String> calculateBmi(payload) async {
var uri = Uri.parse(bmiCaluculateUrl+ '/'+customerId);
var response = await http.post(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.post(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
}
static Future<bool> resetToken() async {
var uri = Uri.parse(resetTokenUrl + '/' + customerId);
try {
// var response = await http.get(uri, headers: await buildPutRequestHeaders());
var response = await http.get(uri,
headers: await buildPutRequestHeadersForResetToken());
if (response.statusCode == 200) {
print(response.body);
var res = jsonDecode(response.body);
print(res);
accessToken = res['access_token'];
return true;
} else {
return false;
}
} catch (e) {
print(e);
return false;
}
}
static Future<bool> verifyPhn(payload) async { static Future<bool> verifyPhn(payload) async {
var response = await http.post(Uri.parse(verifyPhnUrl), var response = await http.post(Uri.parse(verifyPhnUrl),
@ -338,6 +389,43 @@ class AppSettings {
} }
} }
static Future<bool> updateProfilePicture(payload) async {
var uri = Uri.parse(profilePicUrl + '/' + customerId);
var response = await http.post(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
try {
var _response = json.decode(response.body);
print(_response);
return true;
} catch (e) {
// display error toast
return false;
}
}
else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.post(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return true;
} else {
return false;
}
} else {
return false;
}
}
else {
return false;
}
}
/*Apis ends here*/ /*Apis ends here*/
//save data local //save data local
@ -381,6 +469,42 @@ class AppSettings {
fcmId =await getData('fcmId', 'STRING'); fcmId =await getData('fcmId', 'STRING');
} }
static void longFailedStyledToast(String message, context) {
showToast(
message,
context: context,
animation: StyledToastAnimation.scale,
reverseAnimation: StyledToastAnimation.fade,
position: StyledToastPosition.bottom,
animDuration: Duration(seconds: 1),
duration: Duration(seconds: 6),
curve: Curves.elasticOut,
reverseCurve: Curves.linear,
backgroundColor: Colors.red,
);
}
static void longSuccessToast(String message) {
Fluttertoast.showToast(
msg: message,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.green,
textColor: Colors.white,
fontSize: 16.0);
}
static void longFailedToast(String message) {
Fluttertoast.showToast(
msg: message,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0);
}
static Widget noDataUI(String _tabName) { static Widget noDataUI(String _tabName) {
_tabName = _tabName ?? ''; _tabName = _tabName ?? '';

@ -535,16 +535,17 @@ class _SignUpState extends State<SignUp> {
} }
else { else {
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
/*AppSettings.longFailedToast( AppSettings.longFailedToast(
"Mobile number already exists");*/ "Mobile number already exists");
} }
} catch (exception) { } catch (exception) {
print(exception); print(exception);
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
//AppSettings.longFailedToast("Please enter valid details"); AppSettings.longFailedToast("Please enter valid details");
} }
} else { }
//.longFailedToast("details should not be empty"); else {
AppSettings.longFailedToast("details should not be empty");
} }
}, },
child: Text('Sign Up'), child: Text('Sign Up'),

@ -0,0 +1,295 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:healthcare_user/settings.dart';
import 'package:image_picker/image_picker.dart';
import 'dart:io';
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.userName;
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["username"] = 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'),
)
),
],
),
)),
),
]));
}
}

@ -392,6 +392,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
fluttertoast:
dependency: "direct dev"
description:
name: fluttertoast
url: "https://pub.dartlang.org"
source: hosted
version: "8.2.2"
geocoding: geocoding:
dependency: "direct dev" dependency: "direct dev"
description: description:

@ -60,6 +60,7 @@ dev_dependencies:
permission_handler: ^10.2.0 permission_handler: ^10.2.0
cloudinary_public: ^0.21.0 cloudinary_public: ^0.21.0
carousel_slider: ^4.2.1 carousel_slider: ^4.2.1
fluttertoast: ^8.1.2
flutter_icons: flutter_icons:

Loading…
Cancel
Save