From b5a5399b95ea486fa8085d7b8625840220c9a5f9 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Thu, 2 Jun 2022 11:54:02 +0300 Subject: [PATCH] profile --- assets/images/basic-details.svg | 9 ++ assets/images/contact-details.svg | 5 + assets/images/family-members.svg | 3 + assets/images/personal-info.svg | 14 +++ assets/langs/en-US.json | 7 +- lib/api/profile_api_client.dart | 21 +++-- lib/classes/consts.dart | 4 +- lib/models/profile_menu.model.dart | 4 +- lib/ui/profile/basic_details.dart | 78 ++++++++++++++- lib/ui/profile/personal_info.dart | 94 +++++++++---------- lib/ui/screens/profile/profile_screen.dart | 74 ++++++++++++--- .../screens/profile/widgets/profile_info.dart | 14 ++- lib/widgets/bottom_sheet.dart | 39 ++++++++ lib/widgets/radio/show_radio.dart | 5 +- pubspec.yaml | 2 +- 15 files changed, 280 insertions(+), 93 deletions(-) create mode 100644 assets/images/basic-details.svg create mode 100644 assets/images/contact-details.svg create mode 100644 assets/images/family-members.svg create mode 100644 assets/images/personal-info.svg diff --git a/assets/images/basic-details.svg b/assets/images/basic-details.svg new file mode 100644 index 0000000..215f00b --- /dev/null +++ b/assets/images/basic-details.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/assets/images/contact-details.svg b/assets/images/contact-details.svg new file mode 100644 index 0000000..c9ac5a5 --- /dev/null +++ b/assets/images/contact-details.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/images/family-members.svg b/assets/images/family-members.svg new file mode 100644 index 0000000..eca7dd5 --- /dev/null +++ b/assets/images/family-members.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/images/personal-info.svg b/assets/images/personal-info.svg new file mode 100644 index 0000000..9daf5ad --- /dev/null +++ b/assets/images/personal-info.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index dd2d2a4..9097f9e 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -236,16 +236,15 @@ "month": "Month", "day": "Day", "completingYear": "We appreciate you for completing the service of", - "address" : "Address", + "address": "Address", "phoneNumber": "Phone Number", "businessGroup": "Business", "Payroll": "Payroll", "civilIdentityNumber": "Civil Identity Number", - "dateOfBirth" : "Date of Birth", + "dateOfBirth": "Date of Birth", "maritalStatus ": "Marital Status ", "fullName": "Full Name", - "remove": "remove", - "update": "update", + "remove": "Remove", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/api/profile_api_client.dart b/lib/api/profile_api_client.dart index 9d9056e..bb6a900 100644 --- a/lib/api/profile_api_client.dart +++ b/lib/api/profile_api_client.dart @@ -1,5 +1,3 @@ - - import 'dart:async'; import 'package:mohem_flutter_app/app_state/app_state.dart'; @@ -18,12 +16,11 @@ class ProfileApiClient { factory ProfileApiClient() => _instance; - Future> getEmployeeContacts() async { String url = "${ApiConsts.erpRest}GET_EMPLOYEE_CONTACTS"; Map postParams = { - "P_MENU_TYPE": "E", - "P_SELECTED_RESP_ID": -999, + "P_MENU_TYPE": "E", + "P_SELECTED_RESP_ID": -999, }; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { @@ -32,7 +29,7 @@ class ProfileApiClient { }, url, postParams); } - Future> getEmployeeBasicDetails() async { + Future> getEmployeeBasicDetails() async { String url = "${ApiConsts.erpRest}GET_EMPLOYEE_BASIC_DETAILS"; Map postParams = { "P_MENU_TYPE": "E", @@ -70,4 +67,14 @@ class ProfileApiClient { return responseData.getEmployeeAddressList ?? []; }, url, postParams); } -} \ No newline at end of file + + Future updateEmpImage(img) async { + String url = "${ApiConsts.erpRest}UPDATE_EMPLOYEE_IMAGE"; + Map postParams = {"P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999, "P_IMAGE": img}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + // GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return json['UpdateEmployeeImageList']; + }, url, postParams); + } +} diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index ca8e2f0..e9e3c86 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -1,7 +1,7 @@ class ApiConsts { //static String baseUrl = "http://10.200.204.20:2801/"; // Local server - // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server - static String baseUrl = "https://hmgwebservices.com"; // Live server + static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server + //static String baseUrl = "https://hmgwebservices.com"; // Live server static String baseUrlServices = baseUrl + "/Services/"; // server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/"; diff --git a/lib/models/profile_menu.model.dart b/lib/models/profile_menu.model.dart index 4593f9c..c26ee7f 100644 --- a/lib/models/profile_menu.model.dart +++ b/lib/models/profile_menu.model.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; class ProfileMenu { final String name; - final IconData icon; + final String icon; final String route; - ProfileMenu({this.name = '', this.icon = Icons.home, this.route = ''}); + ProfileMenu({this.name = '', this.icon = '', this.route = ''}); } diff --git a/lib/ui/profile/basic_details.dart b/lib/ui/profile/basic_details.dart index e229918..5110fae 100644 --- a/lib/ui/profile/basic_details.dart +++ b/lib/ui/profile/basic_details.dart @@ -11,6 +11,7 @@ import 'package:mohem_flutter_app/models/get_employee_basic_details.model.dart'; import 'package:mohem_flutter_app/ui/profile/profile.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; +import 'package:mohem_flutter_app/widgets/radio/show_radio.dart'; class BasicDetails extends StatefulWidget { const BasicDetails({Key? key}) : super(key: key); @@ -150,9 +151,82 @@ class _BasicDetailsState extends State { ], ), child: DefaultButton(LocaleKeys.update.tr(), () async { - // context.setLocale(const Locale("en", "US")); // to change Loacle - Profile(); + showAlertDialog(context); }).insideContainer, ); } + + showAlertDialog(BuildContext context) { + dynamic changeOrNew = 1; + Widget cancelButton = TextButton( + child: Text("Cancel"), + onPressed: () { + Navigator.pop(context); + }, + ); + Widget continueButton = TextButton( + child: Text("Next"), + onPressed: () {}, + ); + StatefulBuilder alert = StatefulBuilder(builder: (context, setState) { + return AlertDialog( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10.0))), + title: Text("Confirm"), + content: Builder(builder: (context) { + // Get available height and width of the build area of this widget. Make a choice depending on the size. + var height = MediaQuery.of(context).size.height * .5; + return Container( + height: height, + child: Column(children: [ + Text( + "Select the type of change you want to make.", + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + Divider(), + Column( + children: [ + ListTile( + title: Text("correct or complete the current details"), + leading: Radio( + value: 1, + groupValue: changeOrNew, + onChanged: (value) { + setState(() { + changeOrNew = int.parse(value.toString()); + }); + }, + activeColor: Colors.green, + ), + ), + ListTile( + title: Text("Enter new Information because of a real change to the current details (e.g because of a change in marital status)"), + leading: Radio( + value: 2, + groupValue: changeOrNew, + onChanged: (value) { + setState(() { + changeOrNew = int.parse(value.toString()); + }); + }, + activeColor: Colors.green, + ), + ), + ], + ) + ])); + }), + actions: [ + cancelButton, + continueButton, + ], + ); + }); + + showDialog( + context: context, + builder: (BuildContext context) { + return alert; + }, + ); + } } diff --git a/lib/ui/profile/personal_info.dart b/lib/ui/profile/personal_info.dart index b136141..0ad9e2f 100644 --- a/lib/ui/profile/personal_info.dart +++ b/lib/ui/profile/personal_info.dart @@ -1,17 +1,12 @@ - -import 'package:easy_localization/src/public_ext.dart'; +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:mohem_flutter_app/api/profile_api_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; -import 'package:mohem_flutter_app/classes/utils.dart'; -import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; -import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/get_employee_basic_details.model.dart'; import 'package:mohem_flutter_app/models/member_information_list_model.dart'; -import 'package:mohem_flutter_app/ui/profile/profile.dart'; + import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; @@ -37,29 +32,30 @@ class _PesonalInfoState extends State { List getEmployeeBasicDetailsList = []; - @override void initState() { super.initState(); memberInformationList = AppState().memberInformationList!; - } - Widget build(BuildContext context) { return Scaffold( appBar: AppBarWidget( context, title: LocaleKeys.profile_personalInformation.tr(), ), - backgroundColor: MyColors.backgroundColor, - bottomSheet:footer(), - body: Column( - children: [ - Container( + backgroundColor: MyColors.backgroundColor, + // bottomSheet:footer(), + body: Column( + children: [ + Container( width: double.infinity, - margin: EdgeInsets.only(top: 28, left: 26, right: 26,), - padding: EdgeInsets.only(left: 14, right: 14,top: 13, bottom: 20), + margin: EdgeInsets.only( + top: 28, + left: 26, + right: 26, + ), + padding: EdgeInsets.only(left: 14, right: 14, top: 13, bottom: 20), height: 350, decoration: BoxDecoration( boxShadow: [ @@ -70,40 +66,39 @@ class _PesonalInfoState extends State { offset: Offset(0, 3), ), ], - color: Colors.white, - borderRadius: BorderRadius.circular(10.0), + color: Colors.white, + borderRadius: BorderRadius.circular(10.0), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LocaleKeys.category.tr().toText13(color: MyColors.lightGrayColor), - "${memberInformationList!.eMPLOYMENTCATEGORYMEANING}".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20,), - LocaleKeys.address.tr().toText13(color: MyColors.lightGrayColor), - "${memberInformationList!.lOCATIONNAME}".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20,), - LocaleKeys.phoneNumber.tr().toText13(color: MyColors.lightGrayColor), - "${memberInformationList!.eMPLOYEEMOBILENUMBER}".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20,), - LocaleKeys.businessGroup.tr().toText13(color: MyColors.lightGrayColor), - "${memberInformationList!.bUSINESSGROUPNAME}".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20,), - LocaleKeys.Payroll.tr().toText13(color: MyColors.lightGrayColor), - "${memberInformationList!.pAYROLLNAME}".toText16(isBold: true, color: MyColors.blackColor), - ] - ), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + LocaleKeys.category.tr().toText13(color: MyColors.lightGrayColor), + "${memberInformationList!.eMPLOYMENTCATEGORYMEANING}".toText16(isBold: true, color: MyColors.blackColor), + SizedBox( + height: 20, ), - ], - ) - - ); + LocaleKeys.address.tr().toText13(color: MyColors.lightGrayColor), + "${memberInformationList!.lOCATIONNAME}".toText16(isBold: true, color: MyColors.blackColor), + SizedBox( + height: 20, + ), + LocaleKeys.phoneNumber.tr().toText13(color: MyColors.lightGrayColor), + "${memberInformationList!.eMPLOYEEMOBILENUMBER}".toText16(isBold: true, color: MyColors.blackColor), + SizedBox( + height: 20, + ), + LocaleKeys.businessGroup.tr().toText13(color: MyColors.lightGrayColor), + "${memberInformationList!.bUSINESSGROUPNAME}".toText16(isBold: true, color: MyColors.blackColor), + SizedBox( + height: 20, + ), + LocaleKeys.Payroll.tr().toText13(color: MyColors.lightGrayColor), + "${memberInformationList!.pAYROLLNAME}".toText16(isBold: true, color: MyColors.blackColor), + ]), + ), + ], + )); } - footer(){ + footer() { return Container( decoration: BoxDecoration( // borderRadius: BorderRadius.circular(10), @@ -112,10 +107,7 @@ class _PesonalInfoState extends State { BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), ], ), - child: DefaultButton(LocaleKeys.update.tr(), () async { - // context.setLocale(const Locale("en", "US")); // to change Loacle - Profile(); - }).insideContainer, + child: DefaultButton(LocaleKeys.update.tr(), () async {}).insideContainer, ); } } diff --git a/lib/ui/screens/profile/profile_screen.dart b/lib/ui/screens/profile/profile_screen.dart index f1c0f8f..c1be51e 100644 --- a/lib/ui/screens/profile/profile_screen.dart +++ b/lib/ui/screens/profile/profile_screen.dart @@ -1,7 +1,8 @@ import 'dart:ui'; - +import 'dart:convert'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:image_picker/image_picker.dart'; import 'package:mohem_flutter_app/api/profile_api_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; @@ -9,6 +10,7 @@ import 'package:mohem_flutter_app/models/get_employee_basic_details.model.dart'; import 'package:mohem_flutter_app/models/member_information_list_model.dart'; import 'package:mohem_flutter_app/ui/screens/profile/widgets/header.dart'; import 'package:mohem_flutter_app/ui/screens/profile/widgets/profile_panel.dart'; +import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; class ProfileScreen extends StatefulWidget { const ProfileScreen({Key? key}) : super(key: key); @@ -19,8 +21,8 @@ class ProfileScreen extends StatefulWidget { class _ProfileScreenState extends State { late MemberInformationListModel memberInformationList; - - List getEmployeeBasicDetailsList = []; + final ImagePicker _picker = ImagePicker(); + //List getEmployeeBasicDetailsList = []; @override void initState() { @@ -65,6 +67,9 @@ class _ProfileScreenState extends State { color: Colors.white, )), InkWell( + onTap: () { + startImageSheet(); + }, child: Container( padding: EdgeInsets.only(left: 10, right: 10, top: 5, bottom: 5), decoration: BoxDecoration(borderRadius: BorderRadius.circular(15), color: Colors.black.withOpacity(.3)), @@ -84,18 +89,61 @@ class _ProfileScreenState extends State { ])); } - void getEmployeeBasicDetails() async { - try { + startImageSheet() { + showMyBottomSheet(context, + child: Column( + children: [ + Container( + padding: EdgeInsets.only(left: 20, right: 20), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [Text('OK'), Text('CANCEL')], + )), + BottomSheetItem( + onTap: () { + openGallery(false); + }, + title: 'Open Gallery', + icon: Icons.browse_gallery_outlined, + ), + BottomSheetItem( + onTap: () { + openGallery(true); + }, + title: 'Open Camera', + icon: Icons.camera, + ) + ], + )); + } + + void openGallery(bool isCamera) async { + final XFile? image = await _picker.pickImage(source: isCamera ? ImageSource.camera : ImageSource.gallery); + + if (image != null) { + String img = base64.encode(await image!.readAsBytes()); Utils.showLoading(context); - getEmployeeBasicDetailsList = await ProfileApiClient().getEmployeeBasicDetails(); - Utils.hideLoading(context); - //basicDetails(); - print("getEmployeeBasicDetailsList.length"); - print(getEmployeeBasicDetailsList.length); - setState(() {}); - } catch (ex) { + dynamic empImageUpdteResp = await ProfileApiClient().updateEmpImage(img); Utils.hideLoading(context); - Utils.handleException(ex, context, null); + if (empImageUpdteResp['P_RETURN_STATUS'] == 'S') { + setState(() { + memberInformationList.eMPLOYEEIMAGE = img; + }); + } } } + // void getEmployeeBasicDetails() async { + // try { + // Utils.showLoading(context); + // getEmployeeBasicDetailsList = await ProfileApiClient().getEmployeeBasicDetails(); + // Utils.hideLoading(context); + // //basicDetails(); + // print("getEmployeeBasicDetailsList.length"); + // print(getEmployeeBasicDetailsList.length); + // setState(() {}); + // } catch (ex) { + // Utils.hideLoading(context); + // Utils.handleException(ex, context, null); + // } + // } } diff --git a/lib/ui/screens/profile/widgets/profile_info.dart b/lib/ui/screens/profile/widgets/profile_info.dart index 1141fcf..8919924 100644 --- a/lib/ui/screens/profile/widgets/profile_info.dart +++ b/lib/ui/screens/profile/widgets/profile_info.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/member_information_list_model.dart'; @@ -12,10 +13,10 @@ class ProfileInFo extends StatelessWidget { String data = '.'; double sliderValue = 75; List menu = [ - ProfileMenu(name: LocaleKeys.profile_personalInformation.tr(), icon: Icons.info, route: AppRoutes.personalInfo), - ProfileMenu(name: LocaleKeys.profile_basicDetails.tr(), icon: Icons.contacts, route: AppRoutes.basicDetails), - ProfileMenu(name: LocaleKeys.profile_contactDetails.tr(), icon: Icons.location_on, route: AppRoutes.contactDetails), - ProfileMenu(name: LocaleKeys.profile_familyDetails.tr(), icon: Icons.reduce_capacity_sharp, route: AppRoutes.familyMembers), + ProfileMenu(name: LocaleKeys.profile_personalInformation.tr(), icon: 'personal-info.svg', route: AppRoutes.personalInfo), + ProfileMenu(name: LocaleKeys.profile_basicDetails.tr(), icon: 'basic-details.svg', route: AppRoutes.basicDetails), + ProfileMenu(name: LocaleKeys.profile_contactDetails.tr(), icon: 'contact-details.svg', route: AppRoutes.contactDetails), + ProfileMenu(name: LocaleKeys.profile_familyDetails.tr(), icon: 'family-members.svg', route: AppRoutes.familyMembers), ]; @override Widget build(BuildContext context) { @@ -103,10 +104,7 @@ class ProfileInFo extends StatelessWidget { Navigator.pushNamed(context, obj.route); }, child: ListTile( - leading: Icon( - obj.icon, - color: Color(0xff2BB8A6), - ), + leading: SvgPicture.asset('assets/images/' + obj.icon), title: Text(obj.name), trailing: Icon(Icons.arrow_forward), ), diff --git a/lib/widgets/bottom_sheet.dart b/lib/widgets/bottom_sheet.dart index a44fd7b..f0bf3f8 100644 --- a/lib/widgets/bottom_sheet.dart +++ b/lib/widgets/bottom_sheet.dart @@ -39,3 +39,42 @@ showMyBottomSheet(BuildContext context, {required Widget child}) { }, ); } + +class BottomSheetItem extends StatelessWidget { + final Function onTap; + final IconData icon; + final String title; + final Color color; + + const BottomSheetItem({Key? key, required this.onTap, required this.title, required this.icon, this.color = Colors.black}) : super(key: key); + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + if (onTap != null) { + Navigator.pop(context); + onTap(); + } + }, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 18.0, vertical: 18.0), + child: Row( + children: [ + if (icon != null) + Icon( + icon, + color: color, + size: 18.0, + ), + if (icon != null) SizedBox(width: 24.0), + Text( + title ?? "", + style: TextStyle(color: color), + ), + ], + ), + ), + ); + } +} diff --git a/lib/widgets/radio/show_radio.dart b/lib/widgets/radio/show_radio.dart index fda5bf9..65e0e36 100644 --- a/lib/widgets/radio/show_radio.dart +++ b/lib/widgets/radio/show_radio.dart @@ -7,8 +7,7 @@ import 'package:mohem_flutter_app/extensions/int_extensions.dart'; class ShowRadio extends StatelessWidget { String title, value, groupValue; - ShowRadio( - {required this.title, required this.value, required this.groupValue}); + ShowRadio({required this.title, required this.value, required this.groupValue}); @override Widget build(BuildContext context) { @@ -34,7 +33,7 @@ class ShowRadio extends StatelessWidget { ), ), 12.width, - title.toText12(isBold: true) + title.toText12(isBold: true, maxLine: 2) ], ); } diff --git a/pubspec.yaml b/pubspec.yaml index 8afdae3..b613514 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,7 +54,7 @@ dependencies: flutter_countdown_timer: ^4.1.0 nfc_manager: ^3.1.1 uuid: ^3.0.6 - + image_picker: ^0.8.5+3 # maps google_maps_flutter: ^2.0.2 google_maps_utils: ^1.4.0+1