diff --git a/lib/api/profile_api_client.dart b/lib/api/profile_api_client.dart index 7f783f2..3e254b4 100644 --- a/lib/api/profile_api_client.dart +++ b/lib/api/profile_api_client.dart @@ -8,6 +8,7 @@ import 'package:mohem_flutter_app/models/get_employee_address_model.dart'; import 'package:mohem_flutter_app/models/get_employee_basic_details.model.dart'; import 'package:mohem_flutter_app/models/get_employee_contacts.model.dart'; import 'package:mohem_flutter_app/models/get_employee_phones_model.dart'; +import 'package:mohem_flutter_app/models/profile/phone_number_types_modek.dart'; import 'api_client.dart'; class ProfileApiClient { @@ -118,4 +119,17 @@ class ProfileApiClient { return responseData.getValueSetValuesList!.first; }, url, postParams); } + + Future> getPhoneNumberTypes() async { + String url = "${ApiConsts.erpRest}GET_OBJECT_VALUES"; + Map postParams = { + "P_MENU_TYPE": "E", + "P_SELECTED_RESP_ID": -999, + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.getObjectValuesList ?? []; + }, url, postParams); + } } diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index 92eb6db..fa65b1f 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -25,6 +25,7 @@ import 'package:mohem_flutter_app/models/notification_action_model.dart'; import 'package:mohem_flutter_app/models/notification_get_respond_attributes_list_model.dart'; import 'package:mohem_flutter_app/models/profile/basic_details_cols_structions.dart'; import 'package:mohem_flutter_app/models/profile/basic_details_dff_structure.dart'; +import 'package:mohem_flutter_app/models/profile/phone_number_types_modek.dart'; import 'package:mohem_flutter_app/models/subordinates_on_leaves_model.dart'; import 'package:mohem_flutter_app/models/worklist_response_model.dart'; @@ -139,7 +140,7 @@ class GenericResponseModel { List? getMoNotificationBodyList; List? getNotificationButtonsList; List? getNotificationReassignModeList; - List? getObjectValuesList; + List? getObjectValuesList; GetOpenMissingSwipesList? getOpenMissingSwipesList; List? getOpenNotificationsList; List? getOpenNotificationsNumList; @@ -736,8 +737,13 @@ class GenericResponseModel { }); } - getNotificationReassignModeList = json['GetNotificationReassignModeList']; - getObjectValuesList = json['GetObjectValuesList']; + if (json['GetObjectValuesList'] != null) { + getObjectValuesList = []; + json['GetObjectValuesList'].forEach((v) { + getObjectValuesList!.add(new GetPhoneNumberTypesModel.fromJson(v)); + }); + } + getOpenMissingSwipesList = json["GetOpenMissingSwipesList"] == null ? null : GetOpenMissingSwipesList.fromJson(json["GetOpenMissingSwipesList"]); getOpenNotificationsList = json["GetOpenNotificationsList"] == null ? null : List.from(json["GetOpenNotificationsList"].map((x) => GetOpenNotificationsList.fromMap(x))); getOpenNotificationsNumList = json['GetOpenNotificationsNumList']; diff --git a/lib/models/profile/phone_number_types_modek.dart b/lib/models/profile/phone_number_types_modek.dart new file mode 100644 index 0000000..47b8a35 --- /dev/null +++ b/lib/models/profile/phone_number_types_modek.dart @@ -0,0 +1,21 @@ +class GetPhoneNumberTypesModel { + String? cODE; + String? dESCRIPTION; + String? mEANING; + + GetPhoneNumberTypesModel({this.cODE, this.dESCRIPTION, this.mEANING}); + + GetPhoneNumberTypesModel.fromJson(Map json) { + cODE = json['CODE']; + dESCRIPTION = json['DESCRIPTION']; + mEANING = json['MEANING']; + } + + Map toJson() { + final Map data = new Map(); + data['CODE'] = this.cODE; + data['DESCRIPTION'] = this.dESCRIPTION; + data['MEANING'] = this.mEANING; + return data; + } +} diff --git a/lib/ui/profile/basic_details.dart b/lib/ui/profile/basic_details.dart index 4733777..8a316fd 100644 --- a/lib/ui/profile/basic_details.dart +++ b/lib/ui/profile/basic_details.dart @@ -43,7 +43,7 @@ class _BasicDetailsState extends State { basicDetails(); print("getEmployeeBasicDetailsList.length"); print(getEmployeeBasicDetailsList.length); - // setState(() {}); + setState(() {}); } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); diff --git a/lib/ui/profile/contact_details.dart b/lib/ui/profile/contact_details.dart index 32f0ce8..d36b19a 100644 --- a/lib/ui/profile/contact_details.dart +++ b/lib/ui/profile/contact_details.dart @@ -1,7 +1,3 @@ - - - - import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/profile_api_client.dart'; @@ -14,6 +10,7 @@ import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/get_employee_address_model.dart'; import 'package:mohem_flutter_app/models/get_employee_basic_details.model.dart'; import 'package:mohem_flutter_app/models/get_employee_phones_model.dart'; +import 'package:mohem_flutter_app/ui/profile/phone_numbers.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'; @@ -39,15 +36,17 @@ class _ContactDetailsState extends State { @override void initState() { super.initState(); + getEmployeePhones(); - getEmployeeAddress(); + setState(() {}); } void getEmployeePhones() async { try { Utils.showLoading(context); getEmployeePhonesList = await ProfileApiClient().getEmployeePhones(); + getEmployeeAddress(); Utils.hideLoading(context); setState(() {}); } catch (ex) { @@ -68,8 +67,6 @@ class _ContactDetailsState extends State { } } - - Widget build(BuildContext context) { return Scaffold( appBar: AppBarWidget( @@ -77,14 +74,17 @@ class _ContactDetailsState extends State { title: LocaleKeys.profile_contactDetails.tr(), ), backgroundColor: MyColors.backgroundColor, - bottomSheet:footer(), - body: Column( - children: [ - Container( + 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), - height: 150, + margin: EdgeInsets.only( + top: 20, + left: 26, + right: 26, + ), + padding: EdgeInsets.only(left: 14, right: 14, top: 5, bottom: 20), + height: 200, decoration: BoxDecoration( boxShadow: [ BoxShadow( @@ -97,22 +97,48 @@ class _ContactDetailsState extends State { color: Colors.white, borderRadius: BorderRadius.circular(10.0), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, children: [ - "${getEmployeePhonesList[0].pHONETYPEMEANING}".toText13(color: MyColors.lightGrayColor), - "${getEmployeePhonesList[0].pHONENUMBER}".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20,), - "${getEmployeePhonesList[1].pHONETYPEMEANING}".toText13(color: MyColors.lightGrayColor), - "${getEmployeePhonesList[1].pHONENUMBER}".toText16(isBold: true, color: MyColors.blackColor), - ] + IconButton( + icon: Icon( + Icons.edit_location_alt_outlined, + size: 20, + ), + onPressed: () { + updatePhone(); + }, + ) + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: getEmployeePhonesList + .map((e) => Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + "${e.pHONETYPEMEANING}".toText13(color: MyColors.lightGrayColor), + "${e.pHONENUMBER}".toText16(isBold: true, color: MyColors.blackColor), + ])) + .toList()) + ]) + + // [ + // "${getEmployeePhonesList[0].pHONETYPEMEANING}".toText13(color: MyColors.lightGrayColor), + // "${getEmployeePhonesList[0].pHONENUMBER}".toText16(isBold: true, color: MyColors.blackColor), + // SizedBox( + // height: 20,), + // "${getEmployeePhonesList[1].pHONETYPEMEANING}".toText13(color: MyColors.lightGrayColor), + // "${getEmployeePhonesList[1].pHONENUMBER}".toText16(isBold: true, color: MyColors.blackColor), + // ] ), - ), - Container( + 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: 20, + left: 26, + right: 26, + ), + padding: EdgeInsets.only(left: 14, right: 14, top: 5, bottom: 20), height: 400, decoration: BoxDecoration( boxShadow: [ @@ -126,41 +152,66 @@ class _ContactDetailsState extends State { color: Colors.white, borderRadius: BorderRadius.circular(10.0), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + child: SingleChildScrollView( + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, children: [ - "${getEmployeeAddressList[0].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), - "${getEmployeeAddressList[0].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20,), - "${getEmployeeAddressList[2].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), - "${getEmployeeAddressList[2].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20,), - "${getEmployeeAddressList[3].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), - "${getEmployeeAddressList[3].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20,), - "${getEmployeeAddressList[4].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), - "${getEmployeeAddressList[4].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20,), - "${getEmployeeAddressList[5].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), - "${getEmployeeAddressList[5].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20,), - "${getEmployeeAddressList[6].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), - "${getEmployeeAddressList[6].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), - ] - ), - ), - ], - ) - - ); + IconButton( + icon: Icon( + Icons.edit_location_alt_outlined, + size: 20, + ), + onPressed: () {}, + ) + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: getEmployeeAddressList + .map((e) => Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + "${e.sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), + "${e.sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), + SizedBox( + height: 20, + ), + ])) + .toList()) + ]))) + // "${getEmployeeAddressList[0].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), + // "${getEmployeeAddressList[0].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), + // SizedBox( + // height: 20, + // ), + // "${getEmployeeAddressList[2].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), + // "${getEmployeeAddressList[2].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), + // SizedBox( + // height: 20, + // ), + // "${getEmployeeAddressList[3].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), + // "${getEmployeeAddressList[3].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), + // SizedBox( + // height: 20, + // ), + // "${getEmployeeAddressList[4].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), + // "${getEmployeeAddressList[4].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), + // SizedBox( + // height: 20, + // ), + // "${getEmployeeAddressList[5].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), + // "${getEmployeeAddressList[5].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), + // SizedBox( + // height: 20, + // ), + // "${getEmployeeAddressList[6].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), + // "${getEmployeeAddressList[6].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), + //]), + //), + //], + ])); } - footer(){ + footer() { return Container( decoration: BoxDecoration( // borderRadius: BorderRadius.circular(10), @@ -175,4 +226,11 @@ class _ContactDetailsState extends State { }).insideContainer, ); } + + updatePhone() { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => PhoneNumbers(getEmployeePhonesList: this.getEmployeePhonesList)), + ); + } } diff --git a/lib/ui/profile/phone_numbers.dart b/lib/ui/profile/phone_numbers.dart new file mode 100644 index 0000000..aabf50e --- /dev/null +++ b/lib/ui/profile/phone_numbers.dart @@ -0,0 +1,115 @@ +import 'package:easy_localization/src/public_ext.dart'; +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/api/profile_api_client.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_address_model.dart'; +import 'package:mohem_flutter_app/models/get_employee_basic_details.model.dart'; +import 'package:mohem_flutter_app/models/get_employee_phones_model.dart'; +import 'package:mohem_flutter_app/models/profile/phone_number_types_modek.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/dynamic_forms/dynamic_textfield_widget.dart'; + +class PhoneNumbers extends StatefulWidget { + List getEmployeePhonesList; + + PhoneNumbers({Key? key, required this.getEmployeePhonesList}) : super(key: key); + + @override + _PhoneNumbersState createState() => _PhoneNumbersState(); +} + +class _PhoneNumbersState extends State { + List getPhoneNumberTypesList = []; + @override + void initState() { + super.initState(); + getPhoneNumberTypes(); + } + + void getPhoneNumberTypes() async { + Utils.showLoading(context); + getPhoneNumberTypesList = await ProfileApiClient().getPhoneNumberTypes(); + setState(() {}); + Utils.hideLoading(context); + } + + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBarWidget( + context, + title: LocaleKeys.profile_contactDetails.tr(), + ), + backgroundColor: MyColors.backgroundColor, + bottomSheet: footer(), + body: Column(children: [ + Container( + width: double.infinity, + margin: EdgeInsets.only( + top: 20, + left: 26, + right: 26, + ), + padding: EdgeInsets.only(left: 14, right: 14, top: 5, bottom: 20), + height: 400, + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 5, + blurRadius: 26, + offset: Offset(0, 3), + ), + ], + color: Colors.white, + borderRadius: BorderRadius.circular(10.0), + ), + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: widget.getEmployeePhonesList + .map((e) => Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + PopupMenuButton( + child: DynamicTextFieldWidget( + "Please Select *", + e.pHONETYPEMEANING ?? "", + isEnable: true, + isPopup: true, + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + for (int i = 0; i < getPhoneNumberTypesList.length; i++) PopupMenuItem(child: Text(getPhoneNumberTypesList![i].mEANING!), value: i), + ], + onSelected: (int index) { + e.pHONETYPEMEANING = getPhoneNumberTypesList[index].mEANING; + setState(() {}); + }), + "${e.pHONENUMBER}".toText16(isBold: true, color: MyColors.blackColor), + ])) + .toList()))) + ])); + } + + footer() { + return Container( + decoration: BoxDecoration( + // borderRadius: BorderRadius.circular(10), + color: MyColors.white, + boxShadow: [ + BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), + ], + ), + child: DefaultButton(LocaleKeys.update.tr(), () async { + // context.setLocale(const Locale("en", "US")); // to change Loacle + Profile(); + }).insideContainer, + ); + } + + updatePhone() {} +}