diff --git a/images/editprofile.png b/images/editprofile.png new file mode 100644 index 0000000..bf11808 Binary files /dev/null and b/images/editprofile.png differ diff --git a/images/logout.png b/images/logout.png new file mode 100644 index 0000000..e083fc2 Binary files /dev/null and b/images/logout.png differ diff --git a/images/mobilebg2.png b/images/mobilebg2.png index 1b8f8c7..e62652d 100644 Binary files a/images/mobilebg2.png and b/images/mobilebg2.png differ diff --git a/images/mobilebg3.png b/images/mobilebg3.png index 1c24716..1664e0a 100644 Binary files a/images/mobilebg3.png and b/images/mobilebg3.png differ diff --git a/images/myconnections.png b/images/myconnections.png new file mode 100644 index 0000000..05ceab7 Binary files /dev/null and b/images/myconnections.png differ diff --git a/images/myhealth.png b/images/myhealth.png new file mode 100644 index 0000000..7cfbf73 Binary files /dev/null and b/images/myhealth.png differ diff --git a/images/mymedicinetimings.png b/images/mymedicinetimings.png new file mode 100644 index 0000000..195e82e Binary files /dev/null and b/images/mymedicinetimings.png differ diff --git a/images/reportmyself.png b/images/reportmyself.png new file mode 100644 index 0000000..01de7af Binary files /dev/null and b/images/reportmyself.png differ diff --git a/images/updatemobilenumber.png b/images/updatemobilenumber.png new file mode 100644 index 0000000..962b70a Binary files /dev/null and b/images/updatemobilenumber.png differ diff --git a/images/updatemylocation.png b/images/updatemylocation.png new file mode 100644 index 0000000..0d492f4 Binary files /dev/null and b/images/updatemylocation.png differ diff --git a/images/updatepin.png b/images/updatepin.png new file mode 100644 index 0000000..6a386b7 Binary files /dev/null and b/images/updatepin.png differ diff --git a/lib/bmicalculator.dart b/lib/bmi_history.dart similarity index 56% rename from lib/bmicalculator.dart rename to lib/bmi_history.dart index 08e0292..a1a9feb 100644 --- a/lib/bmicalculator.dart +++ b/lib/bmi_history.dart @@ -1,14 +1,14 @@ import 'package:flutter/material.dart'; import 'package:healthcare_user/settings.dart'; -class BMICalculator extends StatefulWidget { - const BMICalculator({Key? key}) : super(key: key); +class BMIHistory extends StatefulWidget { + const BMIHistory({Key? key}) : super(key: key); @override - State createState() => _BMICalculatorState(); + State createState() => _BMIHistoryState(); } -class _BMICalculatorState extends State { +class _BMIHistoryState extends State { @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/dashboard.dart b/lib/dashboard.dart index 743067a..8d9eb65 100644 --- a/lib/dashboard.dart +++ b/lib/dashboard.dart @@ -9,10 +9,12 @@ import 'package:healthcare_user/prescriptions.dart'; import 'package:healthcare_user/reports.dart'; import 'package:healthcare_user/seekopinion.dart'; import 'package:healthcare_user/settings.dart'; +import 'package:healthcare_user/updateprofile.dart'; import 'package:image_picker/image_picker.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'dart:ui' as ui; import 'login.dart'; +import 'dart:io'; class Dashboard extends StatefulWidget { const Dashboard({super.key}); @@ -177,6 +179,45 @@ class _DashboardState extends State { devicedetection(); } + Future uploadProfileApi(image) async { + var payload = new Map(); + 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) { return showDialog( context: context, @@ -275,11 +316,60 @@ class _DashboardState extends State { decoration: BoxDecoration( shape: BoxShape.circle, image: DecorationImage( - image: AssetImage( + image: (AppSettings.updatedImage != + null) + ? FileImage( + AppSettings.updatedImage!) + as ImageProvider + : AssetImage( "images/profile_pic.png"), // picked file fit: BoxFit.cover)), ), - onTap: () {}, + onTap: () { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + 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( @@ -303,7 +393,7 @@ class _DashboardState extends State { title: Row( children: const [ Image( - image: const AssetImage('images/01.png'), + image: const AssetImage('images/editprofile.png'), height: 25, width: 25, fit: BoxFit.fill), @@ -316,7 +406,13 @@ class _DashboardState extends State { Text('Edit Profile', style: TextStyle(color: primaryColor)), ], ), - onTap: () {}, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const UpdateProfile()), + ); + }, ), Divider( color: Colors.grey, @@ -325,7 +421,7 @@ class _DashboardState extends State { title: Row( children: const [ Image( - image: const AssetImage('images/01.png'), + image: const AssetImage('images/myhealth.png'), height: 25, width: 25, fit: BoxFit.fill), @@ -353,7 +449,7 @@ class _DashboardState extends State { title: Row( children: const [ Image( - image: const AssetImage('images/01.png'), + image: const AssetImage('images/reportmyself.png'), height: 25, width: 25, fit: BoxFit.fill), @@ -375,7 +471,7 @@ class _DashboardState extends State { title: Row( children: const [ Image( - image: const AssetImage('images/01.png'), + image: const AssetImage('images/myconnections.png'), height: 25, width: 25, fit: BoxFit.fill), @@ -397,7 +493,7 @@ class _DashboardState extends State { title: Row( children: const [ Image( - image: const AssetImage('images/01.png'), + image: const AssetImage('images/mymedicinetimings.png'), height: 25, width: 25, fit: BoxFit.fill), @@ -419,7 +515,7 @@ class _DashboardState extends State { title: Row( children: const [ Image( - image: const AssetImage('images/01.png'), + image: const AssetImage('images/updatepin.png'), height: 25, width: 25, fit: BoxFit.fill), @@ -441,7 +537,7 @@ class _DashboardState extends State { title: Row( children: const [ Image( - image: const AssetImage('images/01.png'), + image: const AssetImage('images/updatemobilenumber.png'), height: 25, width: 25, fit: BoxFit.fill), @@ -463,7 +559,7 @@ class _DashboardState extends State { title: Row( children: const [ Image( - image: const AssetImage('images/01.png'), + image: const AssetImage('images/updatemylocation.png'), height: 25, width: 25, fit: BoxFit.fill), @@ -485,7 +581,7 @@ class _DashboardState extends State { title: Row( children: const [ Image( - image: const AssetImage('images/01.png'), + image: const AssetImage('images/logout.png'), height: 25, width: 25, fit: BoxFit.fill), diff --git a/lib/login.dart b/lib/login.dart index ad44be2..8d3c84c 100644 --- a/lib/login.dart +++ b/lib/login.dart @@ -218,13 +218,13 @@ class _LoginState extends State { MaterialPageRoute( builder: (context) => const Dashboard()), ); - // AppSettings.longSuccessToast("Logged in Successfully"); + AppSettings.longSuccessToast("Logged in Successfully"); mobileNumberController.text=''; passwordController.text=''; } else { Navigator.of(context,rootNavigator: true).pop(); - //AppSettings.longFailedToast("Please enter valid details"); + AppSettings.longFailedToast("Please enter valid details"); } } catch(exception){ @@ -234,14 +234,14 @@ class _LoginState extends State { } else{ Navigator.of(context,rootNavigator: true).pop(); - // AppSettings.longFailedToast("Please Check internet"); + AppSettings.longFailedToast("Please Check internet"); } } else{ - //AppSettings.longFailedToast("Please enter valid details"); + AppSettings.longFailedToast("Please enter valid details"); } }, diff --git a/lib/my_health.dart b/lib/my_health.dart index 9e58649..7151967 100644 --- a/lib/my_health.dart +++ b/lib/my_health.dart @@ -1,7 +1,9 @@ +import 'dart:convert'; + import 'package:flutter/material.dart'; import 'package:healthcare_user/settings.dart'; -import 'bmicalculator.dart'; +import 'bmi_history.dart'; class MyHealth extends StatefulWidget { const MyHealth({Key? key}) : super(key: key); @@ -11,11 +13,10 @@ class MyHealth extends StatefulWidget { } class _MyHealthState extends State { - TextEditingController heightController = TextEditingController(); TextEditingController weightController = TextEditingController(); TextEditingController ageController = TextEditingController(); - + String bmiValue = ''; var heightUnitItems = [ 'feet', 'cm', @@ -28,315 +29,396 @@ class _MyHealthState extends State { ]; var weightUnits = 'kg'; - showBMIAdddialog(){ + showBMIAdddialog() { return showDialog( context: context, barrierDismissible: false, builder: (BuildContext context) { return StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return AlertDialog( - title: Center( - child: Text('Body Mass Index',style: TextStyle(color: primaryColor),), - ), - content: SingleChildScrollView( - child: ListBody( - children: [ - TextFormField( - cursorColor: greyColor, - controller: ageController, - textCapitalization: TextCapitalization.characters, - decoration: const InputDecoration( - prefixIcon: Icon( - Icons.person, - color: primaryColor, - ), - border: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor)), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor), - ), - labelText: 'Age', - labelStyle: TextStyle( - color: greyColor, //<-- SEE HERE + return AlertDialog( + title: Center( + child: Text( + 'Body Mass Index', + style: TextStyle(color: primaryColor), + ), + ), + content: SingleChildScrollView( + child: ListBody( + children: [ + TextFormField( + cursorColor: greyColor, + controller: ageController, + textCapitalization: TextCapitalization.characters, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.person, + color: primaryColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + labelText: 'Age', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), + SizedBox(height: 10), + Container( + //height: 60, + child: Row( + children: [ + Expanded( + child: TextFormField( + cursorColor: greyColor, + controller: heightController, + textCapitalization: TextCapitalization.characters, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.height, + color: primaryColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + labelText: 'Height', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), ), ), - ), - SizedBox(height:10), - Container( - //height: 60, - child: Row( - children: [ - Expanded(child: TextFormField( - cursorColor: greyColor, - controller: heightController, - textCapitalization: TextCapitalization.characters, - decoration: const InputDecoration( - prefixIcon: Icon( - Icons.height, - color: primaryColor, - ), - border: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor)), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor), - ), - labelText: 'Height', - labelStyle: TextStyle( - color: greyColor, //<-- SEE HERE - ), + SizedBox(width: 5), + Expanded( + child: DropdownButtonFormField( + // Initial Value + value: heightUnits, + isExpanded: true, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.ac_unit_outlined, + color: primaryColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), ), - ),), - SizedBox(width:5), - Expanded(child: DropdownButtonFormField( - // Initial Value - value: heightUnits, - isExpanded: true, - decoration: const InputDecoration( - prefixIcon: Icon( - Icons.ac_unit_outlined, - color: primaryColor, - ), - border: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor)), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor), - ), - labelText: 'Units', - labelStyle: TextStyle( - color: greyColor, //<-- SEE HERE - ), + labelText: 'Units', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE ), + ), - hint: Text('Units'), - // Down Arrow Icon - //icon: const Icon(Icons.keyboard_arrow_down), + hint: Text('Units'), + // Down Arrow Icon + //icon: const Icon(Icons.keyboard_arrow_down), - // Array list of items - items: heightUnitItems.map((String items) { - return DropdownMenuItem( - value: items, - child: Text(items, style: TextStyle( + // Array list of items + items: heightUnitItems.map((String items) { + return DropdownMenuItem( + value: items, + child: Text( + items, + style: TextStyle( fontSize: 16, - ),textAlign: TextAlign.center,) - ); - }).toList(), - // After selecting the desired option,it will - // change button value to selected value - onChanged: (String? newValue) { - setState(() { - heightUnits = newValue!; - }); - }, - ),) - ], + ), + textAlign: TextAlign.center, + )); + }).toList(), + // After selecting the desired option,it will + // change button value to selected value + onChanged: (String? newValue) { + setState(() { + heightUnits = newValue!; + }); + }, + ), + ) + ], + ), + ), + SizedBox(height: 10), + Container( + //height: 40, + padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), + child: Row( + children: [ + Expanded( + child: TextFormField( + cursorColor: greyColor, + controller: weightController, + textCapitalization: TextCapitalization.characters, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.line_weight_outlined, + color: primaryColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + labelText: 'Weight', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), ), - ), - SizedBox(height:10), - Container( - //height: 40, - padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), - child: Row( - children: [ - Expanded(child: TextFormField( - cursorColor: greyColor, - controller: weightController, - textCapitalization: TextCapitalization.characters, - decoration: const InputDecoration( - prefixIcon: Icon( - Icons.line_weight_outlined, - color: primaryColor, - ), - border: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor)), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor), - ), - labelText: 'Weight', - labelStyle: TextStyle( - color: greyColor, //<-- SEE HERE - ), + SizedBox(width: 5), + Expanded( + child: DropdownButtonFormField( + // Initial Value + value: weightUnits, + isExpanded: true, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.ac_unit_outlined, + color: primaryColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), ), - ),), - SizedBox(width:5), - Expanded(child: DropdownButtonFormField( - // Initial Value - value: weightUnits, - isExpanded: true, - decoration: const InputDecoration( - prefixIcon: Icon( - Icons.ac_unit_outlined, - color: primaryColor, - ), - border: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor)), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor), - ), - labelText: 'Units', - labelStyle: TextStyle( - color: greyColor, //<-- SEE HERE - ), + labelText: 'Units', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE ), + ), - hint: Text('Units'), - // Down Arrow Icon - //icon: const Icon(Icons.keyboard_arrow_down), + hint: Text('Units'), + // Down Arrow Icon + //icon: const Icon(Icons.keyboard_arrow_down), - // Array list of items - items: weightUnitItems.map((String items) { - return DropdownMenuItem( - value: items, - child: Text(items, style: TextStyle( + // Array list of items + items: weightUnitItems.map((String items) { + return DropdownMenuItem( + value: items, + child: Text( + items, + style: TextStyle( fontSize: 16, - ),textAlign: TextAlign.center,) - ); - }).toList(), - // After selecting the desired option,it will - // change button value to selected value - onChanged: (String? newValue) { - setState(() { - weightUnits = newValue!; - }); - }, - ),) - ], - ), - ), - ], - ), - ), - actions: [ - TextButton( - child: Text('Cancel', style: textButtonStyle()), - onPressed: () { - Navigator.of(context).pop(); - }, + ), + textAlign: TextAlign.center, + )); + }).toList(), + // After selecting the desired option,it will + // change button value to selected value + onChanged: (String? newValue) { + setState(() { + 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(); + 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'), + ), ], - ); - }); + ), + ), + actions: [ + TextButton( + child: Text('Cancel', style: textButtonStyle()), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + child: Text('Save', style: textButtonStyle()), + onPressed: () async { + Navigator.of(context).pop(); + }, + ), + ], + ); + }); }, ); } - - - @override Widget build(BuildContext context) { return Scaffold( appBar: AppSettings.appBar('My Health'), body: Container( - child: Column( - children: [ - Card( - child: Padding( - padding: EdgeInsets.all(3), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('Body Mass Index'), - IconButton(onPressed: (){ - /* Navigator.push( + child: Column( + children: [ + Card( + child: Padding( + padding: EdgeInsets.all(3), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('Body Mass Index'), + IconButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => BMIHistory()), + ); + }, + icon: Icon( + Icons.history, + color: greyColor, + ), + ), + IconButton( + onPressed: () { + /* Navigator.push( context, MaterialPageRoute( builder: (context) => BMICalculator()), );*/ - showBMIAdddialog(); - - }, icon: Icon(Icons.add,color: greyColor,),) - ], - ), - ) - ), - Card( - child: Padding( - padding: EdgeInsets.all(3), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('Blood Pressure'), - IconButton(onPressed: (){}, icon: Icon(Icons.add,color: greyColor,),) - ], - ), - ) - ), - Card( - child: Padding( - padding: EdgeInsets.all(3), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('Diabetes'), - IconButton(onPressed: (){}, icon: Icon(Icons.add,color: greyColor,),) - ], - ), - ) - ), - Card( - child: Padding( - padding: EdgeInsets.all(3), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('Cholesterol'), - IconButton(onPressed: (){}, icon: Icon(Icons.add,color: greyColor,),) - ], - ), - ) - ), - Card( - child: Padding( - padding: EdgeInsets.all(3), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('Habbits'), - IconButton(onPressed: (){ - - - }, icon: Icon(Icons.add,color: greyColor,),) - ], - ), - ) - ), - Card( - child: Padding( - padding: EdgeInsets.all(3), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('Allergies'), - IconButton(onPressed: (){}, icon: Icon(Icons.add,color: greyColor,),) - ], - ), - ) - ) - - ], - ), + showBMIAdddialog(); + }, + icon: Icon( + Icons.add, + color: greyColor, + ), + ) + ], + ), + )), + Card( + child: Padding( + padding: EdgeInsets.all(3), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('Blood Pressure'), + IconButton( + onPressed: () {}, + icon: Icon( + Icons.add, + color: greyColor, + ), + ) + ], + ), + )), + Card( + child: Padding( + padding: EdgeInsets.all(3), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('Diabetes'), + IconButton( + onPressed: () {}, + icon: Icon( + Icons.add, + color: greyColor, + ), + ) + ], + ), + )), + Card( + child: Padding( + padding: EdgeInsets.all(3), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('Cholesterol'), + IconButton( + onPressed: () {}, + icon: Icon( + Icons.add, + color: greyColor, + ), + ) + ], + ), + )), + Card( + child: Padding( + padding: EdgeInsets.all(3), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('Habbits'), + IconButton( + onPressed: () {}, + icon: Icon( + Icons.add, + color: greyColor, + ), + ) + ], + ), + )), + Card( + child: Padding( + padding: EdgeInsets.all(3), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('Allergies'), + IconButton( + onPressed: () {}, + icon: Icon( + Icons.add, + color: greyColor, + ), + ) + ], + ), + )) + ], + ), ), ); } diff --git a/lib/otpscreen.dart b/lib/otpscreen.dart index 2940a89..85b8a6c 100644 --- a/lib/otpscreen.dart +++ b/lib/otpscreen.dart @@ -175,6 +175,8 @@ class _OtpScreenState extends State { bool phoneVerified = await AppSettings.phoneVerification(payload); if(phoneVerified){ Navigator.of(context,rootNavigator: true).pop(); + AppSettings.longSuccessToast( + "Phone verified successfully"); Navigator.push( context, MaterialPageRoute( @@ -183,12 +185,16 @@ class _OtpScreenState extends State { } else{ Navigator.of(context,rootNavigator: true).pop(); + AppSettings.longFailedToast( + "please enter valid pin"); } } else{ Navigator.of(context,rootNavigator: true).pop(); + AppSettings.longFailedToast( + "Please check your internet"); } diff --git a/lib/settings.dart b/lib/settings.dart index 8b61e4b..7910e0b 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -10,7 +10,7 @@ import 'package:intl/intl.dart'; import 'package:flutter_styled_toast/flutter_styled_toast.dart'; import 'dart:async'; import 'package:geolocator/geolocator.dart'; -import 'package:dio/dio.dart'; +import 'package:fluttertoast/fluttertoast.dart'; const Color primaryColor = Color(0XFF1786A3); const Color greyColor = Color(0XFF8F8E8E); @@ -134,6 +134,10 @@ class AppSettings { static String sendSmsUrl = host + 'sendSms'; static String phoneVerificationUrl = 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 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 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 verifyPhn(payload) async { var response = await http.post(Uri.parse(verifyPhnUrl), @@ -338,6 +389,43 @@ class AppSettings { } } + static Future 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*/ //save data local @@ -381,6 +469,42 @@ class AppSettings { 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) { _tabName = _tabName ?? ''; diff --git a/lib/signup.dart b/lib/signup.dart index 55264ab..e4b1a13 100644 --- a/lib/signup.dart +++ b/lib/signup.dart @@ -535,16 +535,17 @@ class _SignUpState extends State { } else { Navigator.of(context, rootNavigator: true).pop(); - /*AppSettings.longFailedToast( - "Mobile number already exists");*/ + AppSettings.longFailedToast( + "Mobile number already exists"); } } catch (exception) { print(exception); 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'), diff --git a/lib/updateprofile.dart b/lib/updateprofile.dart new file mode 100644 index 0000000..6fa8193 --- /dev/null +++ b/lib/updateprofile.dart @@ -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 createState() => _UpdateprofileState(); +} + +class _UpdateprofileState extends State { + + 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: [ + 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: [ + 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( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + 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(); + 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'), + ) + ), + + ], + ), + )), + ), + ])); + } +} diff --git a/pubspec.lock b/pubspec.lock index cf67ec6..5c070a0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -392,6 +392,13 @@ packages: description: flutter source: sdk version: "0.0.0" + fluttertoast: + dependency: "direct dev" + description: + name: fluttertoast + url: "https://pub.dartlang.org" + source: hosted + version: "8.2.2" geocoding: dependency: "direct dev" description: diff --git a/pubspec.yaml b/pubspec.yaml index 5d3be5a..91290fa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -60,6 +60,7 @@ dev_dependencies: permission_handler: ^10.2.0 cloudinary_public: ^0.21.0 carousel_slider: ^4.2.1 + fluttertoast: ^8.1.2 flutter_icons: