From d614532956eb6e89907cb3e605014fc8a30f2b52 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 23 Jun 2022 12:07:25 +0300 Subject: [PATCH 01/40] Announcements implemented --- lib/models/get_announcement_details.dart | 4 +- .../announcements/announcement_details.dart | 89 +++++++++++-------- .../screens/announcements/announcements.dart | 15 +++- pubspec.yaml | 1 + 4 files changed, 68 insertions(+), 41 deletions(-) diff --git a/lib/models/get_announcement_details.dart b/lib/models/get_announcement_details.dart index 33628ce..9414c9f 100644 --- a/lib/models/get_announcement_details.dart +++ b/lib/models/get_announcement_details.dart @@ -3,8 +3,8 @@ class GetAnnouncementDetails { String? titleAR; String? emailBodyEN; String? emailBodyAR; - String? bodyEN; - String? bodyAR; + String? bodyEN = ""; + String? bodyAR = ""; String? bannerImage; String? rowID; String? awarenessName; diff --git a/lib/ui/screens/announcements/announcement_details.dart b/lib/ui/screens/announcements/announcement_details.dart index a3de742..a2f1f99 100644 --- a/lib/ui/screens/announcements/announcement_details.dart +++ b/lib/ui/screens/announcements/announcement_details.dart @@ -3,9 +3,13 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:mohem_flutter_app/api/pending_transactions_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/models/get_announcement_details.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; +import 'package:url_launcher/url_launcher.dart'; class AnnouncementDetails extends StatefulWidget { const AnnouncementDetails({Key? key}) : super(key: key); @@ -36,59 +40,68 @@ class _AnnouncementDetailsState extends State { title: "Announcements", ), body: SingleChildScrollView( - child: Container( - width: double.infinity, - padding: const EdgeInsets.all(10.0), - margin: const EdgeInsets.all(12.0), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - SizedBox( + child: getAnnouncementDetailsObj != null + ? Container( width: double.infinity, - height: 150.0, - child: ClipRRect( + padding: const EdgeInsets.all(10.0), + margin: const EdgeInsets.all(12.0), + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(10), - child: Image.memory( - base64Decode(Utils.getBase64FromJpeg(getAnnouncementDetailsObj?.bannerImage)), - fit: BoxFit.cover, - ), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], ), - ), - Container( - margin: const EdgeInsets.only(top: 12.0), - child: Html( - data: getAnnouncementDetailsObj?.bodyEN, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + 12.height, + AppState().isArabic(context) + ? Text(getAnnouncementDetailsObj?.titleAR ?? "", style: const TextStyle(color: MyColors.darkTextColor, fontSize: 16, letterSpacing: -0.64, fontWeight: FontWeight.w600)) + : Text(getAnnouncementDetailsObj?.titleEN ?? "", style: const TextStyle(color: MyColors.darkTextColor, fontSize: 16, letterSpacing: -0.64, fontWeight: FontWeight.w600)), + 12.height, + SizedBox( + width: double.infinity, + height: 150.0, + child: ClipRRect( + borderRadius: BorderRadius.circular(10), + child: Image.memory( + base64Decode(Utils.getBase64FromJpeg(getAnnouncementDetailsObj?.bannerImage)), + fit: BoxFit.cover, + ), + ), + ), + Container( + margin: const EdgeInsets.only(top: 12.0), + child: Html( + data: AppState().isArabic(context) ? getAnnouncementDetailsObj?.bodyAR : getAnnouncementDetailsObj?.bodyEN ?? "", + onLinkTap: (String? url, RenderContext context, Map attributes, _) { + launchUrl(Uri.parse(url!)); + }), + ), + ], ), - ), - ], - ), - ), + ) + : Utils.getNoDataWidget(context), ), ); } - getRequestID() { + getRequestID() async { if (currentPageNo == 0) { final arguments = (ModalRoute.of(context)?.settings.arguments ?? {}) as Map; currentPageNo = arguments["currentPageNo"]; rowID = arguments["rowID"]; - getAnnouncementDetails(0, rowID); + await getAnnouncementDetails(0, rowID); } } - void getAnnouncementDetails(int itgAwarenessID, int itgRowID) async { + Future getAnnouncementDetails(int itgAwarenessID, int itgRowID) async { try { Utils.showLoading(context); jsonResponse = await PendingTransactionsApiClient().getAnnouncements(itgAwarenessID, currentPageNo, itgRowID); diff --git a/lib/ui/screens/announcements/announcements.dart b/lib/ui/screens/announcements/announcements.dart index cad3a9a..61ebde4 100644 --- a/lib/ui/screens/announcements/announcements.dart +++ b/lib/ui/screens/announcements/announcements.dart @@ -27,11 +27,22 @@ class _AnnouncementsState extends State { List getAnnouncementsObject = []; List _foundAnnouncements = []; TextEditingController searchController = TextEditingController(); + final ScrollController _controller = ScrollController(); @override void initState() { getAnnouncements(0, 0); super.initState(); + _controller.addListener(() { + if (_controller.position.atEdge) { + bool isTop = _controller.position.pixels == 0; + if (!isTop) { + print('At the bottom'); + currentPageNo++; + getAnnouncements(0, 0); + } + } + }); } @override @@ -71,6 +82,7 @@ class _AnnouncementsState extends State { child: ListView.separated( physics: const BouncingScrollPhysics(), shrinkWrap: true, + controller: _controller, itemBuilder: (BuildContext context, int index) { return InkWell( onTap: () { @@ -125,7 +137,8 @@ class _AnnouncementsState extends State { ); }, separatorBuilder: (BuildContext context, int index) => 1.height, - itemCount: _foundAnnouncements.length ?? 0)) + itemCount: _foundAnnouncements.length ?? 0)), + 20.height, ], ), ) diff --git a/pubspec.yaml b/pubspec.yaml index 365819d..6601587 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -68,6 +68,7 @@ dependencies: open_file: ^3.2.1 wifi_iot: ^0.3.16 flutter_html: ^2.2.1 + url_launcher: ^6.0.15 dev_dependencies: flutter_test: From 058e287b2552fdbd7c602c8f3b2ca74701c8504e Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Sun, 7 Aug 2022 11:28:41 +0300 Subject: [PATCH 02/40] fix translation --- lib/ui/landing/today_attendance_screen.dart | 4 ++-- lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart | 4 ++-- lib/widgets/qr_scanner_dialog.dart | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/ui/landing/today_attendance_screen.dart b/lib/ui/landing/today_attendance_screen.dart index 04ee4b1..9346773 100644 --- a/lib/ui/landing/today_attendance_screen.dart +++ b/lib/ui/landing/today_attendance_screen.dart @@ -163,14 +163,14 @@ class _TodayAttendanceScreenState extends State { Row( children: [ commonStatusView(LocaleKeys.checkIn.tr(), (model.attendanceTracking!.pSwipeIn) ?? "- - : - -"), - commonStatusView("Check Out", (model.attendanceTracking!.pSwipeOut) ?? "- - : - -") + commonStatusView(LocaleKeys.checkOut.tr(), (model.attendanceTracking!.pSwipeOut) ?? "- - : - -") ], ), 21.height, Row( children: [ commonStatusView(LocaleKeys.lateIn.tr(), (model.attendanceTracking!.pLateInHours) ?? "- - : - -"), - commonStatusView("Regular", (model.attendanceTracking!.pScheduledHours) ?? "- - : - -") + commonStatusView(LocaleKeys.regular.tr(), (model.attendanceTracking!.pScheduledHours) ?? "- - : - -") ], ), ], diff --git a/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart b/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart index b557ab9..7ac6c43 100644 --- a/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart +++ b/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart @@ -253,7 +253,7 @@ class _MowadhafhiHRRequestState extends State { children: [ title.toText16().expanded, 6.width, - SimpleButton("Add", () async { + SimpleButton(LocaleKeys.add.tr(), () async { FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true); if (result != null) { attachmentFiles = attachmentFiles + result.paths.map((path) => File(path!)).toList(); @@ -377,7 +377,7 @@ class _MowadhafhiHRRequestState extends State { } int? messageStatus = await MowadhafhiApiClient().submitRequest(selectedDepartment?.projectDepartmentId, description, projectID, selectedSection?.departmentSectionId.toString(), selectedTopic?.sectionTopicId.toString(), int.parse(selectedServiceType), list); - Utils.showToast("Request created successfully"); + Utils.showToast(LocaleKeys.requestCreatedSuccessfully.tr()); Utils.hideLoading(context); Navigator.pop(context); } catch (ex) { diff --git a/lib/widgets/qr_scanner_dialog.dart b/lib/widgets/qr_scanner_dialog.dart index a3adb79..6082d4c 100644 --- a/lib/widgets/qr_scanner_dialog.dart +++ b/lib/widgets/qr_scanner_dialog.dart @@ -1,4 +1,6 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:qr_code_scanner/qr_code_scanner.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; @@ -42,7 +44,7 @@ class _QrScannerDialogState extends State { Padding( padding: const EdgeInsets.all(12.0), child: DefaultButton( - "Cancel", + LocaleKeys.cancel.tr(), () { Navigator.pop(context); }, From d1cc9bd4682228ec056067c0bf56c3ce6c161e25 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Mon, 8 Aug 2022 08:51:04 +0300 Subject: [PATCH 03/40] fix issue --- lib/api/worklist/worklist_api_client.dart | 27 ++++++++++++++ lib/models/generic_response_model.dart | 37 +++++++++++++++---- lib/models/get_user_item_type_list.dart | 30 +++++++++++++++ lib/models/update_item_type_success_list.dart | 25 +++++++++++++ lib/models/update_user_item_type_list.dart | 20 ++++++++++ lib/ui/work_list/work_list_screen.dart | 1 + lib/widgets/app_bar_widget.dart | 13 ++++++- 7 files changed, 144 insertions(+), 9 deletions(-) create mode 100644 lib/models/get_user_item_type_list.dart create mode 100644 lib/models/update_item_type_success_list.dart create mode 100644 lib/models/update_user_item_type_list.dart diff --git a/lib/api/worklist/worklist_api_client.dart b/lib/api/worklist/worklist_api_client.dart index bc05627..2566e59 100644 --- a/lib/api/worklist/worklist_api_client.dart +++ b/lib/api/worklist/worklist_api_client.dart @@ -17,9 +17,11 @@ import 'package:mohem_flutter_app/models/get_po_notification_body_list_model.dar import 'package:mohem_flutter_app/models/get_quotation_analysis_list_model.dart'; import 'package:mohem_flutter_app/models/get_stamp_ms_notification_body_list_model.dart'; import 'package:mohem_flutter_app/models/get_stamp_ns_notification_body_list_model.dart'; +import 'package:mohem_flutter_app/models/get_user_item_type_list.dart'; import 'package:mohem_flutter_app/models/itg_forms_models/itg_request_model.dart'; import 'package:mohem_flutter_app/models/member_information_list_model.dart'; import 'package:mohem_flutter_app/models/notification_get_respond_attributes_list_model.dart'; +import 'package:mohem_flutter_app/models/update_user_item_type_list.dart'; import 'package:mohem_flutter_app/models/worklist/get_favorite_replacements_model.dart'; import 'package:mohem_flutter_app/models/worklist/hr/eit_otification_body_model.dart'; import 'package:mohem_flutter_app/models/worklist/hr/get_basic_det_ntf_body_list_model.dart'; @@ -445,4 +447,29 @@ class WorkListApiClient { return responseData; }, url, postParams); } + + + Future?> getUserItemTypes() async { + String url = "${ApiConsts.erpRest}GET_USER_ITEM_TYPES"; + Map postParams = { + + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + return responseData.getUserItemTypesList; + }, url, postParams); + } + + Future updateUserItemTypes() async { + String url = "${ApiConsts.erpRest}UPDATE_USER_ITEM_TYPES"; + Map postParams = { + + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + return responseData.updateUserItemTypesList; + }, url, postParams); + } } diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index 5d93f16..32290dd 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -32,6 +32,7 @@ import 'package:mohem_flutter_app/models/get_schedule_shifts_details_list_model. import 'package:mohem_flutter_app/models/get_stamp_ms_notification_body_list_model.dart'; import 'package:mohem_flutter_app/models/get_stamp_ns_notification_body_list_model.dart'; import 'package:mohem_flutter_app/models/get_time_card_summary_list_model.dart'; +import 'package:mohem_flutter_app/models/get_user_item_type_list.dart'; import 'package:mohem_flutter_app/models/member_information_list_model.dart'; import 'package:mohem_flutter_app/models/member_login_list_model.dart'; import 'package:mohem_flutter_app/models/monthly_pay_slip/get_deductions_List_model.dart'; @@ -61,6 +62,8 @@ import 'package:mohem_flutter_app/models/profile/submit_contact_transaction_list import 'package:mohem_flutter_app/models/start_eit_approval_process_model.dart'; import 'package:mohem_flutter_app/models/submit_eit_transaction_list_model.dart'; import 'package:mohem_flutter_app/models/subordinates_on_leaves_model.dart'; +import 'package:mohem_flutter_app/models/update_item_type_success_list.dart'; +import 'package:mohem_flutter_app/models/update_user_item_type_list.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_item_type_notifications_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_notification_reassign_mode_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_vacation_rules_list_model.dart'; @@ -221,7 +224,7 @@ class GenericResponseModel { List? getDepartmentSections; List? getPendingTransactionsFunctions; List? getPendingTransactionsDetails; - List? getUserItemTypesList; + List? getUserItemTypesList; List? getVacationRulesList; List? getVaccinationOnHandList; List? getVaccinationsList; @@ -319,8 +322,8 @@ class GenericResponseModel { String? tokenID; String? updateAttachmentList; String? updateEmployeeImageList; - String? updateItemTypeSuccessList; - String? updateUserItemTypesList; + List? updateItemTypeSuccessList; + UpdateUserItemTypesList? updateUserItemTypesList; String? updateVacationRuleList; String? vHREmployeeLoginList; String? vHRGetEmployeeDetailsList; @@ -1017,7 +1020,12 @@ class GenericResponseModel { }); } - getUserItemTypesList = json['GetUserItemTypesList']; + if (json['GetUserItemTypesList'] != null) { + getUserItemTypesList = []; + json['GetUserItemTypesList'].forEach((v) { + getUserItemTypesList!.add(new GetUserItemTypesList.fromJson(v)); + }); + } if (json['GetVacationRulesList'] != null) { getVacationRulesList = []; json['GetVacationRulesList'].forEach((v) { @@ -1180,8 +1188,16 @@ class GenericResponseModel { tokenID = json['TokenID']; updateAttachmentList = json['UpdateAttachmentList']; updateEmployeeImageList = json['UpdateEmployeeImageList']; - updateItemTypeSuccessList = json['UpdateItemTypeSuccessList']; - updateUserItemTypesList = json['UpdateUserItemTypesList']; + if (json['UpdateItemTypeSuccessList'] != null) { + updateItemTypeSuccessList = []; + json['UpdateItemTypeSuccessList'].forEach((v) { + updateItemTypeSuccessList! + .add(new UpdateItemTypeSuccessList.fromJson(v)); + }); + } + updateUserItemTypesList = json['UpdateUserItemTypesList'] != null + ? new UpdateUserItemTypesList.fromJson(json['UpdateUserItemTypesList']) + : null; updateVacationRuleList = json['UpdateVacationRuleList']; vHREmployeeLoginList = json['VHR_EmployeeLoginList']; vHRGetEmployeeDetailsList = json['VHR_GetEmployeeDetailsList']; @@ -1588,8 +1604,13 @@ class GenericResponseModel { data['TokenID'] = this.tokenID; data['UpdateAttachmentList'] = this.updateAttachmentList; data['UpdateEmployeeImageList'] = this.updateEmployeeImageList; - data['UpdateItemTypeSuccessList'] = this.updateItemTypeSuccessList; - data['UpdateUserItemTypesList'] = this.updateUserItemTypesList; + if (this.updateItemTypeSuccessList != null) { + data['UpdateItemTypeSuccessList'] = + this.updateItemTypeSuccessList!.map((v) => v.toJson()).toList(); + } + if (this.updateUserItemTypesList != null) { + data['UpdateUserItemTypesList'] = this.updateUserItemTypesList!.toJson(); + } data['UpdateVacationRuleList'] = this.updateVacationRuleList; data['VHR_EmployeeLoginList'] = this.vHREmployeeLoginList; data['VHR_GetEmployeeDetailsList'] = this.vHRGetEmployeeDetailsList; diff --git a/lib/models/get_user_item_type_list.dart b/lib/models/get_user_item_type_list.dart new file mode 100644 index 0000000..fc7f4c3 --- /dev/null +++ b/lib/models/get_user_item_type_list.dart @@ -0,0 +1,30 @@ + + +class GetUserItemTypesList { + String? fYAENABLEDFALG; + String? fYIENABLEDFLAG; + String? iTEMTYPE; + int? uSERITEMTYPEID; + + GetUserItemTypesList( + {this.fYAENABLEDFALG, + this.fYIENABLEDFLAG, + this.iTEMTYPE, + this.uSERITEMTYPEID}); + + GetUserItemTypesList.fromJson(Map json) { + fYAENABLEDFALG = json['FYA_ENABLED_FALG']; + fYIENABLEDFLAG = json['FYI_ENABLED_FLAG']; + iTEMTYPE = json['ITEM_TYPE']; + uSERITEMTYPEID = json['USER_ITEM_TYPE_ID']; + } + + Map toJson() { + final Map data = new Map(); + data['FYA_ENABLED_FALG'] = this.fYAENABLEDFALG; + data['FYI_ENABLED_FLAG'] = this.fYIENABLEDFLAG; + data['ITEM_TYPE'] = this.iTEMTYPE; + data['USER_ITEM_TYPE_ID'] = this.uSERITEMTYPEID; + return data; + } +} \ No newline at end of file diff --git a/lib/models/update_item_type_success_list.dart b/lib/models/update_item_type_success_list.dart new file mode 100644 index 0000000..1090dca --- /dev/null +++ b/lib/models/update_item_type_success_list.dart @@ -0,0 +1,25 @@ + + +class UpdateItemTypeSuccessList { + int? itemID; + Null? updateError; + bool? updateSuccess; + + UpdateItemTypeSuccessList( + {this.itemID, this.updateError, this.updateSuccess}); + + UpdateItemTypeSuccessList.fromJson(Map json) { + itemID = json['ItemID']; + updateError = json['UpdateError']; + updateSuccess = json['UpdateSuccess']; + } + + Map toJson() { + final Map data = new Map(); + data['ItemID'] = this.itemID; + data['UpdateError'] = this.updateError; + data['UpdateSuccess'] = this.updateSuccess; + return data; + } +} + diff --git a/lib/models/update_user_item_type_list.dart b/lib/models/update_user_item_type_list.dart new file mode 100644 index 0000000..58f4714 --- /dev/null +++ b/lib/models/update_user_item_type_list.dart @@ -0,0 +1,20 @@ + + +class UpdateUserItemTypesList { + String? pRETURNMSG; + String? pRETURNSTATUS; + + UpdateUserItemTypesList({this.pRETURNMSG, this.pRETURNSTATUS}); + + UpdateUserItemTypesList.fromJson(Map json) { + pRETURNMSG = json['P_RETURN_MSG']; + pRETURNSTATUS = json['P_RETURN_STATUS']; + } + + Map toJson() { + final Map data = new Map(); + data['P_RETURN_MSG'] = this.pRETURNMSG; + data['P_RETURN_STATUS'] = this.pRETURNSTATUS; + return data; + } +} \ No newline at end of file diff --git a/lib/ui/work_list/work_list_screen.dart b/lib/ui/work_list/work_list_screen.dart index eb2ba05..a1a8e8a 100644 --- a/lib/ui/work_list/work_list_screen.dart +++ b/lib/ui/work_list/work_list_screen.dart @@ -121,6 +121,7 @@ class _WorkListScreenState extends State { appBar: AppBarWidget( context, title: LocaleKeys.workList.tr(), + showNotificationButton: true, ), body: SizedBox( width: double.infinity, diff --git a/lib/widgets/app_bar_widget.dart b/lib/widgets/app_bar_widget.dart index 5f021d1..b6ff590 100644 --- a/lib/widgets/app_bar_widget.dart +++ b/lib/widgets/app_bar_widget.dart @@ -4,7 +4,7 @@ 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'; -AppBar AppBarWidget(BuildContext context, {required String title, bool showHomeButton = false}) { +AppBar AppBarWidget(BuildContext context, {required String title, bool showHomeButton = false, bool showNotificationButton = false}) { return AppBar( leadingWidth: 0, // leading: GestureDetector( @@ -39,6 +39,17 @@ AppBar AppBarWidget(BuildContext context, {required String title, bool showHomeB }, icon: const Icon(Icons.home, color: MyColors.darkIconColor), ), + if (showNotificationButton) + IconButton( + onPressed: () { + // Navigator.pushAndRemoveUntil( + // context, + // MaterialPageRoute(builder: (context) => LandingPage()), + // (Route route) => false, + // ); + }, + icon: const Icon(Icons.notifications, color: MyColors.textMixColor), + ), ], ); } From c63844dcf75cf569fc164efdee13dcfc1c8a76e5 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 8 Aug 2022 15:41:27 +0300 Subject: [PATCH 04/40] My requests & CCP --- lib/api/my_requests_api_client.dart | 62 +++ lib/classes/file_process.dart | 40 ++ lib/config/routes.dart | 9 + lib/models/generic_response_model.dart | 80 ++-- .../get_ccp_dff_structure_model.dart | 220 +++++++++ .../my_requests/get_ccp_output_model.dart | 21 + .../get_ccp_transactions_model.dart | 32 ++ .../get_concurrent_programs_model.dart | 24 + lib/ui/landing/widget/app_drawer.dart | 10 + lib/ui/screens/my_requests/my_requests.dart | 218 +++++++++ lib/ui/screens/my_requests/new_request.dart | 423 ++++++++++++++++++ 11 files changed, 1108 insertions(+), 31 deletions(-) create mode 100644 lib/api/my_requests_api_client.dart create mode 100644 lib/classes/file_process.dart create mode 100644 lib/models/my_requests/get_ccp_dff_structure_model.dart create mode 100644 lib/models/my_requests/get_ccp_output_model.dart create mode 100644 lib/models/my_requests/get_ccp_transactions_model.dart create mode 100644 lib/models/my_requests/get_concurrent_programs_model.dart create mode 100644 lib/ui/screens/my_requests/my_requests.dart create mode 100644 lib/ui/screens/my_requests/new_request.dart diff --git a/lib/api/my_requests_api_client.dart b/lib/api/my_requests_api_client.dart new file mode 100644 index 0000000..391e297 --- /dev/null +++ b/lib/api/my_requests_api_client.dart @@ -0,0 +1,62 @@ +import 'package:mohem_flutter_app/api/api_client.dart'; +import 'package:mohem_flutter_app/app_state/app_state.dart'; +import 'package:mohem_flutter_app/classes/consts.dart'; +import 'package:mohem_flutter_app/models/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/get_eit_dff_structure_list_model.dart'; +import 'package:mohem_flutter_app/models/my_requests/get_ccp_dff_structure_model.dart'; +import 'package:mohem_flutter_app/models/my_requests/get_ccp_output_model.dart'; +import 'package:mohem_flutter_app/models/my_requests/get_ccp_transactions_model.dart'; +import 'package:mohem_flutter_app/models/my_requests/get_concurrent_programs_model.dart'; + +class MyRequestsApiClient { + static final MyRequestsApiClient _instance = MyRequestsApiClient._internal(); + + MyRequestsApiClient._internal(); + + factory MyRequestsApiClient() => _instance; + + Future> getConcurrentPrograms() async { + String url = "${ApiConsts.erpRest}GET_CONCURRENT_PROGRAMS"; + Map postParams = {"P_REQUEST_GROUP_ID": 3290}; + + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.getConcurrentProgramsModel ?? []; + }, url, postParams); + } + + Future> getCCPTransactions(String? templateName) async { + String url = "${ApiConsts.erpRest}GET_CCP_TRANSACTIONS"; + Map postParams = {"P_DESC_FLEX_NAME": templateName}; + + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.getCCPTransactionsModel ?? []; + }, url, postParams); + } + + Future getCCPOutput(String? requestID) async { + String url = "${ApiConsts.erpRest}GET_CCP_OUTPUT"; + Map postParams = {"P_REQUEST_ID": requestID}; + + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.getCCPOutputModel!; + }, url, postParams); + } + + Future> getCCPDFFStructure(String? templateName) async { + String url = "${ApiConsts.erpRest}GET_CCP_DFF_STRUCTURE"; + Map postParams = {"P_DESC_FLEX_NAME": templateName}; + + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.getEITDFFStructureList ?? []; + }, url, postParams); + } + +} diff --git a/lib/classes/file_process.dart b/lib/classes/file_process.dart new file mode 100644 index 0000000..29f24c8 --- /dev/null +++ b/lib/classes/file_process.dart @@ -0,0 +1,40 @@ +import 'dart:convert'; +import 'dart:io'; +import 'dart:typed_data'; + +import 'package:open_file/open_file.dart'; +import 'package:path_provider/path_provider.dart'; + +class FileProcess { + static bool isFolderCreated = false; + static Directory? directory; + + static checkDocumentFolder() async { + try { + if (!isFolderCreated) { + directory = await getApplicationDocumentsDirectory(); + await directory!.exists().then((value) { + if (value) directory!.create(); + isFolderCreated = true; + }); + } + } catch (e) { + print(e.toString()); + } + } + + static void openFile(String fileName) { + String dir = directory!.path + "/${fileName}.pdf"; + OpenFile.open(dir); + } + + static Future downloadFile(String base64Content, String fileName) async { + Uint8List bytes = base64.decode(base64Content); + await checkDocumentFolder(); + String dir = directory!.path + "/" + fileName + ".pdf"; + File file = File(dir); + if (!file.existsSync()) file.create(); + await file.writeAsBytes(bytes); + return file; + } +} diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 502d852..509f6f8 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -25,6 +25,8 @@ import 'package:mohem_flutter_app/ui/screens/announcements/announcements.dart'; import 'package:mohem_flutter_app/ui/screens/eit/add_eit.dart'; import 'package:mohem_flutter_app/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart'; import 'package:mohem_flutter_app/ui/screens/mowadhafhi/request_details.dart'; +import 'package:mohem_flutter_app/ui/screens/my_requests/my_requests.dart'; +import 'package:mohem_flutter_app/ui/screens/my_requests/new_request.dart'; import 'package:mohem_flutter_app/ui/screens/pending_transactions/pending_transactions.dart'; import 'package:mohem_flutter_app/ui/screens/pending_transactions/pending_transactions_details.dart'; import 'package:mohem_flutter_app/ui/screens/profile/profile_screen.dart'; @@ -95,6 +97,10 @@ class AppRoutes { static const String announcements = "/announcements"; static const String announcementsDetails = "/announcementsDetails"; + // My Requests + static const String myRequests = "/myRequests"; + static const String newRequest = "/newRequests"; + static final Map routes = { @@ -151,6 +157,9 @@ class AppRoutes { announcements: (context) => Announcements(), announcementsDetails: (context) => AnnouncementDetails(), + //My Requests + myRequests: (context) => MyRequests(), + newRequest: (context) => NewRequest(), }; } diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index 00404f4..a550e9d 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -32,6 +32,10 @@ import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_details.dart'; import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_transactions.dart'; import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_types.dart'; import 'package:mohem_flutter_app/models/mowadhafhi/get_tickets_list.dart'; +import 'package:mohem_flutter_app/models/my_requests/get_ccp_dff_structure_model.dart'; +import 'package:mohem_flutter_app/models/my_requests/get_ccp_output_model.dart'; +import 'package:mohem_flutter_app/models/my_requests/get_ccp_transactions_model.dart'; +import 'package:mohem_flutter_app/models/my_requests/get_concurrent_programs_model.dart'; 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/pending_transactions/get_pending_transactions_details.dart'; @@ -128,11 +132,7 @@ class GenericResponseModel { List? getCEICollectionNotificationBodyList; List? getCEIDFFStructureList; List? getCEITransactionList; - List? getCcpDffStructureList; - List? getCcpOutputList; List? getCcpTransactionsList; - List? getCcpTransactionsListNew; - List? getConcurrentProgramsList; List? getContactColsStructureList; List? getContactDetailsList; List? getContactDffStructureList; @@ -170,8 +170,6 @@ class GenericResponseModel { List? getOrganizationsSalariesList; List? getPaymentInformationList; List? getPayslipList; - // List? getPendingReqDetailsList; - // List? getPendingReqFunctionsList; List? getPerformanceAppraisalList; List? getPhonesNotificationBodyList; List? getPoItemHistoryList; @@ -206,6 +204,10 @@ class GenericResponseModel { List? getDepartmentSections; List? getPendingTransactionsFunctions; List? getPendingTransactionsDetails; + List? getConcurrentProgramsModel; + List? getCCPTransactionsModel; + GetCCPOutputModel? getCCPOutputModel; + List? getCCPDFFStructureModel; List? getUserItemTypesList; List? getVacationRulesList; List? getVaccinationOnHandList; @@ -391,11 +393,7 @@ class GenericResponseModel { this.getCEICollectionNotificationBodyList, this.getCEIDFFStructureList, this.getCEITransactionList, - this.getCcpDffStructureList, - this.getCcpOutputList, this.getCcpTransactionsList, - this.getCcpTransactionsListNew, - this.getConcurrentProgramsList, this.getContactColsStructureList, this.getContactDetailsList, this.getContactDffStructureList, @@ -433,8 +431,6 @@ class GenericResponseModel { this.getOrganizationsSalariesList, this.getPaymentInformationList, this.getPayslipList, - // this.getPendingReqDetailsList, - // this.getPendingReqFunctionsList, this.getPerformanceAppraisalList, this.getPhonesNotificationBodyList, this.getPoItemHistoryList, @@ -469,6 +465,10 @@ class GenericResponseModel { this.getDepartmentSections, this.getPendingTransactionsFunctions, this.getPendingTransactionsDetails, + this.getConcurrentProgramsModel, + this.getCCPTransactionsModel, + this.getCCPOutputModel, + this.getCCPDFFStructureModel, this.getUserItemTypesList, this.getVacationRulesList, this.getVaccinationOnHandList, @@ -702,11 +702,7 @@ class GenericResponseModel { getCEICollectionNotificationBodyList = json['GetCEICollectionNotificationBodyList']; getCEIDFFStructureList = json['GetCEIDFFStructureList']; getCEITransactionList = json['GetCEITransactionList']; - getCcpDffStructureList = json['GetCcpDffStructureList']; - getCcpOutputList = json['GetCcpOutputList']; getCcpTransactionsList = json['GetCcpTransactionsList']; - getCcpTransactionsListNew = json['GetCcpTransactionsList_New']; - getConcurrentProgramsList = json['GetConcurrentProgramsList']; getContactColsStructureList = json['GetContactColsStructureList']; getContactDetailsList = json['GetContactDetailsList']; getContactDffStructureList = json['GetContactDffStructureList']; @@ -870,80 +866,105 @@ class GenericResponseModel { if (json['GetTimeCardSummaryList'] != null) { getTimeCardSummaryList = []; json['GetTimeCardSummaryList'].forEach((v) { - getTimeCardSummaryList!.add(new GetTimeCardSummaryList.fromJson(v)); + getTimeCardSummaryList!.add(GetTimeCardSummaryList.fromJson(v)); }); } if (json['Mohemm_ITG_TicketsByEmployeeList'] != null) { getTicketsByEmployeeList = []; json['Mohemm_ITG_TicketsByEmployeeList'].forEach((v) { - getTicketsByEmployeeList!.add(new GetTicketsByEmployeeList.fromJson(v)); + getTicketsByEmployeeList!.add(GetTicketsByEmployeeList.fromJson(v)); }); } if (json['Mohemm_ITG_TicketDetailsList'] != null) { getTicketDetailsByEmployee = []; json['Mohemm_ITG_TicketDetailsList'].forEach((v) { - getTicketDetailsByEmployee!.add(new GetTicketDetailsByEmployee.fromJson(v)); + getTicketDetailsByEmployee!.add(GetTicketDetailsByEmployee.fromJson(v)); }); } if (json['Mohemm_ITG_TicketTransactionsList'] != null) { getTicketTransactions = []; json['Mohemm_ITG_TicketTransactionsList'].forEach((v) { - getTicketTransactions!.add(new GetTicketTransactions.fromJson(v)); + getTicketTransactions!.add(GetTicketTransactions.fromJson(v)); }); } if (json['Mohemm_Itg_TicketTypesList'] != null) { getTicketTypes = []; json['Mohemm_Itg_TicketTypesList'].forEach((v) { - getTicketTypes!.add(new GetTicketTypes.fromJson(v)); + getTicketTypes!.add(GetTicketTypes.fromJson(v)); }); } if (json['Mohemm_Itg_ProjectsList'] != null) { getMowadhafhiProjects = []; json['Mohemm_Itg_ProjectsList'].forEach((v) { - getMowadhafhiProjects!.add(new GetMowadhafhiProjects.fromJson(v)); + getMowadhafhiProjects!.add(GetMowadhafhiProjects.fromJson(v)); }); } if (json['Mohemm_ITG_ProjectDepartmentsList'] != null) { getProjectDepartments = []; json['Mohemm_ITG_ProjectDepartmentsList'].forEach((v) { - getProjectDepartments!.add(new GetProjectDepartments.fromJson(v)); + getProjectDepartments!.add(GetProjectDepartments.fromJson(v)); }); } if (json['Mohemm_ITG_DepartmentSectionsList'] != null) { getDepartmentSections = []; json['Mohemm_ITG_DepartmentSectionsList'].forEach((v) { - getDepartmentSections!.add(new GetDepartmentSections.fromJson(v)); + getDepartmentSections!.add(GetDepartmentSections.fromJson(v)); }); } if (json['Mohemm_ITG_SectionTopicsList'] != null) { getSectionTopics = []; json['Mohemm_ITG_SectionTopicsList'].forEach((v) { - getSectionTopics!.add(new GetSectionTopics.fromJson(v)); + getSectionTopics!.add(GetSectionTopics.fromJson(v)); }); } if (json['GetPendingReqFunctionsList'] != null) { getPendingTransactionsFunctions = []; json['GetPendingReqFunctionsList'].forEach((v) { - getPendingTransactionsFunctions!.add(new GetPendingTransactionsFunctions.fromJson(v)); + getPendingTransactionsFunctions!.add(GetPendingTransactionsFunctions.fromJson(v)); }); } if (json['GetPendingReqDetailsList'] != null) { getPendingTransactionsDetails = []; json['GetPendingReqDetailsList'].forEach((v) { - getPendingTransactionsDetails!.add(new GetPendingTransactionsDetails.fromJson(v)); + getPendingTransactionsDetails!.add(GetPendingTransactionsDetails.fromJson(v)); }); } + if (json['GetConcurrentProgramsList'] != null) { + getConcurrentProgramsModel = []; + json['GetConcurrentProgramsList'].forEach((v) { + getConcurrentProgramsModel!.add(GetConcurrentProgramsModel.fromJson(v)); + }); + } + + if (json['GetCcpTransactionsList_New'] != null) { + getCCPTransactionsModel = []; + json['GetCcpTransactionsList_New'].forEach((v) { + getCCPTransactionsModel!.add(GetCCPTransactionsModel.fromJson(v)); + }); + } + + if (json['GetCcpDffStructureList'] != null) { + getEITDFFStructureList = []; + json['GetCcpDffStructureList'].forEach((v) { + getEITDFFStructureList!.add(GetEITDFFStructureList.fromJson(v)); + }); + } + + if (json['GetCcpOutputList'] != null) { + getCCPOutputModel = GetCCPOutputModel.fromJson(json['GetCcpOutputList']); + } + getUserItemTypesList = json['GetUserItemTypesList']; getVacationRulesList = json['GetVacationRulesList']; getVaccinationOnHandList = json['GetVaccinationOnHandList']; @@ -1213,11 +1234,8 @@ class GenericResponseModel { data['GetCEICollectionNotificationBodyList'] = this.getCEICollectionNotificationBodyList; data['GetCEIDFFStructureList'] = this.getCEIDFFStructureList; data['GetCEITransactionList'] = this.getCEITransactionList; - data['GetCcpDffStructureList'] = this.getCcpDffStructureList; - data['GetCcpOutputList'] = this.getCcpOutputList; data['GetCcpTransactionsList'] = this.getCcpTransactionsList; - data['GetCcpTransactionsList_New'] = this.getCcpTransactionsListNew; - data['GetConcurrentProgramsList'] = this.getConcurrentProgramsList; + // data['GetCcpTransactionsList_New'] = this.getCcpTransactionsListNew; data['GetContactColsStructureList'] = this.getContactColsStructureList; data['GetContactDetailsList'] = this.getContactDetailsList; data['GetContactDffStructureList'] = this.getContactDffStructureList; diff --git a/lib/models/my_requests/get_ccp_dff_structure_model.dart b/lib/models/my_requests/get_ccp_dff_structure_model.dart new file mode 100644 index 0000000..a170466 --- /dev/null +++ b/lib/models/my_requests/get_ccp_dff_structure_model.dart @@ -0,0 +1,220 @@ +class GetCCPDFFStructureModel { + String? aLPHANUMERICALLOWEDFLAG; + String? aPPLICATIONCOLUMNNAME; + String? cHILDSEGMENTSDV; + Null? cHILDSEGMENTSDVSplited; + String? cHILDSEGMENTSVS; + Null? cHILDSEGMENTSVSSplited; + String? dEFAULTTYPE; + String? dEFAULTVALUE; + String? dESCFLEXCONTEXTCODE; + String? dESCFLEXCONTEXTNAME; + String? dESCFLEXNAME; + String? dISPLAYFLAG; + String? eNABLEDFLAG; + ESERVICESDV? eSERVICESDV; + // List? eSERVICESVS; + String? fLEXVALUESETNAME; + String? fORMATTYPE; + String? fORMATTYPEDSP; + String? lONGLISTFLAG; + int? mAXIMUMSIZE; + String? mAXIMUMVALUE; + String? mINIMUMVALUE; + String? mOBILEENABLED; + String? nUMBERPRECISION; + String? nUMERICMODEENABLEDFLAG; + String? pARENTSEGMENTSDV; + List? pARENTSEGMENTSDVSplited; + String? pARENTSEGMENTSVS; + List? pARENTSEGMENTSVSSplitedVS; + String? rEADONLY; + String? rEQUIREDFLAG; + String? sEGMENTNAME; + String? sEGMENTPROMPT; + int? sEGMENTSEQNUM; + String? uPPERCASEONLYFLAG; + String? uSEDFLAG; + String? vALIDATIONTYPE; + String? vALIDATIONTYPEDSP; + + GetCCPDFFStructureModel( + {this.aLPHANUMERICALLOWEDFLAG, + this.aPPLICATIONCOLUMNNAME, + this.cHILDSEGMENTSDV, + this.cHILDSEGMENTSDVSplited, + this.cHILDSEGMENTSVS, + this.cHILDSEGMENTSVSSplited, + this.dEFAULTTYPE, + this.dEFAULTVALUE, + this.dESCFLEXCONTEXTCODE, + this.dESCFLEXCONTEXTNAME, + this.dESCFLEXNAME, + this.dISPLAYFLAG, + this.eNABLEDFLAG, + this.eSERVICESDV, + // this.eSERVICESVS, + this.fLEXVALUESETNAME, + this.fORMATTYPE, + this.fORMATTYPEDSP, + this.lONGLISTFLAG, + this.mAXIMUMSIZE, + this.mAXIMUMVALUE, + this.mINIMUMVALUE, + this.mOBILEENABLED, + this.nUMBERPRECISION, + this.nUMERICMODEENABLEDFLAG, + this.pARENTSEGMENTSDV, + this.pARENTSEGMENTSDVSplited, + this.pARENTSEGMENTSVS, + this.pARENTSEGMENTSVSSplitedVS, + this.rEADONLY, + this.rEQUIREDFLAG, + this.sEGMENTNAME, + this.sEGMENTPROMPT, + this.sEGMENTSEQNUM, + this.uPPERCASEONLYFLAG, + this.uSEDFLAG, + this.vALIDATIONTYPE, + this.vALIDATIONTYPEDSP}); + + GetCCPDFFStructureModel.fromJson(Map json) { + aLPHANUMERICALLOWEDFLAG = json['ALPHANUMERIC_ALLOWED_FLAG']; + aPPLICATIONCOLUMNNAME = json['APPLICATION_COLUMN_NAME']; + cHILDSEGMENTSDV = json['CHILD_SEGMENTS_DV']; + cHILDSEGMENTSDVSplited = json['CHILD_SEGMENTS_DV_Splited']; + cHILDSEGMENTSVS = json['CHILD_SEGMENTS_VS']; + cHILDSEGMENTSVSSplited = json['CHILD_SEGMENTS_VS_Splited']; + dEFAULTTYPE = json['DEFAULT_TYPE']; + dEFAULTVALUE = json['DEFAULT_VALUE']; + dESCFLEXCONTEXTCODE = json['DESC_FLEX_CONTEXT_CODE']; + dESCFLEXCONTEXTNAME = json['DESC_FLEX_CONTEXT_NAME']; + dESCFLEXNAME = json['DESC_FLEX_NAME']; + dISPLAYFLAG = json['DISPLAY_FLAG']; + eNABLEDFLAG = json['ENABLED_FLAG']; + eSERVICESDV = json['E_SERVICES_DV'] != null + ? new ESERVICESDV.fromJson(json['E_SERVICES_DV']) + : null; + // if (json['E_SERVICES_VS'] != null) { + // eSERVICESVS = []; + // json['E_SERVICES_VS'].forEach((v) { + // eSERVICESVS!.add(new Null.fromJson(v)); + // }); + // } + fLEXVALUESETNAME = json['FLEX_VALUE_SET_NAME']; + fORMATTYPE = json['FORMAT_TYPE']; + fORMATTYPEDSP = json['FORMAT_TYPE_DSP']; + lONGLISTFLAG = json['LONGLIST_FLAG']; + mAXIMUMSIZE = json['MAXIMUM_SIZE']; + mAXIMUMVALUE = json['MAXIMUM_VALUE']; + mINIMUMVALUE = json['MINIMUM_VALUE']; + mOBILEENABLED = json['MOBILE_ENABLED']; + nUMBERPRECISION = json['NUMBER_PRECISION']; + nUMERICMODEENABLEDFLAG = json['NUMERIC_MODE_ENABLED_FLAG']; + pARENTSEGMENTSDV = json['PARENT_SEGMENTS_DV']; + // if (json['PARENT_SEGMENTS_DV_Splited'] != null) { + // pARENTSEGMENTSDVSplited = []; + // json['PARENT_SEGMENTS_DV_Splited'].forEach((v) { + // pARENTSEGMENTSDVSplited!.add(new Null.fromJson(v)); + // }); + // } + // pARENTSEGMENTSVS = json['PARENT_SEGMENTS_VS']; + // if (json['PARENT_SEGMENTS_VS_SplitedVS'] != null) { + // pARENTSEGMENTSVSSplitedVS = []; + // json['PARENT_SEGMENTS_VS_SplitedVS'].forEach((v) { + // pARENTSEGMENTSVSSplitedVS!.add(new Null.fromJson(v)); + // }); + // } + rEADONLY = json['READ_ONLY']; + rEQUIREDFLAG = json['REQUIRED_FLAG']; + sEGMENTNAME = json['SEGMENT_NAME']; + sEGMENTPROMPT = json['SEGMENT_PROMPT']; + sEGMENTSEQNUM = json['SEGMENT_SEQ_NUM']; + uPPERCASEONLYFLAG = json['UPPERCASE_ONLY_FLAG']; + uSEDFLAG = json['USED_FLAG']; + vALIDATIONTYPE = json['VALIDATION_TYPE']; + vALIDATIONTYPEDSP = json['VALIDATION_TYPE_DSP']; + } + + Map toJson() { + final Map data = new Map(); + data['ALPHANUMERIC_ALLOWED_FLAG'] = this.aLPHANUMERICALLOWEDFLAG; + data['APPLICATION_COLUMN_NAME'] = this.aPPLICATIONCOLUMNNAME; + data['CHILD_SEGMENTS_DV'] = this.cHILDSEGMENTSDV; + data['CHILD_SEGMENTS_DV_Splited'] = this.cHILDSEGMENTSDVSplited; + data['CHILD_SEGMENTS_VS'] = this.cHILDSEGMENTSVS; + data['CHILD_SEGMENTS_VS_Splited'] = this.cHILDSEGMENTSVSSplited; + data['DEFAULT_TYPE'] = this.dEFAULTTYPE; + data['DEFAULT_VALUE'] = this.dEFAULTVALUE; + data['DESC_FLEX_CONTEXT_CODE'] = this.dESCFLEXCONTEXTCODE; + data['DESC_FLEX_CONTEXT_NAME'] = this.dESCFLEXCONTEXTNAME; + data['DESC_FLEX_NAME'] = this.dESCFLEXNAME; + data['DISPLAY_FLAG'] = this.dISPLAYFLAG; + data['ENABLED_FLAG'] = this.eNABLEDFLAG; + if (this.eSERVICESDV != null) { + data['E_SERVICES_DV'] = this.eSERVICESDV!.toJson(); + } + // if (this.eSERVICESVS != null) { + // data['E_SERVICES_VS'] = this.eSERVICESVS!.map((v) => v.toJson()).toList(); + // } + data['FLEX_VALUE_SET_NAME'] = this.fLEXVALUESETNAME; + data['FORMAT_TYPE'] = this.fORMATTYPE; + data['FORMAT_TYPE_DSP'] = this.fORMATTYPEDSP; + data['LONGLIST_FLAG'] = this.lONGLISTFLAG; + data['MAXIMUM_SIZE'] = this.mAXIMUMSIZE; + data['MAXIMUM_VALUE'] = this.mAXIMUMVALUE; + data['MINIMUM_VALUE'] = this.mINIMUMVALUE; + data['MOBILE_ENABLED'] = this.mOBILEENABLED; + data['NUMBER_PRECISION'] = this.nUMBERPRECISION; + data['NUMERIC_MODE_ENABLED_FLAG'] = this.nUMERICMODEENABLEDFLAG; + data['PARENT_SEGMENTS_DV'] = this.pARENTSEGMENTSDV; + // if (this.pARENTSEGMENTSDVSplited != null) { + // data['PARENT_SEGMENTS_DV_Splited'] = + // this.pARENTSEGMENTSDVSplited!.map((v) => v.toJson()).toList(); + // } + data['PARENT_SEGMENTS_VS'] = this.pARENTSEGMENTSVS; + // if (this.pARENTSEGMENTSVSSplitedVS != null) { + // data['PARENT_SEGMENTS_VS_SplitedVS'] = + // this.pARENTSEGMENTSVSSplitedVS!.map((v) => v.toJson()).toList(); + // } + data['READ_ONLY'] = this.rEADONLY; + data['REQUIRED_FLAG'] = this.rEQUIREDFLAG; + data['SEGMENT_NAME'] = this.sEGMENTNAME; + data['SEGMENT_PROMPT'] = this.sEGMENTPROMPT; + data['SEGMENT_SEQ_NUM'] = this.sEGMENTSEQNUM; + data['UPPERCASE_ONLY_FLAG'] = this.uPPERCASEONLYFLAG; + data['USED_FLAG'] = this.uSEDFLAG; + data['VALIDATION_TYPE'] = this.vALIDATIONTYPE; + data['VALIDATION_TYPE_DSP'] = this.vALIDATIONTYPEDSP; + return data; + } +} + +class ESERVICESDV { + String? pIDCOLUMNNAME; + String? pRETURNMSG; + String? pRETURNSTATUS; + String? pVALUECOLUMNNAME; + + ESERVICESDV( + {this.pIDCOLUMNNAME, + this.pRETURNMSG, + this.pRETURNSTATUS, + this.pVALUECOLUMNNAME}); + + ESERVICESDV.fromJson(Map json) { + pIDCOLUMNNAME = json['P_ID_COLUMN_NAME']; + pRETURNMSG = json['P_RETURN_MSG']; + pRETURNSTATUS = json['P_RETURN_STATUS']; + pVALUECOLUMNNAME = json['P_VALUE_COLUMN_NAME']; + } + + Map toJson() { + final Map data = new Map(); + data['P_ID_COLUMN_NAME'] = this.pIDCOLUMNNAME; + data['P_RETURN_MSG'] = this.pRETURNMSG; + data['P_RETURN_STATUS'] = this.pRETURNSTATUS; + data['P_VALUE_COLUMN_NAME'] = this.pVALUECOLUMNNAME; + return data; + } +} diff --git a/lib/models/my_requests/get_ccp_output_model.dart b/lib/models/my_requests/get_ccp_output_model.dart new file mode 100644 index 0000000..3615a26 --- /dev/null +++ b/lib/models/my_requests/get_ccp_output_model.dart @@ -0,0 +1,21 @@ +class GetCCPOutputModel { + String? pOUTPUTFILE; + String? pRETURNMSG; + String? pRETURNSTATUS; + + GetCCPOutputModel({this.pOUTPUTFILE, this.pRETURNMSG, this.pRETURNSTATUS}); + + GetCCPOutputModel.fromJson(Map json) { + pOUTPUTFILE = json['P_OUTPUT_FILE']; + pRETURNMSG = json['P_RETURN_MSG']; + pRETURNSTATUS = json['P_RETURN_STATUS']; + } + + Map toJson() { + final Map data = new Map(); + data['P_OUTPUT_FILE'] = this.pOUTPUTFILE; + data['P_RETURN_MSG'] = this.pRETURNMSG; + data['P_RETURN_STATUS'] = this.pRETURNSTATUS; + return data; + } +} diff --git a/lib/models/my_requests/get_ccp_transactions_model.dart b/lib/models/my_requests/get_ccp_transactions_model.dart new file mode 100644 index 0000000..9b31244 --- /dev/null +++ b/lib/models/my_requests/get_ccp_transactions_model.dart @@ -0,0 +1,32 @@ +class GetCCPTransactionsModel { + String? cCPPHASE; + String? cCPSTATUS; + String? cONCURRENTPROGRAMNAME; + String? rEQUESTDATE; + int? rEQUESTID; + + GetCCPTransactionsModel( + {this.cCPPHASE, + this.cCPSTATUS, + this.cONCURRENTPROGRAMNAME, + this.rEQUESTDATE, + this.rEQUESTID}); + + GetCCPTransactionsModel.fromJson(Map json) { + cCPPHASE = json['CCP_PHASE']; + cCPSTATUS = json['CCP_STATUS']; + cONCURRENTPROGRAMNAME = json['CONCURRENT_PROGRAM_NAME']; + rEQUESTDATE = json['REQUEST_DATE']; + rEQUESTID = json['REQUEST_ID']; + } + + Map toJson() { + final Map data = new Map(); + data['CCP_PHASE'] = this.cCPPHASE; + data['CCP_STATUS'] = this.cCPSTATUS; + data['CONCURRENT_PROGRAM_NAME'] = this.cONCURRENTPROGRAMNAME; + data['REQUEST_DATE'] = this.rEQUESTDATE; + data['REQUEST_ID'] = this.rEQUESTID; + return data; + } +} diff --git a/lib/models/my_requests/get_concurrent_programs_model.dart b/lib/models/my_requests/get_concurrent_programs_model.dart new file mode 100644 index 0000000..65de317 --- /dev/null +++ b/lib/models/my_requests/get_concurrent_programs_model.dart @@ -0,0 +1,24 @@ +class GetConcurrentProgramsModel { + int? cONCURRENTPROGRAMID; + String? cONCURRENTPROGRAMNAME; + String? uSERCONCURRENTPROGRAMNAME; + + GetConcurrentProgramsModel( + {this.cONCURRENTPROGRAMID, + this.cONCURRENTPROGRAMNAME, + this.uSERCONCURRENTPROGRAMNAME}); + + GetConcurrentProgramsModel.fromJson(Map json) { + cONCURRENTPROGRAMID = json['CONCURRENT_PROGRAM_ID']; + cONCURRENTPROGRAMNAME = json['CONCURRENT_PROGRAM_NAME']; + uSERCONCURRENTPROGRAMNAME = json['USER_CONCURRENT_PROGRAM_NAME']; + } + + Map toJson() { + final Map data = new Map(); + data['CONCURRENT_PROGRAM_ID'] = this.cONCURRENTPROGRAMID; + data['CONCURRENT_PROGRAM_NAME'] = this.cONCURRENTPROGRAMNAME; + data['USER_CONCURRENT_PROGRAM_NAME'] = this.uSERCONCURRENTPROGRAMNAME; + return data; + } +} diff --git a/lib/ui/landing/widget/app_drawer.dart b/lib/ui/landing/widget/app_drawer.dart index c19fab7..346f93a 100644 --- a/lib/ui/landing/widget/app_drawer.dart +++ b/lib/ui/landing/widget/app_drawer.dart @@ -49,6 +49,16 @@ class _AppDrawerState extends State { ), onTap: () { drawerNavigator(context, AppRoutes.pendingTransactions); + }), + const Divider(), + InkWell( + child: const DrawerItem( + 'My Requests', + icon: Icons.person, + color: Colors.grey, + ), + onTap: () { + drawerNavigator(context, AppRoutes.myRequests); }) ])) ]))); diff --git a/lib/ui/screens/my_requests/my_requests.dart b/lib/ui/screens/my_requests/my_requests.dart new file mode 100644 index 0000000..82bc38b --- /dev/null +++ b/lib/ui/screens/my_requests/my_requests.dart @@ -0,0 +1,218 @@ +import 'dart:io'; + +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/api/my_requests_api_client.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/date_uitl.dart'; +import 'package:mohem_flutter_app/classes/file_process.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.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_eit_dff_structure_list_model.dart'; +import 'package:mohem_flutter_app/models/my_requests/get_ccp_output_model.dart'; +import 'package:mohem_flutter_app/models/my_requests/get_ccp_transactions_model.dart'; +import 'package:mohem_flutter_app/models/my_requests/get_concurrent_programs_model.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 MyRequests extends StatefulWidget { + const MyRequests({Key? key}) : super(key: key); + + @override + _MyRequestsState createState() => _MyRequestsState(); +} + +class _MyRequestsState extends State { + List getConcurrentProgramsList = []; + GetConcurrentProgramsModel? selectedConcurrentProgramList; + + List getCCPTransactionsList = []; + + bool isNewRequest = false; + + @override + void initState() { + getConcurrentPrograms(); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBarWidget( + context, + title: "Concurrent Reports", + ), + body: Container( + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Column( + children: [ + 12.height, + Container( + padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 0), + margin: const EdgeInsets.only(left: 12, right: 12, top: 0, bottom: 0), + child: PopupMenuButton( + child: DynamicTextFieldWidget( + "Template Name", + selectedConcurrentProgramList?.uSERCONCURRENTPROGRAMNAME ?? "", + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + for (int i = 0; i < getConcurrentProgramsList!.length; i++) PopupMenuItem(child: Text(getConcurrentProgramsList![i].uSERCONCURRENTPROGRAMNAME!), value: i), + ], + onSelected: (int popupIndex) { + selectedConcurrentProgramList = getConcurrentProgramsList![popupIndex]; + getCCPTransactions(selectedConcurrentProgramList?.cONCURRENTPROGRAMNAME); + setState(() {}); + }), + ), + 12.height, + Expanded( + child: ListView.separated( + physics: const BouncingScrollPhysics(), + shrinkWrap: true, + itemBuilder: (BuildContext context, int index) { + return Container( + width: double.infinity, + padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 12), + margin: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 0), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + ("Request ID: " + getCCPTransactionsList[index].rEQUESTID.toString()).toText12(color: MyColors.grey57Color), + DateUtil.formatDateToDate(DateUtil.convertStringToDate(getCCPTransactionsList[index].rEQUESTDATE!), false).toText12(color: MyColors.grey70Color), + ], + ), + Container( + padding: const EdgeInsets.only(top: 10.0), + child: ("Phase: " + getCCPTransactionsList[index].cCPPHASE!).toText12(color: MyColors.grey57Color, isBold: true), + ), + Container( + padding: const EdgeInsets.only(top: 10.0), + child: "Program Name: ".toText12(color: MyColors.grey57Color, isBold: true), + ), + getCCPTransactionsList[index].cONCURRENTPROGRAMNAME!.toText12(color: MyColors.gradiantEndColor), + Container( + padding: const EdgeInsets.only(top: 10.0), + child: InkWell( + onTap: () { + getCCPOutput(getCCPTransactionsList[index].rEQUESTID.toString()); + }, + child: Row( + children: [ + "Output: ".toText12(color: MyColors.grey57Color), + 8.width, + "Open PDF".toText12(color: MyColors.grey57Color), + 6.width, + const Icon(Icons.launch, size: 16.0), + ], + ), + ), + ), + ], + ), + ); + }, + separatorBuilder: (BuildContext context, int index) => 12.height, + itemCount: getCCPTransactionsList.length ?? 0)), + 80.height + ], + ), + ), + bottomSheet: Container( + decoration: const BoxDecoration( + color: MyColors.white, + boxShadow: [ + BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), + ], + ), + child: DefaultButton(LocaleKeys.createRequest.tr(), () async { + openNewRequest(); + }).insideContainer, + )); + } + + void openNewRequest() async { + await Navigator.pushNamed(context, AppRoutes.newRequest).then((value) { + // getOpenTickets(); + }); + } + + void getConcurrentPrograms() async { + try { + Utils.showLoading(context); + getConcurrentProgramsList = await MyRequestsApiClient().getConcurrentPrograms(); + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getCCPTransactions(String? templateName) async { + try { + Utils.showLoading(context); + getCCPTransactionsList = await MyRequestsApiClient().getCCPTransactions(templateName); + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getCCPOutput(String requestID) async { + GetCCPOutputModel getCCPOutputModel; + try { + Utils.showLoading(context); + getCCPOutputModel = await MyRequestsApiClient().getCCPOutput(requestID); + Utils.hideLoading(context); + await FileProcess.downloadFile(getCCPOutputModel.pOUTPUTFILE!, requestID).then((value) { + File file = value; + debugPrint(file.toString()); + FileProcess.openFile(requestID); + }); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } +} diff --git a/lib/ui/screens/my_requests/new_request.dart b/lib/ui/screens/my_requests/new_request.dart new file mode 100644 index 0000000..7e19646 --- /dev/null +++ b/lib/ui/screens/my_requests/new_request.dart @@ -0,0 +1,423 @@ +import 'dart:io'; + +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/api/my_requests_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_eit_dff_structure_list_model.dart'; +import 'package:mohem_flutter_app/models/my_requests/get_concurrent_programs_model.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 NewRequest extends StatefulWidget { + const NewRequest({Key? key}) : super(key: key); + + @override + _NewRequestState createState() => _NewRequestState(); +} + +class _NewRequestState extends State { + List getConcurrentProgramsList = []; + GetConcurrentProgramsModel? selectedConcurrentProgramList; + + List getCCPDFFStructureModelList = []; + + DateTime selectedDate = DateTime.now(); + + @override + void initState() { + getConcurrentPrograms(); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBarWidget( + context, + title: "Concurrent Reports", + ), + body: Container( + child: Column( + children: [ + 12.height, + Container( + padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 0), + margin: const EdgeInsets.only(left: 12, right: 12, top: 0, bottom: 0), + child: PopupMenuButton( + child: DynamicTextFieldWidget( + "Template Name", + selectedConcurrentProgramList?.uSERCONCURRENTPROGRAMNAME ?? "", + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + for (int i = 0; i < getConcurrentProgramsList!.length; i++) PopupMenuItem(child: Text(getConcurrentProgramsList![i].uSERCONCURRENTPROGRAMNAME!), value: i), + ], + onSelected: (int popupIndex) { + selectedConcurrentProgramList = getConcurrentProgramsList![popupIndex]; + getCCPDFFStructure(selectedConcurrentProgramList?.cONCURRENTPROGRAMNAME); + setState(() {}); + }), + ), + (getCCPDFFStructureModelList.isEmpty + ? LocaleKeys.noDataAvailable.tr().toText16().center + : ListView.separated( + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.all(21), + itemBuilder: (cxt, int parentIndex) => parseDynamicFormatType(getCCPDFFStructureModelList[parentIndex], parentIndex), + separatorBuilder: (cxt, index) => 0.height, + itemCount: getCCPDFFStructureModelList.length)) + .expanded + ], + ), + ), + bottomSheet: Container( + decoration: const BoxDecoration( + color: MyColors.white, + boxShadow: [ + BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), + ], + ), + child: DefaultButton(LocaleKeys.submit.tr(), () async { + // openNewRequest(); + }).insideContainer, + ) + ); + } + + void getConcurrentPrograms() async { + try { + Utils.showLoading(context); + getConcurrentProgramsList = await MyRequestsApiClient().getConcurrentPrograms(); + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getCCPDFFStructure(String? templateName) async { + try { + Utils.showLoading(context); + getCCPDFFStructureModelList = await MyRequestsApiClient().getCCPDFFStructure(templateName); + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + Widget parseDynamicFormatType(GetEITDFFStructureList model, int index) { + if (model.dISPLAYFLAG != "N") { + if (model.vALIDATIONTYPE == "N") { + if (model.fORMATTYPE == "C") { + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pIDCOLUMNNAME ?? "", + isReadOnly: model.rEADONLY == "Y", + onChange: (text) { + model.fieldAnswer = text; + if (model.eSERVICESDV == null) { + model.eSERVICESDV = ESERVICESDV(); + } + model.eSERVICESDV!.pIDCOLUMNNAME = text; + }, + ).paddingOnly(bottom: 12); + } else if (model.fORMATTYPE == "N") { + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pIDCOLUMNNAME ?? "", + isReadOnly: model.rEADONLY == "Y", + isInputTypeNum: true, + onChange: (text) { + model.fieldAnswer = text; + if (model.eSERVICESDV == null) { + model.eSERVICESDV = ESERVICESDV(); + } + model.eSERVICESDV!.pIDCOLUMNNAME = text; + }, + ).paddingOnly(bottom: 12); + } else if (model.fORMATTYPE == "X") { + String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? (getCCPDFFStructureModelList![index].fieldAnswer ?? ""); + if (getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS) { + if (displayText.contains(" 00:00:00")) { + displayText = displayText.replaceAll(" 00:00:00", ""); + } + if (!displayText.contains("-")) { + displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); + } + } + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + displayText, + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + if ((getCCPDFFStructureModelList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + if (getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS) { + selectedDate = DateFormat("yyyy/MM/dd").parse(getCCPDFFStructureModelList![index].eSERVICESDV!.pVALUECOLUMNNAME!.replaceAll('/"', '').replaceAll(" 00:00:00", "")); + } else { + selectedDate = DateTime.parse(getCCPDFFStructureModelList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + } + } + DateTime date = await _selectDate(context); + DateTime date1 = DateTime(date.year, date.month, date.day); + // getEitDffStructureList![index].fieldAnswer = date.toString(); + ESERVICESDV eservicesdv; + if (getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS) { + eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: DateFormat('yyyy/MM/dd HH:MM:SS').format(date1), + pRETURNMSG: "null", + pRETURNSTATUS: getCCPDFFStructureModelList![index].dEFAULTVALUE, + pVALUECOLUMNNAME: getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS ? DateFormat('yyyy/MM/dd HH:MM:SS').format(date) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + } else { + eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: DateFormat('yyyy-MM-dd').format(date1), + pRETURNMSG: "null", + pRETURNSTATUS: getCCPDFFStructureModelList![index].dEFAULTVALUE, + pVALUECOLUMNNAME: getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS ? DateFormat('yyyy-MM-dd hh:mm:ss').format(date) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + } + getCCPDFFStructureModelList![index].eSERVICESDV = eservicesdv; + setState(() {}); + if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // calGetValueSetValues(model); + } + }, + ).paddingOnly(bottom: 12); + } else if (model.fORMATTYPE == "Y") { + String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? (getCCPDFFStructureModelList![index].fieldAnswer ?? ""); + if (getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS) { + if (displayText.contains(" 00:00:00")) { + displayText = displayText.replaceAll(" 00:00:00", ""); + } + if (!displayText.contains("-")) { + displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); + } + } + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + displayText, + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + if ((getCCPDFFStructureModelList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + if (getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS) { + String tempDate = getCCPDFFStructureModelList![index].eSERVICESDV!.pVALUECOLUMNNAME!; + if (tempDate.contains("00:00:00")) { + tempDate = tempDate.replaceAll("00:00:00", '').trim(); + } + selectedDate = DateFormat("yyyy/MM/dd").parse(tempDate); + } else { + selectedDate = DateTime.parse(getCCPDFFStructureModelList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + } + } + DateTime date = await _selectDate(context); + DateTime date1 = DateTime(date.year, date.month, date.day); + // getEitDffStructureList![index].fieldAnswer = date.toString(); + ESERVICESDV eservicesdv; + if (getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS) { + eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: DateFormat('yyyy/MM/dd HH:MM:SS').format(date1), + pRETURNMSG: "null", + pRETURNSTATUS: getCCPDFFStructureModelList![index].dEFAULTVALUE, + pVALUECOLUMNNAME: getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS ? DateFormat('yyyy-MM-dd HH:MM:SS').format(date) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + } else { + eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: DateFormat('yyyy-MM-dd').format(date1), + pRETURNMSG: "null", + pRETURNSTATUS: getCCPDFFStructureModelList![index].dEFAULTVALUE, + pVALUECOLUMNNAME: getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS ? DateFormat('yyyy-MM-dd hh:mm:ss').format(date) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + } + + getCCPDFFStructureModelList![index].eSERVICESDV = eservicesdv; + setState(() {}); + if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + if (getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS) { + // calGetValueSetValues(model); + } else {} + } + }, + ).paddingOnly(bottom: 12); + } + } else { + return PopupMenuButton( + child: DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pVALUECOLUMNNAME ?? "", + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: model.rEADONLY == "Y", + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + for (int i = 0; i < model.eSERVICESVS!.length; i++) PopupMenuItem(child: Text(model.eSERVICESVS![i].vALUECOLUMNNAME!), value: i), + ], + onSelected: (int popipIndex) { + ESERVICESDV eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: model.eSERVICESVS![popipIndex].iDCOLUMNNAME, + pRETURNMSG: "null", + pRETURNSTATUS: getCCPDFFStructureModelList![popipIndex].dEFAULTVALUE, + pVALUECOLUMNNAME: model.eSERVICESVS![popipIndex].vALUECOLUMNNAME); + getCCPDFFStructureModelList![index].eSERVICESDV = eservicesdv; + setState(() {}); + if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // getDefaultValues(model); + } + }); + } + } else { + return const SizedBox(); + } + if (model.fORMATTYPE == "N") { + if (model.eSERVICESVS?.isNotEmpty ?? false) { + return PopupMenuButton( + child: DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pVALUECOLUMNNAME ?? "", + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: model.rEADONLY == "Y", + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + for (int i = 0; i < model.eSERVICESVS!.length; i++) PopupMenuItem(child: Text(model.eSERVICESVS![i].vALUECOLUMNNAME!), value: i), + ], + onSelected: (int popipIndex) { + ESERVICESDV eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: model.eSERVICESVS![popipIndex].iDCOLUMNNAME, + pRETURNMSG: "null", + pRETURNSTATUS: getCCPDFFStructureModelList![popipIndex].dEFAULTVALUE, + pVALUECOLUMNNAME: model.eSERVICESVS![popipIndex].vALUECOLUMNNAME); + getCCPDFFStructureModelList![index].eSERVICESDV = eservicesdv; + setState(() {}); + if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // getDefaultValues(model); + } + }); + } + + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pIDCOLUMNNAME ?? "", + isReadOnly: model.rEADONLY == "Y", + onChange: (text) { + model.fieldAnswer = text; + }, + ).paddingOnly(bottom: 12); + } else if (model.fORMATTYPE == "X" || model.fORMATTYPE == "Y") { + String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? (getCCPDFFStructureModelList![index].fieldAnswer ?? ""); + if (getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS) { + if (displayText.contains(" 00:00:00")) { + displayText = displayText.replaceAll(" 00:00:00", ""); + } + if (!displayText.contains("-")) { + displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); + } + } + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + displayText, + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + if ((getCCPDFFStructureModelList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + if (getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS) { + selectedDate = DateFormat("yyyy/MM/dd").parse(getCCPDFFStructureModelList![index].eSERVICESDV!.pVALUECOLUMNNAME!.replaceAll('/"', '').replaceAll(" 00:00:00", "")); + } else { + selectedDate = DateTime.parse(getCCPDFFStructureModelList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + } + } + DateTime date = await _selectDate(context); + DateTime date1 = DateTime(date.year, date.month, date.day); + getCCPDFFStructureModelList![index].fieldAnswer = date.toString(); + ESERVICESDV eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: DateFormat('yyyy-MM-dd').format(date1), + pRETURNMSG: "null", + pRETURNSTATUS: getCCPDFFStructureModelList![index].dEFAULTVALUE, + pVALUECOLUMNNAME: getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS ? DateFormat('yyyy-MM-dd hh:mm:ss').format(date) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + getCCPDFFStructureModelList![index].eSERVICESDV = eservicesdv; + setState(() {}); + if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // calGetValueSetValues(model); + } + }, + ).paddingOnly(bottom: 12); + } else if (model.fORMATTYPE == "I") { + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pIDCOLUMNNAME ?? (getCCPDFFStructureModelList![index].fieldAnswer ?? ""), + suffixIconData: Icons.access_time_filled_rounded, + isEnable: false, + onTap: () async { + if ((getCCPDFFStructureModelList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + var timeString = getCCPDFFStructureModelList![index].eSERVICESDV!.pVALUECOLUMNNAME!.split(":"); + selectedDate = DateTime(0, 0, 0, int.parse(timeString[0]), int.parse(timeString[1])); + + //DateTime.parse(getEitDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + } + // TimeOfDay _time = await _selectTime(context); + // DateTime tempTime = DateTime(0, 1, 1, _time.hour, _time.minute); + // String time = DateFormat('HH:mm').format(tempTime).trim(); + + // DateTime date1 = DateTime(date.year, date.month, date.day); + // getEitDffStructureList![index].fieldAnswer = date.toString(); + // ESERVICESDV eservicesdv = ESERVICESDV(pIDCOLUMNNAME: time, pRETURNMSG: "null", pRETURNSTATUS: getEitDffStructureList![index].dEFAULTVALUE, pVALUECOLUMNNAME: time); + // getCCPDFFStructureModelList![index].eSERVICESDV = eservicesdv; + setState(() {}); + if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // getCCPDFFStructureModelList(model); + } + }, + ).paddingOnly(bottom: 12); + } + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [], + ).objectContainerView(); + } + + Future _selectDate(BuildContext context) async { + DateTime time = selectedDate; + if (Platform.isIOS) { + await showCupertinoModalPopup( + context: context, + builder: (cxt) => Container( + height: 250, + color: Colors.white, + child: CupertinoDatePicker( + backgroundColor: Colors.white, + mode: CupertinoDatePickerMode.date, + onDateTimeChanged: (value) { + if (value != null && value != selectedDate) { + time = value; + } + }, + initialDateTime: selectedDate, + ), + ), + ); + } else { + final DateTime? picked = + await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); + if (picked != null && picked != selectedDate) { + time = picked; + } + } + return time; + } +} From 3fcbd9946a7fd008946a89ad4635d235dd13c58b Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 16 Aug 2022 12:04:28 +0300 Subject: [PATCH 05/40] configs for ios. --- ios/Runner.xcodeproj/project.pbxproj | 37 ++++++++++++++++--- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- ios/Runner/Info.plist | 2 + lib/main.dart | 3 +- lib/models/profile_menu.model.dart | 4 +- lib/ui/landing/dashboard_screen.dart | 4 +- lib/ui/login/login_screen.dart | 8 ++-- .../dynamic_screens/dynamic_input_screen.dart | 5 +-- 8 files changed, 47 insertions(+), 18 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 7ca764b..f6164da 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ @@ -140,6 +140,7 @@ 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, AAF25E5FC427CABFCDCC628C /* [CP] Embed Pods Frameworks */, + 8E1FBB2EA6B3AEDD9488054A /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -156,7 +157,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -234,6 +235,23 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + 8E1FBB2EA6B3AEDD9488054A /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -358,7 +376,10 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mohemFlutterApp; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -482,7 +503,10 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mohemFlutterApp; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -501,7 +525,10 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mohemFlutterApp; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140c..3db53b6 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + diff --git a/lib/main.dart b/lib/main.dart index cd00082..b1e74db 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,7 @@ import 'dart:io'; import 'package:easy_localization/easy_localization.dart'; -import 'package:firebase_core/firebase_core.dart'; + import 'package:flutter/material.dart'; import 'package:logger/logger.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; @@ -24,7 +24,6 @@ var logger = Logger( Future main() async { WidgetsFlutterBinding.ensureInitialized(); await EasyLocalization.ensureInitialized(); - await Firebase.initializeApp(); AppState().setPostParamsModel( PostParamsModel(channel: 31, versionID: 5.0, mobileType: Platform.isAndroid ? "android" : "ios"), ); diff --git a/lib/models/profile_menu.model.dart b/lib/models/profile_menu.model.dart index c1b77b7..7005c88 100644 --- a/lib/models/profile_menu.model.dart +++ b/lib/models/profile_menu.model.dart @@ -1,6 +1,3 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - class ProfileMenu { final String name; final String icon; @@ -8,5 +5,6 @@ class ProfileMenu { final String dynamicUrl; final String functionName; final String requestID; + ProfileMenu({this.name = '', this.icon = '', this.route = '', this.dynamicUrl = '', this.functionName = '', this.requestID = ''}); } diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 2e7e769..4406a4d 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -324,7 +326,7 @@ class _DashboardScreenState extends State { child: AppDrawer(), ), bottomNavigationBar: SizedBox( - height: 70, + height: Platform.isAndroid ? 70 : 100, child: BottomNavigationBar( items: [ BottomNavigationBarItem( diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index d02fd74..a2ef87a 100644 --- a/lib/ui/login/login_screen.dart +++ b/lib/ui/login/login_screen.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/src/public_ext.dart'; +import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -23,7 +24,6 @@ import 'package:mohem_flutter_app/models/member_login_list_model.dart'; import 'package:mohem_flutter_app/models/privilege_list_model.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:mohem_flutter_app/widgets/input_widget.dart'; -import 'package:shared_preferences/shared_preferences.dart'; class LoginScreen extends StatefulWidget { LoginScreen({Key? key}) : super(key: key); @@ -41,7 +41,7 @@ class _LoginScreenState extends State { CheckMobileAppVersionModel? _checkMobileAppVersion; MemberLoginListModel? _memberLoginList; - final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance; + late final FirebaseMessaging _firebaseMessaging; bool _autoLogin = false; @@ -75,6 +75,8 @@ class _LoginScreenState extends State { Future checkFirebaseToken() async { try { Utils.showLoading(context); + await Firebase.initializeApp(); + _firebaseMessaging = FirebaseMessaging.instance; firebaseToken = await _firebaseMessaging.getToken(); loginInfo = await LoginApiClient().getMobileLoginInfoNEW(firebaseToken ?? "", Platform.isAndroid ? "android" : "ios"); if (loginInfo == null) { @@ -88,7 +90,7 @@ class _LoginScreenState extends State { } } catch (ex) { Utils.hideLoading(context); - Utils.handleException(ex, context, null); + Utils.handleException(ex, context, (errorMsg){}); } } diff --git a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart index a88e041..051d72a 100644 --- a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart +++ b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart @@ -176,7 +176,6 @@ class _DynamicInputScreenState extends State { List> getDefaultValuesIonicLogic(GetEITDFFStructureList structureElement) { try { - Utils.showLoading(context); List parentValue = structureElement.pARENTSEGMENTSVSSplitedVS ?? []; List parentsList = structureElement.pARENTSEGMENTSDVSplited ?? []; @@ -718,7 +717,7 @@ class _DynamicInputScreenState extends State { Future _selectDate(BuildContext context) async { DateTime time = selectedDate; - if (!Platform.isIOS) { + if (Platform.isIOS) { await showCupertinoModalPopup( context: context, builder: (cxt) => Container( @@ -749,7 +748,7 @@ class _DynamicInputScreenState extends State { Future _selectTime(BuildContext context) async { TimeOfDay time = TimeOfDay(hour: selectedDate.hour, minute: selectedDate.minute); - if (!Platform.isIOS) { + if (Platform.isIOS) { await showCupertinoModalPopup( context: context, builder: (cxt) => Container( From 4edb19c2bb214f76ed86c3aa70ead8c1cd91958e Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 16 Aug 2022 16:07:51 +0300 Subject: [PATCH 06/40] Vacation rule added cont. --- lib/classes/colors.dart | 3 + lib/extensions/widget_extensions.dart | 3 +- lib/models/generic_response_model.dart | 9 +- .../attendance/add_vacation_rule_screen.dart | 245 +++++++++++++++++- lib/ui/work_list/sheets/delegate_sheet.dart | 34 +-- .../work_list/sheets/selected_item_sheet.dart | 8 +- lib/widgets/bottom_sheet.dart | 12 +- .../search_employee_bottom_sheet.dart | 224 ++++++++++++++++ .../dynamic_textfield_widget.dart | 5 +- 9 files changed, 494 insertions(+), 49 deletions(-) create mode 100644 lib/widgets/bottom_sheets/search_employee_bottom_sheet.dart diff --git a/lib/classes/colors.dart b/lib/classes/colors.dart index 4b34186..e37a049 100644 --- a/lib/classes/colors.dart +++ b/lib/classes/colors.dart @@ -22,11 +22,14 @@ class MyColors { static const Color darkWhiteColor = Color(0xffE0E0E0); static const Color redColor = Color(0xffD02127); static const Color yellowColor = Color(0xffF4E31C); + static const Color yellowFavColor = Color(0xffEAC321); static const Color backgroundBlackColor = Color(0xff202529); static const Color black = Color(0xff000000); static const Color white = Color(0xffffffff); static const Color green = Color(0xffffffff); static const Color borderColor = Color(0xffE8E8E8); + static const Color borderE3Color = Color(0xffE3E3E3); + static const Color borderCEColor = Color(0xffCECECE); //static const Color grey67Color = Color(0xff676767); static const Color whiteColor = Color(0xFFEEEEEE); static const Color greenColor = Color(0xff1FA269); diff --git a/lib/extensions/widget_extensions.dart b/lib/extensions/widget_extensions.dart index bbe50b4..247cde5 100644 --- a/lib/extensions/widget_extensions.dart +++ b/lib/extensions/widget_extensions.dart @@ -41,7 +41,7 @@ extension WidgetExtensions on Widget { child: this, ); - Widget objectContainerView({String title = ""}) { + Widget objectContainerView({String title = "", String note = ""}) { return Container( padding: const EdgeInsets.only(top: 15, bottom: 15, left: 14, right: 14), decoration: BoxDecoration( @@ -62,6 +62,7 @@ extension WidgetExtensions on Widget { if (title.isNotEmpty) title.toText16(), if (title.isNotEmpty) 12.height, this, + if (note.isNotEmpty) note.toText11(), ], ), ); diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index 782fb7c..1260d80 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -294,7 +294,7 @@ class GenericResponseModel { String? registerUserNameList; List? replacementList; List? respondAttributesList; - String? respondRolesList; + List? respondRolesList; String? resubmitAbsenceTransactionList; String? resubmitEITTransactionList; String? resubmitHrTransactionList; @@ -1163,7 +1163,12 @@ class GenericResponseModel { respondAttributesList!.add(new RespondAttributesList.fromJson(v)); }); } - respondRolesList = json['RespondRolesList']; + if (json['RespondRolesList'] != null) { + respondRolesList = []; + json['RespondRolesList'].forEach((v) { + respondRolesList!.add(v); + }); + } resubmitAbsenceTransactionList = json['ResubmitAbsenceTransactionList']; resubmitEITTransactionList = json['ResubmitEITTransactionList']; resubmitHrTransactionList = json['ResubmitHrTransactionList']; diff --git a/lib/ui/attendance/add_vacation_rule_screen.dart b/lib/ui/attendance/add_vacation_rule_screen.dart index b3c3780..a76e65a 100644 --- a/lib/ui/attendance/add_vacation_rule_screen.dart +++ b/lib/ui/attendance/add_vacation_rule_screen.dart @@ -1,7 +1,11 @@ +import 'dart:io'; + import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/vacation_rule_api_client.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/extensions/int_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/vacation_rule/get_item_type_notifications_list_model.dart'; @@ -9,8 +13,13 @@ import 'package:mohem_flutter_app/models/vacation_rule/get_notification_reassign import 'package:mohem_flutter_app/models/vacation_rule/respond_attributes_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/vr_item_types_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/wf_look_up_list_model.dart'; +import 'package:mohem_flutter_app/models/worklist/replacement_list_model.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; +import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; +import 'package:mohem_flutter_app/widgets/bottom_sheets/search_employee_bottom_sheet.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; +import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; +import 'package:mohem_flutter_app/widgets/item_detail_view_widget.dart'; class AddVacationRuleScreen extends StatefulWidget { AddVacationRuleScreen({Key? key}) : super(key: key); @@ -23,14 +32,24 @@ class AddVacationRuleScreen extends StatefulWidget { class _AddVacationRuleScreenState extends State { List? vrItemTypesList; + VrItemTypesList? selectedItemType; + List? itemTypeNotificationsList; + GetItemTypeNotificationsList? selectedItemTypeNotification; List? notificationReassignModeList; + GetNotificationReassignModeList? notificationReassignMode; + List? respondAttributesList; List? wfLookupList; + ReplacementList? selectedReplacementEmployee; + int currentStage = 0; + DateTime startTime = DateTime.now(); + DateTime? endTime; + @override void initState() { super.initState(); @@ -53,7 +72,8 @@ class _AddVacationRuleScreenState extends State { void getItemTypeNotificationsList() async { try { Utils.showLoading(context); - //itemTypeNotificationsList = await VacationRuleApiClient().getItemTypeNotifications(); + itemTypeNotificationsList = await VacationRuleApiClient().getItemTypeNotifications(selectedItemType!.iTEMTYPE!); + itemTypeNotificationsList!.insert(0, GetItemTypeNotificationsList(nOTIFICATIONDISPLAYNAME: "All", nOTIFICATIONNAME: "*", fYIFLAG: "N")); Utils.hideLoading(context); currentStage = 2; setState(() {}); @@ -67,13 +87,31 @@ class _AddVacationRuleScreenState extends State { try { Utils.showLoading(context); List results = await Future.wait([ - // VacationRuleApiClient().getNotificationReassignMode(), - // VacationRuleApiClient().getRespondAttributes("", ""), + VacationRuleApiClient().getNotificationReassignMode(), + VacationRuleApiClient().getRespondAttributes(selectedItemType!.iTEMTYPE!, selectedItemTypeNotification!.nOTIFICATIONNAME!), // VacationRuleApiClient().getWfLookup(P_LOOKUP_TYPE), ]); notificationReassignModeList = results[0]; + if (selectedItemType!.iTEMTYPE != "*") { + notificationReassignModeList!.add( + GetNotificationReassignModeList( + rADIOBUTTONLABEL: "Deliver notifications to me regardless of any general rules", + rADIOBUTTONACTION: "deliver_notification", + rADIOBUTTONSEQ: 1, + ), + ); + } + if (selectedItemTypeNotification!.fYIFLAG == "Y") { + notificationReassignModeList!.add( + GetNotificationReassignModeList( + rADIOBUTTONLABEL: "Close", + rADIOBUTTONACTION: "close", + rADIOBUTTONSEQ: 1, + ), + ); + } respondAttributesList = results[1]; - wfLookupList = results[2]; + // wfLookupList = results[2]; Utils.hideLoading(context); currentStage = 3; setState(() {}); @@ -94,7 +132,7 @@ class _AddVacationRuleScreenState extends State { backgroundColor: Colors.white, appBar: AppBarWidget( context, - title: LocaleKeys.vacationRule.tr(), + title: LocaleKeys.vacationRule.tr(), // todo @Sikander change title to 'Vacation Type' ), body: vrItemTypesList == null ? const SizedBox() @@ -105,20 +143,199 @@ class _AddVacationRuleScreenState extends State { ListView( padding: const EdgeInsets.all(21), physics: const BouncingScrollPhysics(), - children: [], + children: [ + if (vrItemTypesList!.isNotEmpty) + PopupMenuButton( + child: DynamicTextFieldWidget( + LocaleKeys.itemType.tr(), + selectedItemType == null ? "Select Type" : selectedItemType!.iTEMTYPEDISPLAYNAME!, + isEnable: false, + isPopup: true, + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + for (int i = 0; i < vrItemTypesList!.length; i++) PopupMenuItem(value: i, child: Text(vrItemTypesList![i].iTEMTYPEDISPLAYNAME!)), + ], + onSelected: (int popupIndex) { + if (selectedItemType == vrItemTypesList![popupIndex]) { + return; + } + selectedItemType = vrItemTypesList![popupIndex]; + setState(() {}); + if (selectedItemType!.iTEMTYPE == "*") { + selectedItemTypeNotification = GetItemTypeNotificationsList(nOTIFICATIONDISPLAYNAME: "All", nOTIFICATIONNAME: "*", fYIFLAG: "N"); + itemTypeNotificationsList = null; + notificationReassignMode = null; + callCombineApis(); + } else { + selectedItemTypeNotification = null; + notificationReassignMode = null; + getItemTypeNotificationsList(); + } + }).objectContainerView(title: "Apply for Vacation Rule\nStep 1", note: "*If All is selected, you will skip to step 3"), + if ((itemTypeNotificationsList ?? []).isNotEmpty) ...[ + 12.height, + PopupMenuButton( + child: DynamicTextFieldWidget( + "Notification", + selectedItemTypeNotification == null ? "Select Notification" : selectedItemTypeNotification!.nOTIFICATIONDISPLAYNAME!, + isEnable: false, + isPopup: true, + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + for (int i = 0; i < itemTypeNotificationsList!.length; i++) PopupMenuItem(value: i, child: Text(itemTypeNotificationsList![i].nOTIFICATIONDISPLAYNAME!)), + ], + onSelected: (int popupIndex) { + if (selectedItemTypeNotification == itemTypeNotificationsList![popupIndex]) { + return; + } + selectedItemTypeNotification = itemTypeNotificationsList![popupIndex]; + notificationReassignMode = null; + setState(() {}); + callCombineApis(); + }).objectContainerView(title: "Step 2") + ], + if (selectedItemType != null && selectedItemTypeNotification != null && currentStage == 3) ...[ + 12.height, + Column( + children: [ + ItemDetailView(LocaleKeys.itemType.tr(), selectedItemType!.iTEMTYPEDISPLAYNAME!), + ItemDetailView("Notification", selectedItemTypeNotification!.nOTIFICATIONDISPLAYNAME!), + 12.height, + DynamicTextFieldWidget( + "Start Date", + formattedDate(startTime), + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + var start = await _selectDateTime(context, startTime); + if (start != startTime) { + startTime = start; + setState(() {}); + } + }, + ), + 12.height, + DynamicTextFieldWidget( + "End Date", + formattedDate(endTime), + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + var end = await _selectDateTime(context, endTime ?? startTime); + if (end != endTime) { + endTime = end; + setState(() {}); + } + }, + ), + 12.height, + DynamicTextFieldWidget( + "Message", + "Write a message", + lines: 2, + onChange: (message) {}, + // isEnable: false, + // isPopup: true, + ).paddingOnly(bottom: 12), + PopupMenuButton( + child: DynamicTextFieldWidget( + "Notification Reassign", + notificationReassignMode == null ? "Select Notification" : notificationReassignMode!.rADIOBUTTONLABEL ?? "", + isEnable: false, + isPopup: true, + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + for (int i = 0; i < notificationReassignModeList!.length; i++) PopupMenuItem(value: i, child: Text(notificationReassignModeList![i].rADIOBUTTONLABEL!)), + ], + onSelected: (int popupIndex) { + if (notificationReassignMode == notificationReassignModeList![popupIndex]) { + return; + } + notificationReassignMode = notificationReassignModeList![popupIndex]; + setState(() {}); + }), + DynamicTextFieldWidget( + "Select Employee", + selectedReplacementEmployee == null ? "Search employee for replacement" : selectedReplacementEmployee!.employeeDisplayName ?? "", + isEnable: false, + onTap: () { + showMyBottomSheet( + context, + child: SearchEmployeeBottomSheet( + title: "Search for Employee", + apiMode: "DELEGATE", + onSelectEmployee: (_selectedEmployee) { + // Navigator.pop(context); + selectedReplacementEmployee = _selectedEmployee; + setState(() {}); + }, + ), + ); + }, + ).paddingOnly(bottom: 12), + ], + ).objectContainerView(title: "Step 3") + ] + ], ).expanded, DefaultButton( - currentStage == 3 ? LocaleKeys.apply.tr() : LocaleKeys.next.tr(), - () { - if (currentStage == 1) { - getItemTypeNotificationsList(); - } else if (currentStage == 2) { - callCombineApis(); - } - }, + LocaleKeys.apply.tr(), + currentStage != 3 + ? null + : () { + if (currentStage == 1) { + getItemTypeNotificationsList(); + } else if (currentStage == 2) { + callCombineApis(); + } + }, ).insideContainer, ], )), ); } + + Future _selectDateTime(BuildContext context, DateTime _time) async { + DateTime time = _time; + if (Platform.isIOS) { + await showCupertinoModalPopup( + context: context, + builder: (cxt) => Container( + height: 250, + color: Colors.white, + child: CupertinoDatePicker( + backgroundColor: Colors.white, + mode: CupertinoDatePickerMode.dateAndTime, + onDateTimeChanged: (value) { + if (value != _time) { + time = value; + } + }, + initialDateTime: _time, + ), + ), + ); + } else { + final DateTime? picked = await showDatePicker(context: context, initialDate: _time, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); + final TimeOfDay? timePicked = await showTimePicker( + context: context, + initialTime: TimeOfDay.fromDateTime(picked!), + ); + if (picked != _time || timePicked != TimeOfDay.fromDateTime(picked)) { + time = picked; + time = time.add( + Duration( + hours: timePicked!.hour, + minutes: timePicked.minute, + ), + ); + } + } + return time; + } + + String formattedDate(DateTime? _time) { + if (_time == null) return "Select date and time"; + return DateFormat("MM/dd/yyyy hh:mm:ss a").format(_time); + } } diff --git a/lib/ui/work_list/sheets/delegate_sheet.dart b/lib/ui/work_list/sheets/delegate_sheet.dart index 1923c27..55483bf 100644 --- a/lib/ui/work_list/sheets/delegate_sheet.dart +++ b/lib/ui/work_list/sheets/delegate_sheet.dart @@ -109,14 +109,14 @@ class _DelegateSheetState extends State { Expanded( child: SingleChildScrollView( child: Padding( - padding: EdgeInsets.all(21), + padding: const EdgeInsets.all(21), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - widget.title.toText24(), - 24.height, + widget.title.toText24(isBold: true), + 21.height, "Search".toText16(), - 20.height, + 11.height, Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ @@ -148,7 +148,7 @@ class _DelegateSheetState extends State { ), ), Container( - height: 24, + height: 36, width: 1, color: Color(0xffE5E5E5), ), @@ -156,17 +156,9 @@ class _DelegateSheetState extends State { padding: EdgeInsets.all(8), child: Row( children: [ - Text( - selectedType, - style: const TextStyle( - fontSize: 11, - fontWeight: FontWeight.w600, - color: Color(0xff2B353E), - letterSpacing: -0.44, - ), - ), + selectedType.toText12(), 4.width, - Icon( + const Icon( Icons.keyboard_arrow_down, color: Colors.black, size: 16, @@ -269,7 +261,7 @@ class _DelegateSheetState extends State { }, separatorBuilder: (context, index) { return Container( - color: MyColors.borderColor, + color: MyColors.borderE3Color, width: double.infinity, height: 1, margin: EdgeInsets.only(top: 8, bottom: 8), @@ -286,7 +278,7 @@ class _DelegateSheetState extends State { }, separatorBuilder: (context, index) { return Container( - color: MyColors.borderColor, + color: MyColors.borderE3Color, width: double.infinity, height: 1, margin: EdgeInsets.only(top: 8, bottom: 8), @@ -371,11 +363,11 @@ class _DelegateSheetState extends State { width: 30, isImageBase64: true, ), - 16.width, - Expanded( - child: (actionHistory.nAME ?? "").toText12(), - ), + 9.width, + (actionHistory.nAME ?? "").toText12().expanded, IconButton( + padding: EdgeInsets.zero, + constraints: const BoxConstraints(), onPressed: () { actionHistory.isFavorite = true; fetchChangeFav( diff --git a/lib/ui/work_list/sheets/selected_item_sheet.dart b/lib/ui/work_list/sheets/selected_item_sheet.dart index aadec34..2d37d06 100644 --- a/lib/ui/work_list/sheets/selected_item_sheet.dart +++ b/lib/ui/work_list/sheets/selected_item_sheet.dart @@ -37,12 +37,12 @@ class SelectedItemSheet extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - title.toText24(), - 24.height, + title.toText24(isBold: true), + 21.height, if (actionHistoryList != null) showItem(actionHistoryList!.nAME, actionHistoryList!.isFavorite), if (favoriteReplacements != null) showItem(favoriteReplacements!.employeeDisplayName, true), if (replacementList != null) showItem(replacementList!.employeeDisplayName, replacementList!.isFavorite), - 12.height, + 14.height, InputWidget( "Enter a note", "This is simple note", @@ -61,7 +61,7 @@ class SelectedItemSheet extends StatelessWidget { Container( width: double.infinity, height: 1, - color: MyColors.borderColor, + color: MyColors.borderE3Color, ), Row( children: [ diff --git a/lib/widgets/bottom_sheet.dart b/lib/widgets/bottom_sheet.dart index d151afc..206d017 100644 --- a/lib/widgets/bottom_sheet.dart +++ b/lib/widgets/bottom_sheet.dart @@ -8,11 +8,11 @@ void showMyBottomSheet(BuildContext context, {required Widget child}) { backgroundColor: Colors.transparent, builder: (BuildContext context) { return Container( - decoration: BoxDecoration( + decoration: const BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( - topRight: Radius.circular(24), - topLeft: Radius.circular(24), + topRight: Radius.circular(25), + topLeft: Radius.circular(25), ), ), clipBehavior: Clip.antiAlias, @@ -20,12 +20,12 @@ void showMyBottomSheet(BuildContext context, {required Widget child}) { mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - 8.height, + 13.height, Container( height: 6, width: 60, - decoration: BoxDecoration( - color: Colors.grey[200], + decoration: const BoxDecoration( + color: Color(0xff9A9A9A), borderRadius: BorderRadius.all( Radius.circular(20), ), diff --git a/lib/widgets/bottom_sheets/search_employee_bottom_sheet.dart b/lib/widgets/bottom_sheets/search_employee_bottom_sheet.dart new file mode 100644 index 0000000..9aabbb7 --- /dev/null +++ b/lib/widgets/bottom_sheets/search_employee_bottom_sheet.dart @@ -0,0 +1,224 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:mohem_flutter_app/api/worklist/worklist_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_action_history_list_model.dart'; +import 'package:mohem_flutter_app/models/worklist/get_favorite_replacements_model.dart'; +import 'package:mohem_flutter_app/models/worklist/replacement_list_model.dart'; +import 'package:mohem_flutter_app/widgets/button/default_button.dart'; +import 'package:mohem_flutter_app/widgets/circular_avatar.dart'; +import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; + +class SearchEmployeeBottomSheet extends StatefulWidget { + int? notificationID; + String title, apiMode; + List? actionHistoryList; + Function(ReplacementList) onSelectEmployee; + + SearchEmployeeBottomSheet({required this.title, required this.apiMode, this.notificationID, this.actionHistoryList, required this.onSelectEmployee}); + + @override + State createState() => _SearchEmployeeBottomSheetState(); +} + +class _SearchEmployeeBottomSheetState extends State { + TextEditingController username = TextEditingController(); + String searchText = ""; + + List? optionsList = [ + LocaleKeys.fullName.tr(), + LocaleKeys.username.tr(), + LocaleKeys.endDate.tr(), + ]; + List? favUsersList; + + List? replacementList; + List? favouriteUserList; + List? nonFavouriteUserList; + + int _selectedSearchIndex = 0; + + void fetchUserByInput({bool isNeedLoading = true}) async { + try { + Utils.showLoading(context); + replacementList = await WorkListApiClient().searchUserByInput( + userName: _selectedSearchIndex == 0 ? searchText : "", + userId: _selectedSearchIndex == 1 ? searchText : "", + email: _selectedSearchIndex == 2 ? searchText : "", + ); + favouriteUserList = replacementList?.where((element) => element.isFavorite ?? false).toList(); + nonFavouriteUserList = replacementList?.where((element) => !(element.isFavorite ?? false)).toList(); + Utils.hideLoading(context); + setState(() {}); + } catch (e) { + Utils.hideLoading(context); + Utils.handleException(e, context, null); + } + + if (isNeedLoading) Utils.hideLoading(context); + setState(() {}); + return null; + } + + @override + Widget build(BuildContext context) { + return SizedBox( + width: double.infinity, + height: MediaQuery.of(context).size.height - 100, + child: Column( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + widget.title.toText24(isBold: true), + 21.height, + "Search".toText16(), + 11.height, + Row( + children: [ + radioOption("Name", 0, _selectedSearchIndex), + radioOption("User Name", 1, _selectedSearchIndex), + radioOption("Email", 2, _selectedSearchIndex), + ], + ), + 14.height, + Row( + children: [ + DynamicTextFieldWidget( + "Search", + "Search By Username", + inputAction: TextInputAction.done, + suffixIconData: Icons.search, + onChange: (text) { + searchText = text; + setState(() {}); + }, + ).expanded, + IconButton( + constraints: const BoxConstraints(), + onPressed: () async { + await SystemChannels.textInput.invokeMethod('TextInput.hide'); + fetchUserByInput(); + }, + icon: Icon(Icons.search)) + ], + ), + if (replacementList != null) + replacementList!.isEmpty + ? Utils.getNoDataWidget(context).expanded + : ListView( + physics: const BouncingScrollPhysics(), + padding: EdgeInsets.only(top: 21, bottom: 8), + children: [ + if (favouriteUserList?.isNotEmpty ?? false) ...[ + "Favorites".toText16(), + 12.height, + ListView.separated( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (cxt, index) => employeeItemView(favouriteUserList![index]), + separatorBuilder: (cxt, index) => Container( + height: 1, + color: MyColors.borderE3Color, + ), + itemCount: favouriteUserList?.length ?? 0), + 12.height, + ], + if (nonFavouriteUserList?.isNotEmpty ?? false) ...[ + "Related".toText16(), + 12.height, + ListView.separated( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (cxt, index) => employeeItemView(nonFavouriteUserList![index]), + separatorBuilder: (cxt, index) => Container( + height: 1, + color: MyColors.borderE3Color, + ), + itemCount: nonFavouriteUserList?.length ?? 0), + ] + ], + ).expanded + ], + ).paddingOnly(left: 21, right: 21, bottom: 0, top: 21).expanded, + Container(width: double.infinity, height: 1, color: MyColors.lightGreyEFColor), + DefaultButton( + LocaleKeys.cancel.tr(), + () { + Navigator.pop(context); + }, + textColor: MyColors.grey3AColor, + colors: const [ + Color(0xffE6E6E6), + Color(0xffE6E6E6), + ], + ).insideContainer + ], + ), + ); + } + + Widget employeeItemView(ReplacementList replacement) { + return InkWell( + onTap: () { + Navigator.pop(context); + widget.onSelectEmployee(replacement); + }, + child: SizedBox( + height: 50, + child: Row( + children: [ + CircularAvatar( + url: replacement.employeeImage ?? "", + height: 30, + width: 30, + isImageBase64: true, + ), + 16.width, + Expanded( + child: (replacement.employeeDisplayName ?? "").toText12(), + ), + Icon(Icons.star, size: 16, color: replacement.isFavorite! ? MyColors.yellowFavColor : MyColors.borderCEColor), + ], + ), + ), + ); + } + + Widget radioOption(String title, int value, int groupValue) { + return Row( + children: [ + Container( + width: 24, + height: 24, + decoration: BoxDecoration( + color: Colors.transparent, + border: Border.all(color: MyColors.borderColor, width: 1), + borderRadius: const BorderRadius.all(Radius.circular(100)), + ), + padding: const EdgeInsets.all(4), + child: Container( + width: double.infinity, + height: double.infinity, + decoration: BoxDecoration( + color: value == groupValue ? MyColors.grey3AColor : Colors.transparent, + borderRadius: BorderRadius.all(const Radius.circular(100)), + ), + ), + ), + 9.width, + title.toText12(color: MyColors.grey57Color) + ], + ).onPress(() { + _selectedSearchIndex = value; + setState(() {}); + }).expanded; + } +} diff --git a/lib/widgets/dynamic_forms/dynamic_textfield_widget.dart b/lib/widgets/dynamic_forms/dynamic_textfield_widget.dart index c44be0d..398b746 100644 --- a/lib/widgets/dynamic_forms/dynamic_textfield_widget.dart +++ b/lib/widgets/dynamic_forms/dynamic_textfield_widget.dart @@ -8,6 +8,7 @@ class DynamicTextFieldWidget extends StatelessWidget { final VoidCallback? onTap; final IconData? suffixIconData; final bool isEnable; + final TextInputAction? inputAction; final bool isReadOnly; final bool isPopup; final int? lines; @@ -24,6 +25,7 @@ class DynamicTextFieldWidget extends StatelessWidget { this.isReadOnly = false, this.isPopup = false, this.lines = 1, + this.inputAction, this.onChange, this.isInputTypeNum = false, this.isBackgroundEnable = false}); @@ -62,6 +64,7 @@ class DynamicTextFieldWidget extends StatelessWidget { TextField( enabled: isEnable, scrollPadding: EdgeInsets.zero, readOnly: isReadOnly, + textInputAction: inputAction, keyboardType: isInputTypeNum ? TextInputType.number : TextInputType.text, //controller: controller, maxLines: lines, @@ -99,7 +102,7 @@ class DynamicTextFieldWidget extends StatelessWidget { ), ), if (isPopup) const Icon(Icons.keyboard_arrow_down_outlined, color: MyColors.darkIconColor), - if (onTap != null) Icon(suffixIconData ?? Icons.keyboard_arrow_down_outlined, color: MyColors.darkIconColor,size: 20), + if (onTap != null) Icon(suffixIconData ?? Icons.keyboard_arrow_down_outlined, color: MyColors.darkIconColor), ], ), ), From 5c15d07dc87f22b6570e5e448879b6a6efba060f Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 21 Aug 2022 15:13:06 +0300 Subject: [PATCH 07/40] updates --- lib/models/generic_response_model.dart | 5 -- .../screens/mowadhafhi/mowadhafhi_home.dart | 65 ++++++++++++------- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index e548a92..300ded9 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -745,8 +745,6 @@ class GenericResponseModel { getCEIDFFStructureList = json['GetCEIDFFStructureList']; getCEITransactionList = json['GetCEITransactionList']; getCcpTransactionsList = json['GetCcpTransactionsList']; - getCcpTransactionsListNew = json['GetCcpTransactionsList_New']; - getConcurrentProgramsList = json['GetConcurrentProgramsList']; if (json['GetContactDetailsList'] != null) { getContactDetailsList = []; json['GetContactDetailsList'].forEach((v) { @@ -1367,8 +1365,6 @@ class GenericResponseModel { data['GetCEIDFFStructureList'] = this.getCEIDFFStructureList; data['GetCEITransactionList'] = this.getCEITransactionList; data['GetCcpTransactionsList'] = this.getCcpTransactionsList; - data['GetCcpTransactionsList_New'] = this.getCcpTransactionsListNew; - data['GetConcurrentProgramsList'] = this.getConcurrentProgramsList; if (this.getContactDetailsList != null) { data['GetContactDetailsList'] = this.getContactDetailsList!.map((v) => v.toJson()).toList(); } @@ -1378,7 +1374,6 @@ class GenericResponseModel { if (this.getContactDffStructureList != null) { data['GetContactDffStructureList'] = this.getContactDffStructureList!.map((v) => v.toJson()).toList(); } - // data['GetCcpTransactionsList_New'] = this.getCcpTransactionsListNew; data['GetContactColsStructureList'] = this.getContactColsStructureList; data['GetContactDetailsList'] = this.getContactDetailsList; data['GetContactDffStructureList'] = this.getContactDffStructureList; diff --git a/lib/ui/screens/mowadhafhi/mowadhafhi_home.dart b/lib/ui/screens/mowadhafhi/mowadhafhi_home.dart index edf6b03..e9f17b2 100644 --- a/lib/ui/screens/mowadhafhi/mowadhafhi_home.dart +++ b/lib/ui/screens/mowadhafhi/mowadhafhi_home.dart @@ -53,8 +53,6 @@ class _MowadhafhiHomeState extends State { }, child: Container( width: double.infinity, - // height: 100.0, - padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), margin: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), decoration: BoxDecoration( color: Colors.white, @@ -67,31 +65,52 @@ class _MowadhafhiHomeState extends State { ), ], ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + clipBehavior: Clip.antiAlias, + child: Stack( + clipBehavior: Clip.antiAlias, children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - getTicketsByEmployeeList[index].ticketTypeName!.toText14(color: MyColors.grey57Color), - getTicketsByEmployeeList[index].created!.split(" ")[0].toText12(color: MyColors.grey70Color), - ], - ), - Container( - padding: const EdgeInsets.only(top: 10.0), - child: getTicketsByEmployeeList[index].description!.toText12(color: MyColors.grey57Color), + Positioned( + left: -20, + top: -10, + child: Transform.rotate( + angle: 15, + child: Container( + width: 50, + height: 30, + color: Colors.amber, + ), + ), ), Container( - padding: const EdgeInsets.only(top: 10.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + padding: const EdgeInsets.only(left: 15, right: 15, top: 20, bottom: 10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - getTicketsByEmployeeList[index].ticketStatusInternalName!.toText14(color: MyColors.gradiantEndColor), - SvgPicture.asset( - "assets/images/arrow_next.svg", - color: MyColors.darkIconColor, - ) + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + getTicketsByEmployeeList[index].ticketTypeName!.toText14(color: MyColors.grey57Color), + getTicketsByEmployeeList[index].created!.split(" ")[0].toText12(color: MyColors.grey70Color), + ], + ), + Container( + padding: const EdgeInsets.only(top: 10.0), + child: getTicketsByEmployeeList[index].description!.toText12(color: MyColors.grey57Color), + ), + Container( + padding: const EdgeInsets.only(top: 10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + getTicketsByEmployeeList[index].ticketStatusInternalName!.toText14(color: MyColors.gradiantEndColor), + SvgPicture.asset( + "assets/images/arrow_next.svg", + color: MyColors.darkIconColor, + ) + ], + ), + ), ], ), ), From 3750f2c90455d65667de0a77a7289104b2370f28 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 23 Aug 2022 15:27:47 +0300 Subject: [PATCH 08/40] Vacation rule added complete. --- assets/langs/ar-SA.json | 1 + assets/langs/en-US.json | 1 + lib/api/vacation_rule_api_client.dart | 26 +- lib/extensions/widget_extensions.dart | 25 ++ lib/generated/locale_keys.g.dart | 1 + lib/models/generic_response_model.dart | 15 +- .../create_vacation_rule_list_model.dart | 18 + .../attendance/add_vacation_rule_screen.dart | 338 +++++++++++++++--- lib/ui/attendance/vacation_rule_screen.dart | 2 +- lib/widgets/dialogs/confirm_dialog.dart | 41 +-- 10 files changed, 389 insertions(+), 79 deletions(-) create mode 100644 lib/models/vacation_rule/create_vacation_rule_list_model.dart diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index ecedbdf..6821686 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -31,6 +31,7 @@ "viewAllServices": "عرض جميع الخدمات", "monthlyAttendance": "الحضور الشهري", "vacationRule": "حكم اجازة", + "vacationType": "نوع الاجازة", "startDateT": "تاريخ البدء", "endDateT": "تاريخ الانتهاء", "workFromHome": "العمل من المنزل", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 32a5e43..03ac050 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -31,6 +31,7 @@ "viewAllServices": "View All Services", "monthlyAttendance": "Monthly Attendance", "vacationRule": "Vacation Rule", + "vacationType": "Vacation Type", "startDateT": "Start Date", "endDateT": "End Date", "workFromHome": "Work From Home", diff --git a/lib/api/vacation_rule_api_client.dart b/lib/api/vacation_rule_api_client.dart index d144174..746116a 100644 --- a/lib/api/vacation_rule_api_client.dart +++ b/lib/api/vacation_rule_api_client.dart @@ -2,10 +2,10 @@ import 'package:mohem_flutter_app/api/api_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/vacation_rule/create_vacation_rule_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_item_type_notifications_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_notification_reassign_mode_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_vacation_rules_list_model.dart'; -import 'package:mohem_flutter_app/models/vacation_rule/respond_attributes_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/vr_item_types_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/wf_look_up_list_model.dart'; @@ -56,13 +56,33 @@ class VacationRuleApiClient { }, url, postParams); } - Future> getRespondAttributes(String pItemType, String pNotificationName) async { + Future getRespondAttributes(String pItemType, String pNotificationName) async { String url = "${ApiConsts.erpRest}GET_RESPOND_ATTRIBUTES"; Map postParams = {"P_ITEM_TYPE": pItemType, "P_NOTIFICATION_NAME": pNotificationName}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); - return responseData.respondAttributesList ?? []; + return responseData; + }, url, postParams); + } + + Future createVacationRule(String pBeginDate, String pEndDate, String pItemType, String pNotificationName, String pMessage, String pAction, String pReplacementUserName, + List> respondAttributeList) async { + String url = "${ApiConsts.erpRest}CREATE_VACATION_RULE"; + Map postParams = { + "P_ITEM_TYPE": pItemType, + "P_NOTIFICATION_NAME": pNotificationName, + "P_BEGIN_DATE": pBeginDate, + "P_END_DATE": pEndDate, + "P_MESSAGE": pMessage, + "P_REPLACEMENT_USER_NAME": pReplacementUserName, + "P_ACTION": pAction, + "RespondAttributeList": respondAttributeList, + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.createVacationRuleList; }, url, postParams); } diff --git a/lib/extensions/widget_extensions.dart b/lib/extensions/widget_extensions.dart index 247cde5..c9a4b49 100644 --- a/lib/extensions/widget_extensions.dart +++ b/lib/extensions/widget_extensions.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:shimmer/shimmer.dart'; @@ -67,4 +68,28 @@ extension WidgetExtensions on Widget { ), ); } + + Widget objectContainerBorderView({String title = "", String note = ""}) { + return Container( + padding: const EdgeInsets.only(top: 15, bottom: 15, left: 14, right: 14), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + border: Border.all( + color: MyColors.lightGreyEFColor, + width: 1, + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + if (title.isNotEmpty) title.toText16(), + if (title.isNotEmpty) 12.height, + this, + if (note.isNotEmpty) note.toText11(), + ], + ), + ); + } } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index eac063d..c37b5c8 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -32,6 +32,7 @@ abstract class LocaleKeys { static const viewAllServices = 'viewAllServices'; static const monthlyAttendance = 'monthlyAttendance'; static const vacationRule = 'vacationRule'; + static const vacationType = 'vacationType'; static const startDateT = 'startDateT'; static const endDateT = 'endDateT'; static const workFromHome = 'workFromHome'; diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index 1260d80..e288d38 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -55,18 +55,19 @@ import 'package:mohem_flutter_app/models/privilege_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/get_address_dff_structure_list.dart'; +import 'package:mohem_flutter_app/models/profile/get_contact_clos_structure_list.dart'; +import 'package:mohem_flutter_app/models/profile/get_contact_details_list.dart'; import 'package:mohem_flutter_app/models/profile/get_countries_list_model.dart'; import 'package:mohem_flutter_app/models/profile/phone_number_types_model.dart'; import 'package:mohem_flutter_app/models/profile/start_address_approval_process_model.dart'; import 'package:mohem_flutter_app/models/profile/submit_address_transaction.dart'; -import 'package:mohem_flutter_app/models/profile/get_contact_clos_structure_list.dart'; -import 'package:mohem_flutter_app/models/profile/get_contact_details_list.dart'; import 'package:mohem_flutter_app/models/profile/submit_basic_details_transaction_model.dart'; import 'package:mohem_flutter_app/models/profile/submit_contact_transaction_list_model.dart'; import 'package:mohem_flutter_app/models/start_eit_approval_process_model.dart'; import 'package:mohem_flutter_app/models/start_phone_approval_process_model.dart'; import 'package:mohem_flutter_app/models/submit_eit_transaction_list_model.dart'; import 'package:mohem_flutter_app/models/subordinates_on_leaves_model.dart'; +import 'package:mohem_flutter_app/models/vacation_rule/create_vacation_rule_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_item_type_notifications_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_notification_reassign_mode_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_vacation_rules_list_model.dart'; @@ -124,7 +125,7 @@ class GenericResponseModel { String? companyImageURL; String? companyMainCompany; List? countryList; - String? createVacationRuleList; + CreateVacationRuleList? createVacationRuleList; String? deleteAttachmentList; String? deleteVacationRuleList; String? disableSessionList; @@ -662,7 +663,8 @@ class GenericResponseModel { countryList!.add(new GetCountriesListModel.fromJson(v)); }); } - createVacationRuleList = json['CreateVacationRuleList']; + + createVacationRuleList = json['CreateVacationRuleList'] != null ? new CreateVacationRuleList.fromJson(json['CreateVacationRuleList']) : null; deleteAttachmentList = json['DeleteAttachmentList']; deleteVacationRuleList = json['DeleteVacationRuleList']; disableSessionList = json['DisableSessionList']; @@ -1299,7 +1301,10 @@ class GenericResponseModel { if (this.countryList != null) { data['CountryList'] = this.countryList!.map((v) => v.toJson()).toList(); } - data['CreateVacationRuleList'] = this.createVacationRuleList; + + if (this.createVacationRuleList != null) { + data['CreateVacationRuleList'] = this.createVacationRuleList!.toJson(); + } data['DeleteAttachmentList'] = this.deleteAttachmentList; data['DeleteVacationRuleList'] = this.deleteVacationRuleList; data['DisableSessionList'] = this.disableSessionList; diff --git a/lib/models/vacation_rule/create_vacation_rule_list_model.dart b/lib/models/vacation_rule/create_vacation_rule_list_model.dart new file mode 100644 index 0000000..5fd489a --- /dev/null +++ b/lib/models/vacation_rule/create_vacation_rule_list_model.dart @@ -0,0 +1,18 @@ +class CreateVacationRuleList { + String? pRETURNMSG; + String? pRETURNSTATUS; + + CreateVacationRuleList({this.pRETURNMSG, this.pRETURNSTATUS}); + + CreateVacationRuleList.fromJson(Map json) { + pRETURNMSG = json['P_RETURN_MSG']; + pRETURNSTATUS = json['P_RETURN_STATUS']; + } + + Map toJson() { + final Map data = new Map(); + data['P_RETURN_MSG'] = this.pRETURNMSG; + data['P_RETURN_STATUS'] = this.pRETURNSTATUS; + return data; + } +} \ No newline at end of file diff --git a/lib/ui/attendance/add_vacation_rule_screen.dart b/lib/ui/attendance/add_vacation_rule_screen.dart index a76e65a..51bf0d7 100644 --- a/lib/ui/attendance/add_vacation_rule_screen.dart +++ b/lib/ui/attendance/add_vacation_rule_screen.dart @@ -4,10 +4,15 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/vacation_rule_api_client.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/date_uitl.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/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/vacation_rule/create_vacation_rule_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_item_type_notifications_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_notification_reassign_mode_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/respond_attributes_list_model.dart'; @@ -18,6 +23,7 @@ import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheets/search_employee_bottom_sheet.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; +import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart'; import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; import 'package:mohem_flutter_app/widgets/item_detail_view_widget.dart'; @@ -41,11 +47,18 @@ class _AddVacationRuleScreenState extends State { GetNotificationReassignModeList? notificationReassignMode; List? respondAttributesList; + List? roleList = []; List? wfLookupList; ReplacementList? selectedReplacementEmployee; + String varcharInput = ""; + String numInput = ""; + DateTime? dateInput; + WFLookUpList? wfLook; + int currentStage = 0; + String message = ""; DateTime startTime = DateTime.now(); DateTime? endTime; @@ -89,14 +102,23 @@ class _AddVacationRuleScreenState extends State { List results = await Future.wait([ VacationRuleApiClient().getNotificationReassignMode(), VacationRuleApiClient().getRespondAttributes(selectedItemType!.iTEMTYPE!, selectedItemTypeNotification!.nOTIFICATIONNAME!), - // VacationRuleApiClient().getWfLookup(P_LOOKUP_TYPE), ]); notificationReassignModeList = results[0]; + GenericResponseModel respondAttribute = results[1]; + respondAttributesList = respondAttribute.respondAttributesList; + if (respondAttributesList?.isNotEmpty ?? false) { + int index = respondAttributesList!.indexWhere((element) => element.aTTRIBUTETYPE == "LOOKUP"); + if (index > -1) { + wfLookupList = await VacationRuleApiClient().getWfLookup(respondAttributesList![index].aTTRIBUTEFORMAT!); + } + } + roleList = respondAttribute.respondRolesList; + if (selectedItemType!.iTEMTYPE != "*") { notificationReassignModeList!.add( GetNotificationReassignModeList( rADIOBUTTONLABEL: "Deliver notifications to me regardless of any general rules", - rADIOBUTTONACTION: "deliver_notification", + rADIOBUTTONACTION: "DELIVER", // ionic: DELIVER rADIOBUTTONSEQ: 1, ), ); @@ -105,13 +127,25 @@ class _AddVacationRuleScreenState extends State { notificationReassignModeList!.add( GetNotificationReassignModeList( rADIOBUTTONLABEL: "Close", - rADIOBUTTONACTION: "close", + rADIOBUTTONACTION: "CLOSE", // ionic: CLOSE + rADIOBUTTONSEQ: 1, + ), + ); + } + if (respondAttributesList!.isNotEmpty && !(selectedItemTypeNotification!.fYIFLAG == "Y")) { + notificationReassignModeList!.add( + GetNotificationReassignModeList( + rADIOBUTTONLABEL: "Respond", + rADIOBUTTONACTION: "RESPOND", // ionic: RESPOND rADIOBUTTONSEQ: 1, ), ); } - respondAttributesList = results[1]; - // wfLookupList = results[2]; + + if (notificationReassignModeList!.isNotEmpty) { + notificationReassignMode = notificationReassignModeList!.first; + } + Utils.hideLoading(context); currentStage = 3; setState(() {}); @@ -121,6 +155,111 @@ class _AddVacationRuleScreenState extends State { } } + List getDynamicWidgetList() { + List respondAttributesWidgetList = []; + for (int i = 0; i < respondAttributesList!.length; i++) { + if (respondAttributesList![i].aTTRIBUTETYPE == "VARCHAR2") { + respondAttributesWidgetList.add( + DynamicTextFieldWidget(respondAttributesList![i].aTTRIBUTEDISPLAYNAME!, respondAttributesList![i].aTTRIBUTENAME!, onChange: (message) { + varcharInput = message; + }).paddingOnly(bottom: 12), + ); + } else if (respondAttributesList![i].aTTRIBUTETYPE == "LOOKUP") { + respondAttributesWidgetList.add( + PopupMenuButton( + child: DynamicTextFieldWidget( + respondAttributesList![i].aTTRIBUTEDISPLAYNAME!, + wfLook?.lOOKUPMEANING ?? respondAttributesList![i].aTTRIBUTENAME!, + isEnable: false, + isPopup: true, + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + for (int i = 0; i < wfLookupList!.length; i++) PopupMenuItem(value: i, child: Text(wfLookupList![i].lOOKUPMEANING!)), + ], + onSelected: (int popupIndex) { + wfLook = wfLookupList![popupIndex]; + setState(() {}); + }, + ), + ); + } else if (respondAttributesList![i].aTTRIBUTETYPE == "DATE") { + respondAttributesWidgetList.add(DynamicTextFieldWidget( + respondAttributesList![i].aTTRIBUTEDISPLAYNAME!, + dateInput?.toString() ?? respondAttributesList![i].aTTRIBUTENAME!, + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + dateInput = await _selectDate(context); + setState(() {}); + }, + ).paddingOnly(bottom: 12)); + } else if (respondAttributesList![i].aTTRIBUTETYPE == "NUMBER") { + respondAttributesWidgetList.add( + DynamicTextFieldWidget( + respondAttributesList![i].aTTRIBUTEDISPLAYNAME!, + respondAttributesList![i].aTTRIBUTENAME!, + isInputTypeNum: true, + onChange: (input) { + numInput = input; + }, + ), + ); + } + } + return respondAttributesWidgetList; + } + + void createVacationRule(List> respondAttributeList) async { + try { + Utils.showLoading(context); + CreateVacationRuleList? createVacationRuleList = await VacationRuleApiClient().createVacationRule(DateUtil.convertDateToStringLocation(startTime), DateUtil.convertDateToStringLocation(endTime!), + selectedItemType!.iTEMTYPE!, selectedItemTypeNotification!.nOTIFICATIONNAME!, message, getPAction(), selectedReplacementEmployee!.userName!, respondAttributeList); + Utils.hideLoading(context); + Utils.showToast("Vacation rule added."); + Navigator.popUntil(context, ModalRoute.withName('AppRoutes.dashboard')); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + String getPAction() { + String pAction = ""; + switch (notificationReassignMode?.rADIOBUTTONACTION ?? "") { + case 'DELEGATE': + { + pAction = "FORWARD"; + break; + } + case 'RESPOND': + { + pAction = "RESPOND"; + break; + } + case 'CLOSE': + { + pAction = "RESPOND"; + break; + } + case 'DELIVER': + { + pAction = "NOOP"; + break; + } + case 'TRANSFER': + { + pAction = "TRANSFER"; + break; + } + default: + { + pAction = ""; + break; + } + } + return pAction; + } + @override void dispose() { super.dispose(); @@ -132,7 +271,7 @@ class _AddVacationRuleScreenState extends State { backgroundColor: Colors.white, appBar: AppBarWidget( context, - title: LocaleKeys.vacationRule.tr(), // todo @Sikander change title to 'Vacation Type' + title: LocaleKeys.vacationType.tr(), ), body: vrItemTypesList == null ? const SizedBox() @@ -233,46 +372,75 @@ class _AddVacationRuleScreenState extends State { "Message", "Write a message", lines: 2, - onChange: (message) {}, - // isEnable: false, - // isPopup: true, - ).paddingOnly(bottom: 12), - PopupMenuButton( - child: DynamicTextFieldWidget( - "Notification Reassign", - notificationReassignMode == null ? "Select Notification" : notificationReassignMode!.rADIOBUTTONLABEL ?? "", - isEnable: false, - isPopup: true, - ).paddingOnly(bottom: 12), - itemBuilder: (_) => >[ - for (int i = 0; i < notificationReassignModeList!.length; i++) PopupMenuItem(value: i, child: Text(notificationReassignModeList![i].rADIOBUTTONLABEL!)), - ], - onSelected: (int popupIndex) { - if (notificationReassignMode == notificationReassignModeList![popupIndex]) { - return; - } - notificationReassignMode = notificationReassignModeList![popupIndex]; - setState(() {}); - }), - DynamicTextFieldWidget( - "Select Employee", - selectedReplacementEmployee == null ? "Search employee for replacement" : selectedReplacementEmployee!.employeeDisplayName ?? "", - isEnable: false, - onTap: () { - showMyBottomSheet( - context, - child: SearchEmployeeBottomSheet( - title: "Search for Employee", - apiMode: "DELEGATE", - onSelectEmployee: (_selectedEmployee) { - // Navigator.pop(context); - selectedReplacementEmployee = _selectedEmployee; - setState(() {}); - }, - ), - ); + onChange: (message) { + this.message = message; }, ).paddingOnly(bottom: 12), + ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + padding: EdgeInsets.zero, + itemBuilder: (cxt, index) { + return Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: 20, + height: 20, + decoration: BoxDecoration( + color: Colors.transparent, + border: Border.all(color: MyColors.borderColor, width: 1), + borderRadius: const BorderRadius.all(Radius.circular(100)), + ), + padding: const EdgeInsets.all(4), + child: Container( + width: double.infinity, + height: double.infinity, + decoration: BoxDecoration( + color: notificationReassignModeList![index] == notificationReassignMode ? MyColors.grey3AColor : Colors.transparent, + borderRadius: BorderRadius.all(const Radius.circular(100)), + ), + ), + ), + 9.width, + (notificationReassignModeList![index].rADIOBUTTONLABEL!).toText12(color: MyColors.grey57Color).expanded + ], + ).onPress(() { + if (notificationReassignMode == notificationReassignModeList![index]) { + return; + } + notificationReassignMode = notificationReassignModeList![index]; + setState(() {}); + }); + }, + separatorBuilder: (cxt, index) => 12.height, + itemCount: notificationReassignModeList!.length) + .objectContainerBorderView(title: "Notification Reassign"), + 12.height, + if (respondAttributesList?.isNotEmpty ?? false) ...getDynamicWidgetList(), + if (roleList!.isNotEmpty && notificationReassignMode?.rADIOBUTTONACTION == 'RESPOND' || + // if (notificationReassignMode?.rADIOBUTTONACTION == 'RESPOND' || + (notificationReassignMode?.rADIOBUTTONACTION == 'DELEGATE') || + (notificationReassignMode?.rADIOBUTTONACTION == 'TRANSFER')) + DynamicTextFieldWidget( + "Select Employee", + selectedReplacementEmployee == null ? "Search employee for replacement" : selectedReplacementEmployee!.employeeDisplayName ?? "", + isEnable: false, + onTap: () { + showMyBottomSheet( + context, + child: SearchEmployeeBottomSheet( + title: "Search for Employee", + apiMode: "DELEGATE", + onSelectEmployee: (_selectedEmployee) { + // Navigator.pop(context); + selectedReplacementEmployee = _selectedEmployee; + setState(() {}); + }, + ), + ); + }, + ).paddingOnly(bottom: 12), ], ).objectContainerView(title: "Step 3") ] @@ -283,11 +451,54 @@ class _AddVacationRuleScreenState extends State { currentStage != 3 ? null : () { - if (currentStage == 1) { - getItemTypeNotificationsList(); - } else if (currentStage == 2) { - callCombineApis(); + if (endTime == null) { + Utils.showToast("Please specify End Time"); + return; + } else if (notificationReassignMode == null) { + Utils.showToast("Please select notification reassign"); + return; + } else if (selectedReplacementEmployee == null) { + Utils.showToast("Please select employee for replacement"); + return; } + + List> list = []; + + if (respondAttributesList?.isNotEmpty ?? false) { + for (int i = 0; i < respondAttributesList!.length; i++) { + if (respondAttributesList![i].aTTRIBUTETYPE == "VARCHAR2") { + list.add({"ATTRIBUTE_NAME": respondAttributesList![i].aTTRIBUTENAME, "ATTRIBUTE_TEXT_VALUE": varcharInput}); + } + if (respondAttributesList![i].aTTRIBUTETYPE == "LOOKUP") { + if (wfLook == null) { + Utils.showToast('Please select action'); + break; + } + list.add({"ATTRIBUTE_NAME": respondAttributesList![i].aTTRIBUTENAME, "ATTRIBUTE_TEXT_VALUE": wfLook!.lOOKUPCODE}); + } + if (respondAttributesList![i].aTTRIBUTETYPE == "DATE") { + if (dateInput == null) { + Utils.showToast('Please select date'); + break; + } + list.add({"ATTRIBUTE_NAME": respondAttributesList![i].aTTRIBUTENAME, "ATTRIBUTE_TEXT_VALUE": DateUtil.convertDateToStringLocation(dateInput!)}); + } + if (respondAttributesList![i].aTTRIBUTETYPE == "NUMBER") { + list.add({"ATTRIBUTE_NAME": respondAttributesList![i].aTTRIBUTENAME, "ATTRIBUTE_TEXT_VALUE": numInput}); + } + } + } + + showDialog( + context: context, + builder: (cxt) => ConfirmDialog( + message: LocaleKeys.areYouSureYouWantToSubmit.tr(), + onTap: () { + Navigator.pop(context); + createVacationRule(list); + }, + ), + ); }, ).insideContainer, ], @@ -338,4 +549,35 @@ class _AddVacationRuleScreenState extends State { if (_time == null) return "Select date and time"; return DateFormat("MM/dd/yyyy hh:mm:ss a").format(_time); } + + Future _selectDate(BuildContext context) async { + DateTime time = dateInput ?? DateTime.now(); + if (Platform.isIOS) { + await showCupertinoModalPopup( + context: context, + builder: (cxt) => Container( + height: 250, + color: Colors.white, + child: CupertinoDatePicker( + backgroundColor: Colors.white, + mode: CupertinoDatePickerMode.date, + onDateTimeChanged: (value) { + if (value != null && value != dateInput) { + time = value; + } + }, + initialDateTime: dateInput, + ), + ), + ); + } else { + final DateTime? picked = + await showDatePicker(context: context, initialDate: dateInput ?? DateTime.now(), initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); + if (picked != null && picked != dateInput) { + time = picked; + } + } + time = DateTime(time.year, time.month, time.day); + return time; + } } diff --git a/lib/ui/attendance/vacation_rule_screen.dart b/lib/ui/attendance/vacation_rule_screen.dart index a2aa5df..5598e05 100644 --- a/lib/ui/attendance/vacation_rule_screen.dart +++ b/lib/ui/attendance/vacation_rule_screen.dart @@ -140,7 +140,7 @@ class _VacationRuleScreenState extends State { } String getParsedTime(String time) { - DateTime date = DateFormat("mm/dd/yyyy").parse(time); + DateTime date = DateFormat("MM/dd/yyyy").parse(time); return DateFormat("d MMM yyyy").format(date); } } diff --git a/lib/widgets/dialogs/confirm_dialog.dart b/lib/widgets/dialogs/confirm_dialog.dart index 7264a9b..4c94340 100644 --- a/lib/widgets/dialogs/confirm_dialog.dart +++ b/lib/widgets/dialogs/confirm_dialog.dart @@ -1,25 +1,28 @@ import 'package:easy_localization/src/public_ext.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/classes/colors.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/widgets/button/default_button.dart'; class ConfirmDialog extends StatelessWidget { final String? title; - final String? message; + final String message; final String? okTitle; final VoidCallback? onTap; - const ConfirmDialog({Key? key, this.title, @required this.message, this.okTitle, this.onTap}) : super(key: key); + const ConfirmDialog({Key? key, this.title, required this.message, this.okTitle, this.onTap}) : super(key: key); @override Widget build(BuildContext context) { return Dialog( backgroundColor: Colors.white, - shape: RoundedRectangleBorder(), - insetPadding: EdgeInsets.only(left: 21, right: 21), + shape: const RoundedRectangleBorder(), + insetPadding: const EdgeInsets.only(left: 21, right: 21), child: Padding( - padding: EdgeInsets.only(left: 20, right: 20, top: 18, bottom: 28), + padding: const EdgeInsets.only(left: 20, right: 20, top: 18, bottom: 28), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, @@ -28,33 +31,27 @@ class ConfirmDialog extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( - child: Padding( - padding: const EdgeInsets.only(top: 16.0), - child: Text( - title ?? LocaleKeys.confirm.tr(), - style: TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: Color(0xff2B353E), height: 35 / 24, letterSpacing: -0.96), - ), - ), + child: Text( + title ?? LocaleKeys.confirm.tr(), + style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: MyColors.darkTextColor, height: 35 / 24, letterSpacing: -0.96), + ).paddingOnly(top: 16), ), IconButton( padding: EdgeInsets.zero, - icon: Icon(Icons.close), - color: Color(0xff2B353E), - constraints: BoxConstraints(), + icon: const Icon(Icons.close), + color: MyColors.darkTextColor, + constraints: const BoxConstraints(), onPressed: () { Navigator.pop(context); }, ) ], ), - Text( - message ?? "", - style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff808080), letterSpacing: -0.48), - ), - SizedBox(height: 28), + message.toText16(color: MyColors.lightGrayColor), + 28.height, DefaultButton( okTitle ?? LocaleKeys.ok.tr(), - onTap == null ? () => Navigator.pop(context) : onTap, + onTap ?? () => Navigator.pop(context), textColor: Colors.white, //color: Ap.green, ), From 14047154255ed3d128c05134f179099f2a967d00 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 23 Aug 2022 16:11:52 +0300 Subject: [PATCH 09/40] Vacation rule translation added. --- assets/langs/ar-SA.json | 31 +++++++++-- assets/langs/en-US.json | 31 +++++++++-- lib/generated/codegen_loader.g.dart | 54 +++++++++++++++++++ lib/generated/locale_keys.g.dart | 23 ++++++++ .../attendance/add_vacation_rule_screen.dart | 53 +++++++++--------- 5 files changed, 157 insertions(+), 35 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 6821686..0c6ce54 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -311,11 +311,34 @@ "requestType": "نوع الطلب", "employeeDigitalID": "هويةالموظف الرقمية", "businessCard": "بطاقة العمل", - "checkOut":"وقت الخروج", - "regular":"منتظم", - "mark" : "علامة", - "selectMethodOfAttendance":"اختر طريقة تسجيل الحضور", + "checkOut": "وقت الخروج", + "regular": "منتظم", + "mark": "علامة", + "selectMethodOfAttendance": "اختر طريقة تسجيل الحضور", "comeNearHMGWifi": "HMG wifi من فضلك اقترب من", + "deliverNotificationToMeRegardless": "تسليم الإخطارات إلي بغض النظر عن أي قواعد عامة", + "close": "أغلق", + "respond": "يرد", + "vacationRuleAdded": "تمت إضافة قاعدة الإجازة", + "selectTypeT": "اختر صنف", + "notification": "تنبيه", + "selectNotification": "حدد إعلام", + "ifAllSelectedYouWillSkip": "* إذا تم تحديد الكل ، فستنتقل إلى الخطوة 3", + "applyForVacationRule": "التقدم بطلب للحصول على قانون الإجازة", + "step1": "الخطوة 1", + "step2": "الخطوة 2", + "step3": "الخطوه 3", + "message": "رسالة", + "writeAMessage": "اكتب رسالة", + "notificationReassign": "إعادة تعيين الإخطار", + "selectEmployee": "حدد الموظف", + "searchEmployeeForReplacement": "ابحث عن موظف بديل", + "searchForEmployee": "ابحث عن موظف", + "pleaseSpecifyEndTime": "الرجاء تحديد وقت الانتهاء", + "pleaseSelectNotificationReassign": "يرجى تحديد إعادة تعيين الإخطار", + "pleaseSelectEmployeeForReplacement": "الرجاء تحديد موظف للاستبدال", + "pleaseSelectAction": "الرجاء تحديد الإجراء", + "pleaseSelectDate": "الرجاء تحديد التاريخ", "profile": { "reset_password": { "label": "Reset Password", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 03ac050..812fa49 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -311,11 +311,34 @@ "wantToReject": "Are you sure want to reject?", "employeeDigitalID": "Employee Digital ID", "businessCard": "Business Card", - "checkOut":"Check Out", - "regular":"Regular", - "mark" : "Mark", - "selectMethodOfAttendance":"Select the method to mark the attendance", + "checkOut": "Check Out", + "regular": "Regular", + "mark": "Mark", + "selectMethodOfAttendance": "Select the method to mark the attendance", "comeNearHMGWifi": "Please come near to HMG wifi", + "deliverNotificationToMeRegardless": "Deliver notifications to me regardless of any general rules", + "close": "Close", + "respond": "Respond", + "vacationRuleAdded": "Vacation rule added", + "selectTypeT": "Select Type", + "notification": "Notification", + "selectNotification": "Select Notification", + "ifAllSelectedYouWillSkip": "*If All is selected, you will skip to step 3", + "applyForVacationRule": "Apply for Vacation Rule", + "step1": "Step 1", + "step2": "Step 2", + "step3": "Step 3", + "message": "Message", + "writeAMessage": "Write a message", + "notificationReassign": "Notification Reassign", + "selectEmployee": "Select Employee", + "searchEmployeeForReplacement": "Search employee for replacement", + "searchForEmployee": "Search for Employee", + "pleaseSpecifyEndTime": "Please specify End Time", + "pleaseSelectNotificationReassign": "Please select notification reassign", + "pleaseSelectEmployeeForReplacement": "Please select employee for replacement", + "pleaseSelectAction": "Please select action", + "pleaseSelectDate": "Please select date", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 2fa8d35..57323da 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -47,6 +47,9 @@ class CodegenLoader extends AssetLoader{ "viewAllServices": "عرض جميع الخدمات", "monthlyAttendance": "الحضور الشهري", "vacationRule": "حكم اجازة", + "vacationType": "نوع الاجازة", + "startDateT": "تاريخ البدء", + "endDateT": "تاريخ الانتهاء", "workFromHome": "العمل من المنزل", "ticketRequest": "طلب تذكرة", "viewAllOffers": "مشاهدة جميع العروض", @@ -248,6 +251,7 @@ class CodegenLoader extends AssetLoader{ "myAttendance": "حضوري", "workOnBreak": "التعويض عن العمل اثناءالاستراحه", "next": "التالي", + "apply": "يتقدم", "mobile": "التليفون المحمول", "completingYear": "نحن نقدر لك لاستكمال خدمة", "year": "سنة", @@ -328,6 +332,29 @@ class CodegenLoader extends AssetLoader{ "mark": "علامة", "selectMethodOfAttendance": "اختر طريقة تسجيل الحضور", "comeNearHMGWifi": "HMG wifi من فضلك اقترب من", + "deliverNotificationToMeRegardless": "تسليم الإخطارات إلي بغض النظر عن أي قواعد عامة", + "close": "أغلق", + "respond": "يرد", + "vacationRuleAdded": "تمت إضافة قاعدة الإجازة", + "selectTypeT": "اختر صنف", + "notification": "تنبيه", + "selectNotification": "حدد إعلام", + "ifAllSelectedYouWillSkip": "* إذا تم تحديد الكل ، فستنتقل إلى الخطوة 3", + "applyForVacationRule": "التقدم بطلب للحصول على قانون الإجازة", + "step1": "الخطوة 1", + "step2": "الخطوة 2", + "step3": "الخطوه 3", + "message": "رسالة", + "writeAMessage": "اكتب رسالة", + "notificationReassign": "إعادة تعيين الإخطار", + "selectEmployee": "حدد الموظف", + "searchEmployeeForReplacement": "ابحث عن موظف بديل", + "searchForEmployee": "ابحث عن موظف", + "pleaseSpecifyEndTime": "الرجاء تحديد وقت الانتهاء", + "pleaseSelectNotificationReassign": "يرجى تحديد إعادة تعيين الإخطار", + "pleaseSelectEmployeeForReplacement": "الرجاء تحديد موظف للاستبدال", + "pleaseSelectAction": "الرجاء تحديد الإجراء", + "pleaseSelectDate": "الرجاء تحديد التاريخ", "profile": { "reset_password": { "label": "Reset Password", @@ -395,6 +422,9 @@ static const Map en_US = { "viewAllServices": "View All Services", "monthlyAttendance": "Monthly Attendance", "vacationRule": "Vacation Rule", + "vacationType": "Vacation Type", + "startDateT": "Start Date", + "endDateT": "End Date", "workFromHome": "Work From Home", "ticketRequest": "Ticket Request", "viewAllOffers": "View All Offers", @@ -596,6 +626,7 @@ static const Map en_US = { "myAttendance": "My Attendance", "workOnBreak": "Work On Break", "next": "Next", + "apply": "Apply", "mobile": "Mobile", "year": "Year", "month": "Month", @@ -676,6 +707,29 @@ static const Map en_US = { "mark": "Mark", "selectMethodOfAttendance": "Select the method to mark the attendance", "comeNearHMGWifi": "Please come near to HMG wifi", + "deliverNotificationToMeRegardless": "Deliver notifications to me regardless of any general rules", + "close": "Close", + "respond": "Respond", + "vacationRuleAdded": "Vacation rule added", + "selectTypeT": "Select Type", + "notification": "Notification", + "selectNotification": "Select Notification", + "ifAllSelectedYouWillSkip": "*If All is selected, you will skip to step 3", + "applyForVacationRule": "Apply for Vacation Rule", + "step1": "Step 1", + "step2": "Step 2", + "step3": "Step 3", + "message": "Message", + "writeAMessage": "Write a message", + "notificationReassign": "Notification Reassign", + "selectEmployee": "Select Employee", + "searchEmployeeForReplacement": "Search employee for replacement", + "searchForEmployee": "Search for Employee", + "pleaseSpecifyEndTime": "Please specify End Time", + "pleaseSelectNotificationReassign": "Please select notification reassign", + "pleaseSelectEmployeeForReplacement": "Please select employee for replacement", + "pleaseSelectAction": "Please select action", + "pleaseSelectDate": "Please select date", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index c37b5c8..d736c34 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -317,6 +317,29 @@ abstract class LocaleKeys { static const mark = 'mark'; static const selectMethodOfAttendance = 'selectMethodOfAttendance'; static const comeNearHMGWifi = 'comeNearHMGWifi'; + static const deliverNotificationToMeRegardless = 'deliverNotificationToMeRegardless'; + static const close = 'close'; + static const respond = 'respond'; + static const vacationRuleAdded = 'vacationRuleAdded'; + static const selectTypeT = 'selectTypeT'; + static const notification = 'notification'; + static const selectNotification = 'selectNotification'; + static const ifAllSelectedYouWillSkip = 'ifAllSelectedYouWillSkip'; + static const applyForVacationRule = 'applyForVacationRule'; + static const step1 = 'step1'; + static const step2 = 'step2'; + static const step3 = 'step3'; + static const message = 'message'; + static const writeAMessage = 'writeAMessage'; + static const notificationReassign = 'notificationReassign'; + static const selectEmployee = 'selectEmployee'; + static const searchEmployeeForReplacement = 'searchEmployeeForReplacement'; + static const searchForEmployee = 'searchForEmployee'; + static const pleaseSpecifyEndTime = 'pleaseSpecifyEndTime'; + static const pleaseSelectNotificationReassign = 'pleaseSelectNotificationReassign'; + static const pleaseSelectEmployeeForReplacement = 'pleaseSelectEmployeeForReplacement'; + static const pleaseSelectAction = 'pleaseSelectAction'; + static const pleaseSelectDate = 'pleaseSelectDate'; static const profile_reset_password_label = 'profile.reset_password.label'; static const profile_reset_password_username = 'profile.reset_password.username'; static const profile_reset_password_password = 'profile.reset_password.password'; diff --git a/lib/ui/attendance/add_vacation_rule_screen.dart b/lib/ui/attendance/add_vacation_rule_screen.dart index 51bf0d7..b7f7f5d 100644 --- a/lib/ui/attendance/add_vacation_rule_screen.dart +++ b/lib/ui/attendance/add_vacation_rule_screen.dart @@ -7,6 +7,7 @@ import 'package:mohem_flutter_app/api/vacation_rule_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/date_uitl.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.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'; @@ -117,7 +118,7 @@ class _AddVacationRuleScreenState extends State { if (selectedItemType!.iTEMTYPE != "*") { notificationReassignModeList!.add( GetNotificationReassignModeList( - rADIOBUTTONLABEL: "Deliver notifications to me regardless of any general rules", + rADIOBUTTONLABEL: LocaleKeys.deliverNotificationToMeRegardless.tr(), rADIOBUTTONACTION: "DELIVER", // ionic: DELIVER rADIOBUTTONSEQ: 1, ), @@ -126,7 +127,7 @@ class _AddVacationRuleScreenState extends State { if (selectedItemTypeNotification!.fYIFLAG == "Y") { notificationReassignModeList!.add( GetNotificationReassignModeList( - rADIOBUTTONLABEL: "Close", + rADIOBUTTONLABEL: LocaleKeys.close.tr(), rADIOBUTTONACTION: "CLOSE", // ionic: CLOSE rADIOBUTTONSEQ: 1, ), @@ -135,7 +136,7 @@ class _AddVacationRuleScreenState extends State { if (respondAttributesList!.isNotEmpty && !(selectedItemTypeNotification!.fYIFLAG == "Y")) { notificationReassignModeList!.add( GetNotificationReassignModeList( - rADIOBUTTONLABEL: "Respond", + rADIOBUTTONLABEL: LocaleKeys.respond.tr(), rADIOBUTTONACTION: "RESPOND", // ionic: RESPOND rADIOBUTTONSEQ: 1, ), @@ -215,8 +216,8 @@ class _AddVacationRuleScreenState extends State { CreateVacationRuleList? createVacationRuleList = await VacationRuleApiClient().createVacationRule(DateUtil.convertDateToStringLocation(startTime), DateUtil.convertDateToStringLocation(endTime!), selectedItemType!.iTEMTYPE!, selectedItemTypeNotification!.nOTIFICATIONNAME!, message, getPAction(), selectedReplacementEmployee!.userName!, respondAttributeList); Utils.hideLoading(context); - Utils.showToast("Vacation rule added."); - Navigator.popUntil(context, ModalRoute.withName('AppRoutes.dashboard')); + Utils.showToast("Vacation rule added"); + Navigator.popUntil(context, ModalRoute.withName(AppRoutes.dashboard)); } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); @@ -287,7 +288,7 @@ class _AddVacationRuleScreenState extends State { PopupMenuButton( child: DynamicTextFieldWidget( LocaleKeys.itemType.tr(), - selectedItemType == null ? "Select Type" : selectedItemType!.iTEMTYPEDISPLAYNAME!, + selectedItemType == null ? LocaleKeys.selectType.tr() : selectedItemType!.iTEMTYPEDISPLAYNAME!, isEnable: false, isPopup: true, ).paddingOnly(bottom: 12), @@ -310,13 +311,13 @@ class _AddVacationRuleScreenState extends State { notificationReassignMode = null; getItemTypeNotificationsList(); } - }).objectContainerView(title: "Apply for Vacation Rule\nStep 1", note: "*If All is selected, you will skip to step 3"), + }).objectContainerView(title: "${LocaleKeys.applyForVacationRule.tr()}\n${LocaleKeys.step1.tr()}", note: LocaleKeys.ifAllSelectedYouWillSkip.tr()), if ((itemTypeNotificationsList ?? []).isNotEmpty) ...[ 12.height, PopupMenuButton( child: DynamicTextFieldWidget( "Notification", - selectedItemTypeNotification == null ? "Select Notification" : selectedItemTypeNotification!.nOTIFICATIONDISPLAYNAME!, + selectedItemTypeNotification == null ? LocaleKeys.selectNotification.tr() : selectedItemTypeNotification!.nOTIFICATIONDISPLAYNAME!, isEnable: false, isPopup: true, ).paddingOnly(bottom: 12), @@ -331,17 +332,17 @@ class _AddVacationRuleScreenState extends State { notificationReassignMode = null; setState(() {}); callCombineApis(); - }).objectContainerView(title: "Step 2") + }).objectContainerView(title: LocaleKeys.step2.tr()) ], if (selectedItemType != null && selectedItemTypeNotification != null && currentStage == 3) ...[ 12.height, Column( children: [ ItemDetailView(LocaleKeys.itemType.tr(), selectedItemType!.iTEMTYPEDISPLAYNAME!), - ItemDetailView("Notification", selectedItemTypeNotification!.nOTIFICATIONDISPLAYNAME!), + ItemDetailView(LocaleKeys.notification.tr(), selectedItemTypeNotification!.nOTIFICATIONDISPLAYNAME!), 12.height, DynamicTextFieldWidget( - "Start Date", + LocaleKeys.startDateT.tr(), formattedDate(startTime), suffixIconData: Icons.calendar_today, isEnable: false, @@ -355,7 +356,7 @@ class _AddVacationRuleScreenState extends State { ), 12.height, DynamicTextFieldWidget( - "End Date", + LocaleKeys.endDateT.tr(), formattedDate(endTime), suffixIconData: Icons.calendar_today, isEnable: false, @@ -369,8 +370,8 @@ class _AddVacationRuleScreenState extends State { ), 12.height, DynamicTextFieldWidget( - "Message", - "Write a message", + LocaleKeys.message.tr(), + LocaleKeys.writeAMessage.tr(), lines: 2, onChange: (message) { this.message = message; @@ -415,7 +416,7 @@ class _AddVacationRuleScreenState extends State { }, separatorBuilder: (cxt, index) => 12.height, itemCount: notificationReassignModeList!.length) - .objectContainerBorderView(title: "Notification Reassign"), + .objectContainerBorderView(title: LocaleKeys.notificationReassign.tr()), 12.height, if (respondAttributesList?.isNotEmpty ?? false) ...getDynamicWidgetList(), if (roleList!.isNotEmpty && notificationReassignMode?.rADIOBUTTONACTION == 'RESPOND' || @@ -423,15 +424,15 @@ class _AddVacationRuleScreenState extends State { (notificationReassignMode?.rADIOBUTTONACTION == 'DELEGATE') || (notificationReassignMode?.rADIOBUTTONACTION == 'TRANSFER')) DynamicTextFieldWidget( - "Select Employee", - selectedReplacementEmployee == null ? "Search employee for replacement" : selectedReplacementEmployee!.employeeDisplayName ?? "", + LocaleKeys.selectEmployee.tr(), + selectedReplacementEmployee == null ? LocaleKeys.searchEmployeeForReplacement.tr() : selectedReplacementEmployee!.employeeDisplayName ?? "", isEnable: false, onTap: () { showMyBottomSheet( context, child: SearchEmployeeBottomSheet( - title: "Search for Employee", - apiMode: "DELEGATE", + title: LocaleKeys.searchForEmployee.tr(), + apiMode: LocaleKeys.delegate.tr(), onSelectEmployee: (_selectedEmployee) { // Navigator.pop(context); selectedReplacementEmployee = _selectedEmployee; @@ -442,7 +443,7 @@ class _AddVacationRuleScreenState extends State { }, ).paddingOnly(bottom: 12), ], - ).objectContainerView(title: "Step 3") + ).objectContainerView(title: LocaleKeys.step3.tr()) ] ], ).expanded, @@ -452,18 +453,16 @@ class _AddVacationRuleScreenState extends State { ? null : () { if (endTime == null) { - Utils.showToast("Please specify End Time"); + Utils.showToast(LocaleKeys.pleaseSpecifyEndTime.tr()); return; } else if (notificationReassignMode == null) { - Utils.showToast("Please select notification reassign"); + Utils.showToast(LocaleKeys.pleaseSelectNotificationReassign.tr()); return; } else if (selectedReplacementEmployee == null) { - Utils.showToast("Please select employee for replacement"); + Utils.showToast(LocaleKeys.pleaseSelectEmployeeForReplacement.tr()); return; } - List> list = []; - if (respondAttributesList?.isNotEmpty ?? false) { for (int i = 0; i < respondAttributesList!.length; i++) { if (respondAttributesList![i].aTTRIBUTETYPE == "VARCHAR2") { @@ -471,14 +470,14 @@ class _AddVacationRuleScreenState extends State { } if (respondAttributesList![i].aTTRIBUTETYPE == "LOOKUP") { if (wfLook == null) { - Utils.showToast('Please select action'); + Utils.showToast(LocaleKeys.pleaseSelectAction.tr()); break; } list.add({"ATTRIBUTE_NAME": respondAttributesList![i].aTTRIBUTENAME, "ATTRIBUTE_TEXT_VALUE": wfLook!.lOOKUPCODE}); } if (respondAttributesList![i].aTTRIBUTETYPE == "DATE") { if (dateInput == null) { - Utils.showToast('Please select date'); + Utils.showToast(LocaleKeys.pleaseSelectDate.tr()); break; } list.add({"ATTRIBUTE_NAME": respondAttributesList![i].aTTRIBUTENAME, "ATTRIBUTE_TEXT_VALUE": DateUtil.convertDateToStringLocation(dateInput!)}); From 18084ce29fef54032bbedc54e579ee8d5c8ca18c Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 23 Aug 2022 16:49:40 +0300 Subject: [PATCH 10/40] services menu structure improvements. --- lib/config/routes.dart | 6 ++-- lib/ui/landing/widget/services_widget.dart | 3 +- ...en.dart => services_menu_list_screen.dart} | 28 +++++++++++-------- 3 files changed, 22 insertions(+), 15 deletions(-) rename lib/ui/my_attendance/{my_attendance_screen.dart => services_menu_list_screen.dart} (67%) diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 9285671..61cf8aa 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -13,7 +13,7 @@ import 'package:mohem_flutter_app/ui/login/verify_login_screen.dart'; import 'package:mohem_flutter_app/ui/misc/request_submit_screen.dart'; import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart'; import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart'; -import 'package:mohem_flutter_app/ui/my_attendance/my_attendance_screen.dart'; +import 'package:mohem_flutter_app/ui/my_attendance/services_menu_list_screen.dart'; import 'package:mohem_flutter_app/ui/payslip/monthly_pay_slip_screen.dart'; import 'package:mohem_flutter_app/ui/profile/add_update_family_member.dart'; import 'package:mohem_flutter_app/ui/profile/basic_details.dart'; @@ -61,7 +61,7 @@ class AppRoutes { static const String itgDetail = "/itgDetail"; static const String itemHistory = "/itemHistory"; - static const String myAttendance = "/myAttendance"; + static const String servicesMenuListScreen = "/servicesMenuListScreen"; static const String dynamicScreen = "/dynamicScreen"; static const String addDynamicInput = "/addDynamicInput"; static const String requestSubmitScreen = "/requestSubmitScreen"; @@ -124,7 +124,7 @@ class AppRoutes { itgDetail: (context) => ItgDetailScreen(), itemHistory: (context) => ItemHistoryScreen(), - myAttendance: (context) => MyAttendanceScreen(), + servicesMenuListScreen: (context) => ServicesMenuListScreen(), // workFromHome: (context) => WorkFromHomeScreen(), // addWorkFromHome: (context) => AddWorkFromHomeScreen(), profile: (context) => ProfileScreen(), diff --git a/lib/ui/landing/widget/services_widget.dart b/lib/ui/landing/widget/services_widget.dart index e99205b..868ca5e 100644 --- a/lib/ui/landing/widget/services_widget.dart +++ b/lib/ui/landing/widget/services_widget.dart @@ -9,6 +9,7 @@ import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart'; +import 'package:mohem_flutter_app/ui/my_attendance/services_menu_list_screen.dart'; import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart'; import 'package:provider/provider.dart'; @@ -126,7 +127,7 @@ class ServicesWidget extends StatelessWidget { Navigator.pushNamed(context, AppRoutes.monthlyPaySlip); } } else { - Navigator.pushNamed(context, AppRoutes.myAttendance, arguments: menuList); + Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, menuList)); } return; } diff --git a/lib/ui/my_attendance/my_attendance_screen.dart b/lib/ui/my_attendance/services_menu_list_screen.dart similarity index 67% rename from lib/ui/my_attendance/my_attendance_screen.dart rename to lib/ui/my_attendance/services_menu_list_screen.dart index 207e2c7..fdf6e4f 100644 --- a/lib/ui/my_attendance/my_attendance_screen.dart +++ b/lib/ui/my_attendance/services_menu_list_screen.dart @@ -1,4 +1,3 @@ -import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; @@ -7,37 +6,44 @@ import 'package:mohem_flutter_app/config/routes.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/dashboard/menu_entries.dart'; import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; -class MyAttendanceScreen extends StatelessWidget { - List list; +class ServicesMenuListScreenParams { + final String title; + final List list; - MyAttendanceScreen({Key? key, this.list = const []}) : super(key: key); + ServicesMenuListScreenParams(this.title, this.list); +} + +class ServicesMenuListScreen extends StatelessWidget { + late ServicesMenuListScreenParams servicesMenuData; + + ServicesMenuListScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - list = ModalRoute.of(context)!.settings.arguments as List; + servicesMenuData = ModalRoute.of(context)!.settings.arguments as ServicesMenuListScreenParams; + return Scaffold( backgroundColor: Colors.white, appBar: AppBarWidget( context, - title: LocaleKeys.myAttendance.tr(), + title: servicesMenuData.title, ), body: SizedBox( width: double.infinity, height: double.infinity, - child: list.isEmpty + child: servicesMenuData.list.isEmpty ? Utils.getNoDataWidget(context) : ListView.separated( padding: const EdgeInsets.all(21), - itemBuilder: (cxt, index) => itemView("assets/images/pdf.svg", list[index].prompt!).onPress(() { - Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(list[index].prompt!, list[index].functionName!)); + itemBuilder: (cxt, index) => itemView("assets/images/pdf.svg", servicesMenuData.list[index].prompt!).onPress(() { + Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(servicesMenuData.list[index].prompt!, servicesMenuData.list[index].functionName!)); }), separatorBuilder: (cxt, index) => 12.height, - itemCount: list.length), + itemCount: servicesMenuData.list.length), ), ); } From 11bd7a70851fda5613acf19ef4a39a43fa94060c Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 23 Aug 2022 17:24:17 +0300 Subject: [PATCH 11/40] improvements. --- .../announcements/announcement_details.dart | 64 ++++----- .../screens/announcements/announcements.dart | 130 ++++++++---------- 2 files changed, 79 insertions(+), 115 deletions(-) diff --git a/lib/ui/screens/announcements/announcement_details.dart b/lib/ui/screens/announcements/announcement_details.dart index a788b5d..a8b2c2c 100644 --- a/lib/ui/screens/announcements/announcement_details.dart +++ b/lib/ui/screens/announcements/announcement_details.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:mohem_flutter_app/api/pending_transactions_api_client.dart'; import 'package:mohem_flutter_app/classes/utils.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_announcement_details.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; @@ -37,47 +38,30 @@ class _AnnouncementDetailsState extends State { context, title: LocaleKeys.announcements.tr(), ), - body: SingleChildScrollView( - child: Container( - width: double.infinity, - padding: const EdgeInsets.all(10.0), - margin: const EdgeInsets.all(12.0), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - SizedBox( - width: double.infinity, - height: 150.0, - child: ClipRRect( - borderRadius: BorderRadius.circular(10), - child: Image.memory( - base64Decode(Utils.getBase64FromJpeg(getAnnouncementDetailsObj?.bannerImage)), - fit: BoxFit.cover, + body: getAnnouncementDetailsObj == null + ? const SizedBox() + : SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + SizedBox( + width: double.infinity, + height: 150.0, + child: ClipRRect( + borderRadius: BorderRadius.circular(10), + child: Image.memory( + base64Decode(Utils.getBase64FromJpeg(getAnnouncementDetailsObj?.bannerImage)), + fit: BoxFit.cover, + ), + ), ), - ), - ), - Container( - margin: const EdgeInsets.only(top: 12.0), - child: Html( - data: getAnnouncementDetailsObj?.bodyEN, - ), - ), - ], - ), - ), - ), + Html( + data: getAnnouncementDetailsObj?.bodyEN, + ).paddingOnly(top: 12), + ], + ).objectContainerView().paddingAll(21), + ), ); } diff --git a/lib/ui/screens/announcements/announcements.dart b/lib/ui/screens/announcements/announcements.dart index f367157..56ca155 100644 --- a/lib/ui/screens/announcements/announcements.dart +++ b/lib/ui/screens/announcements/announcements.dart @@ -9,6 +9,7 @@ import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.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_announcements.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; @@ -44,18 +45,15 @@ class _AnnouncementsState extends State { context, title: LocaleKeys.announcements.tr(), ), - body: getAnnouncementsObject.isNotEmpty - ? Container( - margin: const EdgeInsets.only(top: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - 12.height, - Container( - margin: const EdgeInsets.fromLTRB(12.0, 0.0, 12.0, 0.0), - child: DynamicTextFieldWidget( - "Search", + body: jsonResponse.isEmpty + ? const SizedBox() + : getAnnouncementsObject.isNotEmpty + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + DynamicTextFieldWidget( + LocaleKeys.search.tr(), LocaleKeys.searchAnnouncements.tr(), isEnable: true, suffixIconData: Icons.search, @@ -66,72 +64,52 @@ class _AnnouncementsState extends State { onChange: (String value) { _runFilter(value); }, - ), - ), - 12.height, - Expanded( - child: ListView.separated( - physics: const BouncingScrollPhysics(), - shrinkWrap: true, - itemBuilder: (BuildContext context, int index) { - return InkWell( - onTap: () { - openAnnouncementsDetails(int.parse(_foundAnnouncements[index].rowID!)); - }, - child: Container( - width: double.infinity, - padding: const EdgeInsets.all(10.0), - margin: const EdgeInsets.only(left: 12, right: 12, top: 10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - SizedBox( - width: 80.0, - height: 80.0, - child: ClipRRect( - borderRadius: BorderRadius.circular(10), - child: Image.memory( - base64Decode(Utils.getBase64FromJpeg(_foundAnnouncements[index].bannerImage)), - fit: BoxFit.cover, - ), - ), - ), - 12.width, - SizedBox( - height: 80.0, - width: 200.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppState().isArabic(context) ? _foundAnnouncements[index].titleAR!.toText13() : getAnnouncementsObject[index].titleEN!.toText13(), - 8.height, - _foundAnnouncements[index].created!.toText10(color: MyColors.grey98Color) - ], - ), + ).paddingOnly(left: 21, right: 21), + ListView.separated( + physics: const BouncingScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.all(21), + itemBuilder: (BuildContext context, int index) { + return InkWell( + onTap: () { + openAnnouncementsDetails(int.parse(_foundAnnouncements[index].rowID!)); + }, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + width: 80.0, + child: AspectRatio( + aspectRatio: 1 / 1, + child: ClipRRect( + borderRadius: BorderRadius.circular(10), + child: Image.memory( + base64Decode(Utils.getBase64FromJpeg(_foundAnnouncements[index].bannerImage)), + fit: BoxFit.cover, ), - ], + ), ), ), - ); - }, - separatorBuilder: (BuildContext context, int index) => 1.height, - itemCount: _foundAnnouncements.length ?? 0)) - ], - ), - ) - : Utils.getNoDataWidget(context), + 12.width, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + (AppState().isArabic(context) ? _foundAnnouncements[index].titleAR! : getAnnouncementsObject[index].titleEN!).toText13(), + 8.height, + _foundAnnouncements[index].created!.toText10(color: MyColors.grey98Color) + ], + ).expanded, + ], + ).objectContainerView(), + ); + }, + separatorBuilder: (BuildContext context, int index) => 12.height, + itemCount: _foundAnnouncements.length, + ).expanded + ], + ) + : Utils.getNoDataWidget(context), ); } @@ -151,6 +129,8 @@ class _AnnouncementsState extends State { try { Utils.showLoading(context); jsonResponse = await PendingTransactionsApiClient().getAnnouncements(itgAwarenessID, currentPageNo, itgRowID); + // todo '@haroon' move below post processing code to above method and get exact model which you need, + var jsonDecodedData = jsonDecode(jsonDecode(jsonResponse)['result']['data']); for (int i = 0; i < jsonDecodedData.length; i++) { getAnnouncementsObject.add(GetAnnouncementsObject.fromJson(jsonDecodedData[i])); From 20f7d98ce5aec59d394bfc73e56c5656bee2040a Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 24 Aug 2022 14:49:54 +0300 Subject: [PATCH 12/40] profile improvements --- lib/classes/colors.dart | 1 + lib/config/routes.dart | 4 +- lib/extensions/string_extensions.dart | 10 +- lib/ui/profile/contact_details.dart | 2 +- lib/ui/profile/family_members.dart | 2 +- lib/ui/profile/personal_info.dart | 126 ++++---------- .../{screens => }/profile/profile_screen.dart | 106 ++++++------ .../{screens => }/profile/widgets/header.dart | 0 lib/ui/profile/widgets/profile_info.dart | 131 ++++++++++++++ lib/ui/profile/widgets/profile_panel.dart | 49 ++++++ .../screens/profile/widgets/profile_info.dart | 160 ------------------ .../profile/widgets/profile_panel.dart | 39 ----- 12 files changed, 278 insertions(+), 352 deletions(-) rename lib/ui/{screens => }/profile/profile_screen.dart (59%) rename lib/ui/{screens => }/profile/widgets/header.dart (100%) create mode 100644 lib/ui/profile/widgets/profile_info.dart create mode 100644 lib/ui/profile/widgets/profile_panel.dart delete mode 100644 lib/ui/screens/profile/widgets/profile_info.dart delete mode 100644 lib/ui/screens/profile/widgets/profile_panel.dart diff --git a/lib/classes/colors.dart b/lib/classes/colors.dart index e37a049..1b7c1a5 100644 --- a/lib/classes/colors.dart +++ b/lib/classes/colors.dart @@ -12,6 +12,7 @@ class MyColors { static const Color grey57Color = Color(0xff575757); static const Color grey67Color = Color(0xff676767); static const Color grey77Color = Color(0xff777777); + static const Color grey80Color = Color(0xff808080); static const Color grey70Color = Color(0xff707070); static const Color greyACColor = Color(0xffACACAC); static const Color grey98Color = Color(0xff989898); diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 61cf8aa..ca476df 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -32,7 +32,7 @@ import 'package:mohem_flutter_app/ui/screens/mowadhafhi/mowadhafhi_hr_request.da import 'package:mohem_flutter_app/ui/screens/mowadhafhi/request_details.dart'; import 'package:mohem_flutter_app/ui/screens/pending_transactions/pending_transactions.dart'; import 'package:mohem_flutter_app/ui/screens/pending_transactions/pending_transactions_details.dart'; -import 'package:mohem_flutter_app/ui/screens/profile/profile_screen.dart'; +import 'package:mohem_flutter_app/ui/profile/profile_screen.dart'; import 'package:mohem_flutter_app/ui/screens/submenu_screen.dart'; import 'package:mohem_flutter_app/ui/work_list/item_history_screen.dart'; import 'package:mohem_flutter_app/ui/work_list/itg_detail_screen.dart'; @@ -139,7 +139,7 @@ class AppRoutes { //Profile //profile: (context) => Profile(), //profile: (context) => Profile(), - personalInfo: (context) => PesonalInfo(), + personalInfo: (context) => PersonalInfo(), basicDetails: (context) => BasicDetails(), contactDetails: (context) => ContactDetails(), familyMembers: (context) => FamilyMembers(), diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index 869b61c..e895ad1 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -54,10 +54,16 @@ extension EmailValidator on String { style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 14, letterSpacing: -0.48, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), ); - Widget toText16({Color? color, bool isBold = false, int? maxlines}) => Text( + Widget toText16({Color? color, bool isUnderLine = false, bool isBold = false, int? maxlines}) => Text( this, maxLines: maxlines, - style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 16, letterSpacing: -0.64, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), + style: TextStyle( + color: color ?? MyColors.darkTextColor, + fontSize: 16, + letterSpacing: -0.64, + fontWeight: isBold ? FontWeight.bold : FontWeight.w600, + decoration: isUnderLine ? TextDecoration.underline : null, + ), ); Widget toText17({Color? color, bool isBold = false}) => Text( diff --git a/lib/ui/profile/contact_details.dart b/lib/ui/profile/contact_details.dart index 034292d..c0af0c5 100644 --- a/lib/ui/profile/contact_details.dart +++ b/lib/ui/profile/contact_details.dart @@ -13,7 +13,7 @@ import 'package:mohem_flutter_app/models/get_employee_phones_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/ui/profile/dynamic_screens/dynamic_input_address_screen.dart'; import 'package:mohem_flutter_app/ui/profile/phone_numbers.dart'; -import 'package:mohem_flutter_app/ui/screens/profile/profile_screen.dart'; +import 'package:mohem_flutter_app/ui/profile/profile_screen.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:provider/provider.dart'; diff --git a/lib/ui/profile/family_members.dart b/lib/ui/profile/family_members.dart index 2dd84ea..4f38531 100644 --- a/lib/ui/profile/family_members.dart +++ b/lib/ui/profile/family_members.dart @@ -8,7 +8,7 @@ import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/get_employee_contacts.model.dart'; import 'package:mohem_flutter_app/ui/profile/dynamic_screens/dynamic_input_familyMembers_screen.dart'; -import 'package:mohem_flutter_app/ui/screens/profile/profile_screen.dart'; +import 'package:mohem_flutter_app/ui/profile/profile_screen.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; diff --git a/lib/ui/profile/personal_info.dart b/lib/ui/profile/personal_info.dart index ce35bf1..bd7eebd 100644 --- a/lib/ui/profile/personal_info.dart +++ b/lib/ui/profile/personal_info.dart @@ -2,114 +2,48 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/colors.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/widgets/app_bar_widget.dart'; -import 'package:mohem_flutter_app/widgets/button/default_button.dart'; -class PesonalInfo extends StatefulWidget { - const PesonalInfo({Key? key}) : super(key: key); +class PersonalInfo extends StatelessWidget { + PersonalInfo({Key? key}) : super(key: key); - @override - _PesonalInfoState createState() => _PesonalInfoState(); -} - -class _PesonalInfoState extends State { - String? fullName = ""; - String? maritalStatus = ""; - String? birthDate = ""; - String? civilIdentityNumber = ""; - String? emailAddress = ""; - String? employeeNo = ""; - - // List getEmployeeBasicDetailsList = []; - // MemberInformationListModel? _memberInformationList; - - late MemberInformationListModel memberInformationList; - - List getEmployeeBasicDetailsList = []; - - @override - void initState() { - super.initState(); - memberInformationList = AppState().memberInformationList!; - } + MemberInformationListModel memberInformationList = AppState().memberInformationList!; Widget build(BuildContext context) { return Scaffold( - appBar: AppBarWidget( - context, - title: LocaleKeys.profile_personalInformation.tr(), - ), - backgroundColor: MyColors.backgroundColor, - // bottomSheet:footer(), - body: Column( + appBar: AppBarWidget( + context, + title: LocaleKeys.profile_personalInformation.tr(), + ), + backgroundColor: MyColors.backgroundColor, + body: SizedBox( + width: MediaQuery.of(context).size.width, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, 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: 350, - 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: 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), - ]), - ), + LocaleKeys.category.tr().toText13(color: MyColors.lightGrayColor), + (memberInformationList.eMPLOYMENTCATEGORYMEANING ?? "").toText16(), + 20.height, + LocaleKeys.address.tr().toText13(color: MyColors.lightGrayColor), + (memberInformationList.lOCATIONNAME ?? "").toText16(), + 20.height, + LocaleKeys.phoneNumber.tr().toText13(color: MyColors.lightGrayColor), + (memberInformationList.eMPLOYEEMOBILENUMBER ?? "").toText16(), + 20.height, + LocaleKeys.businessGroup.tr().toText13(color: MyColors.lightGrayColor), + (memberInformationList.bUSINESSGROUPNAME ?? "").toText16(), + 20.height, + LocaleKeys.Payroll.tr().toText13(color: MyColors.lightGrayColor), + (memberInformationList.pAYROLLNAME ?? "").toText16(), ], - )); - } - - Widget footer() { - return Container( - decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(10), - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), - ], + ).objectContainerView().paddingAll(21), ), - child: DefaultButton( - LocaleKeys.update.tr(), - () async {}, - ).insideContainer, ); } } diff --git a/lib/ui/screens/profile/profile_screen.dart b/lib/ui/profile/profile_screen.dart similarity index 59% rename from lib/ui/screens/profile/profile_screen.dart rename to lib/ui/profile/profile_screen.dart index 35c4a57..cea9f11 100644 --- a/lib/ui/screens/profile/profile_screen.dart +++ b/lib/ui/profile/profile_screen.dart @@ -1,19 +1,20 @@ -import 'dart:ui'; import 'dart:convert'; import 'dart:ui'; -import 'package:easy_localization/easy_localization.dart'; +import 'package:easy_localization/easy_localization.dart'; 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'; +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/screens/profile/widgets/header.dart'; -import 'package:mohem_flutter_app/ui/screens/profile/widgets/profile_panel.dart'; +import 'package:mohem_flutter_app/ui/profile/widgets/profile_panel.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; // todo '@sultan' kindly follow structure of code written. use extension methods for widgets and dont hard code strings, use localizations @@ -40,17 +41,24 @@ class _ProfileScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( - extendBody: true, - backgroundColor: const Color(0xffefefef), - body: Stack(children: [ + extendBody: true, + backgroundColor: const Color(0xffefefef), + body: Stack( + children: [ Container( height: 300, - margin: EdgeInsets.only(top: 50), - decoration: BoxDecoration(image: DecorationImage(image: MemoryImage(Utils.getPostBytes(memberInformationList.eMPLOYEEIMAGE)), fit: BoxFit.cover)), - child: new BackdropFilter( - filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), - child: new Container( - decoration: new BoxDecoration(color: Colors.white.withOpacity(0.0)), + margin: const EdgeInsets.only(top: 50), + decoration: BoxDecoration( + image: DecorationImage( + image: MemoryImage( + Utils.getPostBytes(memberInformationList.eMPLOYEEIMAGE), + ), + fit: BoxFit.cover), + ), + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), + child: Container( + color: Colors.white.withOpacity(0.0), ), ), ), @@ -59,50 +67,46 @@ class _ProfileScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - SizedBox( - height: 80, - ), - Container( - padding: EdgeInsets.only(left: 15, right: 15), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - IconButton( - onPressed: () { - Navigator.pop(context); - }, - icon: Icon( - Icons.arrow_back_ios, - color: Colors.white, - ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + onPressed: () { + Navigator.pop(context); + }, + icon: const Icon( + Icons.arrow_back_ios, + 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)), - child: Row( - children: [ - Icon(Icons.photo, color: Colors.white), - Text( - 'Edit', - style: TextStyle(color: Colors.white, fontSize: 12), - ) - ], - ), + ), + InkWell( + onTap: () { + startImageSheet(); + }, + child: Container( + padding: const EdgeInsets.only(left: 17, right: 17, top: 8, bottom: 8), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(30), + color: Colors.black.withOpacity(.21), + ), + child: Row( + children: [ + const Icon(Icons.photo, color: Colors.white, size: 16), + 4.width, + LocaleKeys.edit.tr().toText12(color: Colors.white), + ], ), ), - ], - ), - ), - HeaderPanel(memberInformationList), - ProfilePanle(memberInformationList) + ), + ], + ).paddingOnly(left: 16, right: 16, top: 80), + ProfilePanel(memberInformationList) ], ), ) - ])); + ], + ), + ); } void startImageSheet() { diff --git a/lib/ui/screens/profile/widgets/header.dart b/lib/ui/profile/widgets/header.dart similarity index 100% rename from lib/ui/screens/profile/widgets/header.dart rename to lib/ui/profile/widgets/header.dart diff --git a/lib/ui/profile/widgets/profile_info.dart b/lib/ui/profile/widgets/profile_info.dart new file mode 100644 index 0000000..63880b3 --- /dev/null +++ b/lib/ui/profile/widgets/profile_info.dart @@ -0,0 +1,131 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/config/routes.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/dashboard/menu_entries.dart'; +import 'package:mohem_flutter_app/models/member_information_list_model.dart'; +import 'package:mohem_flutter_app/models/profile_menu.model.dart'; + +class ProfileInFo extends StatefulWidget { + ProfileInFo(this.memberInfo); + + MemberInformationListModel memberInfo; + + @override + State createState() => _ProfileInFoState(); +} + +class _ProfileInFoState extends State { + static List menuData = []; + String data = '.'; + double sliderValue = 75; + List menu = [ + ProfileMenu(name: LocaleKeys.profile_personalInformation.tr(), icon: 'personal-info.svg', route: AppRoutes.personalInfo, dynamicUrl: '', menuEntries: getMenuEntries('')), + ProfileMenu(name: LocaleKeys.profile_basicDetails.tr(), icon: 'basic-details.svg', route: AppRoutes.basicDetails, menuEntries: getMenuEntries('BASIC_DETAILS')), + ProfileMenu(name: LocaleKeys.profile_contactDetails.tr(), icon: 'contact-details.svg', route: AppRoutes.contactDetails, dynamicUrl: '', menuEntries: getMenuEntries('ADDRESS')), + ProfileMenu(name: LocaleKeys.profile_familyDetails.tr(), icon: 'family-members.svg', route: AppRoutes.familyMembers, dynamicUrl: '', menuEntries: getMenuEntries('CONTACT')), + ]; + + @override + void setState(VoidCallback fn) { + super.setState(fn); + } + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + 16.height, + widget.memberInfo.eMPLOYEENAME!.toText22(), + ("${widget.memberInfo.eMPLOYEENUMBER!} | ${widget.memberInfo.jOBNAME!}").toText13(color: MyColors.grey80Color), + widget.memberInfo.eMPLOYEEEMAILADDRESS!.toText13(), + 12.height, + const Divider(height: 8, thickness: 8, color: MyColors.lightGreyEFColor), + 12.height, + LocaleKeys.completingYear.tr().toText11(), + Row(children: [ + appreciationTime(LocaleKeys.year.tr(), widget.memberInfo.sERVICEYEARS.toString()), + appreciationTime(LocaleKeys.month.tr(), widget.memberInfo.sERVICEMONTHS.toString()), + appreciationTime(LocaleKeys.day.tr(), widget.memberInfo.sERVICEDAYS.toString()), + ]).paddingOnly(bottom: 12, top: 12), + const Divider(height: 8, thickness: 8, color: MyColors.lightGreyEFColor), + Column( + // mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + (LocaleKeys.profile_profileCompletionPer.tr() + ' 75%').toText16(), + 8.height, + Row( + children: [ + for (var i = 0; i < 4; i++) + if (i < 3) Expanded(child: drawSlider(Color(0xff2BB8A6))) else Expanded(child: drawSlider(const Color(0xffefefef))) + ], + ), + 14.height, + LocaleKeys.profile_completeProfile.tr().toText16(color: MyColors.textMixColor, isUnderLine: true), + ], + ).paddingOnly(left: 21, right: 21, bottom: 18, top: 12), + const Divider(height: 8, thickness: 8, color: MyColors.lightGreyEFColor), + ListView.separated( + padding: EdgeInsets.zero, + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (cxt, index) => Row( + children: [ + SvgPicture.asset('assets/images/' + menu[index].icon, width: 20, height: 20), + 16.width, + menu[index].name.toText16().expanded, + 16.width, + const Icon(Icons.arrow_forward, color: MyColors.darkIconColor) + ], + ).onPress(() { + Navigator.pushNamed(context, menu[index].route); + }).paddingOnly(left: 21, right: 21, top: 21), + separatorBuilder: (cxt, index) => 12.height, + itemCount: menu.length), + ], + ); + } + + Widget drawSlider(color) { + return Row(children: [ + Expanded( + flex: 1, + child: ClipRRect( + borderRadius: BorderRadius.circular(10), + child: Container( + height: 6, + width: 20, + color: color, + ), + )), + Container(height: 6, width: 3, color: Colors.white), + ]); + } + + Widget appreciationTime(String title, String value) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + title.toText13(color: MyColors.grey80Color), + value.padLeft(2, '0').toText20(color: MyColors.textMixColor), + ], + ).expanded; + } +} + +GetMenuEntriesList getMenuEntries(String type) { + List data = _ProfileInFoState.menuData.where((GetMenuEntriesList test) => test.functionName == type).toList(); + if (data.isNotEmpty) { + return data[0]; + } else { + return GetMenuEntriesList(); + } +} diff --git a/lib/ui/profile/widgets/profile_panel.dart b/lib/ui/profile/widgets/profile_panel.dart new file mode 100644 index 0000000..da3e02c --- /dev/null +++ b/lib/ui/profile/widgets/profile_panel.dart @@ -0,0 +1,49 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/models/member_information_list_model.dart'; +import 'package:mohem_flutter_app/ui/profile/widgets/profile_info.dart'; + +class ProfilePanel extends StatelessWidget { + ProfilePanel(this.memberInformationList); + + late MemberInformationListModel memberInformationList; + + @override + Widget build(BuildContext context) { + return SizedBox( + height: MediaQuery.of(context).size.height, + child: Stack( + children: [ + Container( + margin: const EdgeInsets.only(top: 32), + padding: const EdgeInsets.only(top: 37), + decoration: BoxDecoration( + color: Colors.white, + // border: Border.all(color: MyColors.lightGreyEFColor, width: 1), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(25), + topRight: Radius.circular(25), + ), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.1), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: ProfileInFo(memberInformationList), + ), + Container(height: 68, alignment: Alignment.center, child: profileImage()) + ], + ), + ); + } + + Widget profileImage() => CircleAvatar( + radius: 68, + backgroundImage: MemoryImage(Utils.getPostBytes(memberInformationList.eMPLOYEEIMAGE)), + backgroundColor: Colors.black, + ); +} diff --git a/lib/ui/screens/profile/widgets/profile_info.dart b/lib/ui/screens/profile/widgets/profile_info.dart deleted file mode 100644 index 029e50a..0000000 --- a/lib/ui/screens/profile/widgets/profile_info.dart +++ /dev/null @@ -1,160 +0,0 @@ -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/dashboard/menu_entries.dart'; -import 'package:mohem_flutter_app/models/member_information_list_model.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:mohem_flutter_app/models/profile_menu.model.dart'; -import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; -import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart'; -import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart'; -import 'package:provider/provider.dart'; - -// todo '@sultan' kindly follow structure of code written. use extension methods for widgets, also format code - -class ProfileInFo extends StatefulWidget { - ProfileInFo(this.memberInfo); - - MemberInformationListModel memberInfo; - - @override - State createState() => _ProfileInFoState(); -} - -class _ProfileInFoState extends State { - static List menuData = []; - String data = '.'; - double sliderValue = 75; - List menu = [ - ProfileMenu(name: LocaleKeys.profile_personalInformation.tr(), icon: 'personal-info.svg', route: AppRoutes.personalInfo, dynamicUrl: '', menuEntries: getMenuEntries('')), - ProfileMenu(name: LocaleKeys.profile_basicDetails.tr(), icon: 'basic-details.svg', route: AppRoutes.basicDetails, menuEntries: getMenuEntries('BASIC_DETAILS')), - ProfileMenu(name: LocaleKeys.profile_contactDetails.tr(), icon: 'contact-details.svg', route: AppRoutes.contactDetails, dynamicUrl: '', menuEntries: getMenuEntries('ADDRESS')), - ProfileMenu(name: LocaleKeys.profile_familyDetails.tr(), icon: 'family-members.svg', route: AppRoutes.familyMembers, dynamicUrl: '', menuEntries: getMenuEntries('CONTACT')), - ]; - - @override - void setState(VoidCallback fn) { - super.setState(fn); - } - - @override - Widget build(BuildContext context) { - return Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - /// card header - customLabel(widget.memberInfo.eMPLOYEENAME.toString(), 22, Colors.black, true), - - customLabel(widget.memberInfo.eMPLOYEENUMBER.toString() + ' | ' + widget.memberInfo.jOBNAME.toString(), 14, Colors.grey, false), - - customLabel(widget.memberInfo.eMPLOYEEEMAILADDRESS.toString(), 13, Colors.black, true), - - Divider(height: 40, thickness: 8, color: const Color(0xffefefef)), - - customLabel(LocaleKeys.completingYear.tr(), 10, Colors.black, true), - - SizedBox(height: 10), - Container( - child: Row(mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Column( - children: [customLabel(LocaleKeys.year.tr(), 14, const Color(0xff808080), true), customLabel(widget.memberInfo.sERVICEYEARS.toString().padLeft(2, '0'), 22, Color(0xff2BB8A6), true)], - ), - Column( - children: [customLabel(LocaleKeys.month.tr(), 14, const Color(0xff808080), true), customLabel(widget.memberInfo.sERVICEMONTHS.toString().padLeft(2, '0'), 22, Color(0xff2BB8A6), true)], - ), - Column( - children: [customLabel(LocaleKeys.day.tr(), 14, const Color(0xff808080), true), customLabel(widget.memberInfo.sERVICEDAYS.toString().padLeft(2, '0'), 22, Color(0xff2BB8A6), true)], - ) - ])), - - Divider(height: 40, thickness: 8, color: const Color(0xffefefef)), - Container( - padding: EdgeInsets.only( - left: 20, - right: 20, - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - customLabel(LocaleKeys.profile_profileCompletionPer.tr() + ' 75%', 18, Colors.black, true), - const SizedBox(height: 10), - Row( - children: [ - for (var i = 0; i < 4; i++) - if (i < 3) Expanded(child: drawSlider(Color(0xff2BB8A6))) else Expanded(child: drawSlider(const Color(0xffefefef))) - ], - ), - const SizedBox(height: 10), - Text( - LocaleKeys.profile_completeProfile.tr(), - style: TextStyle(color: Color(0xff2BB8A6), fontWeight: FontWeight.bold, decoration: TextDecoration.underline), - ), - ], - ), - ), - - /// description - Divider(height: 50, thickness: 8, color: const Color(0xffefefef)), - - Column( - children: menu.map((i) => rowItem(i, context)).toList(), - ) - ], - ), - ); - } - - Widget drawSlider(color) { - return Row(children: [ - Expanded( - flex: 1, - child: ClipRRect( - borderRadius: BorderRadius.circular(10), - child: Container( - height: 6, - width: 20, - color: color, - ), - )), - Container(height: 6, width: 3, color: Colors.white), - ]); - } - - Widget rowItem(obj, context) { - return InkWell( - onTap: () { - //if (obj.dynamicUrl == '') { - Navigator.pushNamed(context, obj.route); - // } else { - // Navigator.pushNamed(context, AppRoutes.addDynamicInputProfile, arguments: DynamicListViewParams(obj.name, obj.functionName, uRL: obj.dynamicUrl, requestID: obj.requestID)); - //} - }, - child: ListTile( - leading: SvgPicture.asset('assets/images/' + obj.icon), - title: Text(obj.name), - trailing: Icon(Icons.arrow_forward), - ), - ); - } - - Widget customLabel(String label, double size, Color color, bool isBold, {double padding = 0.0}) => Container( - padding: EdgeInsets.all(padding), - // height: 50, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.center, - children: [Text(label, style: TextStyle(color: color, fontSize: size, fontWeight: isBold ? FontWeight.bold : FontWeight.normal))])); -} - -GetMenuEntriesList getMenuEntries(String type) { - List data = _ProfileInFoState.menuData.where((GetMenuEntriesList test) => test.functionName == type).toList(); - if (data.isNotEmpty) { - return data[0]; - } else { - return GetMenuEntriesList(); - } -} diff --git a/lib/ui/screens/profile/widgets/profile_panel.dart b/lib/ui/screens/profile/widgets/profile_panel.dart deleted file mode 100644 index 1facf52..0000000 --- a/lib/ui/screens/profile/widgets/profile_panel.dart +++ /dev/null @@ -1,39 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:mohem_flutter_app/classes/utils.dart'; -import 'package:mohem_flutter_app/models/member_information_list_model.dart'; -import 'package:mohem_flutter_app/ui/screens/profile/widgets/profile_info.dart'; - -class ProfilePanle extends StatelessWidget { - ProfilePanle(this.memberInformationList); - - late MemberInformationListModel memberInformationList; - - @override - Widget build(BuildContext context) { - double _width = MediaQuery.of(context).size.width; - return Container( - margin: EdgeInsets.fromLTRB(5, 0, 5, 10), - height: MediaQuery.of(context).size.height, - child: Stack(children: [ - Container( - width: _width, - margin: EdgeInsets.only(top: 50), - padding: EdgeInsets.only(top: 50), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), - boxShadow: [BoxShadow(color: Colors.white60, blurRadius: 10, spreadRadius: 10)], - ), - child: ProfileInFo(memberInformationList), - ), - Container(height: 100, alignment: Alignment.center, child: ProfileImage()) - ])); - } - - Widget ProfileImage() => CircleAvatar( - radius: 70, - backgroundImage: MemoryImage(Utils.getPostBytes(memberInformationList.eMPLOYEEIMAGE)), - backgroundColor: Colors.black, - ); -} From 8247032a5262cea29f7eba4f660170c6a3531565 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 24 Aug 2022 16:21:34 +0300 Subject: [PATCH 13/40] profile options linked with home page personal information. --- lib/models/profile_menu.model.dart | 9 +--- .../services_menu_list_screen.dart | 13 +++++ lib/ui/profile/widgets/profile_info.dart | 47 +++++-------------- 3 files changed, 27 insertions(+), 42 deletions(-) diff --git a/lib/models/profile_menu.model.dart b/lib/models/profile_menu.model.dart index f125893..b8039ad 100644 --- a/lib/models/profile_menu.model.dart +++ b/lib/models/profile_menu.model.dart @@ -1,12 +1,7 @@ -import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart'; - class ProfileMenu { final String name; final String icon; final String route; - final String dynamicUrl; - final String functionName; - final String requestID; - final GetMenuEntriesList menuEntries; - ProfileMenu({this.name = '', this.icon = '', this.route = '', this.dynamicUrl = '', this.functionName = '', this.requestID = '', required this.menuEntries}); + + ProfileMenu({this.name = '', this.icon = '', this.route = ''}); } diff --git a/lib/ui/my_attendance/services_menu_list_screen.dart b/lib/ui/my_attendance/services_menu_list_screen.dart index fdf6e4f..eac127d 100644 --- a/lib/ui/my_attendance/services_menu_list_screen.dart +++ b/lib/ui/my_attendance/services_menu_list_screen.dart @@ -40,6 +40,19 @@ class ServicesMenuListScreen extends StatelessWidget { : ListView.separated( padding: const EdgeInsets.all(21), itemBuilder: (cxt, index) => itemView("assets/images/pdf.svg", servicesMenuData.list[index].prompt!).onPress(() { + if (servicesMenuData.list[index].parentMenuName == "MBL_PERINFO_SS") { + if (servicesMenuData.list[index].requestType == "BASIC_DETAILS") { + Navigator.pushNamed(context, AppRoutes.basicDetails); + } else if (servicesMenuData.list[index].requestType == "PHONE_NUMBERS") { + Navigator.pushNamed(context, AppRoutes.personalInfo); + } else if (servicesMenuData.list[index].requestType == "ADDRESS") { + Navigator.pushNamed(context, AppRoutes.contactDetails); + } else if (servicesMenuData.list[index].requestType == "CONTACT") { + Navigator.pushNamed(context, AppRoutes.familyMembers); + } + return; + } + Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(servicesMenuData.list[index].prompt!, servicesMenuData.list[index].functionName!)); }), separatorBuilder: (cxt, index) => 12.height, diff --git a/lib/ui/profile/widgets/profile_info.dart b/lib/ui/profile/widgets/profile_info.dart index 63880b3..2be854e 100644 --- a/lib/ui/profile/widgets/profile_info.dart +++ b/lib/ui/profile/widgets/profile_info.dart @@ -8,52 +8,38 @@ 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/dashboard/menu_entries.dart'; import 'package:mohem_flutter_app/models/member_information_list_model.dart'; import 'package:mohem_flutter_app/models/profile_menu.model.dart'; -class ProfileInFo extends StatefulWidget { - ProfileInFo(this.memberInfo); - +class ProfileInFo extends StatelessWidget { MemberInformationListModel memberInfo; - @override - State createState() => _ProfileInFoState(); -} + ProfileInFo(this.memberInfo, {Key? key}) : super(key: key); -class _ProfileInFoState extends State { - static List menuData = []; - String data = '.'; - double sliderValue = 75; List menu = [ - ProfileMenu(name: LocaleKeys.profile_personalInformation.tr(), icon: 'personal-info.svg', route: AppRoutes.personalInfo, dynamicUrl: '', menuEntries: getMenuEntries('')), - ProfileMenu(name: LocaleKeys.profile_basicDetails.tr(), icon: 'basic-details.svg', route: AppRoutes.basicDetails, menuEntries: getMenuEntries('BASIC_DETAILS')), - ProfileMenu(name: LocaleKeys.profile_contactDetails.tr(), icon: 'contact-details.svg', route: AppRoutes.contactDetails, dynamicUrl: '', menuEntries: getMenuEntries('ADDRESS')), - ProfileMenu(name: LocaleKeys.profile_familyDetails.tr(), icon: 'family-members.svg', route: AppRoutes.familyMembers, dynamicUrl: '', menuEntries: getMenuEntries('CONTACT')), + 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 - void setState(VoidCallback fn) { - super.setState(fn); - } - @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ 16.height, - widget.memberInfo.eMPLOYEENAME!.toText22(), - ("${widget.memberInfo.eMPLOYEENUMBER!} | ${widget.memberInfo.jOBNAME!}").toText13(color: MyColors.grey80Color), - widget.memberInfo.eMPLOYEEEMAILADDRESS!.toText13(), + memberInfo.eMPLOYEENAME!.toText22(), + ("${memberInfo.eMPLOYEENUMBER!} | ${memberInfo.jOBNAME!}").toText13(color: MyColors.grey80Color), + memberInfo.eMPLOYEEEMAILADDRESS!.toText13(), 12.height, const Divider(height: 8, thickness: 8, color: MyColors.lightGreyEFColor), 12.height, LocaleKeys.completingYear.tr().toText11(), Row(children: [ - appreciationTime(LocaleKeys.year.tr(), widget.memberInfo.sERVICEYEARS.toString()), - appreciationTime(LocaleKeys.month.tr(), widget.memberInfo.sERVICEMONTHS.toString()), - appreciationTime(LocaleKeys.day.tr(), widget.memberInfo.sERVICEDAYS.toString()), + appreciationTime(LocaleKeys.year.tr(), memberInfo.sERVICEYEARS.toString()), + appreciationTime(LocaleKeys.month.tr(), memberInfo.sERVICEMONTHS.toString()), + appreciationTime(LocaleKeys.day.tr(), memberInfo.sERVICEDAYS.toString()), ]).paddingOnly(bottom: 12, top: 12), const Divider(height: 8, thickness: 8, color: MyColors.lightGreyEFColor), Column( @@ -120,12 +106,3 @@ class _ProfileInFoState extends State { ).expanded; } } - -GetMenuEntriesList getMenuEntries(String type) { - List data = _ProfileInFoState.menuData.where((GetMenuEntriesList test) => test.functionName == type).toList(); - if (data.isNotEmpty) { - return data[0]; - } else { - return GetMenuEntriesList(); - } -} From a22f679908104f386eac0c8c971abbfc01009c83 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Thu, 25 Aug 2022 08:06:41 +0300 Subject: [PATCH 14/40] my team module and workList settings --- lib/api/monthly_attendance_api_client.dart | 1 - lib/api/my_team/my_team_api_client.dart | 149 +++++ lib/api/worklist/worklist_api_client.dart | 11 +- lib/classes/colors.dart | 1 + lib/config/routes.dart | 32 + lib/models/generic_response_model.dart | 18 +- lib/models/get_user_item_type_list.dart | 7 +- .../get_attendance_tracking_list_model.dart | 58 ++ .../get_employee_subordinates_list.dart | 313 ++++++++++ lib/models/profile_menu.model.dart | 3 +- lib/models/update_item_type_success_list.dart | 2 +- .../worklist/update_user_type_list.dart | 28 + lib/ui/landing/widget/app_drawer.dart | 11 + lib/ui/my_team/create_request.dart | 95 +++ lib/ui/my_team/employee_details.dart | 314 ++++++++++ lib/ui/my_team/my_team.dart | 241 ++++++++ lib/ui/my_team/profile_details.dart | 91 +++ lib/ui/my_team/team_members.dart | 156 +++++ lib/ui/my_team/view_attendance.dart | 569 ++++++++++++++++++ lib/ui/profile/family_members.dart | 51 +- lib/ui/work_list/worklist_settings.dart | 197 ++++++ lib/widgets/app_bar_widget.dart | 2 + pubspec.yaml | 1 + 23 files changed, 2329 insertions(+), 22 deletions(-) create mode 100644 lib/api/my_team/my_team_api_client.dart create mode 100644 lib/models/my_team/get_attendance_tracking_list_model.dart create mode 100644 lib/models/my_team/get_employee_subordinates_list.dart create mode 100644 lib/models/worklist/update_user_type_list.dart create mode 100644 lib/ui/my_team/create_request.dart create mode 100644 lib/ui/my_team/employee_details.dart create mode 100644 lib/ui/my_team/my_team.dart create mode 100644 lib/ui/my_team/profile_details.dart create mode 100644 lib/ui/my_team/team_members.dart create mode 100644 lib/ui/my_team/view_attendance.dart create mode 100644 lib/ui/work_list/worklist_settings.dart diff --git a/lib/api/monthly_attendance_api_client.dart b/lib/api/monthly_attendance_api_client.dart index 543addb..00d444f 100644 --- a/lib/api/monthly_attendance_api_client.dart +++ b/lib/api/monthly_attendance_api_client.dart @@ -10,7 +10,6 @@ import 'package:mohem_flutter_app/models/get_schedule_shifts_details_list_model. import 'package:mohem_flutter_app/models/get_time_card_summary_list_model.dart'; import 'package:mohem_flutter_app/api/api_client.dart'; -// todo '@fatima' change file name according to structure class MonthlyAttendanceApiClient { static final MonthlyAttendanceApiClient _instance = MonthlyAttendanceApiClient._internal(); diff --git a/lib/api/my_team/my_team_api_client.dart b/lib/api/my_team/my_team_api_client.dart new file mode 100644 index 0000000..4a843c1 --- /dev/null +++ b/lib/api/my_team/my_team_api_client.dart @@ -0,0 +1,149 @@ + + +import 'package:mohem_flutter_app/api/api_client.dart'; +import 'package:mohem_flutter_app/app_state/app_state.dart'; +import 'package:mohem_flutter_app/classes/consts.dart'; +import 'package:mohem_flutter_app/models/dashboard/get_attendance_tracking_list_model.dart'; +import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart'; +import 'package:mohem_flutter_app/models/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/get_day_hours_type_details_list_model.dart'; +import 'package:mohem_flutter_app/models/get_time_card_summary_list_model.dart'; +import 'package:mohem_flutter_app/models/my_team/get_employee_subordinates_list.dart'; +import 'package:mohem_flutter_app/models/worklist/get_favorite_replacements_model.dart'; + +class MyTeamApiClient { + static final MyTeamApiClient _instance = MyTeamApiClient._internal(); + + MyTeamApiClient._internal(); + + factory MyTeamApiClient() => _instance; + + + Future> getEmployeeSubordinates(String searchEmpEmail, String searchEmpName, String searchEmpNo) async { + String url = "${ApiConsts.erpRest}GET_EMPLOYEE_SUBORDINATES"; + Map postParams = { + "P_PAGE_LIMIT": 50, + "P_PAGE_NUM": 1, + "P_SEARCH_EMAIL_ADDRESS": searchEmpEmail, + "P_SEARCH_EMPLOYEE_DISPLAY_NAME": searchEmpName, + "P_SEARCH_EMPLOYEE_NUMBER": searchEmpNo, + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.getEmployeeSubordinatesList ?? []; + }, url, postParams); + } + + Future getTimeCardSummary(String month, int year, String? empID) async { + String url = "${ApiConsts.erpRest}GET_TIME_CARD_SUMMARY"; + Map postParams = { + "P_MENU_TYPE": "M", + "P_SELECTED_RESP_ID": -999, + "SearchMonth": month, + "SearchYear": year, + }; + + postParams.addAll(AppState().postParamsJson); + postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return (responseData.getTimeCardSummaryList?.length ?? 0) > 0 ? responseData.getTimeCardSummaryList!.first : null; + }, url, postParams); + } + + Future> getDayHoursTypeDetails(String month, int year, String? empID) async { + String url = "${ApiConsts.erpRest}GET_DAY_HOURS_TYPE_DETAILS"; + Map postParams = { + "P_MENU_TYPE": "M", + "P_PAGE_LIMIT": 100, + "P_PAGE_NUM": 1, + "P_SELECTED_RESP_ID": -999, + "SearchMonth": month, + "SearchYear": year, + }; + postParams.addAll(AppState().postParamsJson); + postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + print(responseData.getDayHoursTypeDetailsList!.length); + return responseData.getDayHoursTypeDetailsList ?? []; + }, url, postParams); + } + + + Future getAttendanceTracking(String? empID) async { + String url = "${ApiConsts.erpRest}GET_Attendance_Tracking"; + Map postParams = {}; + postParams.addAll(AppState().postParamsJson); + postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + print(responseData.getAttendanceTrackingList); + return responseData.getAttendanceTrackingList; + }, url, postParams); + } + + Future> employeeSubordinates(String searchEmpEmail, String searchEmpName, String searchEmpNo, String? empID) async { + String url = "${ApiConsts.erpRest}GET_EMPLOYEE_SUBORDINATES"; + Map postParams = { + "P_PAGE_LIMIT": 50, + "P_PAGE_NUM": 1, + "P_SEARCH_EMAIL_ADDRESS": searchEmpEmail, + "P_SEARCH_EMPLOYEE_DISPLAY_NAME": searchEmpName, + "P_SEARCH_EMPLOYEE_NUMBER": searchEmpNo, + }; + postParams.addAll(AppState().postParamsJson); + postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.getEmployeeSubordinatesList ?? []; + }, url, postParams); + } + + Future> employeeSubordinatesRequest(String? empID) async { + String url = "${ApiConsts.erpRest}GET_MENU_ENTRIES"; + Map postParams = { + "P_MENU_TYPE": "M", + "P_SELECTED_RESP_ID": -999, + }; + postParams.addAll(AppState().postParamsJson); + postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.getMenuEntriesList ?? []; + }, url, postParams); + } + + Future?> getFavoriteReplacement() async { + String url = "${ApiConsts.erpRest}Mohemm_GetFavoriteReplacements"; + Map postParams = { + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + return responseData.mohemmGetFavoriteReplacementsList; + }, url, postParams); + } + + Future changeFavoriteReplacements({required String email, required String employeName, required String image, required String userName, bool isFav = false}) async { + String url = "${ApiConsts.erpRest}Mohemm_ChangeFavoriteReplacements"; + Map postParamsObj = { + "EMAIL_ADDRESS": email, + "EMPLOYEE_DISPLAY_NAME": employeName, + "EMPLOYEE_IMAGE": image, + "IsFavorite": isFav, + "USER_NAME": userName, + }; + Map postParams = { + "Mohemm_ChangeReplacementsInputList": [postParamsObj], + //postParams["Mohemm_ChangeReplacementsInputList"] = list; + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + return responseData; + }, url, postParams); + } +} + diff --git a/lib/api/worklist/worklist_api_client.dart b/lib/api/worklist/worklist_api_client.dart index 2566e59..f1f9408 100644 --- a/lib/api/worklist/worklist_api_client.dart +++ b/lib/api/worklist/worklist_api_client.dart @@ -28,6 +28,7 @@ import 'package:mohem_flutter_app/models/worklist/hr/get_basic_det_ntf_body_list import 'package:mohem_flutter_app/models/worklist/hr/get_contact_notification_body_list_model.dart'; import 'package:mohem_flutter_app/models/worklist/hr/get_phones_notification_body_list_model.dart'; import 'package:mohem_flutter_app/models/worklist/replacement_list_model.dart'; +import 'package:mohem_flutter_app/models/worklist/update_user_type_list.dart'; import 'package:mohem_flutter_app/models/worklist_response_model.dart'; class WorkListApiClient { @@ -449,7 +450,7 @@ class WorkListApiClient { } - Future?> getUserItemTypes() async { + Future> getUserItemTypes() async { String url = "${ApiConsts.erpRest}GET_USER_ITEM_TYPES"; Map postParams = { @@ -457,14 +458,14 @@ class WorkListApiClient { postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); - return responseData.getUserItemTypesList; + return responseData.getUserItemTypesList ?? []; }, url, postParams); } - Future updateUserItemTypes() async { + Future updateUserItemTypes(List> itemList) async { String url = "${ApiConsts.erpRest}UPDATE_USER_ITEM_TYPES"; Map postParams = { - + "UpdateItemTypeList": itemList }; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { @@ -472,4 +473,6 @@ class WorkListApiClient { return responseData.updateUserItemTypesList; }, url, postParams); } + + } diff --git a/lib/classes/colors.dart b/lib/classes/colors.dart index 4b34186..c5d469d 100644 --- a/lib/classes/colors.dart +++ b/lib/classes/colors.dart @@ -38,4 +38,5 @@ class MyColors { static const Color darkColor = Color(0xff000015); static const Color lightGrayColor = Color(0xff808080); static const Color DarkRedColor = Color(0xffD02127); + static const Color lightGreyColor = Color(0xffC7C7C7); } diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 9285671..a9c5ae2 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -14,6 +14,12 @@ import 'package:mohem_flutter_app/ui/misc/request_submit_screen.dart'; import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart'; import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart'; import 'package:mohem_flutter_app/ui/my_attendance/my_attendance_screen.dart'; +import 'package:mohem_flutter_app/ui/my_team/create_request.dart'; +import 'package:mohem_flutter_app/ui/my_team/employee_details.dart'; +import 'package:mohem_flutter_app/ui/my_team/my_team.dart'; +import 'package:mohem_flutter_app/ui/my_team/profile_details.dart'; +import 'package:mohem_flutter_app/ui/my_team/team_members.dart'; +import 'package:mohem_flutter_app/ui/my_team/view_attendance.dart'; import 'package:mohem_flutter_app/ui/payslip/monthly_pay_slip_screen.dart'; import 'package:mohem_flutter_app/ui/profile/add_update_family_member.dart'; import 'package:mohem_flutter_app/ui/profile/basic_details.dart'; @@ -38,6 +44,9 @@ import 'package:mohem_flutter_app/ui/work_list/item_history_screen.dart'; import 'package:mohem_flutter_app/ui/work_list/itg_detail_screen.dart'; import 'package:mohem_flutter_app/ui/work_list/work_list_screen.dart'; import 'package:mohem_flutter_app/ui/work_list/worklist_detail_screen.dart'; +import 'package:mohem_flutter_app/ui/my_team/my_team.dart'; +import 'package:mohem_flutter_app/ui/my_team/create_request.dart'; +import 'package:mohem_flutter_app/ui/work_list/worklist_settings.dart'; class AppRoutes { static const String splash = "/splash"; @@ -60,6 +69,7 @@ class AppRoutes { static const String workListDetail = "/workListDetail"; static const String itgDetail = "/itgDetail"; static const String itemHistory = "/itemHistory"; + static const String worklistSettings = "/worklistSettings"; static const String myAttendance = "/myAttendance"; static const String dynamicScreen = "/dynamicScreen"; @@ -104,6 +114,15 @@ class AppRoutes { //Pay slip static const String monthlyPaySlip = "/monthlyPaySlip"; + //My Team + static const String myTeam = "/myTeam"; + static const String employeeDetails = "/employeeDetails"; + static const String profileDetails = "/profileDetails"; + static const String viewAttendance = "/viewAttendance"; + static const String teamMembers = "/teamMembers"; + static const String createRequest = "/createRequest"; + + static final Map routes = { login: (context) => LoginScreen(), verifyLogin: (context) => VerifyLoginScreen(), @@ -123,6 +142,7 @@ class AppRoutes { workListDetail: (context) => WorkListDetailScreen(), itgDetail: (context) => ItgDetailScreen(), itemHistory: (context) => ItemHistoryScreen(), + worklistSettings: (context) => WorklistSettings(), myAttendance: (context) => MyAttendanceScreen(), // workFromHome: (context) => WorkFromHomeScreen(), @@ -165,5 +185,17 @@ class AppRoutes { //pay slip monthlyPaySlip: (context) => MonthlyPaySlipScreen(), + + //My Team + myTeam: (context) => MyTeam(), + employeeDetails: (context) => EmployeeDetails(), + profileDetails: (context) => ProfileDetails(), + viewAttendance: (context) => ViewAttendance(), + teamMembers: (context) => TeamMembers(), + createRequest: (context) => CreateRequest(), + + + + }; } diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index 23536bf..563804f 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -48,6 +48,7 @@ import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_details.dart'; import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_transactions.dart'; import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_types.dart'; import 'package:mohem_flutter_app/models/mowadhafhi/get_tickets_list.dart'; +import 'package:mohem_flutter_app/models/my_team/get_employee_subordinates_list.dart'; 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/pending_transactions/get_pending_transactions_details.dart'; @@ -172,7 +173,7 @@ class GenericResponseModel { List? getEmployeeBasicDetailsList; List? getEmployeeContactsList; List? getEmployeePhonesList; - List? getEmployeeSubordinatesList; + List? getEmployeeSubordinatesList; List? getFliexfieldStructureList; List? getHrCollectionNotificationBodyList; List? getHrTransactionList; @@ -285,7 +286,7 @@ class GenericResponseModel { String? pForm; String? pINFORMATION; int? pMBLID; - String? pNUMOFSUBORDINATES; + int? pNUMOFSUBORDINATES; int? pOPENNTFNUMBER; String? pQUESTION; int? pSESSIONID; @@ -830,7 +831,13 @@ class GenericResponseModel { getEmployeePhonesList!.add(new GetEmployeePhonesList.fromJson(v)); }); } - getEmployeeSubordinatesList = json['GetEmployeeSubordinatesList']; + if (json['GetEmployeeSubordinatesList'] != null) { + getEmployeeSubordinatesList = []; + json['GetEmployeeSubordinatesList'].forEach((v) { + getEmployeeSubordinatesList! + .add(new GetEmployeeSubordinatesList.fromJson(v)); + }); + } getFliexfieldStructureList = json['GetFliexfieldStructureList']; getHrCollectionNotificationBodyList = json['GetHrCollectionNotificationBodyList']; getHrTransactionList = json['GetHrTransactionList']; @@ -1402,7 +1409,10 @@ class GenericResponseModel { if (this.getEmployeePhonesList != null) { data['GetEmployeePhonesList'] = this.getEmployeePhonesList!.map((v) => v.toJson()).toList(); } - data['GetEmployeeSubordinatesList'] = this.getEmployeeSubordinatesList; + if (this.getEmployeeSubordinatesList != null) { + data['GetEmployeeSubordinatesList'] = + this.getEmployeeSubordinatesList!.map((v) => v.toJson()).toList(); + } data['GetFliexfieldStructureList'] = this.getFliexfieldStructureList; data['GetHrCollectionNotificationBodyList'] = this.getHrCollectionNotificationBodyList; data['GetHrTransactionList'] = this.getHrTransactionList; diff --git a/lib/models/get_user_item_type_list.dart b/lib/models/get_user_item_type_list.dart index fc7f4c3..a197c2e 100644 --- a/lib/models/get_user_item_type_list.dart +++ b/lib/models/get_user_item_type_list.dart @@ -5,12 +5,17 @@ class GetUserItemTypesList { String? fYIENABLEDFLAG; String? iTEMTYPE; int? uSERITEMTYPEID; + bool? isFYI; + bool? isFYA; GetUserItemTypesList( {this.fYAENABLEDFALG, this.fYIENABLEDFLAG, this.iTEMTYPE, - this.uSERITEMTYPEID}); + this.uSERITEMTYPEID, + this.isFYI, + this.isFYA + }); GetUserItemTypesList.fromJson(Map json) { fYAENABLEDFALG = json['FYA_ENABLED_FALG']; diff --git a/lib/models/my_team/get_attendance_tracking_list_model.dart b/lib/models/my_team/get_attendance_tracking_list_model.dart new file mode 100644 index 0000000..7670702 --- /dev/null +++ b/lib/models/my_team/get_attendance_tracking_list_model.dart @@ -0,0 +1,58 @@ + + +class GetAttendanceTrackingList { + String? pBREAKHOURS; + String? pLATEINHOURS; + String? pREMAININGHOURS; + String? pRETURNMSG; + String? pRETURNSTATUS; + String? pSCHEDULEDHOURS; + String? pSHTNAME; + String? pSPENTHOURS; + String? pSWIPESEXEMPTEDFLAG; + Null? pSWIPEIN; + Null? pSWIPEOUT; + + GetAttendanceTrackingList( + {this.pBREAKHOURS, + this.pLATEINHOURS, + this.pREMAININGHOURS, + this.pRETURNMSG, + this.pRETURNSTATUS, + this.pSCHEDULEDHOURS, + this.pSHTNAME, + this.pSPENTHOURS, + this.pSWIPESEXEMPTEDFLAG, + this.pSWIPEIN, + this.pSWIPEOUT}); + + GetAttendanceTrackingList.fromJson(Map json) { + pBREAKHOURS = json['P_BREAK_HOURS']; + pLATEINHOURS = json['P_LATE_IN_HOURS']; + pREMAININGHOURS = json['P_REMAINING_HOURS']; + pRETURNMSG = json['P_RETURN_MSG']; + pRETURNSTATUS = json['P_RETURN_STATUS']; + pSCHEDULEDHOURS = json['P_SCHEDULED_HOURS']; + pSHTNAME = json['P_SHT_NAME']; + pSPENTHOURS = json['P_SPENT_HOURS']; + pSWIPESEXEMPTEDFLAG = json['P_SWIPES_EXEMPTED_FLAG']; + pSWIPEIN = json['P_SWIPE_IN']; + pSWIPEOUT = json['P_SWIPE_OUT']; + } + + Map toJson() { + final Map data = new Map(); + data['P_BREAK_HOURS'] = this.pBREAKHOURS; + data['P_LATE_IN_HOURS'] = this.pLATEINHOURS; + data['P_REMAINING_HOURS'] = this.pREMAININGHOURS; + data['P_RETURN_MSG'] = this.pRETURNMSG; + data['P_RETURN_STATUS'] = this.pRETURNSTATUS; + data['P_SCHEDULED_HOURS'] = this.pSCHEDULEDHOURS; + data['P_SHT_NAME'] = this.pSHTNAME; + data['P_SPENT_HOURS'] = this.pSPENTHOURS; + data['P_SWIPES_EXEMPTED_FLAG'] = this.pSWIPESEXEMPTEDFLAG; + data['P_SWIPE_IN'] = this.pSWIPEIN; + data['P_SWIPE_OUT'] = this.pSWIPEOUT; + return data; + } +} \ No newline at end of file diff --git a/lib/models/my_team/get_employee_subordinates_list.dart b/lib/models/my_team/get_employee_subordinates_list.dart new file mode 100644 index 0000000..b90034b --- /dev/null +++ b/lib/models/my_team/get_employee_subordinates_list.dart @@ -0,0 +1,313 @@ + +class GetEmployeeSubordinatesList { + String? aCTUALTERMINATIONDATE; + String? aSSIGNMENTENDDATE; + int? aSSIGNMENTID; + String? aSSIGNMENTNUMBER; + String? aSSIGNMENTSTARTDATE; + int? aSSIGNMENTSTATUSTYPEID; + String? aSSIGNMENTTYPE; + int? bUSINESSGROUPID; + String? bUSINESSGROUPNAME; + String? cURRENTEMPLOYEEFLAG; + String? eMPLOYEEDISPLAYNAME; + String? eMPLOYEEEMAILADDRESS; + String? eMPLOYEEIMAGE; + String? eMPLOYEEMOBILENUMBER; + String? eMPLOYEENAME; + String? eMPLOYEENUMBER; + String? eMPLOYEEWORKNUMBER; + String? eMPLOYMENTCATEGORY; + String? eMPLOYMENTCATEGORYMEANING; + String? fREQUENCY; + String? fREQUENCYMEANING; + int? fROMROWNUM; + dynamic? gRADEID; + dynamic? gRADENAME; + dynamic? genderCode; + dynamic? genderMeaning; + String? hIREDATE; + bool? isFavorite; + int? jOBID; + String? jOBNAME; + int? lOCATIONID; + String? lOCATIONNAME; + String? mANUALTIMECARDFLAG; + String? mANUALTIMECARDMEANING; + String? nATIONALITYCODE; + String? nATIONALITYMEANING; + String? nATIONALIDENTIFIER; + dynamic? nORMALHOURS; + int? nOOFROWS; + int? nUMOFSUBORDINATES; + int? oRGANIZATIONID; + String? oRGANIZATIONNAME; + String? pAYROLLCODE; + int? pAYROLLID; + String? pAYROLLNAME; + int? pERSONID; + String? pERSONTYPE; + int? pERSONTYPEID; + String? pERINFORMATIONCATEGORY; + int? pOSITIONID; + String? pOSITIONNAME; + String? pRIMARYFLAG; + int? rOWNUM; + int? sERVICEDAYS; + int? sERVICEMONTHS; + int? sERVICEYEARS; + String? sUPERVISORASSIGNMENTID; + String? sUPERVISORDISPLAYNAME; + String? sUPERVISOREMAILADDRESS; + int? sUPERVISORID; + String? sUPERVISORMOBILENUMBER; + String? sUPERVISORNAME; + String? sUPERVISORNUMBER; + String? sUPERVISORWORKNUMBER; + String? sWIPESEXEMPTEDFLAG; + String? sWIPESEXEMPTEDMEANING; + String? sYSTEMPERSONTYPE; + String? tKEMAILADDRESS; + String? tKEMPLOYEEDISPLAYNAME; + String? tKEMPLOYEENAME; + String? tKEMPLOYEENUMBER; + int? tKPERSONID; + int? tOROWNUM; + String? uNITNUMBER; + String? uSERSTATUS; + + GetEmployeeSubordinatesList( + {this.aCTUALTERMINATIONDATE, + this.aSSIGNMENTENDDATE, + this.aSSIGNMENTID, + this.aSSIGNMENTNUMBER, + this.aSSIGNMENTSTARTDATE, + this.aSSIGNMENTSTATUSTYPEID, + this.aSSIGNMENTTYPE, + this.bUSINESSGROUPID, + this.bUSINESSGROUPNAME, + this.cURRENTEMPLOYEEFLAG, + this.eMPLOYEEDISPLAYNAME, + this.eMPLOYEEEMAILADDRESS, + this.eMPLOYEEIMAGE, + this.eMPLOYEEMOBILENUMBER, + this.eMPLOYEENAME, + this.eMPLOYEENUMBER, + this.eMPLOYEEWORKNUMBER, + this.eMPLOYMENTCATEGORY, + this.eMPLOYMENTCATEGORYMEANING, + this.fREQUENCY, + this.fREQUENCYMEANING, + this.fROMROWNUM, + this.gRADEID, + this.gRADENAME, + this.genderCode, + this.genderMeaning, + this.hIREDATE, + this.isFavorite, + this.jOBID, + this.jOBNAME, + this.lOCATIONID, + this.lOCATIONNAME, + this.mANUALTIMECARDFLAG, + this.mANUALTIMECARDMEANING, + this.nATIONALITYCODE, + this.nATIONALITYMEANING, + this.nATIONALIDENTIFIER, + this.nORMALHOURS, + this.nOOFROWS, + this.nUMOFSUBORDINATES, + this.oRGANIZATIONID, + this.oRGANIZATIONNAME, + this.pAYROLLCODE, + this.pAYROLLID, + this.pAYROLLNAME, + this.pERSONID, + this.pERSONTYPE, + this.pERSONTYPEID, + this.pERINFORMATIONCATEGORY, + this.pOSITIONID, + this.pOSITIONNAME, + this.pRIMARYFLAG, + this.rOWNUM, + this.sERVICEDAYS, + this.sERVICEMONTHS, + this.sERVICEYEARS, + this.sUPERVISORASSIGNMENTID, + this.sUPERVISORDISPLAYNAME, + this.sUPERVISOREMAILADDRESS, + this.sUPERVISORID, + this.sUPERVISORMOBILENUMBER, + this.sUPERVISORNAME, + this.sUPERVISORNUMBER, + this.sUPERVISORWORKNUMBER, + this.sWIPESEXEMPTEDFLAG, + this.sWIPESEXEMPTEDMEANING, + this.sYSTEMPERSONTYPE, + this.tKEMAILADDRESS, + this.tKEMPLOYEEDISPLAYNAME, + this.tKEMPLOYEENAME, + this.tKEMPLOYEENUMBER, + this.tKPERSONID, + this.tOROWNUM, + this.uNITNUMBER, + this.uSERSTATUS}); + + GetEmployeeSubordinatesList.fromJson(Map json) { + aCTUALTERMINATIONDATE = json['ACTUAL_TERMINATION_DATE']; + aSSIGNMENTENDDATE = json['ASSIGNMENT_END_DATE']; + aSSIGNMENTID = json['ASSIGNMENT_ID']; + aSSIGNMENTNUMBER = json['ASSIGNMENT_NUMBER']; + aSSIGNMENTSTARTDATE = json['ASSIGNMENT_START_DATE']; + aSSIGNMENTSTATUSTYPEID = json['ASSIGNMENT_STATUS_TYPE_ID']; + aSSIGNMENTTYPE = json['ASSIGNMENT_TYPE']; + bUSINESSGROUPID = json['BUSINESS_GROUP_ID']; + bUSINESSGROUPNAME = json['BUSINESS_GROUP_NAME']; + cURRENTEMPLOYEEFLAG = json['CURRENT_EMPLOYEE_FLAG']; + eMPLOYEEDISPLAYNAME = json['EMPLOYEE_DISPLAY_NAME']; + eMPLOYEEEMAILADDRESS = json['EMPLOYEE_EMAIL_ADDRESS']; + eMPLOYEEIMAGE = json['EMPLOYEE_IMAGE']; + eMPLOYEEMOBILENUMBER = json['EMPLOYEE_MOBILE_NUMBER']; + eMPLOYEENAME = json['EMPLOYEE_NAME']; + eMPLOYEENUMBER = json['EMPLOYEE_NUMBER']; + eMPLOYEEWORKNUMBER = json['EMPLOYEE_WORK_NUMBER']; + eMPLOYMENTCATEGORY = json['EMPLOYMENT_CATEGORY']; + eMPLOYMENTCATEGORYMEANING = json['EMPLOYMENT_CATEGORY_MEANING']; + fREQUENCY = json['FREQUENCY']; + fREQUENCYMEANING = json['FREQUENCY_MEANING']; + fROMROWNUM = json['FROM_ROW_NUM']; + gRADEID = json['GRADE_ID']; + gRADENAME = json['GRADE_NAME']; + genderCode = json['GenderCode']; + genderMeaning = json['GenderMeaning']; + hIREDATE = json['HIRE_DATE']; + isFavorite = json['IsFavorite']; + jOBID = json['JOB_ID']; + jOBNAME = json['JOB_NAME']; + lOCATIONID = json['LOCATION_ID']; + lOCATIONNAME = json['LOCATION_NAME']; + mANUALTIMECARDFLAG = json['MANUAL_TIMECARD_FLAG']; + mANUALTIMECARDMEANING = json['MANUAL_TIMECARD_MEANING']; + nATIONALITYCODE = json['NATIONALITY_CODE']; + nATIONALITYMEANING = json['NATIONALITY_MEANING']; + nATIONALIDENTIFIER = json['NATIONAL_IDENTIFIER']; + nORMALHOURS = json['NORMAL_HOURS']; + nOOFROWS = json['NO_OF_ROWS']; + nUMOFSUBORDINATES = json['NUM_OF_SUBORDINATES']; + oRGANIZATIONID = json['ORGANIZATION_ID']; + oRGANIZATIONNAME = json['ORGANIZATION_NAME']; + pAYROLLCODE = json['PAYROLL_CODE']; + pAYROLLID = json['PAYROLL_ID']; + pAYROLLNAME = json['PAYROLL_NAME']; + pERSONID = json['PERSON_ID']; + pERSONTYPE = json['PERSON_TYPE']; + pERSONTYPEID = json['PERSON_TYPE_ID']; + pERINFORMATIONCATEGORY = json['PER_INFORMATION_CATEGORY']; + pOSITIONID = json['POSITION_ID']; + pOSITIONNAME = json['POSITION_NAME']; + pRIMARYFLAG = json['PRIMARY_FLAG']; + rOWNUM = json['ROW_NUM']; + sERVICEDAYS = json['SERVICE_DAYS']; + sERVICEMONTHS = json['SERVICE_MONTHS']; + sERVICEYEARS = json['SERVICE_YEARS']; + sUPERVISORASSIGNMENTID = json['SUPERVISOR_ASSIGNMENT_ID']; + sUPERVISORDISPLAYNAME = json['SUPERVISOR_DISPLAY_NAME']; + sUPERVISOREMAILADDRESS = json['SUPERVISOR_EMAIL_ADDRESS']; + sUPERVISORID = json['SUPERVISOR_ID']; + sUPERVISORMOBILENUMBER = json['SUPERVISOR_MOBILE_NUMBER']; + sUPERVISORNAME = json['SUPERVISOR_NAME']; + sUPERVISORNUMBER = json['SUPERVISOR_NUMBER']; + sUPERVISORWORKNUMBER = json['SUPERVISOR_WORK_NUMBER']; + sWIPESEXEMPTEDFLAG = json['SWIPES_EXEMPTED_FLAG']; + sWIPESEXEMPTEDMEANING = json['SWIPES_EXEMPTED_MEANING']; + sYSTEMPERSONTYPE = json['SYSTEM_PERSON_TYPE']; + tKEMAILADDRESS = json['TK_EMAIL_ADDRESS']; + tKEMPLOYEEDISPLAYNAME = json['TK_EMPLOYEE_DISPLAY_NAME']; + tKEMPLOYEENAME = json['TK_EMPLOYEE_NAME']; + tKEMPLOYEENUMBER = json['TK_EMPLOYEE_NUMBER']; + tKPERSONID = json['TK_PERSON_ID']; + tOROWNUM = json['TO_ROW_NUM']; + uNITNUMBER = json['UNIT_NUMBER']; + uSERSTATUS = json['USER_STATUS']; + } + + Map toJson() { + final Map data = new Map(); + data['ACTUAL_TERMINATION_DATE'] = this.aCTUALTERMINATIONDATE; + data['ASSIGNMENT_END_DATE'] = this.aSSIGNMENTENDDATE; + data['ASSIGNMENT_ID'] = this.aSSIGNMENTID; + data['ASSIGNMENT_NUMBER'] = this.aSSIGNMENTNUMBER; + data['ASSIGNMENT_START_DATE'] = this.aSSIGNMENTSTARTDATE; + data['ASSIGNMENT_STATUS_TYPE_ID'] = this.aSSIGNMENTSTATUSTYPEID; + data['ASSIGNMENT_TYPE'] = this.aSSIGNMENTTYPE; + data['BUSINESS_GROUP_ID'] = this.bUSINESSGROUPID; + data['BUSINESS_GROUP_NAME'] = this.bUSINESSGROUPNAME; + data['CURRENT_EMPLOYEE_FLAG'] = this.cURRENTEMPLOYEEFLAG; + data['EMPLOYEE_DISPLAY_NAME'] = this.eMPLOYEEDISPLAYNAME; + data['EMPLOYEE_EMAIL_ADDRESS'] = this.eMPLOYEEEMAILADDRESS; + data['EMPLOYEE_IMAGE'] = this.eMPLOYEEIMAGE; + data['EMPLOYEE_MOBILE_NUMBER'] = this.eMPLOYEEMOBILENUMBER; + data['EMPLOYEE_NAME'] = this.eMPLOYEENAME; + data['EMPLOYEE_NUMBER'] = this.eMPLOYEENUMBER; + data['EMPLOYEE_WORK_NUMBER'] = this.eMPLOYEEWORKNUMBER; + data['EMPLOYMENT_CATEGORY'] = this.eMPLOYMENTCATEGORY; + data['EMPLOYMENT_CATEGORY_MEANING'] = this.eMPLOYMENTCATEGORYMEANING; + data['FREQUENCY'] = this.fREQUENCY; + data['FREQUENCY_MEANING'] = this.fREQUENCYMEANING; + data['FROM_ROW_NUM'] = this.fROMROWNUM; + data['GRADE_ID'] = this.gRADEID; + data['GRADE_NAME'] = this.gRADENAME; + data['GenderCode'] = this.genderCode; + data['GenderMeaning'] = this.genderMeaning; + data['HIRE_DATE'] = this.hIREDATE; + data['IsFavorite'] = this.isFavorite; + data['JOB_ID'] = this.jOBID; + data['JOB_NAME'] = this.jOBNAME; + data['LOCATION_ID'] = this.lOCATIONID; + data['LOCATION_NAME'] = this.lOCATIONNAME; + data['MANUAL_TIMECARD_FLAG'] = this.mANUALTIMECARDFLAG; + data['MANUAL_TIMECARD_MEANING'] = this.mANUALTIMECARDMEANING; + data['NATIONALITY_CODE'] = this.nATIONALITYCODE; + data['NATIONALITY_MEANING'] = this.nATIONALITYMEANING; + data['NATIONAL_IDENTIFIER'] = this.nATIONALIDENTIFIER; + data['NORMAL_HOURS'] = this.nORMALHOURS; + data['NO_OF_ROWS'] = this.nOOFROWS; + data['NUM_OF_SUBORDINATES'] = this.nUMOFSUBORDINATES; + data['ORGANIZATION_ID'] = this.oRGANIZATIONID; + data['ORGANIZATION_NAME'] = this.oRGANIZATIONNAME; + data['PAYROLL_CODE'] = this.pAYROLLCODE; + data['PAYROLL_ID'] = this.pAYROLLID; + data['PAYROLL_NAME'] = this.pAYROLLNAME; + data['PERSON_ID'] = this.pERSONID; + data['PERSON_TYPE'] = this.pERSONTYPE; + data['PERSON_TYPE_ID'] = this.pERSONTYPEID; + data['PER_INFORMATION_CATEGORY'] = this.pERINFORMATIONCATEGORY; + data['POSITION_ID'] = this.pOSITIONID; + data['POSITION_NAME'] = this.pOSITIONNAME; + data['PRIMARY_FLAG'] = this.pRIMARYFLAG; + data['ROW_NUM'] = this.rOWNUM; + data['SERVICE_DAYS'] = this.sERVICEDAYS; + data['SERVICE_MONTHS'] = this.sERVICEMONTHS; + data['SERVICE_YEARS'] = this.sERVICEYEARS; + data['SUPERVISOR_ASSIGNMENT_ID'] = this.sUPERVISORASSIGNMENTID; + data['SUPERVISOR_DISPLAY_NAME'] = this.sUPERVISORDISPLAYNAME; + data['SUPERVISOR_EMAIL_ADDRESS'] = this.sUPERVISOREMAILADDRESS; + data['SUPERVISOR_ID'] = this.sUPERVISORID; + data['SUPERVISOR_MOBILE_NUMBER'] = this.sUPERVISORMOBILENUMBER; + data['SUPERVISOR_NAME'] = this.sUPERVISORNAME; + data['SUPERVISOR_NUMBER'] = this.sUPERVISORNUMBER; + data['SUPERVISOR_WORK_NUMBER'] = this.sUPERVISORWORKNUMBER; + data['SWIPES_EXEMPTED_FLAG'] = this.sWIPESEXEMPTEDFLAG; + data['SWIPES_EXEMPTED_MEANING'] = this.sWIPESEXEMPTEDMEANING; + data['SYSTEM_PERSON_TYPE'] = this.sYSTEMPERSONTYPE; + data['TK_EMAIL_ADDRESS'] = this.tKEMAILADDRESS; + data['TK_EMPLOYEE_DISPLAY_NAME'] = this.tKEMPLOYEEDISPLAYNAME; + data['TK_EMPLOYEE_NAME'] = this.tKEMPLOYEENAME; + data['TK_EMPLOYEE_NUMBER'] = this.tKEMPLOYEENUMBER; + data['TK_PERSON_ID'] = this.tKPERSONID; + data['TO_ROW_NUM'] = this.tOROWNUM; + data['UNIT_NUMBER'] = this.uNITNUMBER; + data['USER_STATUS'] = this.uSERSTATUS; + return data; + } +} \ No newline at end of file diff --git a/lib/models/profile_menu.model.dart b/lib/models/profile_menu.model.dart index 65a9069..c585056 100644 --- a/lib/models/profile_menu.model.dart +++ b/lib/models/profile_menu.model.dart @@ -10,5 +10,6 @@ class ProfileMenu { final String functionName; final String requestID; final GetMenuEntriesList menuEntries; - ProfileMenu({this.name = '', this.icon = '', this.route = '', this.dynamicUrl = '', this.functionName = '', this.requestID = '', required this.menuEntries}); + final dynamic arguments; + ProfileMenu({this.name = '', this.icon = '', this.route = '', this.arguments = '', this.dynamicUrl = '', this.functionName = '', this.requestID = '', required this.menuEntries}); } diff --git a/lib/models/update_item_type_success_list.dart b/lib/models/update_item_type_success_list.dart index 1090dca..f133e38 100644 --- a/lib/models/update_item_type_success_list.dart +++ b/lib/models/update_item_type_success_list.dart @@ -2,7 +2,7 @@ class UpdateItemTypeSuccessList { int? itemID; - Null? updateError; + String? updateError; bool? updateSuccess; UpdateItemTypeSuccessList( diff --git a/lib/models/worklist/update_user_type_list.dart b/lib/models/worklist/update_user_type_list.dart new file mode 100644 index 0000000..4ff377f --- /dev/null +++ b/lib/models/worklist/update_user_type_list.dart @@ -0,0 +1,28 @@ + + + +class UpdateUserTypesList { + int? itemID; + String? pFYAENABLEDFALG; + String? pFYIENABLEDFALG; + String? pITEMTYPE; + + + UpdateUserTypesList({this.itemID, this.pFYAENABLEDFALG, this.pFYIENABLEDFALG, this.pITEMTYPE}); + + UpdateUserTypesList.fromJson(Map json) { + itemID = json['ItemID']; + pFYAENABLEDFALG = json['P_FYAENABLED_FALG']; + pFYIENABLEDFALG = json['P_FYIENABLED_FALG']; + pITEMTYPE = json['P_ITEM_TYPE']; + } + + Map toJson() { + final Map data = new Map(); + data['ItemID'] = this.itemID; + data['P_FYAENABLED_FALG'] = this.pFYAENABLEDFALG; + data['P_FYIENABLED_FALG'] = this.pFYIENABLEDFALG; + data['P_ITEM_TYPE'] = this.pITEMTYPE; + return data; + } +} \ No newline at end of file diff --git a/lib/ui/landing/widget/app_drawer.dart b/lib/ui/landing/widget/app_drawer.dart index 9bc9985..e9a33b4 100644 --- a/lib/ui/landing/widget/app_drawer.dart +++ b/lib/ui/landing/widget/app_drawer.dart @@ -64,6 +64,17 @@ class _AppDrawerState extends State { drawerNavigator(context, AppRoutes.pendingTransactions); }, ), + const Divider(), + InkWell( + child: DrawerItem( + "My Team", + icon: Icons.person, + color: Colors.grey, + ), + onTap: () { + drawerNavigator(context, AppRoutes.myTeam); + }, + ), InkWell( child: DrawerItem( LocaleKeys.employeeDigitalID.tr(), diff --git a/lib/ui/my_team/create_request.dart b/lib/ui/my_team/create_request.dart new file mode 100644 index 0000000..5044c22 --- /dev/null +++ b/lib/ui/my_team/create_request.dart @@ -0,0 +1,95 @@ + +import 'dart:ui'; +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:mohem_flutter_app/api/my_team/my_team_api_client.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.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/dashboard/menu_entries.dart'; +import 'package:mohem_flutter_app/models/my_team/get_employee_subordinates_list.dart'; +import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; +import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart'; +import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; + +class CreateRequest extends StatefulWidget { + const CreateRequest ({Key? key}) : super(key: key); + + @override + _CreateRequestState createState() => _CreateRequestState(); +} + +class _CreateRequestState extends State { + String searchEmpEmail =""; + String searchEmpName =""; + String searchEmpNo = ""; + String? empId; + List getEmployeeSubordinatesList = []; +// late DashboardProviderModel data; + List getMenuEntriesList = []; + GetEmployeeSubordinatesList? getEmployeeSubordinates; + + @override + void initState() { + super.initState(); + // data.fetchMenuEntries(); + employeeSubRequest(); + } + + void employeeSubRequest() async { + try { + Utils.showLoading(context); + getEmployeeSubordinatesList = await MyTeamApiClient().getEmployeeSubordinates(searchEmpEmail.toString(), searchEmpName.toString(), searchEmpNo.toString()); + getMenuEntriesList = await MyTeamApiClient().employeeSubordinatesRequest(getEmployeeSubordinates?.eMPLOYEENUMBER); + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + @override + Widget build(BuildContext context) { + getEmployeeSubordinates ??= ModalRoute.of(context)?.settings.arguments as GetEmployeeSubordinatesList; + print(getMenuEntriesList.length); + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBarWidget( + context, + title: LocaleKeys.createRequest.tr(), + ), + body: SizedBox( + width: double.infinity, + height: double.infinity, + child: getMenuEntriesList.isEmpty + ? Utils.getNoDataWidget(context) + : ListView.separated( + padding: const EdgeInsets.all(21), + itemBuilder: (cxt, index) => itemView("assets/images/pdf.svg", getMenuEntriesList[index].prompt!, index).onPress(() { + Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(getMenuEntriesList[index].prompt!, getMenuEntriesList[index].functionName!)); + }), + separatorBuilder: (cxt, index) => 12.height, + itemCount: getMenuEntriesList.length), + ), + + ); + } + + Widget itemView(String icon, String title, index) { + return getMenuEntriesList[index].parentMenuName !=""? Row( + children: [ + (title).toText16().expanded, 12.width, + SvgPicture.asset( + "assets/images/arrow_next.svg", + color: MyColors.darkIconColor, + ) + ], + ).objectContainerView() : SizedBox(); + } +} diff --git a/lib/ui/my_team/employee_details.dart b/lib/ui/my_team/employee_details.dart new file mode 100644 index 0000000..064158c --- /dev/null +++ b/lib/ui/my_team/employee_details.dart @@ -0,0 +1,314 @@ +import 'dart:collection'; +import 'dart:ui'; +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:mohem_flutter_app/api/my_team/my_team_api_client.dart'; +import 'package:mohem_flutter_app/api/worklist/worklist_api_client.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.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/dashboard/menu_entries.dart'; +import 'package:mohem_flutter_app/models/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/my_team/get_employee_subordinates_list.dart'; +import 'package:mohem_flutter_app/models/profile_menu.model.dart'; +import 'package:mohem_flutter_app/models/worklist/get_favorite_replacements_model.dart'; +import 'package:mohem_flutter_app/models/worklist/replacement_list_model.dart'; +import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; +import 'package:mohem_flutter_app/widgets/circular_avatar.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class EmployeeDetails extends StatefulWidget { + EmployeeDetails(); + + @override + _EmployeeDetailsState createState() => _EmployeeDetailsState(); + +} + +class _EmployeeDetailsState extends State { + GetEmployeeSubordinatesList? getEmployeeSubordinates; + static List menuData = []; + List menu =[]; + String? selectedFavLetter; + List? favLetters; + List? favUsersList; + List? replacementList; + + @override + void initState() { + super.initState(); + setState(() {}); + } + + //favorite + void fetchChangeFav({required String email, required String employeName, required String image, required String userName, bool isFav = false, bool isNeedToRefresh = false}) async { + Utils.showLoading(context); + getEmployeeSubordinates = ModalRoute.of(context)?.settings.arguments as GetEmployeeSubordinatesList; + GenericResponseModel model = await MyTeamApiClient().changeFavoriteReplacements( + email: email, + employeName: employeName, + image: image, + userName: userName, + isFav: isFav, + ); + getEmployeeSubordinates!.isFavorite = isFav; + Utils.hideLoading(context); + setState(() {}); + } + + + @override + Widget build(BuildContext context) { + getEmployeeSubordinates = ModalRoute.of(context)?.settings.arguments as GetEmployeeSubordinatesList; + setMenu(); + return Scaffold( + extendBody: true, + backgroundColor: MyColors.lightGreyEFColor, + body: Stack(children: [ + Container( + height: 200, + margin: EdgeInsets.only(top: 30), + decoration: BoxDecoration(image: DecorationImage(image: MemoryImage(Utils.getPostBytes(getEmployeeSubordinates!.eMPLOYEEIMAGE)), fit: BoxFit.cover)), + child: new BackdropFilter( + filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), + child: new Container( + decoration: new BoxDecoration(color: Colors.white.withOpacity(0.0)), + ), + ), + ), + SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + 80.height, + Container( + padding: EdgeInsets.only(left: 15, right: 15), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + onPressed: () { + Navigator.pop(context); + }, + icon: Icon( + Icons.arrow_back_ios, + color: Colors.white, + ), + ), + ], + ), + ), + myTeamInfo() + ], + ), + ) + ])); + } + + Widget myTeamInfo() { + Uri phoneNumber = Uri.parse('tel:${getEmployeeSubordinates?.eMPLOYEEMOBILENUMBER}'); + double _width = MediaQuery + .of(context) + .size + .width; + return Column( + children: [ + Container( + margin: EdgeInsets.fromLTRB(21, 0, 21, 10), + child: Stack(children: [ + Container( + width: _width, + //height: 150, + margin: EdgeInsets.only(top: 50), + padding: EdgeInsets.only(top: 50), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(15)), + boxShadow: [BoxShadow(color: MyColors.lightGreyColor, blurRadius: 15, spreadRadius: 3)], + ), + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + /// card header + customLabel(getEmployeeSubordinates!.eMPLOYEENAME.toString(), 22, Colors.black, true), + customLabel(getEmployeeSubordinates!.eMPLOYEENUMBER.toString() + ' | ' + getEmployeeSubordinates!.jOBNAME.toString(), 14, Colors.grey, false), + customLabel(getEmployeeSubordinates!.eMPLOYEEEMAILADDRESS.toString(), 13, Colors.black, true), + ], + ).paddingOnly(top: 10, bottom: 10), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + onPressed: (){ + if(getEmployeeSubordinates!.isFavorite != true){ + showFavoriteAlertDialog(context); + setState(() {}); + }else{ + fetchChangeFav( + email: getEmployeeSubordinates?.eMPLOYEEEMAILADDRESS ?? "", + employeName: getEmployeeSubordinates!.eMPLOYEENAME ?? "", + image: getEmployeeSubordinates!.eMPLOYEEIMAGE ?? "", + userName: getEmployeeSubordinates!.eMPLOYEENUMBER ?? "", + isFav: false,); + setState(() {}); + } }, + icon: getEmployeeSubordinates!.isFavorite != true + ? Icon( + Icons.star_outline, + size: 35, + color: Colors.green, + ) + : Icon( + Icons.star_outlined, + size: 35, + color: Colors.green, + ), + ).paddingOnly(top: 50), + Container(height: 100, alignment: Alignment.center, child: ProfileImage()), + IconButton( + onPressed: () { + launchUrl(phoneNumber); + }, + icon: Icon( + Icons.whatsapp, + color: Colors.green, + size: 30, + ).paddingOnly(top: 30), + ), + ], + ) + ])), + Container( + margin: EdgeInsets.fromLTRB(21, 8, 21, 10), + height: 260, + padding: EdgeInsets.only(top: 15, bottom: 15), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(15)), + boxShadow: [BoxShadow(color: MyColors.lightGreyColor, blurRadius: 15, spreadRadius: 3)], + ), + child: Column( + children: menu.map((ProfileMenu i) => rowItem(i, context)).toList(), + ), + ), + ], + ); + } + + Widget ProfileImage() => + CircleAvatar( + radius: 70, + backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSubordinates?.eMPLOYEEIMAGE)), + backgroundColor: Colors.black, + ); + + Widget customLabel(String label, double size, Color color, bool isBold, {double padding = 0.0}) => + Container( + padding: EdgeInsets.all(padding), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, + children: [Text(label, style: TextStyle(color: color, fontSize: size, fontWeight: isBold ? FontWeight.bold : FontWeight.normal))])); + + Widget rowItem(obj, context) { + return InkWell( + onTap: () { + + Navigator.pushNamed(context, obj.route, arguments:obj.arguments); + + }, + child: ListTile( + leading: SvgPicture.asset('assets/images/' + obj.icon), + title: Text(obj.name), + trailing: Icon(Icons.arrow_forward), + ), + ); + } + void setMenu(){ + menu = [ + ProfileMenu(name: "Profile Details", icon: 'personal-info.svg', route: AppRoutes.profileDetails, arguments:getEmployeeSubordinates, dynamicUrl: '', menuEntries: getMenuEntries('')), + ProfileMenu(name: "Create Request", icon: 'personal-info.svg', route: AppRoutes.createRequest,arguments: getEmployeeSubordinates, menuEntries: getMenuEntries('')), + ProfileMenu(name: "View Attendance", icon: 'personal-info.svg', route: AppRoutes.viewAttendance, arguments: getEmployeeSubordinates, dynamicUrl: '', menuEntries: getMenuEntries('')), + ProfileMenu(name: "Team Members", icon: 'family-members.svg', route: AppRoutes.teamMembers, arguments: getEmployeeSubordinates, dynamicUrl: '', menuEntries: getMenuEntries('')), + ]; + } + + void showFavoriteAlertDialog(BuildContext context) { + Widget cancelButton = TextButton( + child: Text( + LocaleKeys.cancel.tr(), + ), + onPressed: () { + Navigator.pop(context); + }, + ); + Widget continueButton = TextButton( + child: Text( + LocaleKeys.ok.tr(), + ), + onPressed: () { + fetchChangeFav( + email: getEmployeeSubordinates?.eMPLOYEEEMAILADDRESS ?? "", + employeName: getEmployeeSubordinates!.eMPLOYEENAME ?? "", + image: getEmployeeSubordinates!.eMPLOYEEIMAGE ?? "", + userName: getEmployeeSubordinates!.eMPLOYEENUMBER ?? "", + isFav: true, + ); + setState(() {}); + Navigator.pop(context); + }, + ); + AlertDialog alert = AlertDialog( + title: Text( + LocaleKeys.confirm.tr(), + ), + content: Container( + height: 150, + child: Column( + children: [ + Text("Do you want to add" + "${getEmployeeSubordinates!.eMPLOYEENAME.toString()}" + "in your favorite list "), + CircularAvatar( + url: getEmployeeSubordinates!.eMPLOYEEIMAGE ?? "", + height: 50, + width: 50, + isImageBase64: true, + ).paddingOnly(top: 21), + // 16.width, + ], + ), + ), + actions: [ + cancelButton, + continueButton, + ], + ); + showDialog( + context: context, + builder: (BuildContext context) { + return alert; + }, + ); + } +} + + GetMenuEntriesList getMenuEntries(String type) { + List data = _EmployeeDetailsState.menuData.where((GetMenuEntriesList test) => test.functionName == type).toList(); + if (data.isNotEmpty) { + return data[0]; + } else { + return GetMenuEntriesList(); + } + + +} + + diff --git a/lib/ui/my_team/my_team.dart b/lib/ui/my_team/my_team.dart new file mode 100644 index 0000000..5cb89ef --- /dev/null +++ b/lib/ui/my_team/my_team.dart @@ -0,0 +1,241 @@ + +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/api/my_team/my_team_api_client.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.dart'; +import 'package:mohem_flutter_app/extensions/string_extensions.dart'; +import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; +import 'package:mohem_flutter_app/models/my_team/get_employee_subordinates_list.dart'; +import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; +import 'package:url_launcher/url_launcher.dart'; + + +class MyTeam extends StatefulWidget { + const MyTeam({Key? key}) : super(key: key); + + @override + _MyTeamState createState() => _MyTeamState(); +} + +class _MyTeamState extends State { + String searchEmpEmail =""; + String searchEmpName =""; + String searchEmpNo = ""; + String? empId; + List getEmployeeSubordinatesList = []; + TextEditingController? _textEditingController = TextEditingController(); + List getEmployeeSListOnSearch = []; + + String dropdownValue = 'Name'; + + void initState() { + super.initState(); + getEmployeeSubordinates(); + } + + void getEmployeeSubordinates() async { + try { + Utils.showLoading(context); + getEmployeeSubordinatesList = await MyTeamApiClient().getEmployeeSubordinates(searchEmpEmail.toString(), searchEmpName.toString(), searchEmpNo.toString()); + getEmployeeSListOnSearch =getEmployeeSubordinatesList; + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBarWidget( + context, + title:"My Team Members", + ), + backgroundColor: MyColors.backgroundColor, + body: SingleChildScrollView( + child: Column( + children: [ + Container( + width: double.infinity, + margin: EdgeInsets.only( + top: 28, + left: 18, + right: 18, + // bottom: 28 + ), + padding: EdgeInsets.only( left: 10, right: 10), + height: 65, + 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: + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children : [ + Expanded( + child: + TextField( + onChanged: dropdownValue =="Name" ? + (String value){ + getEmployeeSListOnSearch = getEmployeeSubordinatesList.where((GetEmployeeSubordinatesList element) + => element.eMPLOYEENAME!.toLowerCase().contains(value.toLowerCase())).toList(); + setState(() {}); + }: (String value){ + getEmployeeSListOnSearch = getEmployeeSubordinatesList.where((GetEmployeeSubordinatesList element) + => element.eMPLOYEEEMAILADDRESS!.toLowerCase().contains(value.toLowerCase())).toList(); + setState(() {}); + }, + controller: _textEditingController, + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + border: InputBorder.none, + enabledBorder: InputBorder.none, + focusedBorder: InputBorder.none, + // contentPadding: EdgeInsets.fromLTRB(10, 15, 10, 15), + hintText: 'Search by $dropdownValue', + hintStyle: TextStyle(fontSize: 16.0, color: Colors.black,), + ), + )), + dropDown() + ]), + ), + Container( + width: MediaQuery.of(context).size.width, + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Column( + children: [ + _textEditingController!.text.isNotEmpty && getEmployeeSListOnSearch.isEmpty ? + Container( + child: "No Results found".toText16(color: MyColors.blackColor),).paddingOnly(top: 10) + : ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: ScrollPhysics(), + itemCount: _textEditingController!.text.isNotEmpty ? getEmployeeSListOnSearch.length : getEmployeeSubordinatesList.length, + itemBuilder: (context, index) { + var phoneNumber = Uri.parse('tel:${getEmployeeSListOnSearch[index].eMPLOYEEMOBILENUMBER}'); + return Container( + width: double.infinity, + margin: EdgeInsets.only( + top: 18, + left: 18, + right: 18, + ), + padding: EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10), + // height: 110, + 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: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Column( + children: [ + + CircleAvatar( + radius: 25, + backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSListOnSearch[index].eMPLOYEEIMAGE)), + backgroundColor: Colors.black, + ), + ], + ), + SizedBox( + width: 10, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "Present".toText13(color: MyColors.greenColor), + "${getEmployeeSListOnSearch[index].eMPLOYEENAME}".toText16(color: MyColors.blackColor), + "${getEmployeeSListOnSearch[index].pOSITIONNAME}".toText13(color: MyColors.blackColor), + + ], + ), + ], + ), + Column( + children: [ + IconButton( + onPressed: () { + launchUrl(phoneNumber); + }, + icon: Icon( + Icons.whatsapp, + color: Colors.green, + ), + ), + IconButton( + onPressed: () async{ + Navigator.pushNamed(context,AppRoutes.employeeDetails,arguments: getEmployeeSListOnSearch[index]); + // Navigator.of(context).push(MaterialPageRoute(builder: (context)=> EmployeeDetails(getEmployeeSubordinates: getEmployeeSubordinatesList[index])),); + }, + icon: Icon( + Icons.arrow_forward_outlined, + color: Colors.grey, + ), + ), + + + ], + ), + ], + ), + ); + }) + ], + ), + ) + ) + ], + ), + ) + ); + } + + Widget dropDown(){ + return DropdownButton( + value: dropdownValue, + icon: const Icon(Icons.keyboard_arrow_down), + elevation: 16, + onChanged: (String? newValue) { + setState(() { + dropdownValue = newValue!; + }); + }, + items: ['Name', 'Email'] + .map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + ); + } + +} + diff --git a/lib/ui/my_team/profile_details.dart b/lib/ui/my_team/profile_details.dart new file mode 100644 index 0000000..49690f0 --- /dev/null +++ b/lib/ui/my_team/profile_details.dart @@ -0,0 +1,91 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/app_state/app_state.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/extensions/string_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/models/my_team/get_employee_subordinates_list.dart'; +import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; +import 'package:mohem_flutter_app/widgets/button/default_button.dart'; + +class ProfileDetails extends StatefulWidget { + const ProfileDetails({Key? key}) : super(key: key); + + @override + _ProfileDetailsState createState() => _ProfileDetailsState(); +} + +class _ProfileDetailsState extends State { + + GetEmployeeSubordinatesList? getEmployeeSubordinates; + + + + @override + void initState() { + super.initState(); + } + + Widget build(BuildContext context) { + getEmployeeSubordinates ??= ModalRoute.of(context)?.settings.arguments as GetEmployeeSubordinatesList; + return Scaffold( + appBar: AppBarWidget( + context, + title: "Profile Details", + ), + backgroundColor: MyColors.backgroundColor, + 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: 350, + 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: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + LocaleKeys.category.tr().toText13(color: MyColors.lightGrayColor), + "${getEmployeeSubordinates?.eMPLOYMENTCATEGORYMEANING}".toText16(isBold: true, color: MyColors.blackColor), + SizedBox( + height: 20, + ), + LocaleKeys.address.tr().toText13(color: MyColors.lightGrayColor), + "${getEmployeeSubordinates?.lOCATIONNAME}".toText16(isBold: true, color: MyColors.blackColor), + SizedBox( + height: 20, + ), + LocaleKeys.phoneNumber.tr().toText13(color: MyColors.lightGrayColor), + "${getEmployeeSubordinates?.eMPLOYEEMOBILENUMBER}".toText16(isBold: true, color: MyColors.blackColor), + SizedBox( + height: 20, + ), + LocaleKeys.businessGroup.tr().toText13(color: MyColors.lightGrayColor), + "${getEmployeeSubordinates?.bUSINESSGROUPNAME}".toText16(isBold: true, color: MyColors.blackColor), + SizedBox( + height: 20, + ), + LocaleKeys.Payroll.tr().toText13(color: MyColors.lightGrayColor), + "${getEmployeeSubordinates?.pAYROLLNAME}".toText16(isBold: true, color: MyColors.blackColor), + ]), + ), + ], + )); + } + +} diff --git a/lib/ui/my_team/team_members.dart b/lib/ui/my_team/team_members.dart new file mode 100644 index 0000000..7dccf5e --- /dev/null +++ b/lib/ui/my_team/team_members.dart @@ -0,0 +1,156 @@ +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/api/my_team/my_team_api_client.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.dart'; +import 'package:mohem_flutter_app/extensions/string_extensions.dart'; +import 'package:mohem_flutter_app/models/my_team/get_employee_subordinates_list.dart'; +import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class TeamMembers extends StatefulWidget { + const TeamMembers({Key? key}) : super(key: key); + + @override + _TeamMembersState createState() => _TeamMembersState(); +} + +class _TeamMembersState extends State { + String searchEmpEmail =""; + String searchEmpName =""; + String searchEmpNo = ""; + String? empId; + List getEmployeeSubordinatesList = []; + GetEmployeeSubordinatesList? getEmployeeSubordinates; + + void initState() { + super.initState(); + employeeSubordinates(); + setState(() {}); + + } + + void employeeSubordinates() async { + try { + Utils.showLoading(context); + getEmployeeSubordinatesList = await MyTeamApiClient().getEmployeeSubordinates(searchEmpEmail.toString(), searchEmpName.toString(), searchEmpNo.toString()); + getEmployeeSubordinatesList = await MyTeamApiClient().employeeSubordinates(searchEmpEmail.toString(), searchEmpName.toString(), searchEmpNo.toString(),getEmployeeSubordinates?.eMPLOYEENUMBER); + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + @override + Widget build(BuildContext context) { + getEmployeeSubordinates ??= ModalRoute.of(context)?.settings.arguments as GetEmployeeSubordinatesList; + return Scaffold( + appBar: AppBarWidget( + context, + title: "Team Members", + ), + backgroundColor: MyColors.backgroundColor, + body: SingleChildScrollView( + child: Column( + children: [ + Container( + width: MediaQuery.of(context).size.width, + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Column( + children: [ + if(getEmployeeSubordinatesList != 0) + ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: ScrollPhysics(), + itemCount: getEmployeeSubordinatesList.length, + itemBuilder: (context, index) { + var phoneNumber = Uri.parse('tel:${getEmployeeSubordinatesList[index].eMPLOYEENUMBER}'); + return Container( + width: double.infinity, + margin: EdgeInsets.only( + top: 18, + left: 18, + right: 18, + ), + padding: EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10), + 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: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Column( + children: [ + CircleAvatar( + radius: 25, + backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSubordinatesList[index].eMPLOYEEIMAGE)), + backgroundColor: Colors.black, + ), + // MyTeamImage() + ], + ), + SizedBox( + width: 10, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + "Present".toText13(color: MyColors.greenColor), + "${getEmployeeSubordinatesList[index].eMPLOYEENAME}".toText16(color: MyColors.blackColor), + "${getEmployeeSubordinatesList[index].pOSITIONNAME}".toText13(color: MyColors.blackColor), + ], + ), + ], + ), + Column( + children: [ + IconButton( + onPressed: () { + launchUrl(phoneNumber); + }, + icon: Icon( + Icons.whatsapp, + color: Colors.green, + ), + ), + ], + ), + ], + ), + ); + }), + Container( + margin: EdgeInsets.only(top:30), + child: "No Members".toText16(isBold: true, color: MyColors.black), + ) + ], + ), + ) + // SizedBox(height: 20), + ) + ], + ), + )); + } + + Widget MyTeamImage() => CircleAvatar( + radius: 30, + //backgroundImage: MemoryImage(Utils.getPostBytes(memberInformationList.eMPLOYEEIMAGE)), + backgroundColor: Colors.black, + ); +} diff --git a/lib/ui/my_team/view_attendance.dart b/lib/ui/my_team/view_attendance.dart new file mode 100644 index 0000000..f08ca3b --- /dev/null +++ b/lib/ui/my_team/view_attendance.dart @@ -0,0 +1,569 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/api/monthly_attendance_api_client.dart'; +import 'package:mohem_flutter_app/api/my_team/my_team_api_client.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.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/dashboard/get_attendance_tracking_list_model.dart'; +import 'package:mohem_flutter_app/models/get_day_hours_type_details_list_model.dart'; +import 'package:mohem_flutter_app/models/get_schedule_shifts_details_list_model.dart'; +import 'package:mohem_flutter_app/models/get_time_card_summary_list_model.dart'; +import 'package:mohem_flutter_app/models/my_team/get_employee_subordinates_list.dart'; +import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; +import 'package:mohem_flutter_app/widgets/circular_step_progress_bar.dart'; +import 'package:month_picker_dialog/month_picker_dialog.dart'; +import 'package:pie_chart/pie_chart.dart'; +import 'package:syncfusion_flutter_calendar/calendar.dart'; + +class ViewAttendance extends StatefulWidget { + const ViewAttendance({Key? key}) : super(key: key); + + @override + _ViewAttendanceState createState() => _ViewAttendanceState(); +} + +class _ViewAttendanceState extends State { + bool isPresent = false; + bool isAbsent = false; + bool isMissing = false; + bool isOff = false; + DateTime date = DateTime.now(); + late DateTime formattedDate; + var currentMonth = DateTime.now().month; + String searchMonth = getMonth(DateTime.now().month); + int searchYear = DateTime.now().year; + int? pRTPID; + + String searchEmpEmail =""; + String searchEmpName =""; + String searchEmpNo = ""; + String? empId; + List getEmployeeSubordinatesList = []; + List getDayHoursTypeDetailsList = []; + GetTimeCardSummaryList? getTimeCardSummaryList; + GetAttendanceTracking? attendanceTracking; + GetEmployeeSubordinatesList? getEmployeeSubordinates; + + @override + void initState() { + super.initState(); + formattedDate = date; + callTimeCardAndHourDetails(date.day, searchMonth, searchYear); + // setState(() {}); + } + + + void callTimeCardAndHourDetails(index, searchMonth, searchYear) async { + try { + Utils.showLoading(context); + getEmployeeSubordinatesList = await MyTeamApiClient().getEmployeeSubordinates(searchEmpEmail.toString(), searchEmpName.toString(), searchEmpNo.toString()); + getTimeCardSummaryList = await MyTeamApiClient().getTimeCardSummary(searchMonth, searchYear,getEmployeeSubordinates?.eMPLOYEENUMBER); + getDayHoursTypeDetailsList = await MyTeamApiClient().getDayHoursTypeDetails(searchMonth, searchYear, getEmployeeSubordinates?.eMPLOYEENUMBER); + attendanceTracking = await MyTeamApiClient().getAttendanceTracking(getEmployeeSubordinates?.eMPLOYEENUMBER); + Utils.hideLoading(context); + _calendarController.displayDate = formattedDate; + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + + + final CalendarController _calendarController = CalendarController(); + final List _colorList = [Color(0xff2AB2AB), Color(0xff202529)]; + + @override + Widget build(BuildContext context) { + getEmployeeSubordinates ??= ModalRoute.of(context)?.settings.arguments as GetEmployeeSubordinatesList; + Map dataMap = { + "Present": getTimeCardSummaryList?.aTTENDEDDAYS != null ? getTimeCardSummaryList!.aTTENDEDDAYS!.toDouble() : 0, + "Absent": getTimeCardSummaryList?.aBSENTDAYS != null ? getTimeCardSummaryList!.aBSENTDAYS!.toDouble() : 0, + }; + //if(getTimeCardSummaryList ==null) + // callTimeCardAndHourDetails(date.day, searchMonth, searchYear); + return Scaffold( + appBar: AppBarWidget( + context, + title: "View Attendance", + ), + backgroundColor: MyColors.backgroundColor, + body: SingleChildScrollView( + child: Column(children: [ + Container( + width: double.infinity, + margin: EdgeInsets.only( + top: 28, + left: 18, + right: 18, + ), + padding: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 16), + // height: 120, + 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: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "Today's Attendance".toText20(color: MyColors.blackColor), + SizedBox( + height: 10, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + children: [ + LocaleKeys.checkIn.tr().toText12(isBold: true, color: MyColors.greenColor), + "${(attendanceTracking?.pSwipeIn)?? "- - : - -"}".toText16(isBold: true, color: MyColors.grey57Color), + ], + ), + Column( + children: [ + LocaleKeys.checkOut.tr().toText12(isBold: true, color: MyColors.redColor), + "${(attendanceTracking?.pSwipeOut)?? "- - : - -"}".toText16(isBold: true, color: MyColors.grey57Color), + ], + ), + Column( + children: [ + LocaleKeys.lateIn.tr().toText12(isBold: true, color: MyColors.blackColor), + "${(attendanceTracking?.pLateInHours)?? "- - : - -"}".toText16(isBold: true, color: MyColors.grey57Color), + ], + ), + ], + ) + ], + ), + ), + Container( + width: double.infinity, + margin: EdgeInsets.only( + top: 18, + left: 18, + right: 18, + bottom: 28, + ), + padding: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 16), + 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: Column( + children: [ + //20.height, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + "${DateFormat("MMMM-yyyy").format(formattedDate)}".toText16(color: MyColors.blackColor), + const Icon(Icons.keyboard_arrow_down_rounded, color: MyColors.blackColor), + ], + ).onPress(() async { + showMonthPicker( + context: context, //locale: EasyLocalization.of(context)?.locale, + initialDate: formattedDate, + firstDate: DateTime(searchYear - 2), + lastDate: DateTime.now(), + ).then((selectedDate) { + if (selectedDate != null) { + searchMonth = getMonth(selectedDate.month); + searchYear = selectedDate.year; + formattedDate = selectedDate; //DateFormat('MMMM-yyyy').format(selectedDate); + // _calendarController.selectedDate = formattedDate; + callTimeCardAndHourDetails(selectedDate.day, searchMonth, searchYear); + } + }); + }) + ], + ), + 18.height, + AspectRatio(aspectRatio: 333 / 270, child: calendarWidget()), + Row( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + children: [ + LocaleKeys.attendance.tr().toText12(isBold: true, color: MyColors.grey3AColor), + LocaleKeys.stats.tr().toText24(isBold: true, color: MyColors.grey3AColor), + ], + ), + 30.height, + Row( + children: [ + Container( + height: 8, + width: 8, + decoration: BoxDecoration( + color: MyColors.lightGreenColor, + borderRadius: BorderRadius.circular(100), + ), + ), + Container( + margin: const EdgeInsets.only(left: 5, right: 5), + child: "${LocaleKeys.present.tr()} ${getTimeCardSummaryList?.aTTENDEDDAYS != null ? getTimeCardSummaryList?.aTTENDEDDAYS : 0}".toText16(isBold: true, color: MyColors.lightGreenColor), + ), + ], + ), + 8.height, + Row( + children: [ + Container( + height: 9, + width: 9, + decoration: BoxDecoration( + color: MyColors.backgroundBlackColor, + borderRadius: BorderRadius.circular(100), + ), + ), + Container( + margin: const EdgeInsets.only(left: 5, right: 5), + child: "${LocaleKeys.absent.tr()} ${getTimeCardSummaryList?.aBSENTDAYS != null ? getTimeCardSummaryList?.aBSENTDAYS : 0 }".toText16( + isBold: true, + color: MyColors.backgroundBlackColor, + ), + ) + ], + ), + ], + ), + SizedBox( + width: 20, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 170, + height: 170, + child: PieChart( + dataMap: dataMap, + animationDuration: const Duration(milliseconds: 800), + chartLegendSpacing: 0, + chartRadius: MediaQuery.of(context).size.width / 5.2, + colorList: _colorList, + initialAngleInDegree: 0, + chartType: ChartType.ring, + ringStrokeWidth: 80, + legendOptions: const LegendOptions( + showLegendsInRow: false, + showLegends: false, + ), + chartValuesOptions: const ChartValuesOptions( + showChartValueBackground: false, + showChartValues: true, + showChartValuesInPercentage: true, + showChartValuesOutside: false, + decimalPlaces: 1, + chartValueStyle: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16, + color: MyColors.white, + )), + ), + ), + ], + ).paddingOnly(left: 21, right: 21, bottom: 21), + ], + ), + ], + ), + ), + ]), + ), + ); + } + + Widget calendarWidget() { + return SfCalendar( + view: CalendarView.month, + showDatePickerButton: false, + controller: _calendarController, + backgroundColor: Colors.white, + headerHeight: 0, + viewNavigationMode: ViewNavigationMode.none, + todayHighlightColor: MyColors.grey3AColor, + showNavigationArrow: false, + showCurrentTimeIndicator: false, + showWeekNumber: false, + cellBorderColor: Colors.white, + selectionDecoration: BoxDecoration( + border: Border.all(color: MyColors.white, width: 10), + borderRadius: const BorderRadius.all(Radius.circular(100)), + shape: BoxShape.circle, + ), + dataSource: MeetingDataSource(_getDataSource()), + monthViewSettings: const MonthViewSettings( + dayFormat: 'EEE', + showTrailingAndLeadingDates: false, + showAgenda: false, + //navigationDirection: MonthNavigationDirection.vertical, + monthCellStyle: MonthCellStyle( + textStyle: TextStyle( + fontStyle: FontStyle.normal, + fontSize: 13, + color: Colors.white, + ), + ), + ), + viewHeaderStyle: const ViewHeaderStyle( + dayTextStyle: TextStyle(color: MyColors.grey3AColor, fontSize: 13, fontWeight: FontWeight.w600), + ), + monthCellBuilder: (build, details) { + if (details.date.month == formattedDate.month && details.date.year == formattedDate.year) { + int val = details.date.day; + //check day is off + if (getDayHoursTypeDetailsList.isNotEmpty) { + if (getDayHoursTypeDetailsList?[val - 1].aTTENDEDFLAG == 'N' && getDayHoursTypeDetailsList?[val - 1].dAYTYPE == 'OFF') { + return Container( + margin: const EdgeInsets.all(4), + decoration: BoxDecoration( + color: MyColors.greyACColor.withOpacity(.12), + shape: BoxShape.circle, + ), + alignment: Alignment.center, + child: Text( + "$val", + style: const TextStyle( + fontSize: 13, + fontWeight: FontWeight.w500, + color: MyColors.greyA5Color, + ), + ), + ); + } + //check day is Present + else if (getDayHoursTypeDetailsList?[val - 1].aTTENDEDFLAG == 'Y') { + return Container( + margin: const EdgeInsets.all(4), + decoration: BoxDecoration( + gradient: const LinearGradient( + transform: GradientRotation(.46), + begin: Alignment.topRight, + end: Alignment.bottomLeft, + colors: [MyColors.gradiantEndColor, MyColors.gradiantStartColor], + ), + shape: BoxShape.circle, + boxShadow: [ + BoxShadow( + offset: const Offset(0, 2), + blurRadius: 26, + color: MyColors.blackColor.withOpacity(0.100), + ), + ], + ), + alignment: Alignment.center, + child: Text( + "$val", + style: const TextStyle( + fontSize: 13, + fontWeight: FontWeight.w500, + color: MyColors.white, + ), + ), + ); + } + //check day is Absent + else if (getDayHoursTypeDetailsList?[val - 1].aTTENDEDFLAG == 'N' && getDayHoursTypeDetailsList?[val - 1].aBSENTFLAG == 'Y') { + return Container( + margin: const EdgeInsets.all(4), + decoration: BoxDecoration( + color: MyColors.backgroundBlackColor, + shape: BoxShape.circle, + boxShadow: [ + BoxShadow( + offset: const Offset(0, 2), + blurRadius: 26, + color: MyColors.blackColor.withOpacity(0.100), + ), + ], + ), + alignment: Alignment.center, + child: Text( + "$val", + style: const TextStyle( + fontSize: 13, + fontWeight: FontWeight.w500, + color: MyColors.white, + ), + ), + ); + } + } + return Container( + margin: const EdgeInsets.all(4), + decoration: BoxDecoration( + border: Border.all(color: MyColors.backgroundBlackColor, width: 2.0, style: BorderStyle.solid), //Border.all + shape: BoxShape.circle, + boxShadow: [ + BoxShadow( + offset: const Offset(0, 2), + blurRadius: 26, + color: MyColors.blackColor.withOpacity(0.100), + ), + ], + ), + alignment: Alignment.center, + child: Text( + "$val", + style: const TextStyle( + fontSize: 13, + fontWeight: FontWeight.w500, + color: Color(0xff1F2428), + ), + ), + ); + // return Container( + // alignment: Alignment.center, + // child: Text("$val"), + // ); + } else { + return const SizedBox(); + } + }, + ); + } + + + List _getDataSource() { + final List meetings = []; + return meetings; + } + + static String getMonth(int month) { + switch (month) { + case 1: + return "January"; + case 2: + return "February"; + case 3: + return "March"; + case 4: + return "April"; + case 5: + return "May"; + case 6: + return "June"; + case 7: + return "July"; + case 8: + return "August"; + case 9: + return "September"; + case 10: + return "October"; + case 11: + return "November"; + case 12: + return "December"; + default: + return ""; + } + } + + static String getMonthAr(int month) { + switch (month) { + case 1: + return 'يناير'; + case 2: + return ' فبراير'; + case 3: + return 'مارس'; + case 4: + return 'أبريل'; + case 5: + return 'مايو'; + case 6: + return 'يونيو'; + case 7: + return 'يوليو'; + case 8: + return 'أغسطس'; + case 9: + return 'سبتمبر'; + case 10: + return ' اكتوبر'; + case 11: + return ' نوفمبر'; + case 12: + return 'ديسمبر'; + default: + return ""; + } + } +} + +class MeetingDataSource extends CalendarDataSource { + MeetingDataSource(List source) { + appointments = source; + } + + @override + DateTime getStartTime(int index) { + return _getMeetingData(index).from; + } + + @override + DateTime getEndTime(int index) { + return _getMeetingData(index).to; + } + + @override + String getSubject(int index) { + return _getMeetingData(index).eventName; + } + + @override + Color getColor(int index) { + return _getMeetingData(index).background; + } + + @override + bool isAllDay(int index) { + return _getMeetingData(index).isAllDay; + } + + Meeting _getMeetingData(int index) { + final dynamic meeting = appointments; + Meeting meetingData; + if (meeting is Meeting) { + meetingData = meeting; + } + return meeting; + } +} + +class Meeting { + Meeting(this.eventName, this.from, this.to, this.background, this.isAllDay); + + String eventName; + DateTime from; + DateTime to; + Color background; + bool isAllDay; +} diff --git a/lib/ui/profile/family_members.dart b/lib/ui/profile/family_members.dart index 2dd84ea..f42c3fb 100644 --- a/lib/ui/profile/family_members.dart +++ b/lib/ui/profile/family_members.dart @@ -6,11 +6,14 @@ import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; +import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart'; import 'package:mohem_flutter_app/models/get_employee_contacts.model.dart'; +import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/ui/profile/dynamic_screens/dynamic_input_familyMembers_screen.dart'; import 'package:mohem_flutter_app/ui/screens/profile/profile_screen.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; +import 'package:provider/provider.dart'; class FamilyMembers extends StatefulWidget { const FamilyMembers({Key? key}) : super(key: key); @@ -24,9 +27,14 @@ class _FamilyMembersState extends State { int? relationId; int? flag; + GetMenuEntriesList menuEntries = GetMenuEntriesList(); + @override void initState() { super.initState(); + List menuData = Provider.of(context, listen: false).getMenuEntriesList!; + menuEntries = menuData.where((GetMenuEntriesList e) => e.requestType == 'CONTACT').toList()[0]; + setState(() {}); getEmployeeContacts(); } @@ -108,12 +116,13 @@ class _FamilyMembersState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( - child: InkWell( - onTap: () { + child: menuEntries.updateButton == 'Y' + ? InkWell( + onTap: () async{ relationId = getEmployeeContactsList[index]!.cONTACTRELATIONSHIPID!.toInt(); showUpdateAlertDialog(context, relationId!.toInt(), 2, LocaleKeys.update.tr()); }, - child: RichText( + child: RichText( text: TextSpan( children: [ WidgetSpan( @@ -134,7 +143,28 @@ class _FamilyMembersState extends State { ], ), ), - )), + ) + : RichText( + text: TextSpan( + children: [ + WidgetSpan( + child: Icon( + Icons.edit, + size: 15, + color: MyColors.lightGreyColor, + ), + ), + TextSpan( + text: LocaleKeys.update.tr(), + style: TextStyle( + color: MyColors.lightGreyColor, + fontSize: 12, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ) ), Padding( padding: const EdgeInsets.symmetric(horizontal: 8), child: SizedBox( @@ -203,17 +233,18 @@ class _FamilyMembersState extends State { Widget footer() { return Container( decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(10), color: MyColors.white, boxShadow: [ BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), ], ), - child: DefaultButton(LocaleKeys.addNewFamilyMember.tr(), () async { - Navigator.pushNamed(context, AppRoutes.addUpdateFamilyMember, arguments: {"relationID": relationId, "flag": 1, "actionType": "ADD"}); - // context.setLocale(const Locale("en", "US")); // to change Loacle - ProfileScreen(); - }).insideContainer, + child: DefaultButton( + LocaleKeys.addNewFamilyMember.tr(), () async { + Navigator.pushNamed(context, AppRoutes.addUpdateFamilyMember, arguments: {"relationID": relationId, "flag": 1, "actionType": "ADD"}); + ProfileScreen(); + } + ) + .insideContainer, ); } diff --git a/lib/ui/work_list/worklist_settings.dart b/lib/ui/work_list/worklist_settings.dart new file mode 100644 index 0000000..8c72d71 --- /dev/null +++ b/lib/ui/work_list/worklist_settings.dart @@ -0,0 +1,197 @@ + +import 'package:easy_localization/src/public_ext.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:mohem_flutter_app/api/worklist/worklist_api_client.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.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/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/get_user_item_type_list.dart'; +import 'package:mohem_flutter_app/models/update_user_item_type_list.dart'; +import 'package:mohem_flutter_app/models/worklist/update_user_type_list.dart'; +import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; +import 'package:mohem_flutter_app/widgets/button/default_button.dart'; + +class WorklistSettings extends StatefulWidget { + const WorklistSettings({Key? key}) : super(key: key); + + @override + _WorklistSettingsState createState() => _WorklistSettingsState(); +} + +class _WorklistSettingsState extends State { + List getUserItemTypesList = []; + UpdateUserItemTypesList? updateUserItemTypesList; + + + void initState() { + super.initState(); + userItemTypesList(); + } + + void userItemTypesList() async { + try { + Utils.showLoading(context); + getUserItemTypesList = await WorkListApiClient().getUserItemTypes(); + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + + void updateUserItem() async { + try { + Utils.showLoading(context); + List> itemList=[]; + for (var element in getUserItemTypesList) { + + itemList.add(UpdateUserTypesList(itemID: element.uSERITEMTYPEID, pITEMTYPE: element.iTEMTYPE,pFYAENABLEDFALG: element.fYAENABLEDFALG, pFYIENABLEDFALG: element.fYIENABLEDFLAG).toJson()); + + } + updateUserItemTypesList = await WorkListApiClient().updateUserItemTypes(itemList); + Utils.hideLoading(context); + Navigator.pushNamed(context, AppRoutes.workList); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + + + @override + Widget build(BuildContext context) { + return Scaffold(backgroundColor: Colors.white, + appBar: AppBarWidget( + context, + title: "Worklist Settings", + ), + body:Container( + margin: const EdgeInsets.only(top: 21, left: 21, right: 21), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: "Turn on notifications for".tr().toText22(color: MyColors.blackColor), + ).paddingOnly(top: 10, bottom: 50), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: "Item Type".tr().toText14(color: MyColors.blackColor) , + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Container( + child: "FYA".tr().toText14(color: MyColors.blackColor) , + ), + Container( + child: "FYI".tr().toText14(color: MyColors.blackColor) , + ).paddingOnly(left: 30, right: 30), + ], + ) + ], + ), + Divider( + color: MyColors.greyA5Color, + ), + Container( + width: MediaQuery.of(context).size.width, + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: ScrollPhysics(), + itemCount: getUserItemTypesList == null ? 0 : getUserItemTypesList.length, + itemBuilder: (BuildContext context,int index) { + return Container( + child: Column( + children:[ + + customSwitch(getUserItemTypesList[index]), + ] + ), + ); + } + ), + ) + ), + SizedBox( + height: 30, + ), + Container( + decoration: BoxDecoration( + color: MyColors.white, + boxShadow: [ + BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), + ], + ), + child: DefaultButton( + LocaleKeys.submit.tr(), () async { + updateUserItem(); + } + ) + .insideContainer, + ), + ], + ), + ) + + ); + } + + + Widget customSwitch(GetUserItemTypesList list){ + return Padding( + padding: const EdgeInsets.only(top: 21), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(list.iTEMTYPE.toString(), style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: MyColors.blackColor + ),), + const Spacer(), + Row( + children: [ + CupertinoSwitch( + trackColor: Colors.grey, + activeColor: MyColors.gradiantEndColor, + value: list?.fYAENABLEDFALG =='Y' ?true : false, + onChanged: (value){ + setState(() { + list?.fYAENABLEDFALG = value == true ? 'Y': 'N'; + }); + } + ), + CupertinoSwitch( + trackColor: Colors.grey, + activeColor: MyColors.gradiantEndColor, + value: list?.fYIENABLEDFLAG =='Y' ?true : false, + onChanged: (value){ + setState(() { + // list.isFYI = value; + list?.fYIENABLEDFLAG = value ==true ? 'Y': 'N'; + }); + } + ), + ], + ) + ], + ), + ); + } + +} diff --git a/lib/widgets/app_bar_widget.dart b/lib/widgets/app_bar_widget.dart index b6ff590..806fe6b 100644 --- a/lib/widgets/app_bar_widget.dart +++ b/lib/widgets/app_bar_widget.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/config/routes.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'; @@ -42,6 +43,7 @@ AppBar AppBarWidget(BuildContext context, {required String title, bool showHomeB if (showNotificationButton) IconButton( onPressed: () { + Navigator.pushNamed(context, AppRoutes.worklistSettings); // Navigator.pushAndRemoveUntil( // context, // MaterialPageRoute(builder: (context) => LandingPage()), diff --git a/pubspec.yaml b/pubspec.yaml index 789d51c..dde9d39 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -71,6 +71,7 @@ dependencies: # flutter_barcode_scanner: ^2.0.0 qr_code_scanner: ^1.0.0 qr_flutter: ^4.0.0 + url_launcher: ^6.1.5 From 9b50c2cf31245fbb750e010f6c199c8b094c6383 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 25 Aug 2022 09:25:47 +0300 Subject: [PATCH 15/40] mark attendance improvement. --- lib/ui/landing/dashboard_screen.dart | 6 +- lib/ui/landing/today_attendance_screen.dart | 296 ++++++++++---------- lib/widgets/mark_attendance_widget.dart | 249 ++++++++++++++++ 3 files changed, 405 insertions(+), 146 deletions(-) create mode 100644 lib/widgets/mark_attendance_widget.dart diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 4406a4d..da9cb5f 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -17,6 +17,8 @@ import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/ui/landing/widget/app_drawer.dart'; import 'package:mohem_flutter_app/ui/landing/widget/menus_widget.dart'; import 'package:mohem_flutter_app/ui/landing/widget/services_widget.dart'; +import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; +import 'package:mohem_flutter_app/widgets/mark_attendance_widget.dart'; import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart'; import 'package:provider/provider.dart'; @@ -206,7 +208,9 @@ class _DashboardScreenState extends State { ), ), child: SvgPicture.asset(model.isTimeRemainingInSeconds == 0 ? "assets/images/play.svg" : "assets/images/stop.svg"), - ), + ).onPress(() { + showMyBottomSheet(context, child: MarkAttendanceWidget(model)); + }), ], ), ], diff --git a/lib/ui/landing/today_attendance_screen.dart b/lib/ui/landing/today_attendance_screen.dart index 9346773..83c3f06 100644 --- a/lib/ui/landing/today_attendance_screen.dart +++ b/lib/ui/landing/today_attendance_screen.dart @@ -1,6 +1,5 @@ import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_countdown_timer/flutter_countdown_timer.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; @@ -16,17 +15,13 @@ import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/widgets/circular_step_progress_bar.dart'; -import 'package:mohem_flutter_app/widgets/dialogs/dialogs.dart'; import 'package:mohem_flutter_app/widgets/location/Location.dart'; import 'package:mohem_flutter_app/widgets/nfc/nfc_reader_sheet.dart'; +import 'package:mohem_flutter_app/widgets/qr_scanner_dialog.dart'; import 'package:nfc_manager/nfc_manager.dart'; import 'package:provider/provider.dart'; import 'package:wifi_iot/wifi_iot.dart'; -import 'package:mohem_flutter_app/widgets/qr_scanner_dialog.dart'; - - - class TodayAttendanceScreen extends StatefulWidget { TodayAttendanceScreen({Key? key}) : super(key: key); @@ -44,11 +39,11 @@ class _TodayAttendanceScreenState extends State { @override void initState() { super.initState(); - checkAttendanceAvailablity(); + checkAttendanceAvailability(); data = Provider.of(context, listen: false); } - void checkAttendanceAvailablity() async { + void checkAttendanceAvailability() async { bool isAvailable = await NfcManager.instance.isAvailable(); setState(() { AppState().privilegeListModel!.forEach((element) { @@ -104,7 +99,7 @@ class _TodayAttendanceScreenState extends State { builder: (context, model, child) { return (model.isAttendanceTrackingLoading ? Center(child: CircularProgressIndicator()) - : ListView( + : Column( children: [ Container( color: MyColors.backgroundBlackColor, @@ -114,144 +109,156 @@ class _TodayAttendanceScreenState extends State { children: [ DateUtil.getWeekDayMonthDayYearDateFormatted(DateTime.now(), "en").toText24(isBold: true, color: Colors.white), LocaleKeys.timeLeftToday.tr().toText16(color: Color(0xffACACAC)), - 21.height, + //21.height, Center( - child: CircularStepProgressBar( - totalSteps: 16 * 4, - currentStep: (model.progress * 100).toInt(), - width: 216, - height: 216, - selectedColor: MyColors.gradiantEndColor, - unselectedColor: MyColors.grey70Color, - child: Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - CountdownTimer( - endTime: model.endTime, - onEnd: null, - endWidget: "00:00:00".toText32(color: Colors.white, isBold: true), - textStyle: TextStyle(color: Colors.white, fontSize: 32, letterSpacing: -1.92, fontWeight: FontWeight.bold, height: 1), - ), - 19.height, - LocaleKeys.shiftTime.tr().tr().toText12(color: MyColors.greyACColor), - (model.attendanceTracking!.pShtName ?? "00:00:00").toString().toText22(color: Colors.white, isBold: true), - ], + child: AspectRatio( + aspectRatio: 265 / 265, + child: CircularStepProgressBar( + totalSteps: 16 * 4, + currentStep: (model.progress * 100).toInt(), + //width: 216, + // height: 216, + selectedColor: MyColors.gradiantEndColor, + unselectedColor: MyColors.grey70Color, + child: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + CountdownTimer( + endTime: model.endTime, + onEnd: null, + endWidget: "00:00:00".toText32(color: Colors.white, isBold: true), + textStyle: TextStyle(color: Colors.white, fontSize: 32, letterSpacing: -1.92, fontWeight: FontWeight.bold, height: 1), + ), + 19.height, + LocaleKeys.shiftTime.tr().tr().toText12(color: MyColors.greyACColor), + (model.attendanceTracking!.pShtName ?? "00:00:00").toString().toText22(color: Colors.white, isBold: true), + ], + ), ), ), - ), - ), + ).paddingAll(21), + ).expanded, ], ), - ), - Container( - color: MyColors.backgroundBlackColor, - child: Stack( - children: [ - Container( - height: 187, - padding: EdgeInsets.only(left: 31, right: 31, top: 31, bottom: 16), - decoration: BoxDecoration( - borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), - gradient: const LinearGradient(transform: GradientRotation(.64), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [ - MyColors.gradiantEndColor, - MyColors.gradiantStartColor, - ]), - ), - child: Column( - children: [ - Row( - children: [ - commonStatusView(LocaleKeys.checkIn.tr(), (model.attendanceTracking!.pSwipeIn) ?? "- - : - -"), - commonStatusView(LocaleKeys.checkOut.tr(), (model.attendanceTracking!.pSwipeOut) ?? "- - : - -") - ], - ), - 21.height, - Row( - children: [ - commonStatusView(LocaleKeys.lateIn.tr(), (model.attendanceTracking!.pLateInHours) ?? "- - : - -"), - commonStatusView(LocaleKeys.regular.tr(), (model.attendanceTracking!.pScheduledHours) ?? "- - : - -") - ], - ), - ], - ), - ), - Container( - width: double.infinity, - decoration: BoxDecoration(borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), color: Colors.white), - margin: EdgeInsets.only(top: 187 - 31), - padding: EdgeInsets.only(left: 21, right: 21, top: 24, bottom: 24), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - LocaleKeys.mark.tr().tr().toText12(), - LocaleKeys.attendance.tr().tr().toText24(), - LocaleKeys.selectMethodOfAttendance.tr().tr().toText12(color: Color(0xff535353)), - 24.height, - GridView( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - padding: EdgeInsets.zero, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8), - children: [ - if (isNfcEnabled) - attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () { - if (isNfcLocationEnabled) { - Location.getCurrentLocation((LatLng? latlng) { - performNfcAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); - }); - } else { - performNfcAttendance(model); - } - }), - if (isWifiEnabled) - attendanceMethod("Wifi", "assets/images/wufu.svg", isWifiEnabled, () { - if (isWifiLocationEnabled) { + ).expanded, + Center( + child: Container( + // color: MyColors.backgroundBlackColor, + decoration: const BoxDecoration( + borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), + gradient: LinearGradient(transform: GradientRotation(.64), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ]), + ), + child: Column( + children: [ + Container( + //height: 187, + padding: const EdgeInsets.only(left: 31, right: 31, top: 31, bottom: 16), + decoration: const BoxDecoration( + borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), + gradient: LinearGradient(transform: GradientRotation(.64), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ]), + ), + child: Column( + children: [ + Row( + children: [ + commonStatusView(LocaleKeys.checkIn.tr(), (model.attendanceTracking!.pSwipeIn) ?? "- - : - -"), + commonStatusView(LocaleKeys.checkOut.tr(), (model.attendanceTracking!.pSwipeOut) ?? "- - : - -") + ], + ), + 21.height, + Row( + children: [ + commonStatusView(LocaleKeys.lateIn.tr(), (model.attendanceTracking!.pLateInHours) ?? "- - : - -"), + commonStatusView(LocaleKeys.regular.tr(), (model.attendanceTracking!.pScheduledHours) ?? "- - : - -") + ], + ), + ], + ), + ), //.expanded, - Location.getCurrentLocation((LatLng? latlng) { - performWifiAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); - }); - } else { - performWifiAttendance(model); - } - // connectWifi(); - }), - if (isQrEnabled) - attendanceMethod("QR", "assets/images/ic_qr.svg", isQrEnabled, () async { - if (isQrLocationEnabled) { - Location.getCurrentLocation((LatLng? latlng) { - performQrCodeAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); - }); - } else { - performQrCodeAttendance(model); - } - // performQrCodeAttendance(model); - }), - ], - ) - ], + // MarkAttendanceWidget(model), + Container( + width: double.infinity, + decoration: BoxDecoration(borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), color: Colors.white), + // margin: EdgeInsets.only(top: 187 - 31), + padding: EdgeInsets.only(left: 21, right: 21, top: 24, bottom: 24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + LocaleKeys.markAttendance.tr().toSectionHeading(), + LocaleKeys.selectMethodOfAttendance.tr().tr().toText11(color: Color(0xff535353)), + 24.height, + GridView( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.zero, + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8), + children: [ + if (isNfcEnabled) + attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () { + if (isNfcLocationEnabled) { + Location.getCurrentLocation((LatLng? latlng) { + performNfcAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + }); + } else { + performNfcAttendance(model); + } + }), + if (isWifiEnabled) + attendanceMethod("Wifi", "assets/images/wufu.svg", isWifiEnabled, () { + if (isWifiLocationEnabled) { + Location.getCurrentLocation((LatLng? latlng) { + performWifiAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + }); + } else { + performWifiAttendance(model); + } + // connectWifi(); + }), + if (isQrEnabled) + attendanceMethod("QR", "assets/images/ic_qr.svg", isQrEnabled, () async { + if (isQrLocationEnabled) { + Location.getCurrentLocation((LatLng? latlng) { + performQrCodeAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + }); + } else { + performQrCodeAttendance(model); + } + // performQrCodeAttendance(model); + }), + ], + ) + ], + ), ), - ), - // Positioned( - // top: 187 - 21, - // child: Container( - // padding: EdgeInsets.only(left: 31, right: 31, top: 31, bottom: 16), - // decoration: BoxDecoration(borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), color: Colors.white), - // child: Column( - // children: [ - // Row( - // children: [commonStatusView("Check In", "09:27"), commonStatusView("Check Out", "- - : - -")], - // ), - // 21.height, - // Row( - // children: [commonStatusView("Late In", "00:27"), commonStatusView("Regular", "08:00")], - // ), - // ], - // ), - // ), - // ), - ], + // Positioned( + // top: 187 - 21, + // child: Container( + // padding: EdgeInsets.only(left: 31, right: 31, top: 31, bottom: 16), + // decoration: BoxDecoration(borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), color: Colors.white), + // child: Column( + // children: [ + // Row( + // children: [commonStatusView("Check In", "09:27"), commonStatusView("Check Out", "- - : - -")], + // ), + // 21.height, + // Row( + // children: [commonStatusView("Late In", "00:27"), commonStatusView("Regular", "08:00")], + // ), + // ], + // ), + // ), + // ), + ], + ), ), ) ], @@ -328,7 +335,7 @@ class _TodayAttendanceScreenState extends State { builder: (context) => QrScannerDialog(), ), ); - if(qrCodeValue!=null){ + if (qrCodeValue != null) { print("qrCode: " + qrCodeValue); Utils.showLoading(context); try { @@ -361,11 +368,10 @@ class _TodayAttendanceScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: SvgPicture.asset( + SvgPicture.asset( image, color: Colors.white, - )), + ).expanded, title.toText17(isBold: true, color: Colors.white), ], ), @@ -382,7 +388,7 @@ class _TodayAttendanceScreenState extends State { Widget commonStatusView(String title, String time) => Expanded( child: Column(mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - title.toText12(color: Colors.white), + title.toText12(color: Colors.white.withOpacity(.69)), time.toText22(color: Colors.white, isBold: true), ]), ); diff --git a/lib/widgets/mark_attendance_widget.dart b/lib/widgets/mark_attendance_widget.dart new file mode 100644 index 0000000..c534dee --- /dev/null +++ b/lib/widgets/mark_attendance_widget.dart @@ -0,0 +1,249 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:mohem_flutter_app/api/dashboard_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/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/generic_response_model.dart'; +import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; +import 'package:mohem_flutter_app/widgets/location/Location.dart'; +import 'package:mohem_flutter_app/widgets/nfc/nfc_reader_sheet.dart'; +import 'package:mohem_flutter_app/widgets/qr_scanner_dialog.dart'; +import 'package:nfc_manager/nfc_manager.dart'; +import 'package:wifi_iot/wifi_iot.dart'; + +class MarkAttendanceWidget extends StatefulWidget { + DashboardProviderModel model; + + MarkAttendanceWidget(this.model, {Key? key}) : super(key: key); + + @override + _MarkAttendanceWidgetState createState() { + return _MarkAttendanceWidgetState(); + } +} + +class _MarkAttendanceWidgetState extends State { + bool isNfcEnabled = false, isNfcLocationEnabled = false, isQrEnabled = false, isQrLocationEnabled = false, isWifiEnabled = false, isWifiLocationEnabled = false; + + @override + void initState() { + super.initState(); + checkAttendanceAvailability(); + } + + void checkAttendanceAvailability() async { + bool isAvailable = await NfcManager.instance.isAvailable(); + setState(() { + AppState().privilegeListModel!.forEach((element) { + print(element.serviceName.toString() + " " + element.previlege.toString()); // Check availability + + if (element.serviceName == "enableNFC") { + if (isAvailable) if (element.previlege ?? false) isNfcEnabled = true; + } else if (element.serviceName == "enableQR") { + if (element.previlege ?? false) isQrEnabled = true; + } else if (element.serviceName == "enableWIFI") { + if (element.previlege ?? false) isWifiEnabled = true; + } else if (element.serviceName!.trim() == "enableLocationNFC") { + if (element.previlege ?? false) isNfcLocationEnabled = true; + } else if (element.serviceName == "enableLocationQR") { + if (element.previlege ?? false) isQrLocationEnabled = true; + } else if (element.serviceName == "enableLocationWIFI") { + if (element.previlege ?? false) isWifiLocationEnabled = true; + } + }); + }); + } + + @override + void dispose() { + super.dispose(); + // Stop Session + NfcManager.instance.stopSession(); + } + + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.only(left: 21, right: 21, bottom: 21), + decoration: BoxDecoration(borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), color: Colors.white), + + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.markAttendance.tr().toSectionHeading(), + LocaleKeys.selectMethodOfAttendance.tr().tr().toText11(color: const Color(0xff535353)), + GridView( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: const EdgeInsets.only(bottom: 14, top: 21), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8), + children: [ + if (isNfcEnabled) + attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () { + if (isNfcLocationEnabled) { + Location.getCurrentLocation((LatLng? latlng) { + performNfcAttendance(widget.model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + }); + } else { + performNfcAttendance(widget.model); + } + }), + if (isWifiEnabled) + attendanceMethod("Wifi", "assets/images/wufu.svg", isWifiEnabled, () { + if (isWifiLocationEnabled) { + Location.getCurrentLocation((LatLng? latlng) { + performWifiAttendance(widget.model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + }); + } else { + performWifiAttendance(widget.model); + } + // connectWifi(); + }), + if (isQrEnabled) + attendanceMethod("QR", "assets/images/ic_qr.svg", isQrEnabled, () async { + if (isQrLocationEnabled) { + Location.getCurrentLocation((LatLng? latlng) { + performQrCodeAttendance(widget.model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + }); + } else { + performQrCodeAttendance(widget.model); + } + // performQrCodeAttendance(model); + }), + ], + ) + ], + ), + ); + } + + Future performNfcAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async { + if (isNfcLocationEnabled) { + print("nfc location enabled"); + } else { + print("nfc not location enabled"); + } + + showNfcReader(context, onNcfScan: (String? nfcId) async { + print(nfcId); + Utils.showLoading(context); + try { + GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 2, nfcValue: nfcId ?? "", isGpsRequired: isNfcLocationEnabled, lat: lat, long: lng); + bool status = await model.fetchAttendanceTracking(context); + Utils.hideLoading(context); + } catch (ex) { + print(ex); + Utils.hideLoading(context); + Utils.handleException(ex, context, (msg) { + Utils.confirmDialog(context, msg); + }); + } + }); + } + + Future performWifiAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async { + if (isWifiLocationEnabled) { + print("wifi location enabled"); + } else { + print("wifi not location enabled"); + } + + bool v = await WiFiForIoTPlugin.connect(AppState().mohemmWifiSSID ?? "", password: AppState().mohemmWifiPassword ?? "", joinOnce: true, security: NetworkSecurity.WPA, withInternet: false); + if (v) { + await WiFiForIoTPlugin.forceWifiUsage(true); + print("connected"); + Utils.showLoading(context); + try { + GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 3, nfcValue: "", isGpsRequired: isWifiLocationEnabled, lat: lat, long: lng); + bool status = await model.fetchAttendanceTracking(context); + Utils.hideLoading(context); + await closeWifiRequest(); + } catch (ex) { + print(ex); + await closeWifiRequest(); + Utils.hideLoading(context); + Utils.handleException(ex, context, (msg) { + Utils.confirmDialog(context, msg); + }); + } + } else { + Utils.confirmDialog(context, LocaleKeys.comeNearHMGWifi.tr()); + } + } + + Future closeWifiRequest() async { + await WiFiForIoTPlugin.forceWifiUsage(false); + bool v = await WiFiForIoTPlugin.disconnect(); + return v; + } + + Future performQrCodeAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async { + var qrCodeValue = await Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => QrScannerDialog(), + ), + ); + if (qrCodeValue != null) { + print("qrCode: " + qrCodeValue); + Utils.showLoading(context); + try { + GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 1, isGpsRequired: isQrLocationEnabled, lat: lat, long: lng, QRValue: qrCodeValue); + bool status = await model.fetchAttendanceTracking(context); + Utils.hideLoading(context); + } catch (ex) { + print(ex); + Utils.hideLoading(context); + Utils.handleException(ex, context, (msg) { + Utils.confirmDialog(context, msg); + }); + } + } + } + + Widget attendanceMethod(String title, String image, bool isEnabled, VoidCallback onPress) => Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + gradient: const LinearGradient( + transform: GradientRotation(.64), + begin: Alignment.topRight, + end: Alignment.bottomLeft, + colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ], + ), + ), + clipBehavior: Clip.antiAlias, + child: Stack( + children: [ + Container( + padding: const EdgeInsets.only(left: 10, right: 10, top: 14, bottom: 14), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: SvgPicture.asset( + image, + color: Colors.white, + )), + title.toText17(isBold: true, color: Colors.white), + ], + ), + ), + if (!isEnabled) + Container( + width: double.infinity, + height: double.infinity, + color: Colors.grey.withOpacity(0.7), + ) + ], + ), + ).onPress(onPress); +} From fc6b923fc4da5b6984dc4a2de314b63b8bd1302b Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 25 Aug 2022 11:12:39 +0300 Subject: [PATCH 16/40] mowadhafhi improvement. --- lib/config/routes.dart | 6 +- .../screens/mowadhafhi/mowadhafhi_home.dart | 167 +++++------ .../mowadhafhi/mowadhafhi_hr_request.dart | 267 +++++++----------- 3 files changed, 169 insertions(+), 271 deletions(-) diff --git a/lib/config/routes.dart b/lib/config/routes.dart index ca476df..91e4b56 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -18,13 +18,15 @@ import 'package:mohem_flutter_app/ui/payslip/monthly_pay_slip_screen.dart'; import 'package:mohem_flutter_app/ui/profile/add_update_family_member.dart'; import 'package:mohem_flutter_app/ui/profile/basic_details.dart'; import 'package:mohem_flutter_app/ui/profile/contact_details.dart'; +import 'package:mohem_flutter_app/ui/profile/delete_family_member.dart'; import 'package:mohem_flutter_app/ui/profile/dynamic_screens/dynamic_input_address_screen.dart'; import 'package:mohem_flutter_app/ui/profile/dynamic_screens/dynamic_input_basic_details_screen.dart'; import 'package:mohem_flutter_app/ui/profile/family_members.dart'; import 'package:mohem_flutter_app/ui/profile/personal_info.dart'; +import 'package:mohem_flutter_app/ui/profile/profile_screen.dart'; import 'package:mohem_flutter_app/ui/screens/announcements/announcement_details.dart'; import 'package:mohem_flutter_app/ui/screens/announcements/announcements.dart'; -import 'package:mohem_flutter_app/ui/profile/delete_family_member.dart'; + // import 'package:mohem_flutter_app/ui/my_attendance/work_from_home_screen.dart'; import 'package:mohem_flutter_app/ui/screens/eit/add_eit.dart'; import 'package:mohem_flutter_app/ui/screens/mowadhafhi/mowadhafhi_home.dart'; @@ -32,7 +34,6 @@ import 'package:mohem_flutter_app/ui/screens/mowadhafhi/mowadhafhi_hr_request.da import 'package:mohem_flutter_app/ui/screens/mowadhafhi/request_details.dart'; import 'package:mohem_flutter_app/ui/screens/pending_transactions/pending_transactions.dart'; import 'package:mohem_flutter_app/ui/screens/pending_transactions/pending_transactions_details.dart'; -import 'package:mohem_flutter_app/ui/profile/profile_screen.dart'; import 'package:mohem_flutter_app/ui/screens/submenu_screen.dart'; import 'package:mohem_flutter_app/ui/work_list/item_history_screen.dart'; import 'package:mohem_flutter_app/ui/work_list/itg_detail_screen.dart'; @@ -70,6 +71,7 @@ class AppRoutes { static const String addDynamicInputProfile = 'addDynamicInputProfile'; static const String addDynamicAddressScreen = 'addDynamicAddressProfile'; + //Attendance static const String attendance = "/attendance"; static const String monthlyAttendance = "/monthlyAttendance"; diff --git a/lib/ui/screens/mowadhafhi/mowadhafhi_home.dart b/lib/ui/screens/mowadhafhi/mowadhafhi_home.dart index edf6b03..45d881f 100644 --- a/lib/ui/screens/mowadhafhi/mowadhafhi_home.dart +++ b/lib/ui/screens/mowadhafhi/mowadhafhi_home.dart @@ -7,6 +7,7 @@ import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.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/mowadhafhi/get_tickets_list.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; @@ -20,7 +21,7 @@ class MowadhafhiHome extends StatefulWidget { } class _MowadhafhiHomeState extends State { - List getTicketsByEmployeeList = []; + List? getTicketsByEmployeeList; @override void initState() { @@ -28,111 +29,10 @@ class _MowadhafhiHomeState extends State { super.initState(); } - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: Colors.white, - appBar: AppBarWidget( - context, - title: LocaleKeys.mowadhafhiRequest.tr(), - ), - body: Container( - margin: const EdgeInsets.only(top: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Expanded( - child: ListView.separated( - physics: const BouncingScrollPhysics(), - shrinkWrap: true, - itemBuilder: (BuildContext context, int index) { - return InkWell( - onTap: () { - openRequestDetails(getTicketsByEmployeeList[index].ticketId!); - }, - child: Container( - width: double.infinity, - // height: 100.0, - padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), - margin: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - getTicketsByEmployeeList[index].ticketTypeName!.toText14(color: MyColors.grey57Color), - getTicketsByEmployeeList[index].created!.split(" ")[0].toText12(color: MyColors.grey70Color), - ], - ), - Container( - padding: const EdgeInsets.only(top: 10.0), - child: getTicketsByEmployeeList[index].description!.toText12(color: MyColors.grey57Color), - ), - Container( - padding: const EdgeInsets.only(top: 10.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - getTicketsByEmployeeList[index].ticketStatusInternalName!.toText14(color: MyColors.gradiantEndColor), - SvgPicture.asset( - "assets/images/arrow_next.svg", - color: MyColors.darkIconColor, - ) - ], - ), - ), - ], - ), - ), - ); - }, - separatorBuilder: (BuildContext context, int index) => 12.height, - itemCount: getTicketsByEmployeeList.length ?? 0)), - 80.height - ], - ), - ), - bottomSheet: Container( - decoration: const BoxDecoration( - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), - ], - ), - child: DefaultButton(LocaleKeys.createRequest.tr(), () async { - openHRRequest(); - }).insideContainer, - )); - } - - void openRequestDetails(String itgTicketID) async { - await Navigator.pushNamed(context, AppRoutes.mowadhafhiDetails, arguments: itgTicketID); - } - - void openHRRequest() async { - await Navigator.pushNamed(context, AppRoutes.mowadhafhiHRRequest).then((value) { - getOpenTickets(); - }); - } - void getOpenTickets() async { try { Utils.showLoading(context); - getTicketsByEmployeeList.clear(); + getTicketsByEmployeeList?.clear(); getTicketsByEmployeeList = await MowadhafhiApiClient().getTicketsByEmployee(); Utils.hideLoading(context); setState(() {}); @@ -141,4 +41,65 @@ class _MowadhafhiHomeState extends State { Utils.handleException(ex, context, null); } } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBarWidget( + context, + title: LocaleKeys.mowadhafhiRequest.tr(), + ), + body: getTicketsByEmployeeList == null + ? const SizedBox() + : (getTicketsByEmployeeList!.isEmpty) + ? Utils.getNoDataWidget(context) + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + ListView.separated( + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.all(21), + itemBuilder: (BuildContext context, int index) { + return InkWell( + onTap: () { + Navigator.pushNamed(context, AppRoutes.mowadhafhiDetails, arguments: getTicketsByEmployeeList![index].ticketId); + }, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + getTicketsByEmployeeList![index].ticketTypeName!.toText14(color: MyColors.darkTextColor).expanded, + getTicketsByEmployeeList![index].created!.split(" ")[0].toText12(color: MyColors.grey70Color), + ], + ), + getTicketsByEmployeeList![index].description!.toText12(color: MyColors.grey57Color), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + getTicketsByEmployeeList![index].ticketStatusInternalName!.toText14(color: MyColors.textMixColor), + SvgPicture.asset( + "assets/images/arrow_next.svg", + color: MyColors.darkIconColor, + ) + ], + ), + ], + ).objectContainerView(), + ); + }, + separatorBuilder: (BuildContext context, int index) => 12.height, + itemCount: getTicketsByEmployeeList!.length) + .expanded, + DefaultButton(LocaleKeys.createRequest.tr(), () async { + await Navigator.pushNamed(context, AppRoutes.mowadhafhiHRRequest); + getOpenTickets(); + }).insideContainer + ], + ), + ); + } } diff --git a/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart b/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart index 7ac6c43..44b3833 100644 --- a/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart +++ b/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart @@ -21,7 +21,6 @@ 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/button/simple_button.dart'; import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; -import 'package:mohem_flutter_app/widgets/radio/show_radio.dart'; class MowadhafhiHRRequest extends StatefulWidget { const MowadhafhiHRRequest({Key? key}) : super(key: key); @@ -42,7 +41,9 @@ class _MowadhafhiHRRequestState extends State { GetSectionTopics? selectedTopic; List attachmentFiles = []; - String selectedServiceType = ""; + GetTicketTypes? selectedServiceType; + + // String selectedServiceType = ""; String description = ""; int? projectID; @@ -58,69 +59,40 @@ class _MowadhafhiHRRequestState extends State { backgroundColor: Colors.white, appBar: AppBarWidget( context, - title: LocaleKeys.mowadhafhiRequest.tr(), + title: LocaleKeys.createRequest.tr(), ), - body: SingleChildScrollView( - child: getTicketTypesList.isNotEmpty - ? Container( - width: double.infinity, - padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), - margin: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + body: getTicketTypesList.isNotEmpty + ? Column( + children: [ + ListView( + padding: const EdgeInsets.all(21), children: [ - LocaleKeys.serviceType.tr().toText16(), - 12.height, - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - SizedBox( - height: 40, - child: ListView.separated( - itemBuilder: (context, index) { - return Container( - padding: const EdgeInsets.only(right: 6, top: 8, bottom: 8), - child: ShowRadio( - title: getTicketTypesList[index].typeName!, - value: getTicketTypesList[index].ticketTypeId!.toString(), - groupValue: selectedServiceType, - selectedColor: MyColors.gradiantStartColor), - ).onPress(() { - selectedServiceType = getTicketTypesList[index].ticketTypeId!.toString(); - setState(() {}); - }); - }, - separatorBuilder: (context, index) => 1.width, - shrinkWrap: true, - itemCount: getTicketTypesList.length ?? 0, - scrollDirection: Axis.horizontal, - ), + PopupMenuButton( + child: DynamicTextFieldWidget( + LocaleKeys.serviceType.tr(), + selectedServiceType?.typeName ?? LocaleKeys.selectTypeT.tr(), + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, ), - ], - ), - 12.height, - LocaleKeys.departmentName.tr().toText16(), + itemBuilder: (_) => >[ + for (int i = 0; i < getTicketTypesList.length; i++) PopupMenuItem(child: Text(getTicketTypesList[i].typeName!), value: i), + ], + onSelected: (int popupIndex) { + selectedServiceType = getTicketTypesList[popupIndex]; //.ticketTypeId!.toString(); + setState(() {}); + }), 12.height, PopupMenuButton( child: DynamicTextFieldWidget( - LocaleKeys.selectDepartment.tr(), - selectedDepartment?.departmentName ?? "", + LocaleKeys.departmentName.tr(), + selectedDepartment?.departmentName ?? LocaleKeys.selectDepartment.tr(), isEnable: false, isPopup: true, isInputTypeNum: true, isReadOnly: false, - ).paddingOnly(bottom: 12), + ), itemBuilder: (_) => >[ for (int i = 0; i < getProjectDepartmentsList!.length; i++) PopupMenuItem(child: Text(getProjectDepartmentsList![i].departmentName!), value: i), ], @@ -130,17 +102,15 @@ class _MowadhafhiHRRequestState extends State { setState(() {}); }), 12.height, - LocaleKeys.relatedSection.tr().toText16(), - 12.height, PopupMenuButton( child: DynamicTextFieldWidget( - LocaleKeys.selectSection.tr(), - selectedSection?.sectionName ?? "", + LocaleKeys.relatedSection.tr(), + selectedSection?.sectionName ?? LocaleKeys.selectSection.tr(), isEnable: false, isPopup: true, isInputTypeNum: true, isReadOnly: false, - ).paddingOnly(bottom: 12), + ), itemBuilder: (_) => >[ for (int i = 0; i < getDepartmentSectionsList!.length; i++) PopupMenuItem(child: Text(getDepartmentSectionsList![i].sectionName!), value: i), ], @@ -150,35 +120,29 @@ class _MowadhafhiHRRequestState extends State { setState(() {}); }), 12.height, - LocaleKeys.relatedTopic.tr().toText16(), - 12.height, PopupMenuButton( child: DynamicTextFieldWidget( - LocaleKeys.selectTopic.tr(), - selectedTopic?.topicName ?? "", + LocaleKeys.relatedTopic.tr(), + selectedTopic?.topicName ?? LocaleKeys.selectTopic.tr(), isEnable: false, isPopup: true, isInputTypeNum: true, isReadOnly: false, - ).paddingOnly(bottom: 12), + ), itemBuilder: (_) => >[ - for (int i = 0; i < getSectionTopicsList!.length; i++) PopupMenuItem(child: Text(getSectionTopicsList![i].topicName!), value: i), + for (int i = 0; i < getSectionTopicsList.length; i++) PopupMenuItem(child: Text(getSectionTopicsList[i].topicName!), value: i), ], onSelected: (int popupIndex) { - selectedTopic = getSectionTopicsList![popupIndex]; + selectedTopic = getSectionTopicsList[popupIndex]; // getDepartmentSections(selectedSection?.departmentSectionId); setState(() {}); }), 12.height, - LocaleKeys.supportingDocument.tr().toText16(), - 12.height, - attachmentView("Attachments"), - 12.height, - LocaleKeys.description.tr().toText16(), + attachmentView("Attachments").objectContainerView(title: LocaleKeys.supportingDocument.tr()), 12.height, DynamicTextFieldWidget( - "", - "", + LocaleKeys.description.tr(), + LocaleKeys.writeAMessage.tr(), isEnable: true, isPopup: false, lines: 4, @@ -189,40 +153,25 @@ class _MowadhafhiHRRequestState extends State { description = value; }, ), - 50.height ], - ), - ) - : Container(), - ), - bottomSheet: Container( - padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), - decoration: const BoxDecoration( - color: MyColors.white, - ), - child: Row( - children: [ - 12.width, - Expanded( - child: DefaultButton( - LocaleKeys.submit.tr(), - !checkValidation() - ? null - : () { - submitHRRequest(); - }, - color: const Color(0xFFD02127), - ), - ), - 12.width, - ], - ), - ), + ).expanded, + DefaultButton( + LocaleKeys.submit.tr(), + !checkValidation() + ? null + : () { + submitHRRequest(); + }, + color: const Color(0xFFD02127), + ).insideContainer + ], + ) + : Container(), ); } bool checkValidation() { - if (selectedServiceType == "" || selectedDepartment == null || selectedSection == null || selectedTopic == null) { + if (selectedServiceType == null || selectedDepartment == null || selectedSection == null || selectedTopic == null) { return false; } else { return true; @@ -230,69 +179,55 @@ class _MowadhafhiHRRequestState extends State { } Widget attachmentView(String title) { - return Container( - padding: const EdgeInsets.only(top: 15, bottom: 15, left: 14, right: 14), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(15), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - title.toText16().expanded, - 6.width, - SimpleButton(LocaleKeys.add.tr(), () async { - FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true); - if (result != null) { - attachmentFiles = attachmentFiles + result.paths.map((path) => File(path!)).toList(); - attachmentFiles = attachmentFiles.toSet().toList(); - setState(() {}); - } - }, fontSize: 14), - ], - ), - if (attachmentFiles.isNotEmpty) 12.height, - if (attachmentFiles.isNotEmpty) - ListView.separated( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemBuilder: (cxt, index) { - String fileName = attachmentFiles[index].path.split('/').last; + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + title.toText16().expanded, + 6.width, + SimpleButton(LocaleKeys.add.tr(), () async { + FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true); + if (result != null) { + attachmentFiles = attachmentFiles + result.paths.map((path) => File(path!)).toList(); + attachmentFiles = attachmentFiles.toSet().toList(); + setState(() {}); + } + }, fontSize: 14), + ], + ), + if (attachmentFiles.isNotEmpty) 12.height, + if (attachmentFiles.isNotEmpty) + ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (cxt, index) { + String fileName = attachmentFiles[index].path.split('/').last; - return Row( - children: [ - fileName.toText13().expanded, - 6.width, - IconButton( - padding: EdgeInsets.zero, - iconSize: 20, - icon: const Icon(Icons.cancel_rounded), - color: MyColors.redColor, - constraints: const BoxConstraints(), - onPressed: () async { - attachmentFiles.removeAt(index); - setState(() {}); - }, - ) - ], - ); - }, - separatorBuilder: (cxt, index) => 6.height, - itemCount: attachmentFiles.length), - ], - ), + return Row( + children: [ + fileName.toText13().expanded, + 6.width, + IconButton( + padding: EdgeInsets.zero, + iconSize: 20, + icon: const Icon(Icons.cancel_rounded), + color: MyColors.redColor, + constraints: const BoxConstraints(), + onPressed: () async { + attachmentFiles.removeAt(index); + setState(() {}); + }, + ) + ], + ); + }, + separatorBuilder: (cxt, index) => 6.height, + itemCount: attachmentFiles.length), + ], ); } @@ -376,7 +311,7 @@ class _MowadhafhiHRRequestState extends State { } } int? messageStatus = await MowadhafhiApiClient().submitRequest(selectedDepartment?.projectDepartmentId, description, projectID, selectedSection?.departmentSectionId.toString(), - selectedTopic?.sectionTopicId.toString(), int.parse(selectedServiceType), list); + selectedTopic?.sectionTopicId.toString(), selectedServiceType!.ticketTypeId, list); Utils.showToast(LocaleKeys.requestCreatedSuccessfully.tr()); Utils.hideLoading(context); Navigator.pop(context); From a855e535cd2f1a3016d22796ae448def8f5624ac Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 25 Aug 2022 11:37:36 +0300 Subject: [PATCH 17/40] Item for sale implemented --- ios/Runner/Info.plist | 14 +- lib/api/api_client.dart | 15 +- .../items_for_sale_api_client.dart | 123 ++++++++ lib/classes/colors.dart | 1 + lib/classes/consts.dart | 1 + lib/classes/utils.dart | 25 ++ lib/config/routes.dart | 16 +- .../add_item_for_sale_image_model.dart | 25 ++ .../items_for_sale/get_employee_ads_list.dart | 181 +++++++++++ .../get_items_for_sale_list.dart | 181 +++++++++++ .../items_for_sale/get_regions_list.dart | 48 +++ .../get_sale_categories_list.dart | 36 +++ .../items_for_sale/item_review_model.dart | 35 +++ lib/ui/landing/dashboard_screen.dart | 5 +- .../items_for_sale/add_new_item_for_sale.dart | 216 +++++++++++++ .../fragments/add_details_fragment.dart | 293 ++++++++++++++++++ .../fragments/item_review_fragment.dart | 154 +++++++++ .../fragments/items_for_sale.dart | 239 ++++++++++++++ .../fragments/my_posted_ads_fragment.dart | 213 +++++++++++++ .../fragments/select_category_fragment.dart | 78 +++++ .../items_for_sale/item_for_sale_detail.dart | 136 ++++++++ .../items_for_sale/items_for_sale_home.dart | 111 +++++++ .../dynamic_textfield_widget.dart | 3 +- lib/widgets/image_picker.dart | 154 +++++++++ 24 files changed, 2293 insertions(+), 10 deletions(-) create mode 100644 lib/api/items_for_sale/items_for_sale_api_client.dart create mode 100644 lib/models/items_for_sale/add_item_for_sale_image_model.dart create mode 100644 lib/models/items_for_sale/get_employee_ads_list.dart create mode 100644 lib/models/items_for_sale/get_items_for_sale_list.dart create mode 100644 lib/models/items_for_sale/get_regions_list.dart create mode 100644 lib/models/items_for_sale/get_sale_categories_list.dart create mode 100644 lib/models/items_for_sale/item_review_model.dart create mode 100644 lib/ui/screens/items_for_sale/add_new_item_for_sale.dart create mode 100644 lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart create mode 100644 lib/ui/screens/items_for_sale/fragments/item_review_fragment.dart create mode 100644 lib/ui/screens/items_for_sale/fragments/items_for_sale.dart create mode 100644 lib/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart create mode 100644 lib/ui/screens/items_for_sale/fragments/select_category_fragment.dart create mode 100644 lib/ui/screens/items_for_sale/item_for_sale_detail.dart create mode 100644 lib/ui/screens/items_for_sale/items_for_sale_home.dart create mode 100644 lib/widgets/image_picker.dart diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index dadaab0..eaa735c 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -2,6 +2,8 @@ + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable @@ -26,6 +28,10 @@ LaunchScreen UIMainStoryboardFile Main + NSCameraUsageDescription + This app requires camera access to capture & upload pictures. + NSPhotoLibraryUsageDescription + This app requires photo library access to select image as document & upload it. UISupportedInterfaceOrientations UIInterfaceOrientationPortrait @@ -39,9 +45,13 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + LSApplicationQueriesSchemes + + sms + tel + mailto + UIViewControllerBasedStatusBarAppearance - CADisableMinimumFrameDurationOnPhone - diff --git a/lib/api/api_client.dart b/lib/api/api_client.dart index 2f53f78..3385815 100644 --- a/lib/api/api_client.dart +++ b/lib/api/api_client.dart @@ -67,7 +67,7 @@ class ApiClient { factory ApiClient() => _instance; Future postJsonForObject(FactoryConstructor factoryConstructor, String url, T jsonObject, - {String? token, Map? queryParameters, Map? headers, int retryTimes = 0}) async { + {String? token, Map? queryParameters, Map? headers, int retryTimes = 0, bool isFormData = false}) async { var _headers = {'Accept': 'application/json'}; if (headers != null && headers.isNotEmpty) { _headers.addAll(headers); @@ -76,7 +76,7 @@ class ApiClient { print("Url:$url"); print("body:$jsonObject"); } - var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes); + var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes, isFormData: isFormData); // try { if (!kReleaseMode) { logger.i("res: " + response.body); @@ -101,8 +101,10 @@ class ApiClient { // } } - Future postJsonForResponse(String url, T jsonObject, {String? token, Map? queryParameters, Map? headers, int retryTimes = 0}) async { + Future postJsonForResponse(String url, T jsonObject, + {String? token, Map? queryParameters, Map? headers, int retryTimes = 0, bool isFormData = false}) async { String? requestBody; + late Map stringObj; if (jsonObject != null) { requestBody = jsonEncode(jsonObject); if (headers == null) { @@ -112,7 +114,12 @@ class ApiClient { } } - return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes); + if (isFormData) { + headers = {'Content-Type': 'application/x-www-form-urlencoded'}; + stringObj = ((jsonObject ?? {}) as Map).map((key, value) => MapEntry(key, value?.toString() ?? "")); + } + + return await _postForResponse(url, isFormData ? stringObj : requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes); } Future _postForResponse(String url, requestBody, {String? token, Map? queryParameters, Map? headers, int retryTimes = 0}) async { diff --git a/lib/api/items_for_sale/items_for_sale_api_client.dart b/lib/api/items_for_sale/items_for_sale_api_client.dart new file mode 100644 index 0000000..31acbc2 --- /dev/null +++ b/lib/api/items_for_sale/items_for_sale_api_client.dart @@ -0,0 +1,123 @@ +import 'dart:convert'; + +import 'package:mohem_flutter_app/api/api_client.dart'; +import 'package:mohem_flutter_app/app_state/app_state.dart'; +import 'package:mohem_flutter_app/classes/consts.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/get_employee_ads_list.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/get_items_for_sale_list.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/get_regions_list.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/get_sale_categories_list.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/item_review_model.dart'; + +class ItemsForSaleApiClient { + static final ItemsForSaleApiClient _instance = ItemsForSaleApiClient._internal(); + + ItemsForSaleApiClient._internal(); + + factory ItemsForSaleApiClient() => _instance; + + Future> getSaleCategories() async { + List getSaleCategoriesList = []; + + String url = "${ApiConsts.cocRest}Mohemm_ITG_GetItemSaleCategory"; + Map postParams = {"EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER, "ItgPageSize": 10, "ItgPageNo": 1}; + + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((response) { + final body = json.decode(response['Mohemm_ITG_ResponseItem']); + + GetSaleCategoriesList getSaleCategoriesListObj = new GetSaleCategoriesList(); + getSaleCategoriesListObj.categoryID = 0; + getSaleCategoriesListObj.title = "All"; + getSaleCategoriesListObj.titleAr = "الجميع"; + getSaleCategoriesListObj.isActive = true; + getSaleCategoriesListObj.content = + ''; + + getSaleCategoriesList.add(getSaleCategoriesListObj); + + body['result']['data'].forEach((v) { + getSaleCategoriesList.add(new GetSaleCategoriesList.fromJson(v)); + }); + return getSaleCategoriesList; + }, url, postParams); + } + + Future> getItemsForSale(int itgPageNo, int itgCategoryID) async { + List getItemsForSaleList = []; + + String url = "${ApiConsts.cocRest}Mohemm_ITG_GetItemForSale"; + Map postParams = { + "EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER, + "ItgPageSize": 10, + "ItgPageNo": itgPageNo, + "ItgStatus": "Approved", + "ItgCategoryID": itgCategoryID + }; + + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((response) { + final body = json.decode(response['Mohemm_ITG_ResponseItem']); + + body['result']['data'].forEach((v) { + getItemsForSaleList.add(new GetItemsForSaleList.fromJson(v)); + }); + return getItemsForSaleList; + }, url, postParams); + } + + Future> getEmployeePostedAds() async { + List employeePostedAdsList = []; + + String url = "${ApiConsts.cocRest}Mohemm_ITG_GetItemForSaleByEmployee"; + Map postParams = {"EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER, "ItgEmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER}; + + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((response) { + final body = json.decode(response['Mohemm_ITG_ResponseItem']); + + body['result']['data'].forEach((v) { + employeePostedAdsList.add(new EmployeePostedAds.fromJson(v)); + }); + return employeePostedAdsList; + }, url, postParams); + } + + Future> getRegions() async { + String url = "${ApiConsts.cocRest}Mohemm_ITG_GetRegion"; + List getRegionsList = []; + Map postParams = {"EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER, "ItgEmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((response) { + final body = json.decode(response['Mohemm_ITG_ResponseItem']); + + body['result']['data'].forEach((v) { + getRegionsList.add(new GetRegionsList.fromJson(v)); + }); + return getRegionsList; + }, url, postParams); + } + + Future addItemForSale(ItemReviewModel itemReviewModel, List> imagesList) async { + String url = "${ApiConsts.cocRest}Mohemm_ITG_AddItemForSaleMobile"; + Map postParams = { + "ItgImageCollList": imagesList, + "ItgTitle": itemReviewModel.itemTitle, + "ItgTitleAr": itemReviewModel.itemTitle, + "ItgCategoryID": itemReviewModel.selectedSaleCategory!.categoryID, + "ItgDescription": itemReviewModel.itemDescription, + "ItgDescriptionAr": itemReviewModel.itemDescription, + "ItgQuotePrice": itemReviewModel.itemPrice, + "RegionID": itemReviewModel.selectedRegion!.regionID, + "ItgIsActive": true, + "EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER, + "employeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER, + "ItgStatus": itemReviewModel.itemCondition + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((response) { + final body = json.decode(response['Mohemm_ITG_ResponseItem']); + return body["message"]; + }, url, postParams); + } +} diff --git a/lib/classes/colors.dart b/lib/classes/colors.dart index 4b34186..794b37e 100644 --- a/lib/classes/colors.dart +++ b/lib/classes/colors.dart @@ -22,6 +22,7 @@ class MyColors { static const Color darkWhiteColor = Color(0xffE0E0E0); static const Color redColor = Color(0xffD02127); static const Color yellowColor = Color(0xffF4E31C); + static const Color orange = Color(0xFFCC9B14); static const Color backgroundBlackColor = Color(0xff202529); static const Color black = Color(0xff000000); static const Color white = Color(0xffffffff); diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index e806301..12f818e 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -22,4 +22,5 @@ class SharedPrefsConsts { static String doNotShowWelcomeVideo = "doNotShowWelcomeVideo"; static String mohemmWifiSSID = "mohemmWifiSSID"; static String mohemmWifiPassword = "mohemmWifiPassword"; + static String editItemForSale = "editItemForSale"; } diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index 292bc4c..e2ae38e 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -178,6 +178,31 @@ class Utils { ); } + static Decoration containerRadius(Color background, double radius) { + return BoxDecoration( + color: background, + border: Border.all( + width: 1, // + color: background // <--- border width here + ), + borderRadius: BorderRadius.circular(radius), + ); + } + + static Widget mHeight(double h) { + return Container( + height: h, + ); + } + + static Widget mDivider(Color color) { + return Divider( + // width: double.infinity, + height: 1, + color: color, + ); + } + static Widget tableColumnValue(String text, {bool isCapitable = true, bool alignCenter = false}) { return Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 72dc5ed..6928f09 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -28,6 +28,9 @@ import 'package:mohem_flutter_app/ui/screens/announcements/announcements.dart'; // import 'package:mohem_flutter_app/ui/my_attendance/work_from_home_screen.dart'; import 'package:mohem_flutter_app/ui/screens/eit/add_eit.dart'; +import 'package:mohem_flutter_app/ui/screens/items_for_sale/add_new_item_for_sale.dart'; +import 'package:mohem_flutter_app/ui/screens/items_for_sale/item_for_sale_detail.dart'; +import 'package:mohem_flutter_app/ui/screens/items_for_sale/items_for_sale_home.dart'; import 'package:mohem_flutter_app/ui/screens/mowadhafhi/mowadhafhi_home.dart'; import 'package:mohem_flutter_app/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart'; import 'package:mohem_flutter_app/ui/screens/mowadhafhi/request_details.dart'; @@ -109,6 +112,11 @@ class AppRoutes { static const String myRequests = "/myRequests"; static const String newRequest = "/newRequests"; + // Items For Sale + static const String itemsForSale = "/itemsForSale"; + static const String itemsForSaleDetail = "/itemsForSaleDetail"; + static const String addNewItemForSale = "/addNewItemForSale"; + //Pay slip static const String monthlyPaySlip = "/monthlyPaySlip"; @@ -175,7 +183,13 @@ class AppRoutes { myRequests: (context) => MyRequests(), newRequest: (context) => NewRequest(), + // Items for sale + itemsForSale: (context) => ItemsForSale(), + itemsForSaleDetail: (context) => ItemForSaleDetailPage(), + addNewItemForSale: (context) => AddNewItemForSale(), + + //pay slip monthlyPaySlip: (context) => MonthlyPaySlipScreen(), }; -} +} \ No newline at end of file diff --git a/lib/models/items_for_sale/add_item_for_sale_image_model.dart b/lib/models/items_for_sale/add_item_for_sale_image_model.dart new file mode 100644 index 0000000..b26929e --- /dev/null +++ b/lib/models/items_for_sale/add_item_for_sale_image_model.dart @@ -0,0 +1,25 @@ +class AddItemForSaleImageModel { + int? attachmentID; + String? base64Data; + String? fileName; + String? contentType; + + AddItemForSaleImageModel( + {this.attachmentID, this.base64Data, this.fileName, this.contentType}); + + AddItemForSaleImageModel.fromJson(Map json) { + attachmentID = json['AttachmentID']; + base64Data = json['Base64Data']; + fileName = json['FileName']; + contentType = json['ContentType']; + } + + Map toJson() { + final Map data = new Map(); + data['AttachmentID'] = this.attachmentID; + data['Base64Data'] = this.base64Data; + data['FileName'] = this.fileName; + data['ContentType'] = this.contentType; + return data; + } +} diff --git a/lib/models/items_for_sale/get_employee_ads_list.dart b/lib/models/items_for_sale/get_employee_ads_list.dart new file mode 100644 index 0000000..97e06b8 --- /dev/null +++ b/lib/models/items_for_sale/get_employee_ads_list.dart @@ -0,0 +1,181 @@ +class EmployeePostedAds { + int? itemSaleID; + String? title; + String? titleAr; + String? description; + String? descriptionAr; + int? categoryID; + String? categoryTitle; + int? regionID; + String? regionName; + String? countryName; + String? currencyCode; + String? startDate; + String? endDate; + int? quotePrice; + int? employeeNumber; + String? profilePicture; + String? fullName; + String? emailAddress; + String? mobileNumber; + bool? isApproved; + String? status; + List? itemAttachments; + String? created; + dynamic? comments; + dynamic? isActive; + int? pageSize; + int? pageNo; + dynamic? languageId; + + EmployeePostedAds( + {this.itemSaleID, + this.title, + this.titleAr, + this.description, + this.descriptionAr, + this.categoryID, + this.categoryTitle, + this.regionID, + this.regionName, + this.countryName, + this.currencyCode, + this.startDate, + this.endDate, + this.quotePrice, + this.employeeNumber, + this.profilePicture, + this.fullName, + this.emailAddress, + this.mobileNumber, + this.isApproved, + this.status, + this.itemAttachments, + this.created, + this.comments, + this.isActive, + this.pageSize, + this.pageNo, + this.languageId}); + + EmployeePostedAds.fromJson(Map json) { + itemSaleID = json['itemSaleID']; + title = json['title']; + titleAr = json['title_Ar']; + description = json['description']; + descriptionAr = json['description_Ar']; + categoryID = json['categoryID']; + categoryTitle = json['categoryTitle']; + regionID = json['regionID']; + regionName = json['regionName']; + countryName = json['countryName']; + currencyCode = json['currencyCode']; + startDate = json['startDate']; + endDate = json['endDate']; + quotePrice = json['quotePrice']; + employeeNumber = json['employeeNumber']; + profilePicture = json['profilePicture']; + fullName = json['fullName']; + emailAddress = json['emailAddress']; + mobileNumber = json['mobileNumber']; + isApproved = json['isApproved']; + status = json['status']; + if (json['itemAttachments'] != null) { + itemAttachments = []; + json['itemAttachments'].forEach((v) { + itemAttachments!.add(new ItemAttachments.fromJson(v)); + }); + } + created = json['created']; + comments = json['comments']; + isActive = json['isActive']; + pageSize = json['pageSize']; + pageNo = json['pageNo']; + languageId = json['languageId']; + } + + Map toJson() { + final Map data = new Map(); + data['itemSaleID'] = this.itemSaleID; + data['title'] = this.title; + data['title_Ar'] = this.titleAr; + data['description'] = this.description; + data['description_Ar'] = this.descriptionAr; + data['categoryID'] = this.categoryID; + data['categoryTitle'] = this.categoryTitle; + data['regionID'] = this.regionID; + data['regionName'] = this.regionName; + data['countryName'] = this.countryName; + data['currencyCode'] = this.currencyCode; + data['startDate'] = this.startDate; + data['endDate'] = this.endDate; + data['quotePrice'] = this.quotePrice; + data['employeeNumber'] = this.employeeNumber; + data['profilePicture'] = this.profilePicture; + data['fullName'] = this.fullName; + data['emailAddress'] = this.emailAddress; + data['mobileNumber'] = this.mobileNumber; + data['isApproved'] = this.isApproved; + data['status'] = this.status; + if (this.itemAttachments != null) { + data['itemAttachments'] = + this.itemAttachments!.map((v) => v.toJson()).toList(); + } + data['created'] = this.created; + data['comments'] = this.comments; + data['isActive'] = this.isActive; + data['pageSize'] = this.pageSize; + data['pageNo'] = this.pageNo; + data['languageId'] = this.languageId; + return data; + } +} + +class ItemAttachments { + int? attachmentId; + String? fileName; + String? contentType; + String? attachFileStream; + String? base64String; + dynamic? isActive; + int? referenceItemId; + String? content; + String? filePath; + + ItemAttachments( + {this.attachmentId, + this.fileName, + this.contentType, + this.attachFileStream, + this.base64String, + this.isActive, + this.referenceItemId, + this.content, + this.filePath}); + + ItemAttachments.fromJson(Map json) { + attachmentId = json['attachmentId']; + fileName = json['fileName']; + contentType = json['contentType']; + attachFileStream = json['attachFileStream']; + base64String = json['base64String']; + isActive = json['isActive']; + referenceItemId = json['referenceItemId']; + content = json['content']; + filePath = json['filePath']; + } + + Map toJson() { + final Map data = new Map(); + data['attachmentId'] = this.attachmentId; + data['fileName'] = this.fileName; + data['contentType'] = this.contentType; + data['attachFileStream'] = this.attachFileStream; + data['base64String'] = this.base64String; + data['isActive'] = this.isActive; + data['referenceItemId'] = this.referenceItemId; + data['content'] = this.content; + data['filePath'] = this.filePath; + return data; + } +} diff --git a/lib/models/items_for_sale/get_items_for_sale_list.dart b/lib/models/items_for_sale/get_items_for_sale_list.dart new file mode 100644 index 0000000..091b023 --- /dev/null +++ b/lib/models/items_for_sale/get_items_for_sale_list.dart @@ -0,0 +1,181 @@ +class GetItemsForSaleList { + int? itemSaleID; + String? title; + String? titleAr; + String? description; + String? descriptionAr; + int? categoryID; + String? categoryTitle; + int? regionID; + String? regionName; + String? countryName; + String? currencyCode; + String? startDate; + String? endDate; + int? quotePrice; + int? employeeNumber; + String? profilePicture; + String? fullName; + String? emailAddress; + String? mobileNumber; + bool? isApproved; + String? status; + List? itemAttachments; + String? created; + dynamic? comments; + dynamic? isActive; + dynamic? pageSize; + dynamic? pageNo; + dynamic? languageId; + + GetItemsForSaleList( + {this.itemSaleID, + this.title, + this.titleAr, + this.description, + this.descriptionAr, + this.categoryID, + this.categoryTitle, + this.regionID, + this.regionName, + this.countryName, + this.currencyCode, + this.startDate, + this.endDate, + this.quotePrice, + this.employeeNumber, + this.profilePicture, + this.fullName, + this.emailAddress, + this.mobileNumber, + this.isApproved, + this.status, + this.itemAttachments, + this.created, + this.comments, + this.isActive, + this.pageSize, + this.pageNo, + this.languageId}); + + GetItemsForSaleList.fromJson(Map json) { + itemSaleID = json['itemSaleID']; + title = json['title']; + titleAr = json['title_Ar']; + description = json['description']; + descriptionAr = json['description_Ar']; + categoryID = json['categoryID']; + categoryTitle = json['categoryTitle']; + regionID = json['regionID']; + regionName = json['regionName']; + countryName = json['countryName']; + currencyCode = json['currencyCode']; + startDate = json['startDate']; + endDate = json['endDate']; + quotePrice = json['quotePrice']; + employeeNumber = json['employeeNumber']; + profilePicture = json['profilePicture']; + fullName = json['fullName']; + emailAddress = json['emailAddress']; + mobileNumber = json['mobileNumber']; + isApproved = json['isApproved']; + status = json['status']; + if (json['itemAttachments'] != null) { + itemAttachments = []; + json['itemAttachments'].forEach((v) { + itemAttachments!.add(new ItemAttachments.fromJson(v)); + }); + } + created = json['created']; + comments = json['comments']; + isActive = json['isActive']; + pageSize = json['pageSize']; + pageNo = json['pageNo']; + languageId = json['languageId']; + } + + Map toJson() { + final Map data = new Map(); + data['itemSaleID'] = this.itemSaleID; + data['title'] = this.title; + data['title_Ar'] = this.titleAr; + data['description'] = this.description; + data['description_Ar'] = this.descriptionAr; + data['categoryID'] = this.categoryID; + data['categoryTitle'] = this.categoryTitle; + data['regionID'] = this.regionID; + data['regionName'] = this.regionName; + data['countryName'] = this.countryName; + data['currencyCode'] = this.currencyCode; + data['startDate'] = this.startDate; + data['endDate'] = this.endDate; + data['quotePrice'] = this.quotePrice; + data['employeeNumber'] = this.employeeNumber; + data['profilePicture'] = this.profilePicture; + data['fullName'] = this.fullName; + data['emailAddress'] = this.emailAddress; + data['mobileNumber'] = this.mobileNumber; + data['isApproved'] = this.isApproved; + data['status'] = this.status; + if (this.itemAttachments != null) { + data['itemAttachments'] = + this.itemAttachments!.map((v) => v.toJson()).toList(); + } + data['created'] = this.created; + data['comments'] = this.comments; + data['isActive'] = this.isActive; + data['pageSize'] = this.pageSize; + data['pageNo'] = this.pageNo; + data['languageId'] = this.languageId; + return data; + } +} + +class ItemAttachments { + int? attachmentId; + String? fileName; + String? contentType; + dynamic? attachFileStream; + dynamic? base64String; + dynamic? isActive; + int? referenceItemId; + String? content; + String? filePath; + + ItemAttachments( + {this.attachmentId, + this.fileName, + this.contentType, + this.attachFileStream, + this.base64String, + this.isActive, + this.referenceItemId, + this.content, + this.filePath}); + + ItemAttachments.fromJson(Map json) { + attachmentId = json['attachmentId']; + fileName = json['fileName']; + contentType = json['contentType']; + attachFileStream = json['attachFileStream']; + base64String = json['base64String']; + isActive = json['isActive']; + referenceItemId = json['referenceItemId']; + content = json['content']; + filePath = json['filePath']; + } + + Map toJson() { + final Map data = new Map(); + data['attachmentId'] = this.attachmentId; + data['fileName'] = this.fileName; + data['contentType'] = this.contentType; + data['attachFileStream'] = this.attachFileStream; + data['base64String'] = this.base64String; + data['isActive'] = this.isActive; + data['referenceItemId'] = this.referenceItemId; + data['content'] = this.content; + data['filePath'] = this.filePath; + return data; + } +} diff --git a/lib/models/items_for_sale/get_regions_list.dart b/lib/models/items_for_sale/get_regions_list.dart new file mode 100644 index 0000000..4b36f03 --- /dev/null +++ b/lib/models/items_for_sale/get_regions_list.dart @@ -0,0 +1,48 @@ +class GetRegionsList { + int? regionID; + String? regionName; + String? regionNameAr; + int? countryID; + String? countryName; + dynamic? isActive; + int? pageSize; + int? pageNo; + dynamic? languageId; + + GetRegionsList( + {this.regionID, + this.regionName, + this.regionNameAr, + this.countryID, + this.countryName, + this.isActive, + this.pageSize, + this.pageNo, + this.languageId}); + + GetRegionsList.fromJson(Map json) { + regionID = json['regionID']; + regionName = json['regionName']; + regionNameAr = json['regionName_Ar']; + countryID = json['countryID']; + countryName = json['countryName']; + isActive = json['isActive']; + pageSize = json['pageSize']; + pageNo = json['pageNo']; + languageId = json['languageId']; + } + + Map toJson() { + final Map data = new Map(); + data['regionID'] = this.regionID; + data['regionName'] = this.regionName; + data['regionName_Ar'] = this.regionNameAr; + data['countryID'] = this.countryID; + data['countryName'] = this.countryName; + data['isActive'] = this.isActive; + data['pageSize'] = this.pageSize; + data['pageNo'] = this.pageNo; + data['languageId'] = this.languageId; + return data; + } +} diff --git a/lib/models/items_for_sale/get_sale_categories_list.dart b/lib/models/items_for_sale/get_sale_categories_list.dart new file mode 100644 index 0000000..03f28e3 --- /dev/null +++ b/lib/models/items_for_sale/get_sale_categories_list.dart @@ -0,0 +1,36 @@ +class GetSaleCategoriesList { + int? categoryID; + String? title; + String? titleAr; + String? content; + bool? isActive; + dynamic? pageSize; + dynamic? pageNo; + dynamic? languageId; + + GetSaleCategoriesList({this.categoryID, this.title, this.titleAr, this.content, this.isActive, this.pageSize, this.pageNo, this.languageId}); + + GetSaleCategoriesList.fromJson(Map json) { + categoryID = json['categoryID']; + title = json['title']; + titleAr = json['title_Ar']; + content = json['content']; + isActive = json['isActive']; + pageSize = json['pageSize']; + pageNo = json['pageNo']; + languageId = json['languageId']; + } + + Map toJson() { + final Map data = new Map(); + data['categoryID'] = this.categoryID; + data['title'] = this.title; + data['title_Ar'] = this.titleAr; + data['content'] = this.content; + data['isActive'] = this.isActive; + data['pageSize'] = this.pageSize; + data['pageNo'] = this.pageNo; + data['languageId'] = this.languageId; + return data; + } +} diff --git a/lib/models/items_for_sale/item_review_model.dart b/lib/models/items_for_sale/item_review_model.dart new file mode 100644 index 0000000..4033746 --- /dev/null +++ b/lib/models/items_for_sale/item_review_model.dart @@ -0,0 +1,35 @@ +import 'package:mohem_flutter_app/models/items_for_sale/get_regions_list.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/get_sale_categories_list.dart'; + +class ItemReviewModel { + String? itemTitle; + String? itemDescription; + String? itemCondition; + GetRegionsList? selectedRegion; + num? itemPrice; + List? itemPhotos; + GetSaleCategoriesList? selectedSaleCategory; + + ItemReviewModel( + this.itemTitle, + this.itemDescription, + this.itemCondition, + this.selectedRegion, + this.itemPrice, + this.itemPhotos, + this.selectedSaleCategory, + ); + + Map toJson() { + final Map data = new Map(); + data['itemTitle'] = this.itemTitle; + data['itemDescription'] = this.itemDescription; + data['itemCondition'] = this.itemCondition; + data['selectedRegion'] = this.selectedRegion; + data['itemPrice'] = this.itemPrice; + data['itemPhotos'] = this.itemPhotos; + data['selectedSaleCategory'] = this.selectedSaleCategory; + return data; + } + +} diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 4406a4d..d5acce6 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -389,8 +389,9 @@ class _DashboardScreenState extends State { selectedIconTheme: const IconThemeData(color: MyColors.grey3AColor, size: 28), unselectedIconTheme: const IconThemeData(color: MyColors.grey98Color, size: 28), onTap: (int index) { - currentIndex = index; - setState(() {}); + // currentIndex = index; + // setState(() {}); + Navigator.pushNamed(context, AppRoutes.itemsForSale); }, ), ), diff --git a/lib/ui/screens/items_for_sale/add_new_item_for_sale.dart b/lib/ui/screens/items_for_sale/add_new_item_for_sale.dart new file mode 100644 index 0000000..307a834 --- /dev/null +++ b/lib/ui/screens/items_for_sale/add_new_item_for_sale.dart @@ -0,0 +1,216 @@ +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/api/items_for_sale/items_for_sale_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/widget_extensions.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/get_sale_categories_list.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/item_review_model.dart'; +import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/add_details_fragment.dart'; +import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/item_review_fragment.dart'; +import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/select_category_fragment.dart'; +import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; + +class AddNewItemForSale extends StatefulWidget { + int? pageIndex = 0; + ItemReviewModel? itemReviewModel; + + AddNewItemForSale({Key? key, this.pageIndex, this.itemReviewModel}) : super(key: key); + + @override + State createState() => _AddNewItemForSaleState(); +} + +class _AddNewItemForSaleState extends State { + int _currentIndex = 0; + List getSaleCategoriesList = []; + late PageController _controller; + ItemReviewModel? itemReviewModel; + int pageIndex = 0; + + @override + void initState() { + _controller = PageController(); + getItemForSaleCategory(); + super.initState(); + } + + void changePageViewIndex(pageIndex) { + _controller.jumpToPage(pageIndex); + } + + @override + Widget build(BuildContext context) { + getRequestID(); + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBarWidget( + context, + // title: LocaleKeys.mowadhafhiRequest.tr(), + title: "Items for sale", + showHomeButton: true, + ), + body: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AspectRatio( + aspectRatio: 335 / 118, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Row( + children: [ + Expanded( + child: showProgress( + title: "Select Category", + status: _currentIndex == 0 + ? "InProgress" + : _currentIndex > 0 + ? "Completed" + : "Locked", + color: _currentIndex == 0 ? MyColors.orange : MyColors.greenColor, + pageIndex: 0, + ), + ), + Expanded( + child: showProgress( + title: "Add Details", + status: _currentIndex == 1 + ? "InProgress" + : _currentIndex > 1 + ? "Completed" + : "Locked", + color: _currentIndex == 1 + ? MyColors.orange + : _currentIndex > 1 + ? MyColors.greenColor + : MyColors.lightGrayColor, + pageIndex: 1, + ), + ), + showProgress( + title: "Review & Sell", + status: _currentIndex == 2 ? "InProgress" : "Locked", + color: _currentIndex == 2 + ? MyColors.orange + : _currentIndex > 3 + ? MyColors.greenColor + : MyColors.lightGrayColor, + isNeedBorder: false, + pageIndex: 2, + ), + ], + ).paddingAll(21), + ).paddingOnly(left: 21, right: 21, top: 21), + ), + Expanded( + child: PageView( + physics: NeverScrollableScrollPhysics(), + controller: _controller, + onPageChanged: (index) { + setState(() { + _currentIndex = index; + }); + }, + scrollDirection: Axis.horizontal, + children: [ + getSaleCategoriesList.isNotEmpty ? SelectCategoryFragment(changePageViewIndex: changePageViewIndex, getSaleCategoriesList: getSaleCategoriesList) : Container(), + getSaleCategoriesList.isNotEmpty ? AddItemDetailsFragment(changePageViewIndex: changePageViewIndex, selectedSaleCategory: getSaleCategoriesList[0]) : Container(), + ItemReviewFragment(changePageViewIndex: changePageViewIndex), + ], + ), + ), + ], + ), + ); + } + + Widget showProgress({String? title, String? status, Color? color, bool isNeedBorder = true, int? pageIndex}) { + return InkWell( + onTap: () { + if (_currentIndex > pageIndex!) changePageViewIndex(pageIndex); + }, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + width: 26, + height: 26, + decoration: Utils.containerRadius(color!, 200), + child: const Icon( + Icons.done, + color: Colors.white, + size: 16, + ), + ), + if (isNeedBorder) + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Utils.mDivider(Colors.grey), + )), + ], + ), + Utils.mHeight(8), + Text( + title!, + style: const TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + letterSpacing: -0.44, + ), + ), + Utils.mHeight(2), + Container( + padding: EdgeInsets.all(5), + decoration: Utils.containerRadius(color.withOpacity(0.2), 4), + child: Text( + status!, + style: TextStyle( + fontSize: 8, + fontWeight: FontWeight.w600, + letterSpacing: -0.32, + color: color, + ), + ), + ), + ], + ) + ], + ), + ); + } + + void getRequestID() async { + int args = (ModalRoute.of(context)?.settings.arguments ?? {}) as int; + pageIndex = args; + } + + void getItemForSaleCategory() async { + try { + Utils.showLoading(context); + getSaleCategoriesList = await ItemsForSaleApiClient().getSaleCategories(); + Utils.hideLoading(context); + setState(() {}); + if (pageIndex == 1) { + changePageViewIndex(1); + } + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } +} diff --git a/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart b/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart new file mode 100644 index 0000000..9d253f0 --- /dev/null +++ b/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart @@ -0,0 +1,293 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/api/items_for_sale/items_for_sale_api_client.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/consts.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/items_for_sale/get_regions_list.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/get_sale_categories_list.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/item_review_model.dart'; +import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/select_category_fragment.dart'; +import 'package:mohem_flutter_app/widgets/button/default_button.dart'; +import 'package:mohem_flutter_app/widgets/button/simple_button.dart'; +import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; +import 'package:mohem_flutter_app/widgets/image_picker.dart'; +import 'package:mohem_flutter_app/widgets/radio/show_radio.dart'; + +class AddItemDetailsFragment extends StatefulWidget { + final Function changePageViewIndex; + final GetSaleCategoriesList selectedSaleCategory; + static late ItemReviewModel itemReviewModel; + + const AddItemDetailsFragment({Key? key, required this.changePageViewIndex, required this.selectedSaleCategory}) : super(key: key); + + @override + State createState() => _AddItemDetailsFragmentState(); +} + +class _AddItemDetailsFragmentState extends State { + String itemTitle = ""; + String itemDescription = ""; + num itemPrice = 0; + String selectedItemCondition = "new"; + + List getRegionsList = []; + GetRegionsList selectedRegion = GetRegionsList(); + + List images = []; + + @override + void initState() { + getRegions(); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "Add details".toText20(isBold: true).paddingOnly(top: 24, left: 21, right: 21), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + DynamicTextFieldWidget( + "Title", + itemTitle.isEmpty ? "Item title" : itemTitle, + isEnable: true, + suffixIconData: Icons.search, + isPopup: false, + lines: 1, + isInputTypeNum: false, + isReadOnly: false, + onChange: (String value) { + itemTitle = value; + }, + ).paddingOnly(), + DynamicTextFieldWidget( + "Description", + itemDescription.isEmpty ? "Item description" : itemDescription, + isEnable: true, + suffixIconData: Icons.search, + isPopup: false, + lines: 4, + isInputTypeNum: false, + isReadOnly: false, + onChange: (String value) { + itemDescription = value; + }, + ).paddingOnly(top: 12), + "Item Condition".toText14(isBold: true).paddingOnly(top: 21), + Row( + children: [ + ShowRadio(title: "New", value: "new", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() { + selectedItemCondition = "new"; + setState(() {}); + }), + 12.width, + ShowRadio(title: "Used", value: "used", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() { + selectedItemCondition = "used"; + setState(() {}); + }), + ], + ).paddingOnly(top: 12), + PopupMenuButton( + child: DynamicTextFieldWidget( + "Region", + selectedRegion.regionName ?? "Select Region", + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, + ), + itemBuilder: (_) => >[ + for (int i = 0; i < getRegionsList!.length; i++) PopupMenuItem(child: Text(getRegionsList[i].regionName!), value: i), + ], + onSelected: (int popupIndex) { + selectedRegion = getRegionsList![popupIndex]; + setState(() {}); + }, + ).paddingOnly(top: 21), + DynamicTextFieldWidget( + "Item Price", + itemPrice == 0 ? "Price" : itemPrice.toString(), + isEnable: true, + suffixIconData: Icons.search, + isPopup: false, + lines: 1, + isInputTypeNum: true, + isReadOnly: false, + onChange: (String value) { + itemPrice = num.parse(value); + }, + ).paddingOnly(top: 12), + "Item Photos".toText14(isBold: true).paddingOnly(top: 16), + attachmentView("Attachments").paddingOnly(top: 12), + Row( + children: [ + DefaultButton( + LocaleKeys.cancel.tr(), + () async { + Navigator.of(context).pop(); + }, + colors: const [Color(0xffD02127), Color(0xffD02127)], + ).expanded, + 12.width, + DefaultButton( + LocaleKeys.next.tr(), + isButtonDisabled() + ? null + : () async { + AddItemDetailsFragment.itemReviewModel = getItemReviewObject(); + widget.changePageViewIndex(2); + }, + disabledColor: MyColors.lightGrayColor, + ).expanded + ], + ).paddingOnly(top: 21), + ], + ).objectContainerView(title: "Item Info").paddingAll(21), + ], + ), + ); + } + + ItemReviewModel getItemReviewObject() { + ItemReviewModel itemReviewModel = ItemReviewModel(itemTitle, itemDescription, selectedItemCondition, selectedRegion, itemPrice, images, widget.selectedSaleCategory); + return itemReviewModel; + } + + bool isButtonDisabled() { + if (itemTitle.isNotEmpty && itemDescription.isNotEmpty && selectedRegion != null && itemPrice != 0 && images.isNotEmpty) { + return false; + } else { + return true; + } + } + + Widget attachmentView(String title) { + return Container( + padding: const EdgeInsets.only(top: 15, bottom: 15, left: 14, right: 14), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(15), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + title.toText16().expanded, + 6.width, + SimpleButton(LocaleKeys.add.tr(), () async { + ImageOptions.showImageOptions(context, (String image, File file) { + setState(() { + images.add(image); + }); + }); + }, fontSize: 14), + ], + ), + if (images.isNotEmpty) 12.height, + if (images.isNotEmpty) + ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (cxt, index) { + return Container( + margin: const EdgeInsets.all(10), + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Icon(Icons.attach_file_sharp), + const SizedBox( + width: 8, + ), + 'image ${index + 1}.png'.toText16(), + ], + ), + InkWell( + onTap: () { + setState(() { + images.remove(images[index]); + }); + }, + child: Icon( + Icons.delete_sharp, + color: Colors.red[300], + )) + ], + ), + ); + }, + separatorBuilder: (cxt, index) => 6.height, + itemCount: images.length), + ], + ), + ); + } + + void getAdDetails() async { + String details = await Utils.getStringFromPrefs(SharedPrefsConsts.editItemForSale); + final body = json.decode(details); + + GetRegionsList selectedRegionAd = GetRegionsList(); + + GetSaleCategoriesList selectedSaleCategoryAd = GetSaleCategoriesList(); + + itemTitle = body["itemTitle"]; + itemDescription = body["itemDescription"]; + selectedItemCondition = body["itemCondition"].toString().toLowerCase(); + selectedRegionAd.regionID = body["selectedRegion"]["regionID"]; + selectedRegionAd.regionName = body["selectedRegion"]["regionName"]; + selectedRegion = selectedRegionAd; + itemPrice = body["itemPrice"]; + selectedSaleCategoryAd.categoryID = body["selectedSaleCategory"]["categoryID"]; + selectedSaleCategoryAd.title = body["selectedSaleCategory"]["title"]; + if (body["itemPhotos"].length != 0) { + images.add(body["itemPhotos"][0]); + } + ItemReviewModel itemReviewModel = + ItemReviewModel(body["itemTitle"], body["itemDescription"], body["itemCondition"].toString().toLowerCase(), selectedRegionAd, body["itemPrice"], images, selectedSaleCategoryAd); + + AddItemDetailsFragment.itemReviewModel = itemReviewModel; + SelectCategoryFragment.selectedSaleCategory = selectedSaleCategoryAd; + + setState(() {}); + } + + void getRegions() async { + try { + Utils.showLoading(context); + getRegionsList = await ItemsForSaleApiClient().getRegions(); + Utils.hideLoading(context); + setState(() {}); + getAdDetails(); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } +} diff --git a/lib/ui/screens/items_for_sale/fragments/item_review_fragment.dart b/lib/ui/screens/items_for_sale/fragments/item_review_fragment.dart new file mode 100644 index 0000000..0b02658 --- /dev/null +++ b/lib/ui/screens/items_for_sale/fragments/item_review_fragment.dart @@ -0,0 +1,154 @@ +import 'dart:convert'; + +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/api/items_for_sale/items_for_sale_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/items_for_sale/add_item_for_sale_image_model.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/item_review_model.dart'; +import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/add_details_fragment.dart'; +import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/select_category_fragment.dart'; +import 'package:mohem_flutter_app/widgets/button/default_button.dart'; + +class ItemReviewFragment extends StatefulWidget { + final Function changePageViewIndex; + + ItemReviewFragment({Key? key, required this.changePageViewIndex}) : super(key: key); + + @override + State createState() => _ItemReviewFragmentState(); +} + +class _ItemReviewFragmentState extends State { + ItemReviewModel? itemReviewModel; + + @override + void initState() { + itemReviewModel = AddItemDetailsFragment.itemReviewModel; + itemReviewModel!.selectedSaleCategory = SelectCategoryFragment.selectedSaleCategory; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + itemReviewModel!.itemTitle.toString().toText17(isBold: true).paddingOnly(top: 12), + itemReviewModel!.itemDescription.toString().toText14().paddingOnly(top: 8), + itemReviewModel!.itemCondition.toString().toText14(color: MyColors.yellowColor).paddingOnly(top: 12), + SizedBox( + height: 105.0, + child: ListView.separated( + shrinkWrap: true, + physics: const BouncingScrollPhysics(), + scrollDirection: Axis.horizontal, + itemBuilder: (cxt, index) { + return Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + width: 100, + height: 100, + child: ClipRRect( + borderRadius: BorderRadius.circular(6), + child: Image.memory( + base64Decode(itemReviewModel!.itemPhotos![index]), + fit: BoxFit.contain, + ), + ), + ).paddingOnly(top: 12.0, bottom: 12.0); + }, + separatorBuilder: (cxt, index) => 8.width, + itemCount: itemReviewModel!.itemPhotos!.length), + ), + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + "Selling for ".toText14(), + "${itemReviewModel!.itemPrice.toString()} SAR".toText20(isBold: true), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + const Icon( + Icons.warning_sharp, + size: 20, + color: MyColors.redColor, + ).paddingOnly(top: 21), + "This ad will be valid for 2 weeks after approval.".toText11(color: MyColors.redColor).paddingOnly(left: 10, right: 10), + ], + ), + const Spacer(), + Row( + children: [ + DefaultButton( + LocaleKeys.cancel.tr(), + () async { + Navigator.of(context).pop(); + }, + colors: const [Color(0xffD02127), Color(0xffD02127)], + ).expanded, + 12.width, + DefaultButton( + LocaleKeys.submit.tr(), + () async { + submitItemForSale(); + }, + disabledColor: MyColors.lightGrayColor, + ).expanded + ], + ).paddingOnly(top: 21), + ], + ), + ).paddingAll(21); + } + + void submitItemForSale() async { + List> imagesList = []; + int attachmentID = 1; + for (var element in itemReviewModel!.itemPhotos!) { + imagesList.add(AddItemForSaleImageModel(attachmentID: attachmentID, base64Data: element, fileName: "Image_$attachmentID", contentType: "image/png").toJson()); + attachmentID++; + } + + try { + Utils.showLoading(context); + String message = await ItemsForSaleApiClient().addItemForSale(itemReviewModel!, imagesList); + Utils.hideLoading(context); + Utils.showToast(message); + Navigator.of(context).pop(); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } +} diff --git a/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart b/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart new file mode 100644 index 0000000..ffb45e0 --- /dev/null +++ b/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart @@ -0,0 +1,239 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:mohem_flutter_app/api/items_for_sale/items_for_sale_api_client.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.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/models/items_for_sale/get_items_for_sale_list.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/get_sale_categories_list.dart'; +import 'package:mohem_flutter_app/ui/screens/items_for_sale/items_for_sale_home.dart'; +import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; + +class ItemsForSaleFragment extends StatefulWidget { + @override + State createState() => _ItemsForSaleFragmentState(); +} + +class _ItemsForSaleFragmentState extends State { + TextEditingController searchController = TextEditingController(); + + List getSaleCategoriesList = []; + List getItemsForSaleList = []; + + ScrollController gridScrollController = ScrollController(); + int currentPageNo = 1; + int currentCategoryID = 0; + + @override + void initState() { + getItemForSaleCategory(); + gridScrollController.addListener(() { + if (gridScrollController.position.atEdge) { + bool isTop = gridScrollController.position.pixels == 0; + if (!isTop) { + print('At the bottom'); + currentPageNo++; + getItemsForSale(currentPageNo, currentCategoryID); + } + } + }); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + controller: gridScrollController, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + DynamicTextFieldWidget( + "Search", + "Search Items", + isEnable: true, + suffixIconData: Icons.search, + isPopup: false, + lines: 1, + isInputTypeNum: false, + isReadOnly: false, + onChange: (String value) { + // _runFilter(value); + }, + ).paddingOnly(left: 21, right: 21, top: 21, bottom: 18), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + "Browse Categories".toText17(), + IconButton( + icon: const Icon(Icons.filter_alt_sharp, color: MyColors.darkIconColor, size: 28.0), + onPressed: () => Navigator.pop(context), + ), + ], + ).paddingOnly(left: 21, right: 21), + SizedBox( + height: 105.0, + child: getSaleCategoriesList.isNotEmpty + ? ListView.separated( + shrinkWrap: true, + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), + scrollDirection: Axis.horizontal, + itemBuilder: (cxt, index) { + return AspectRatio( + aspectRatio: 1 / 1, + child: InkWell( + onTap: () { + setState(() { + currentCategoryID = getSaleCategoriesList[index].categoryID!; + getItemsForSaleList.clear(); + currentPageNo = 1; + getItemsForSale(currentPageNo, currentCategoryID); + }); + }, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(15), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SvgPicture.string(getSaleCategoriesList[index].content!, fit: BoxFit.contain), + currentCategoryID == getSaleCategoriesList[index].categoryID ? const Icon(Icons.check_circle_rounded, color: MyColors.greenColor, size: 16.0) : Container(), + ], + ).expanded, + getSaleCategoriesList[index].title!.toText10() + ], + ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), + ), + ), + ); + }, + separatorBuilder: (cxt, index) => 12.width, + itemCount: getSaleCategoriesList.length) + : Container(), + ), + getItemsForSaleList.isNotEmpty + ? GridView( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 162 / 266, crossAxisSpacing: 12, mainAxisSpacing: 12), + padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 21), + shrinkWrap: true, + primary: false, + physics: const ScrollPhysics(), + children: getItemsForSaleWidgets(), + ) + : Utils.getNoDataWidget(context).paddingOnly(top: 50), + // 32.height, + ], + ), + ); + } + + List getItemsForSaleWidgets() { + List itemsList = []; + + getItemsForSaleList.forEach((element) { + itemsList.add(getItemCard(element)); + }); + + return itemsList; + } + + Widget getItemCard(GetItemsForSaleList getItemsForSaleList) { + return InkWell( + onTap: () { + Navigator.pushNamed(context, AppRoutes.itemsForSaleDetail, arguments: getItemsForSaleList); + }, + child: Container( + padding: const EdgeInsets.all(10.0), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Hero( + tag: "ItemImage" + getItemsForSaleList.itemSaleID.toString(), + transitionOnUserGestures: true, + child: AspectRatio( + aspectRatio: 148 / 127, + child: ClipRRect( + borderRadius: BorderRadius.circular(6), + child: Image.memory( + base64Decode(getItemsForSaleList.itemAttachments![0].content!), + fit: BoxFit.cover, + ), + ), + ), + ), + 10.height, + getItemsForSaleList.title!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), + 10.height, + getItemsForSaleList.description!.toText12(maxLine: 2, color: const Color(0xff535353)), + 16.height, + getItemsForSaleList.status!.toText14(isBold: true, color: getItemsForSaleList.status == 'Approved' ? MyColors.greenColor : MyColors.yellowColor), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: ["${getItemsForSaleList.quotePrice} ${getItemsForSaleList.currencyCode!}".toText14(isBold: true), SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)], + ), + ], + ), + ), + ); + } + + void getItemForSaleCategory() async { + try { + Utils.showLoading(context); + getSaleCategoriesList = await ItemsForSaleApiClient().getSaleCategories(); + Utils.hideLoading(context); + setState(() {}); + getItemsForSale(currentPageNo, currentCategoryID); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getItemsForSale(int itgPageNo, int itgCategoryID) async { + List getItemsForSaleListLocal = []; + try { + Utils.showLoading(context); + getItemsForSaleListLocal.clear(); + getItemsForSaleListLocal = await ItemsForSaleApiClient().getItemsForSale(itgPageNo, itgCategoryID); + getItemsForSaleList.addAll(getItemsForSaleListLocal); + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } +} diff --git a/lib/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart b/lib/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart new file mode 100644 index 0000000..f477672 --- /dev/null +++ b/lib/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart @@ -0,0 +1,213 @@ +import 'dart:convert'; + +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; +import 'package:mohem_flutter_app/api/items_for_sale/items_for_sale_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/consts.dart'; +import 'package:mohem_flutter_app/classes/date_uitl.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.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/items_for_sale/get_employee_ads_list.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/get_regions_list.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/get_sale_categories_list.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/item_review_model.dart'; + +class MyPostedAdsFragment extends StatefulWidget { + const MyPostedAdsFragment({Key? key}) : super(key: key); + + @override + State createState() => _MyPostedAdsFragmentState(); +} + +class _MyPostedAdsFragmentState extends State { + List employeePostedAdsList = []; + + @override + void initState() { + getAdsByEmployee(); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: Container( + margin: const EdgeInsets.all(21), + child: employeePostedAdsList.isNotEmpty + ? ListView.separated( + shrinkWrap: true, + physics: const BouncingScrollPhysics(), + itemBuilder: (cxt, index) { + return Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(15), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Column( + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Container( + width: 50, + height: 50, + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(6), + child: employeePostedAdsList[index].itemAttachments!.isNotEmpty + ? Image.memory( + base64Decode(employeePostedAdsList[index].itemAttachments![0].content!), + fit: BoxFit.contain, + ) + : Container(), + ), + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + employeePostedAdsList[index].title!.toText16(isBold: true, color: const Color(0xff2B353E)).paddingOnly(left: 12, right: 12), + "Posted on ${DateUtil.formatDateToDate(DateTime.parse(employeePostedAdsList[index].created!), false)}" + .toText12(color: Color(0xff969696)) + .paddingOnly(left: 7, right: 7), + ], + ), + employeePostedAdsList[index].description!.toText12(color: const Color(0xff2B353E), maxLine: 1).paddingOnly(left: 12, right: 12, bottom: 12), + employeePostedAdsList[index] + .status! + .toText12(isBold: true, color: employeePostedAdsList[index].status == 'Approved' ? MyColors.greenColor : MyColors.yellowColor) + .paddingOnly(left: 12, right: 12), + // Row( + // children: [ + // IconButton( + // padding: EdgeInsets.zero, + // icon: const Icon( + // Icons.delete_rounded, + // size: 25, + // color: MyColors.redColor, + // ), + // constraints: const BoxConstraints(), + // onPressed: () { + // updateItemForSale(employeePostedAdsList[index].itemSaleID!); + // }), + // 37.width, + // IconButton( + // padding: EdgeInsets.zero, + // icon: const Icon( + // Icons.edit_note_sharp, + // size: 25, + // color: Color(0xff2E303A), + // ), + // constraints: const BoxConstraints(), + // onPressed: () {}), + // ], + // ), + ], + ), + ), + ], + ).paddingOnly(left: 7, right: 7, bottom: 0, top: 12), + const Divider( + color: MyColors.lightGreyEFColor, + thickness: 1.0, + ), + Row( + children: [ + LocaleKeys.remove.tr().toText12(color: MyColors.redColor).center.onPress(() { + updateItemForSale(employeePostedAdsList[index].itemSaleID!); + }).expanded, + Container(width: 1, height: 30, color: MyColors.lightGreyEFColor), + LocaleKeys.edit.tr().toText12(color: MyColors.gradiantEndColor).center.onPress(() { + GetRegionsList selectedRegion = GetRegionsList(); + selectedRegion.regionID = employeePostedAdsList[index].regionID; + selectedRegion.regionName = employeePostedAdsList[index].regionName; + GetSaleCategoriesList selectedSaleCategory = GetSaleCategoriesList(); + selectedSaleCategory.categoryID = employeePostedAdsList[index].categoryID; + selectedSaleCategory.title = employeePostedAdsList[index].categoryTitle; + List itemPhotos = []; + itemPhotos.add(employeePostedAdsList[index].itemAttachments![0].content!.toString()); + ItemReviewModel itemReviewModel = ItemReviewModel(employeePostedAdsList[index].title, employeePostedAdsList[index].description, employeePostedAdsList[index].status, + selectedRegion, employeePostedAdsList[index].quotePrice, itemPhotos, selectedSaleCategory); + Utils.saveStringFromPrefs(SharedPrefsConsts.editItemForSale, jsonEncode(itemReviewModel.toJson())); + Navigator.pushNamed(context, AppRoutes.addNewItemForSale, arguments: 1); + }).expanded, + ], + ), + 8.height + ], + ), + ); + }, + separatorBuilder: (cxt, index) => 12.height, + itemCount: employeePostedAdsList.length) + : Utils.getNoDataWidget(context).paddingOnly(top: 200.0), + ), + ); + } + + void updateItemForSale(int itemSaleID) async { + Utils.showLoading(context); + + String? empNum = AppState().memberInformationList?.eMPLOYEENUMBER; + String? empMobNum = AppState().memberInformationList?.eMPLOYEEMOBILENUMBER; + String? loginTokenID = AppState().postParamsObject?.logInTokenID; + String? tokenID = AppState().postParamsObject?.tokenID; + + var request = http.MultipartRequest('POST', Uri.parse("${ApiConsts.cocRest}Mohemm_ITG_UpdateItemForSale")); + request.fields['itemSaleID'] = itemSaleID.toString(); + request.fields['Channel'] = "31"; + request.fields['isActive'] = "false"; + request.fields['LogInToken'] = loginTokenID!; + request.fields['Token'] = tokenID!; + request.fields['MobileNo'] = empMobNum!; + request.fields['EmployeeNumber'] = empNum!; + request.fields['employeeNumber'] = empNum; + var response = await request.send().catchError((e) { + Utils.hideLoading(context); + Utils.handleException(e, context, null); + }); + print(response.statusCode); + Utils.hideLoading(context); + getAdsByEmployee(); + } + + void getAdsByEmployee() async { + try { + employeePostedAdsList.clear(); + Utils.showLoading(context); + employeePostedAdsList = await ItemsForSaleApiClient().getEmployeePostedAds(); + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } +} diff --git a/lib/ui/screens/items_for_sale/fragments/select_category_fragment.dart b/lib/ui/screens/items_for_sale/fragments/select_category_fragment.dart new file mode 100644 index 0000000..6255302 --- /dev/null +++ b/lib/ui/screens/items_for_sale/fragments/select_category_fragment.dart @@ -0,0 +1,78 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:mohem_flutter_app/extensions/string_extensions.dart'; +import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/get_sale_categories_list.dart'; + +class SelectCategoryFragment extends StatelessWidget { + final Function changePageViewIndex; + final List getSaleCategoriesList; + static late GetSaleCategoriesList selectedSaleCategory; + + SelectCategoryFragment({Key? key, required this.changePageViewIndex, required this.getSaleCategoriesList}) : super(key: key); + + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + "What are you offering".toText20(isBold: true).paddingOnly(top: 24, left: 21, right: 21), + getSaleCategoriesList.isNotEmpty + ? GridView( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 105 / 105, crossAxisSpacing: 12, mainAxisSpacing: 12), + padding: const EdgeInsets.only(top: 15, bottom: 15, left: 21, right: 21), + shrinkWrap: true, + primary: false, + physics: const ScrollPhysics(), + children: getItemsForSaleWidgets(), + ) + : Container(), + ], + ), + ); + } + + List getItemsForSaleWidgets() { + List itemsList = []; + + getSaleCategoriesList.forEach((element) { + itemsList.add(InkWell( + onTap: () { + selectedSaleCategory = element; + changePageViewIndex(1); + }, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(15), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SvgPicture.string(element.content!, fit: BoxFit.contain, width: 32, height: 32), + ], + ).expanded, + element.title!.toText12() + ], + ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), + ), + )); + }); + + return itemsList; + } +} diff --git a/lib/ui/screens/items_for_sale/item_for_sale_detail.dart b/lib/ui/screens/items_for_sale/item_for_sale_detail.dart new file mode 100644 index 0000000..8d3b09c --- /dev/null +++ b/lib/ui/screens/items_for_sale/item_for_sale_detail.dart @@ -0,0 +1,136 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/date_uitl.dart'; +import 'package:mohem_flutter_app/extensions/string_extensions.dart'; +import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; +import 'package:mohem_flutter_app/models/items_for_sale/get_items_for_sale_list.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/circular_avatar.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class ItemForSaleDetailPage extends StatefulWidget { + const ItemForSaleDetailPage({Key? key}) : super(key: key); + + @override + State createState() => _ItemForSaleDetailPageState(); +} + +class _ItemForSaleDetailPageState extends State { + late GetItemsForSaleList getItemsForSaleList; + + @override + Widget build(BuildContext context) { + getItemsForSaleList = ModalRoute.of(context)?.settings.arguments as GetItemsForSaleList; + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBarWidget(context, + // title: LocaleKeys.mowadhafhiRequest.tr(), + title: "Items for sale", + showHomeButton: true), + body: SingleChildScrollView( + child: AspectRatio( + aspectRatio: 336 / 554, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + // color: Colors.red, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: const Color(0xffEBEBEB).withOpacity(1.0), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Hero( + tag: "ItemImage" + getItemsForSaleList.itemSaleID.toString(), + transitionOnUserGestures: true, + child: AspectRatio( + aspectRatio: 148 / 127, + child: ClipRRect( + borderRadius: BorderRadius.circular(6), + child: Image.memory( + base64Decode(getItemsForSaleList.itemAttachments![0].content!), + fit: BoxFit.cover, + ), + ), + ).paddingAll(8), + ), + ), + getItemsForSaleList.title!.toText20(isBold: true, color: const Color(0xff2B353E)).paddingOnly(left: 21, right: 21), + getItemsForSaleList.description!.toText12(maxLine: 5, color: const Color(0xff535353)).paddingOnly(left: 21, right: 21, bottom: 21), + getItemsForSaleList.status!.toText16(isBold: true, color: getItemsForSaleList.status == 'Approved' ? MyColors.greenColor : MyColors.yellowColor).paddingOnly(left: 21, right: 21), + "${getItemsForSaleList.quotePrice} ${getItemsForSaleList.currencyCode!}".toText20(isBold: true).paddingOnly(left: 21, right: 21, bottom: 15), + const Divider().paddingOnly(left: 21, right: 21), + Row( + children: [ + CircularAvatar( + height: 40, + width: 40, + ).paddingOnly(left: 21, top: 21), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + getItemsForSaleList.fullName!.toText14(isBold: true).paddingOnly(left: 7, right: 7), + "Posted on: ${DateUtil.formatDateToDate(DateTime.parse(getItemsForSaleList.created!), false)}".toText12().paddingOnly(left: 7, right: 7), + ], + ).paddingOnly(top: 18), + ], + ), + ], + ), + ).paddingAll(21), + ), + ), + bottomSheet: Container( + decoration: const BoxDecoration( + color: MyColors.white, + boxShadow: [ + BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 1), + ], + ), + child: Row( + children: [ + DefaultButton("Email", () async { + final Uri emailLaunchUri = Uri( + scheme: 'mailto', + path: getItemsForSaleList.emailAddress, + ); + launchUrl(emailLaunchUri); + }, iconData: Icons.email_sharp, isTextExpanded: false) + .insideContainer + .expanded, + DefaultButton("Call", () async { + final Uri callLaunchUri = Uri( + scheme: 'tel', + path: getItemsForSaleList.mobileNumber, + ); + launchUrl(callLaunchUri); + }, iconData: Icons.call_sharp, isTextExpanded: false) + .insideContainer + .expanded, + ], + ), + ), + ); + } +} diff --git a/lib/ui/screens/items_for_sale/items_for_sale_home.dart b/lib/ui/screens/items_for_sale/items_for_sale_home.dart new file mode 100644 index 0000000..360c0ae --- /dev/null +++ b/lib/ui/screens/items_for_sale/items_for_sale_home.dart @@ -0,0 +1,111 @@ +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/config/routes.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/models/items_for_sale/get_sale_categories_list.dart'; +import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/items_for_sale.dart'; +import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart'; +import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; + +class ItemsForSale extends StatefulWidget { + const ItemsForSale({Key? key}) : super(key: key); + + @override + State createState() => _ItemsForSaleState(); +} + +class _ItemsForSaleState extends State { + int tabIndex = 0; + PageController controller = PageController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBarWidget(context, + // title: LocaleKeys.mowadhafhiRequest.tr(), + title: "Items for sale", + showHomeButton: true), + body: Column( + children: [ + Container( + padding: const EdgeInsets.only(left: 21, right: 21, top: 16, bottom: 16), + decoration: const BoxDecoration( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(25), + bottomRight: Radius.circular(25), + ), + gradient: LinearGradient( + transform: GradientRotation(.83), + begin: Alignment.topRight, + end: Alignment.bottomLeft, + colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ], + ), + ), + child: Row( + children: [myTab("Items for sale", 0), myTab("My posted ads", 1)], + ), + ), + PageView( + controller: controller, + physics: const NeverScrollableScrollPhysics(), + onPageChanged: (int pageIndex) { + setState(() { + tabIndex = pageIndex; + }); + }, + children: [ + ItemsForSaleFragment(), + MyPostedAdsFragment() + ], + ).expanded, + ], + ), + floatingActionButton: Container( + height: 50, + width: 50, + decoration: const BoxDecoration( + shape: BoxShape.circle, + gradient: LinearGradient(transform: GradientRotation(.83), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ]), + ), + child: const Icon(Icons.add, color: Colors.white, size: 30), + ).onPress(() { + Navigator.pushNamed(context, AppRoutes.addNewItemForSale); + }) + ); + } + + Widget myTab(String title, int index) { + bool isSelected = (index == tabIndex); + return Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + title.toText12(color: isSelected ? Colors.white : Colors.white.withOpacity(.74), isCenter: true), + 4.height, + Container( + height: 8, + width: 8, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: isSelected ? Colors.white : Colors.transparent, + ), + ).onPress(() { + setState(() { + // showFabOptions = true; + }); + }) + ], + ).onPress(() { + controller.jumpToPage(index); + }).expanded; + } +} diff --git a/lib/widgets/dynamic_forms/dynamic_textfield_widget.dart b/lib/widgets/dynamic_forms/dynamic_textfield_widget.dart index c44be0d..5bf8875 100644 --- a/lib/widgets/dynamic_forms/dynamic_textfield_widget.dart +++ b/lib/widgets/dynamic_forms/dynamic_textfield_widget.dart @@ -62,7 +62,8 @@ class DynamicTextFieldWidget extends StatelessWidget { TextField( enabled: isEnable, scrollPadding: EdgeInsets.zero, readOnly: isReadOnly, - keyboardType: isInputTypeNum ? TextInputType.number : TextInputType.text, + keyboardType: isInputTypeNum ? const TextInputType.numberWithOptions(signed: true) : TextInputType.text, + textInputAction: TextInputAction.done, //controller: controller, maxLines: lines, obscuringCharacter: "*", diff --git a/lib/widgets/image_picker.dart b/lib/widgets/image_picker.dart new file mode 100644 index 0000000..6c1a06f --- /dev/null +++ b/lib/widgets/image_picker.dart @@ -0,0 +1,154 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/extensions/string_extensions.dart'; + +class ImageOptions { + static void showImageOptions( + BuildContext context, + Function(String, File) image, + ) { + showModalBottomSheet( + backgroundColor: Colors.transparent, + context: context, + builder: (BuildContext bc) { + return _BottomSheet( + children: [ + _BottomSheetItem( + title: "Select File Source", + onTap: () {}, + icon: Icons.file_present, + color: MyColors.black, + ), + _BottomSheetItem( + title: "Gallery", + icon: Icons.image, + onTap: () async { + if (Platform.isAndroid) { + galleryImageAndroid(image); + } else { + File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 20))?.path ?? ""); + String fileName = _image.path; + final bytes = File(fileName).readAsBytesSync(); + String base64Encode = base64.encode(bytes); + if (base64Encode != null) { + image(base64Encode, _image); + } + } + }, + ), + _BottomSheetItem( + title: "Camera", + icon: Icons.camera_alt, + onTap: () async { + if (Platform.isAndroid) { + cameraImageAndroid(image); + } else { + File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 20))?.path ?? ""); + String fileName = _image.path; + final bytes = File(fileName).readAsBytesSync(); + String base64Encode = base64.encode(bytes); + if (base64Encode != null) { + image(base64Encode, _image); + } + } + }, + ), + _BottomSheetItem( + title: "Cancel", + onTap: () {}, + icon: Icons.cancel, + color: MyColors.redColor, + ) + ], + ); + }); + } +} + +void galleryImageAndroid(Function(String, File) image) async { + File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 20))?.path ?? ""); + String fileName = _image.path; + final bytes = File(fileName).readAsBytesSync(); + String base64Encode = base64.encode(bytes); + if (base64Encode != null) { + image(base64Encode, _image); + } +} + +void cameraImageAndroid(Function(String, File) image) async { + File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 20))?.path ?? ""); + String fileName = _image.path; + final bytes = File(fileName).readAsBytesSync(); + String base64Encode = base64.encode(bytes); + if (base64Encode != null) { + image(base64Encode, _image); + } +} + +class _BottomSheet extends StatelessWidget { + final List children; + + const _BottomSheet({Key? key, required this.children}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(vertical: 12.0), + decoration: BoxDecoration(color: Theme.of(context).backgroundColor, borderRadius: const BorderRadius.only(topLeft: Radius.circular(16.0), topRight: Radius.circular(16.0))), + child: SafeArea( + top: false, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + decoration: BoxDecoration(color: Theme.of(context).dividerColor, borderRadius: BorderRadius.circular(3.0)), + width: 40.0, + height: 6.0, + ), + ...children + ], + ), + ), + ); + } +} + +class _BottomSheetItem extends StatelessWidget { + final Function onTap; + final IconData icon; + final String title; + final Color color; + + _BottomSheetItem({Key? key, required this.onTap, required this.title, required this.icon, this.color = MyColors.gradiantStartColor}) : super(key: key); + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + if (onTap != null) { + Navigator.pop(context); + onTap(); + } + }, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical: 18.0), + child: Row( + children: [ + if (icon != null) + Icon( + icon, + color: color, + size: 18.0, + ), + if (icon != null) const SizedBox(width: 24.0), + title.toText17(), + ], + ), + ), + ); + } +} From d6cc5fcc6cc5d93852b490f76cfc91e9629a8a92 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 25 Aug 2022 12:40:52 +0300 Subject: [PATCH 18/40] pending transaction. --- analysis_options.yaml | 2 + lib/classes/date_uitl.dart | 8 +- lib/models/add_att_success_list_model.dart | 4 +- lib/models/add_attachment_list_model.dart | 2 +- lib/models/attachment_model.dart | 2 +- .../basic_member_information_model.dart | 2 +- .../check_mobile_app_version_model.dart | 2 +- lib/models/content_info_model.dart | 4 +- .../get_set_values_request_model.dart | 2 +- .../validate_eit_transaction_model.dart | 2 +- lib/models/eit/get_eit_transaction_model.dart | 4 +- lib/models/generic_response_model.dart | 2 +- ...llection_notification_body_list_model.dart | 4 +- lib/models/get_action_history_list_model.dart | 2 +- lib/models/get_announcement_details.dart | 2 +- lib/models/get_announcements.dart | 2 +- lib/models/get_approves_list_model.dart | 2 +- lib/models/get_attachement_list_model.dart | 2 +- .../get_contact_dff_structure_list.dart | 2 +- ...get_day_hours_type_details_list_model.dart | 2 +- lib/models/get_default_value_list_model.dart | 2 +- .../get_eit_dff_structure_list_model.dart | 10 +- .../get_eit_transaction_list_model.dart | 4 +- lib/models/get_employee_address_model.dart | 2 +- .../get_employee_basic_details.model.dart | 2 +- lib/models/get_employee_contacts.model.dart | 2 +- lib/models/get_employee_phones_model.dart | 2 +- ...get_item_creation_ntf_body_list_model.dart | 6 +- .../get_mo_Item_history_list_model.dart | 2 +- .../get_mo_notification_body_list_model.dart | 2 +- .../get_mobile_login_info_list_model.dart | 2 +- .../get_notification_buttons_list_model.dart | 2 +- .../get_po_Item_history_list_model.dart | 2 +- .../get_po_notification_body_list_model.dart | 6 +- .../get_quotation_analysis_list_model.dart | 2 +- ...et_schedule_shifts_details_list_model.dart | 2 +- ...stamp_ms_notification_body_list_model.dart | 2 +- ...stamp_ns_notification_body_list_model.dart | 2 +- .../get_time_card_summary_list_model.dart | 2 +- .../allowed_actions_model.dart | 2 +- .../itg_forms_models/field_goups_model.dart | 2 +- lib/models/itg_forms_models/fields_model.dart | 2 +- .../itg_forms_models/itg_request_model.dart | 2 +- .../request_detail_model.dart | 2 +- .../itg_forms_models/request_type_model.dart | 2 +- .../itg_forms_models/wf_history_model.dart | 2 +- lib/models/member_information_list_model.dart | 2 +- lib/models/member_login_list_model.dart | 2 +- .../get_deductions_List_model.dart | 2 +- .../get_earnings_list_model.dart | 2 +- .../get_pay_slip_list_model.dart | 2 +- .../get_payment_information_list_model.dart | 2 +- .../get_summary_of_payment_list_model.dart | 2 +- .../mowadhafhi/get_department_sections.dart | 2 +- .../mowadhafhi/get_project_departments.dart | 2 +- lib/models/mowadhafhi/get_projects.dart | 2 +- lib/models/mowadhafhi/get_section_topics.dart | 2 +- lib/models/mowadhafhi/get_ticket_details.dart | 2 +- .../mowadhafhi/get_ticket_transactions.dart | 2 +- lib/models/mowadhafhi/get_ticket_types.dart | 2 +- lib/models/mowadhafhi/get_tickets_list.dart | 2 +- .../mowadhafhi_attachement_request.dart | 2 +- lib/models/notification_action_model.dart | 2 +- ...ion_get_respond_attributes_list_model.dart | 2 +- lib/models/payslip/get_deductions_list.dart | 2 +- lib/models/payslip/get_earnings_list.dart | 2 +- .../payslip/get_payment_information.dart | 2 +- lib/models/payslip/get_payslip.dart | 2 +- .../payslip/get_summary_of_payment.dart | 2 +- .../get_pending_transactions_details.dart | 2 +- .../get_req_functions.dart | 2 +- lib/models/post_params_model.dart | 4 +- lib/models/privilege_list_model.dart | 2 +- .../basic_details_cols_structions.dart | 4 +- .../profile/basic_details_dff_structure.dart | 2 +- .../get_address_dff_structure_list.dart | 2 +- .../get_contact_clos_structure_list.dart | 4 +- .../profile/get_contact_details_list.dart | 2 +- .../profile/get_countries_list_model.dart | 2 +- .../profile/phone_number_types_model.dart | 2 +- .../start_address_approval_process_model.dart | 2 +- .../profile/submit_address_transaction.dart | 2 +- ...ubmit_basic_details_transaction_model.dart | 2 +- ...submit_contact_transaction_list_model.dart | 2 +- .../profile/submit_phone_transactions.dart | 2 +- .../start_eit_approval_process_model.dart | 2 +- .../start_phone_approval_process_model.dart | 2 +- .../submit_eit_transaction_list_model.dart | 2 +- lib/models/subordinates_on_leaves_model.dart | 2 +- lib/models/surah_model.dart | 4 +- .../create_vacation_rule_list_model.dart | 2 +- ...et_item_type_notifications_list_model.dart | 2 +- ...notification_reassign_mode_list_model.dart | 2 +- .../get_vacation_rules_list_model.dart | 2 +- .../respond_attributes_list_model.dart | 2 +- .../vr_item_types_list_model.dart | 2 +- .../vacation_rule/wf_look_up_list_model.dart | 2 +- .../validate_eit_transaction_list_model.dart | 2 +- .../hr/get_basic_det_ntf_body_list_model.dart | 2 +- lib/models/worklist_item_type_model.dart | 2 +- lib/models/worklist_response_model.dart | 2 +- .../attendance/add_vacation_rule_screen.dart | 6 +- .../attendance/monthly_attendance_screen.dart | 4 +- lib/ui/landing/dashboard_screen.dart | 2 +- .../dynamic_screens/dynamic_input_screen.dart | 4 +- lib/ui/profile/add_update_family_member.dart | 2 +- lib/ui/profile/delete_family_member.dart | 2 +- .../dynamic_input_address_screen.dart | 2 +- .../dynamic_input_basic_details_screen.dart | 2 +- lib/ui/profile/profile_screen.dart | 2 +- .../announcements/announcement_details.dart | 2 +- .../pending_transactions.dart | 156 +++++++----------- .../pending_transactions_details.dart | 104 +++--------- lib/widgets/circular_step_progress_bar.dart | 52 +++--- lib/widgets/location/Location.dart | 4 +- lib/widgets/nfc/nfc_reader_sheet.dart | 2 +- 116 files changed, 252 insertions(+), 336 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index a84033c..674be66 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -18,6 +18,7 @@ analyzer: avoid_annotating_with_dynamic: error unnecessary_null_checks: error unnecessary_brace_in_string_interps: error + unnecessary_final: error linter: @@ -49,6 +50,7 @@ linter: unnecessary_null_checks: true unnecessary_brace_in_string_interps: true unnecessary_string_interpolations: true + unnecessary_final: true # avoid_print: false # Uncomment to disable the `avoid_print` rule # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule diff --git a/lib/classes/date_uitl.dart b/lib/classes/date_uitl.dart index 8754fdb..73945f8 100644 --- a/lib/classes/date_uitl.dart +++ b/lib/classes/date_uitl.dart @@ -8,8 +8,8 @@ class DateUtil { if (date != null) { const start = "/Date("; const end = "+0300)"; - final startIndex = date.indexOf(start); - final endIndex = date.indexOf(end, startIndex + start.length); + int startIndex = date.indexOf(start); + int endIndex = date.indexOf(end, startIndex + start.length); return DateTime.fromMillisecondsSinceEpoch( int.parse( date.substring(startIndex + start.length, endIndex), @@ -32,8 +32,8 @@ class DateUtil { if (date != null) { const start = "/Date("; const end = ")"; - final startIndex = date.indexOf(start); - final endIndex = date.indexOf(end, startIndex + start.length); + int startIndex = date.indexOf(start); + int endIndex = date.indexOf(end, startIndex + start.length); return DateTime.fromMillisecondsSinceEpoch( int.parse( date.substring(startIndex + start.length, endIndex), diff --git a/lib/models/add_att_success_list_model.dart b/lib/models/add_att_success_list_model.dart index e33fff2..f432d42 100644 --- a/lib/models/add_att_success_list_model.dart +++ b/lib/models/add_att_success_list_model.dart @@ -10,9 +10,9 @@ class AddAttSuccessList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['AddSuccess'] = this.addSuccess; data['AttachmentID'] = this.attachmentID; return data; } -} \ No newline at end of file +} diff --git a/lib/models/add_attachment_list_model.dart b/lib/models/add_attachment_list_model.dart index e34d80c..aa75d8f 100644 --- a/lib/models/add_attachment_list_model.dart +++ b/lib/models/add_attachment_list_model.dart @@ -10,7 +10,7 @@ class AddAttachmentList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; return data; diff --git a/lib/models/attachment_model.dart b/lib/models/attachment_model.dart index eb51dcf..855a490 100644 --- a/lib/models/attachment_model.dart +++ b/lib/models/attachment_model.dart @@ -16,7 +16,7 @@ class AttachmentModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['AttachmentID'] = this.attachmentID; data['P_FILE_CONTENT_TYPE'] = this.pFILECONTENTTYPE; data['P_FILE_DATA'] = this.pFILEDATA; diff --git a/lib/models/basic_member_information_model.dart b/lib/models/basic_member_information_model.dart index 33b55fa..6df7e84 100644 --- a/lib/models/basic_member_information_model.dart +++ b/lib/models/basic_member_information_model.dart @@ -21,7 +21,7 @@ class BasicMemberInformationModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_EMAIL_ADDRESS'] = this.pEMAILADDRESS; data['P_LEGISLATION_CODE'] = this.pLEGISLATIONCODE; data['P_MOBILE_NUMBER'] = this.pMOBILENUMBER; diff --git a/lib/models/check_mobile_app_version_model.dart b/lib/models/check_mobile_app_version_model.dart index cd301d3..a7a72d1 100644 --- a/lib/models/check_mobile_app_version_model.dart +++ b/lib/models/check_mobile_app_version_model.dart @@ -139,7 +139,7 @@ class CheckMobileAppVersionModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['Date'] = this.date; data['LanguageID'] = this.languageID; data['ServiceName'] = this.serviceName; diff --git a/lib/models/content_info_model.dart b/lib/models/content_info_model.dart index 4eec746..c7a4a7a 100644 --- a/lib/models/content_info_model.dart +++ b/lib/models/content_info_model.dart @@ -19,7 +19,7 @@ class ContentInfoModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['totalItemsCount'] = this.totalItemsCount; data['statusCode'] = this.statusCode; data['message'] = this.message; @@ -52,7 +52,7 @@ class ContentInfoDataModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['contentInfoId'] = this.contentInfoId; data['contentTypeId'] = this.contentTypeId; data['content'] = this.content; diff --git a/lib/models/dyanmic_forms/get_set_values_request_model.dart b/lib/models/dyanmic_forms/get_set_values_request_model.dart index 82bc05a..07c840a 100644 --- a/lib/models/dyanmic_forms/get_set_values_request_model.dart +++ b/lib/models/dyanmic_forms/get_set_values_request_model.dart @@ -21,7 +21,7 @@ class GetSetValuesRequestModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['SEGMENT_NAME'] = this.sEGMENTNAME; data['VALUE_COLUMN_NAME'] = this.vALUECOLUMNNAME; data['DESCRIPTION'] = this.dESCRIPTION; diff --git a/lib/models/dyanmic_forms/validate_eit_transaction_model.dart b/lib/models/dyanmic_forms/validate_eit_transaction_model.dart index a543e5c..3b485d7 100644 --- a/lib/models/dyanmic_forms/validate_eit_transaction_model.dart +++ b/lib/models/dyanmic_forms/validate_eit_transaction_model.dart @@ -16,7 +16,7 @@ class ValidateEitTransactionModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['TRANSACTION_NUMBER'] = this.tRANSACTIONNUMBER; data['NAME'] = this.nAME; data['VARCHAR2_VALUE'] = this.vARCHAR2VALUE; diff --git a/lib/models/eit/get_eit_transaction_model.dart b/lib/models/eit/get_eit_transaction_model.dart index 309c0a4..dffe320 100644 --- a/lib/models/eit/get_eit_transaction_model.dart +++ b/lib/models/eit/get_eit_transaction_model.dart @@ -13,7 +13,7 @@ class GetEitTransactionsModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); if (this.collectionTransaction != null) { data['Collection_Transaction'] = this.collectionTransaction!.map((v) => v.toJson()).toList(); } @@ -80,7 +80,7 @@ class CollectionTransaction { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['APPLICATION_COLUMN_NAME'] = this.aPPLICATIONCOLUMNNAME; data['DATATYPE'] = this.dATATYPE; data['DATE_VALUE'] = this.dATEVALUE; diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index e288d38..23026e3 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -1249,7 +1249,7 @@ class GenericResponseModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['Date'] = this.date; data['LanguageID'] = this.languageID; data['ServiceName'] = this.serviceName; diff --git a/lib/models/get_absence_collection_notification_body_list_model.dart b/lib/models/get_absence_collection_notification_body_list_model.dart index 057cb64..8ca774a 100644 --- a/lib/models/get_absence_collection_notification_body_list_model.dart +++ b/lib/models/get_absence_collection_notification_body_list_model.dart @@ -13,7 +13,7 @@ class GetAbsenceCollectionNotificationBodyList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); if (this.collectionNotification != null) { data['Collection_Notification'] = this.collectionNotification!.map((v) => v.toJson()).toList(); } @@ -74,7 +74,7 @@ class CollectionNotificationAbsence { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ACTION'] = this.aCTION; data['APPLICATION_COLUMN_NAME'] = this.aPPLICATIONCOLUMNNAME; data['DATATYPE'] = this.dATATYPE; diff --git a/lib/models/get_action_history_list_model.dart b/lib/models/get_action_history_list_model.dart index c89a974..fd6857a 100644 --- a/lib/models/get_action_history_list_model.dart +++ b/lib/models/get_action_history_list_model.dart @@ -54,7 +54,7 @@ class GetActionHistoryList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ACTION'] = this.aCTION; data['ACTION_CODE'] = this.aCTIONCODE; data['EMAIL_ADDRESS'] = this.eMAILADDRESS; diff --git a/lib/models/get_announcement_details.dart b/lib/models/get_announcement_details.dart index 33628ce..45e4a1c 100644 --- a/lib/models/get_announcement_details.dart +++ b/lib/models/get_announcement_details.dart @@ -51,7 +51,7 @@ class GetAnnouncementDetails { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['Title_EN'] = this.titleEN; data['Title_AR'] = this.titleAR; data['EmailBody_EN'] = this.emailBodyEN; diff --git a/lib/models/get_announcements.dart b/lib/models/get_announcements.dart index 05b6988..70e93dc 100644 --- a/lib/models/get_announcements.dart +++ b/lib/models/get_announcements.dart @@ -51,7 +51,7 @@ class GetAnnouncementsObject { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['Title_EN'] = this.titleEN; data['Title_AR'] = this.titleAR; data['Banner_Image'] = this.bannerImage; diff --git a/lib/models/get_approves_list_model.dart b/lib/models/get_approves_list_model.dart index f5a4d82..2aec5b8 100644 --- a/lib/models/get_approves_list_model.dart +++ b/lib/models/get_approves_list_model.dart @@ -42,7 +42,7 @@ class GetApprovesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['APPROVAL_STATUS'] = this.aPPROVALSTATUS; data['APPROVER'] = this.aPPROVER; data['APPROVER_CATEGORY'] = this.aPPROVERCATEGORY; diff --git a/lib/models/get_attachement_list_model.dart b/lib/models/get_attachement_list_model.dart index 79c43bb..7dd6376 100644 --- a/lib/models/get_attachement_list_model.dart +++ b/lib/models/get_attachement_list_model.dart @@ -51,7 +51,7 @@ class GetAttachementList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ATTACHED_DOCUMENT_ID'] = this.aTTACHEDDOCUMENTID; data['CATEGORY_ID'] = this.cATEGORYID; data['DATATYPE_ID'] = this.dATATYPEID; diff --git a/lib/models/get_contact_dff_structure_list.dart b/lib/models/get_contact_dff_structure_list.dart index 44a86be..7c226a9 100644 --- a/lib/models/get_contact_dff_structure_list.dart +++ b/lib/models/get_contact_dff_structure_list.dart @@ -126,7 +126,7 @@ class GetContactDffStructureList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ALPHANUMERIC_ALLOWED_FLAG'] = this.aLPHANUMERICALLOWEDFLAG; data['APPLICATION_COLUMN_NAME'] = this.aPPLICATIONCOLUMNNAME; data['CHILD_SEGMENTS_VS'] = this.cHILDSEGMENTSVS; diff --git a/lib/models/get_day_hours_type_details_list_model.dart b/lib/models/get_day_hours_type_details_list_model.dart index daaac74..e4eef25 100644 --- a/lib/models/get_day_hours_type_details_list_model.dart +++ b/lib/models/get_day_hours_type_details_list_model.dart @@ -132,7 +132,7 @@ class GetDayHoursTypeDetailsList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ABSENCE_ATTENDANCE_ID'] = this.aBSENCEATTENDANCEID; data['ABSENCE_ATTENDANCE_TYPE_ID'] = this.aBSENCEATTENDANCETYPEID; data['ABSENT_FLAG'] = this.aBSENTFLAG; diff --git a/lib/models/get_default_value_list_model.dart b/lib/models/get_default_value_list_model.dart index 3ee7fc1..6e46d2b 100644 --- a/lib/models/get_default_value_list_model.dart +++ b/lib/models/get_default_value_list_model.dart @@ -18,7 +18,7 @@ class GetDefaultValueList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_ID_COLUMN_NAME'] = this.pIDCOLUMNNAME; data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; diff --git a/lib/models/get_eit_dff_structure_list_model.dart b/lib/models/get_eit_dff_structure_list_model.dart index 5856014..832dc86 100644 --- a/lib/models/get_eit_dff_structure_list_model.dart +++ b/lib/models/get_eit_dff_structure_list_model.dart @@ -151,7 +151,7 @@ class GetEITDFFStructureList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ALPHANUMERIC_ALLOWED_FLAG'] = this.aLPHANUMERICALLOWEDFLAG; data['APPLICATION_COLUMN_NAME'] = this.aPPLICATIONCOLUMNNAME; data['CHILD_SEGMENTS_DV'] = this.cHILDSEGMENTSDV; @@ -225,7 +225,7 @@ class ESERVICESDV { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_ID_COLUMN_NAME'] = this.pIDCOLUMNNAME; data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; @@ -256,7 +256,7 @@ class ESERVICESVS { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['DESCRIPTION'] = this.dESCRIPTION; data['FROM_ROW_NUM'] = this.fROMROWNUM; data['ID_COLUMN_NAME'] = this.iDCOLUMNNAME; @@ -280,7 +280,7 @@ class PARENTSEGMENTSDVSplited { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['IsRequired'] = this.isRequired; data['Name'] = this.name; return data; @@ -299,7 +299,7 @@ class PARENTSEGMENTSVSSplitedVS { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['IsRequired'] = this.isRequired; data['Name'] = this.name; return data; diff --git a/lib/models/get_eit_transaction_list_model.dart b/lib/models/get_eit_transaction_list_model.dart index d2ff7c0..d8c39c9 100644 --- a/lib/models/get_eit_transaction_list_model.dart +++ b/lib/models/get_eit_transaction_list_model.dart @@ -13,7 +13,7 @@ class GetEITTransactionList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); if (this.collectionTransaction != null) { data['Collection_Transaction'] = this.collectionTransaction!.map((v) => v.toJson()).toList(); @@ -81,7 +81,7 @@ class CollectionTransaction { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['APPLICATION_COLUMN_NAME'] = this.aPPLICATIONCOLUMNNAME; data['DATATYPE'] = this.dATATYPE; data['DATE_VALUE'] = this.dATEVALUE; diff --git a/lib/models/get_employee_address_model.dart b/lib/models/get_employee_address_model.dart index 1033797..8531ced 100644 --- a/lib/models/get_employee_address_model.dart +++ b/lib/models/get_employee_address_model.dart @@ -35,7 +35,7 @@ } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['APPLICATION_COLUMN_NAME'] = this.aPPLICATIONCOLUMNNAME; data['DATATYPE'] = this.dATATYPE; data['DATE_VALUE'] = this.dATEVALUE; diff --git a/lib/models/get_employee_basic_details.model.dart b/lib/models/get_employee_basic_details.model.dart index 06713c0..0a3acd7 100644 --- a/lib/models/get_employee_basic_details.model.dart +++ b/lib/models/get_employee_basic_details.model.dart @@ -37,7 +37,7 @@ class GetEmployeeBasicDetailsList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['APPLICATION_COLUMN_NAME'] = this.aPPLICATIONCOLUMNNAME; data['DATATYPE'] = this.dATATYPE; data['DATE_VALUE'] = this.dATEVALUE; diff --git a/lib/models/get_employee_contacts.model.dart b/lib/models/get_employee_contacts.model.dart index 4064d10..df0a41f 100644 --- a/lib/models/get_employee_contacts.model.dart +++ b/lib/models/get_employee_contacts.model.dart @@ -31,7 +31,7 @@ class GetEmployeeContactsList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['CONTACT_NAME'] = this.cONTACTNAME; data['CONTACT_PERSON_ID'] = this.cONTACTPERSONID; data['CONTACT_RELATIONSHIP_ID'] = this.cONTACTRELATIONSHIPID; diff --git a/lib/models/get_employee_phones_model.dart b/lib/models/get_employee_phones_model.dart index b4038ae..f18138e 100644 --- a/lib/models/get_employee_phones_model.dart +++ b/lib/models/get_employee_phones_model.dart @@ -28,7 +28,7 @@ class GetEmployeePhonesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ACTION'] = this.aCTION; data['DATE_FROM'] = this.dATEFROM; data['DATE_TO'] = this.dATETO; diff --git a/lib/models/get_item_creation_ntf_body_list_model.dart b/lib/models/get_item_creation_ntf_body_list_model.dart index 83c81cb..e4c22e7 100644 --- a/lib/models/get_item_creation_ntf_body_list_model.dart +++ b/lib/models/get_item_creation_ntf_body_list_model.dart @@ -24,7 +24,7 @@ class GetItemCreationNtfBodyList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); if (this.itemCreationHeader != null) { data['ItemCreationHeader'] = this.itemCreationHeader!.map((v) => v.toJson()).toList(); } @@ -108,7 +108,7 @@ class ItemCreationHeader { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ANALYZED_BY'] = this.aNALYZEDBY; data['ANALYZED_BY_ID'] = this.aNALYZEDBYID; data['ANALYZED_DATE'] = this.aNALYZEDDATE; @@ -250,7 +250,7 @@ class ItemCreationLines { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['CHARGE_TO_PATIENT'] = this.cHARGETOPATIENT; data['FROM_ROW_NUM'] = this.fROMROWNUM; data['INVENTORY_ITEM_ID'] = this.iNVENTORYITEMID; diff --git a/lib/models/get_mo_Item_history_list_model.dart b/lib/models/get_mo_Item_history_list_model.dart index 3604322..f008a17 100644 --- a/lib/models/get_mo_Item_history_list_model.dart +++ b/lib/models/get_mo_Item_history_list_model.dart @@ -72,7 +72,7 @@ class GetMoItemHistoryList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['DATE_REQUIRED'] = this.dATEREQUIRED; data['DESCRIPTION'] = this.dESCRIPTION; data['FROM_LOCATOR'] = this.fROMLOCATOR; diff --git a/lib/models/get_mo_notification_body_list_model.dart b/lib/models/get_mo_notification_body_list_model.dart index 613d10f..1fc11ca 100644 --- a/lib/models/get_mo_notification_body_list_model.dart +++ b/lib/models/get_mo_notification_body_list_model.dart @@ -75,7 +75,7 @@ class GetMoNotificationBodyList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['DATE_REQUIRED'] = this.dATEREQUIRED; data['DESCRIPTION'] = this.dESCRIPTION; data['FROM_LOCATOR'] = this.fROMLOCATOR; diff --git a/lib/models/get_mobile_login_info_list_model.dart b/lib/models/get_mobile_login_info_list_model.dart index ff419f2..a2f7799 100644 --- a/lib/models/get_mobile_login_info_list_model.dart +++ b/lib/models/get_mobile_login_info_list_model.dart @@ -45,7 +45,7 @@ class GetMobileLoginInfoListModel { } Map toJson() { - final Map data = Map(); + Map data = Map(); data['ID'] = iD; data['EmployeeID'] = employeeID; data['ChannelID'] = channelID; diff --git a/lib/models/get_notification_buttons_list_model.dart b/lib/models/get_notification_buttons_list_model.dart index a6b29d2..91ac57d 100644 --- a/lib/models/get_notification_buttons_list_model.dart +++ b/lib/models/get_notification_buttons_list_model.dart @@ -15,7 +15,7 @@ class GetNotificationButtonsList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['BUTTON_ACTION'] = this.bUTTONACTION; data['BUTTON_ICON'] = this.bUTTONICON; data['BUTTON_LABEL'] = this.bUTTONLABEL; diff --git a/lib/models/get_po_Item_history_list_model.dart b/lib/models/get_po_Item_history_list_model.dart index d51861b..656457d 100644 --- a/lib/models/get_po_Item_history_list_model.dart +++ b/lib/models/get_po_Item_history_list_model.dart @@ -66,7 +66,7 @@ class GetPoItemHistoryList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['BALANCE_QUANTITY'] = this.bALANCEQUANTITY; data['BONUS_QUANTITY'] = this.bONUSQUANTITY; data['BUYER'] = this.bUYER; diff --git a/lib/models/get_po_notification_body_list_model.dart b/lib/models/get_po_notification_body_list_model.dart index 7b5c1cb..5d77b68 100644 --- a/lib/models/get_po_notification_body_list_model.dart +++ b/lib/models/get_po_notification_body_list_model.dart @@ -26,7 +26,7 @@ class GetPoNotificationBodyList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); if (this.pOHeader != null) { data['POHeader'] = this.pOHeader!.map((v) => v.toJson()).toList(); } @@ -116,7 +116,7 @@ class POHeader { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['BUYER'] = this.bUYER; data['COMMENTS'] = this.cOMMENTS; data['CREATION_DATE'] = this.cREATIONDATE; @@ -215,7 +215,7 @@ class POLines { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['DELIVER_TO_LOCATION'] = this.dELIVERTOLOCATION; data['FROM_ROW_NUM'] = this.fROMROWNUM; data['ITEM_CODE'] = this.iTEMCODE; diff --git a/lib/models/get_quotation_analysis_list_model.dart b/lib/models/get_quotation_analysis_list_model.dart index c0be32d..4ceaa96 100644 --- a/lib/models/get_quotation_analysis_list_model.dart +++ b/lib/models/get_quotation_analysis_list_model.dart @@ -60,7 +60,7 @@ class GetQuotationAnalysisList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['FROM_ROW_NUM'] = this.fROMROWNUM; data['ITEM_CODE'] = this.iTEMCODE; data['ITEM_DESC'] = this.iTEMDESC; diff --git a/lib/models/get_schedule_shifts_details_list_model.dart b/lib/models/get_schedule_shifts_details_list_model.dart index 8003446..df740a0 100644 --- a/lib/models/get_schedule_shifts_details_list_model.dart +++ b/lib/models/get_schedule_shifts_details_list_model.dart @@ -94,7 +94,7 @@ class GetScheduleShiftsDetailsList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ACTUAL_WOB_HRS'] = this.aCTUALWOBHRS; data['APPROVED_END_DATETIME'] = this.aPPROVEDENDDATETIME; data['APPROVED_END_REASON'] = this.aPPROVEDENDREASON; diff --git a/lib/models/get_stamp_ms_notification_body_list_model.dart b/lib/models/get_stamp_ms_notification_body_list_model.dart index dbead87..884f32b 100644 --- a/lib/models/get_stamp_ms_notification_body_list_model.dart +++ b/lib/models/get_stamp_ms_notification_body_list_model.dart @@ -96,7 +96,7 @@ class GetStampMsNotificationBodyList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ACTUAL_WOB_HRS'] = this.aCTUALWOBHRS; data['ACTUAL_WOB_SEC'] = this.aCTUALWOBSEC; data['APPROVED_END_REASON_DESC'] = this.aPPROVEDENDREASONDESC; diff --git a/lib/models/get_stamp_ns_notification_body_list_model.dart b/lib/models/get_stamp_ns_notification_body_list_model.dart index 4ce708c..c1c8515 100644 --- a/lib/models/get_stamp_ns_notification_body_list_model.dart +++ b/lib/models/get_stamp_ns_notification_body_list_model.dart @@ -43,7 +43,7 @@ class GetStampNsNotificationBodyList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ASSIGNMENT_ID'] = this.aSSIGNMENTID; data['ASSIGNMENT_NUMBER'] = this.aSSIGNMENTNUMBER; data['BUSINESS_GROUP_ID'] = this.bUSINESSGROUPID; diff --git a/lib/models/get_time_card_summary_list_model.dart b/lib/models/get_time_card_summary_list_model.dart index 727e29f..85a2a8e 100644 --- a/lib/models/get_time_card_summary_list_model.dart +++ b/lib/models/get_time_card_summary_list_model.dart @@ -113,7 +113,7 @@ class GetTimeCardSummaryList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ABSENT_DAYS'] = this.aBSENTDAYS; data['ACTUAL_HRS'] = this.aCTUALHRS; data['APPROVED_TIMEBACK_HRS'] = this.aPPROVEDTIMEBACKHRS; diff --git a/lib/models/itg_forms_models/allowed_actions_model.dart b/lib/models/itg_forms_models/allowed_actions_model.dart index 9c394c3..0ab5efc 100644 --- a/lib/models/itg_forms_models/allowed_actions_model.dart +++ b/lib/models/itg_forms_models/allowed_actions_model.dart @@ -12,7 +12,7 @@ class AllowedActions { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['Action'] = this.action; data['Details'] = this.details; data['IsAvailable'] = this.isAvailable; diff --git a/lib/models/itg_forms_models/field_goups_model.dart b/lib/models/itg_forms_models/field_goups_model.dart index 362fda7..a964a4d 100644 --- a/lib/models/itg_forms_models/field_goups_model.dart +++ b/lib/models/itg_forms_models/field_goups_model.dart @@ -17,7 +17,7 @@ class FieldGoups { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); if (this.fields != null) { data['Fields'] = this.fields!.map((v) => v.toJson()).toList(); } diff --git a/lib/models/itg_forms_models/fields_model.dart b/lib/models/itg_forms_models/fields_model.dart index 3800f81..528c960 100644 --- a/lib/models/itg_forms_models/fields_model.dart +++ b/lib/models/itg_forms_models/fields_model.dart @@ -16,7 +16,7 @@ class Fields { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['MultipleValue'] = this.multipleValue; data['TableValue'] = this.tableValue; data['Title'] = this.title; diff --git a/lib/models/itg_forms_models/itg_request_model.dart b/lib/models/itg_forms_models/itg_request_model.dart index 5bc4fa4..75f6a69 100644 --- a/lib/models/itg_forms_models/itg_request_model.dart +++ b/lib/models/itg_forms_models/itg_request_model.dart @@ -35,7 +35,7 @@ class ITGRequest { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); if (this.allowedActions != null) { data['AllowedActions'] = this.allowedActions!.map((v) => v.toJson()).toList(); } diff --git a/lib/models/itg_forms_models/request_detail_model.dart b/lib/models/itg_forms_models/request_detail_model.dart index b7b5a9c..1193423 100644 --- a/lib/models/itg_forms_models/request_detail_model.dart +++ b/lib/models/itg_forms_models/request_detail_model.dart @@ -21,7 +21,7 @@ class RequestDetails { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ID'] = this.iD; data['ItemID'] = this.itemID; data['ListID'] = this.listID; diff --git a/lib/models/itg_forms_models/request_type_model.dart b/lib/models/itg_forms_models/request_type_model.dart index 92d2515..0845183 100644 --- a/lib/models/itg_forms_models/request_type_model.dart +++ b/lib/models/itg_forms_models/request_type_model.dart @@ -21,7 +21,7 @@ class RequestType { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ItemCount'] = this.itemCount; if (this.requestDetails != null) { data['RequestDetails'] = this.requestDetails!.map((v) => v.toJson()).toList(); diff --git a/lib/models/itg_forms_models/wf_history_model.dart b/lib/models/itg_forms_models/wf_history_model.dart index 8e3dd6d..c804f67 100644 --- a/lib/models/itg_forms_models/wf_history_model.dart +++ b/lib/models/itg_forms_models/wf_history_model.dart @@ -27,7 +27,7 @@ class WFHistory { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['Action'] = this.action; data['ApprovalLevel'] = this.approvalLevel; data['Date'] = this.date; diff --git a/lib/models/member_information_list_model.dart b/lib/models/member_information_list_model.dart index dc64e53..0050fed 100644 --- a/lib/models/member_information_list_model.dart +++ b/lib/models/member_information_list_model.dart @@ -254,7 +254,7 @@ class MemberInformationListModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ACTUAL_TERMINATION_DATE'] = this.aCTUALTERMINATIONDATE; data['ASSIGNMENT_END_DATE'] = this.aSSIGNMENTENDDATE; data['ASSIGNMENT_ID'] = this.aSSIGNMENTID; diff --git a/lib/models/member_login_list_model.dart b/lib/models/member_login_list_model.dart index ffbc942..c9e1039 100644 --- a/lib/models/member_login_list_model.dart +++ b/lib/models/member_login_list_model.dart @@ -33,7 +33,7 @@ class MemberLoginListModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_EMAIL_ADDRESS'] = this.pEMAILADDRESS; data['P_INVALID_LOGIN_MSG'] = this.pINVALIDLOGINMSG; data['P_LEGISLATION_CODE'] = this.pLEGISLATIONCODE; diff --git a/lib/models/monthly_pay_slip/get_deductions_List_model.dart b/lib/models/monthly_pay_slip/get_deductions_List_model.dart index 7a99447..07bf1ba 100644 --- a/lib/models/monthly_pay_slip/get_deductions_List_model.dart +++ b/lib/models/monthly_pay_slip/get_deductions_List_model.dart @@ -24,7 +24,7 @@ class GetDeductionsList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['AMOUNT'] = this.aMOUNT; data['ELEMENT_NAME'] = this.eLEMENTNAME; data['FROM_ROW_NUM'] = this.fROMROWNUM; diff --git a/lib/models/monthly_pay_slip/get_earnings_list_model.dart b/lib/models/monthly_pay_slip/get_earnings_list_model.dart index 4c38fa6..f525d16 100644 --- a/lib/models/monthly_pay_slip/get_earnings_list_model.dart +++ b/lib/models/monthly_pay_slip/get_earnings_list_model.dart @@ -24,7 +24,7 @@ class GetEarningsList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['AMOUNT'] = this.aMOUNT; data['ELEMENT_NAME'] = this.eLEMENTNAME; data['FROM_ROW_NUM'] = this.fROMROWNUM; diff --git a/lib/models/monthly_pay_slip/get_pay_slip_list_model.dart b/lib/models/monthly_pay_slip/get_pay_slip_list_model.dart index 7cf8883..c3e9d7e 100644 --- a/lib/models/monthly_pay_slip/get_pay_slip_list_model.dart +++ b/lib/models/monthly_pay_slip/get_pay_slip_list_model.dart @@ -24,7 +24,7 @@ class GetPayslipList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ACTION_CONTEXT_ID'] = this.aCTIONCONTEXTID; data['PAYMENT_DATE'] = this.pAYMENTDATE; data['PAYSLIP_CHOICE'] = this.pAYSLIPCHOICE; diff --git a/lib/models/monthly_pay_slip/get_payment_information_list_model.dart b/lib/models/monthly_pay_slip/get_payment_information_list_model.dart index 75ed21c..f73be78 100644 --- a/lib/models/monthly_pay_slip/get_payment_information_list_model.dart +++ b/lib/models/monthly_pay_slip/get_payment_information_list_model.dart @@ -21,7 +21,7 @@ class GetPaymentInformationList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ACCOUNT_NUMBER'] = this.aCCOUNTNUMBER; data['AMOUNT'] = this.aMOUNT; data['BANK_NAME'] = this.bANKNAME; diff --git a/lib/models/monthly_pay_slip/get_summary_of_payment_list_model.dart b/lib/models/monthly_pay_slip/get_summary_of_payment_list_model.dart index 72ee89b..be65e35 100644 --- a/lib/models/monthly_pay_slip/get_summary_of_payment_list_model.dart +++ b/lib/models/monthly_pay_slip/get_summary_of_payment_list_model.dart @@ -24,7 +24,7 @@ class GetSummaryOfPaymentList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['TOTAL_DEDUCTIONS_AMOUNT'] = this.tOTALDEDUCTIONSAMOUNT; data['TOTAL_DEDUCTIONS_PERCENTAGE'] = this.tOTALDEDUCTIONSPERCENTAGE; data['TOTAL_EARNINGS_AMOUNT'] = this.tOTALEARNINGSAMOUNT; diff --git a/lib/models/mowadhafhi/get_department_sections.dart b/lib/models/mowadhafhi/get_department_sections.dart index 2d534ba..3a98db4 100644 --- a/lib/models/mowadhafhi/get_department_sections.dart +++ b/lib/models/mowadhafhi/get_department_sections.dart @@ -30,7 +30,7 @@ class GetDepartmentSections { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['departmentId'] = this.departmentId; data['departmentName'] = this.departmentName; data['departmentSectionId'] = this.departmentSectionId; diff --git a/lib/models/mowadhafhi/get_project_departments.dart b/lib/models/mowadhafhi/get_project_departments.dart index 436399d..53a2d5d 100644 --- a/lib/models/mowadhafhi/get_project_departments.dart +++ b/lib/models/mowadhafhi/get_project_departments.dart @@ -21,7 +21,7 @@ class GetProjectDepartments { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['departmentId'] = this.departmentId; data['departmentName'] = this.departmentName; data['projectCode'] = this.projectCode; diff --git a/lib/models/mowadhafhi/get_projects.dart b/lib/models/mowadhafhi/get_projects.dart index 62b99c3..3e76e84 100644 --- a/lib/models/mowadhafhi/get_projects.dart +++ b/lib/models/mowadhafhi/get_projects.dart @@ -10,7 +10,7 @@ class GetMowadhafhiProjects { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['projectId'] = this.projectId; data['projectName'] = this.projectName; return data; diff --git a/lib/models/mowadhafhi/get_section_topics.dart b/lib/models/mowadhafhi/get_section_topics.dart index c596527..d7ed3b8 100644 --- a/lib/models/mowadhafhi/get_section_topics.dart +++ b/lib/models/mowadhafhi/get_section_topics.dart @@ -42,7 +42,7 @@ class GetSectionTopics { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['departmentId'] = this.departmentId; data['departmentName'] = this.departmentName; data['projectCode'] = this.projectCode; diff --git a/lib/models/mowadhafhi/get_ticket_details.dart b/lib/models/mowadhafhi/get_ticket_details.dart index 5f896bd..cc1b13c 100644 --- a/lib/models/mowadhafhi/get_ticket_details.dart +++ b/lib/models/mowadhafhi/get_ticket_details.dart @@ -57,7 +57,7 @@ class GetTicketDetailsByEmployee { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['closedBy'] = this.closedBy; data['created'] = this.created; data['departmentId'] = this.departmentId; diff --git a/lib/models/mowadhafhi/get_ticket_transactions.dart b/lib/models/mowadhafhi/get_ticket_transactions.dart index 9091761..be793ca 100644 --- a/lib/models/mowadhafhi/get_ticket_transactions.dart +++ b/lib/models/mowadhafhi/get_ticket_transactions.dart @@ -27,7 +27,7 @@ class GetTicketTransactions { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['actionBy'] = this.actionBy; data['actionDate'] = this.actionDate; data['comments'] = this.comments; diff --git a/lib/models/mowadhafhi/get_ticket_types.dart b/lib/models/mowadhafhi/get_ticket_types.dart index ae68e2d..53a9fc4 100644 --- a/lib/models/mowadhafhi/get_ticket_types.dart +++ b/lib/models/mowadhafhi/get_ticket_types.dart @@ -12,7 +12,7 @@ class GetTicketTypes { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ticketIdPrefix'] = this.ticketIdPrefix; data['ticketTypeId'] = this.ticketTypeId; data['typeName'] = this.typeName; diff --git a/lib/models/mowadhafhi/get_tickets_list.dart b/lib/models/mowadhafhi/get_tickets_list.dart index 34005df..0172b45 100644 --- a/lib/models/mowadhafhi/get_tickets_list.dart +++ b/lib/models/mowadhafhi/get_tickets_list.dart @@ -135,7 +135,7 @@ class GetTicketsByEmployeeList { } Map toJson() { - final Map data = {}; + Map data = {}; data['agentRating'] = agentRating; data['assignedSpecialist'] = assignedSpecialist; data['assignedSpecialistName'] = assignedSpecialistName; diff --git a/lib/models/mowadhafhi/mowadhafhi_attachement_request.dart b/lib/models/mowadhafhi/mowadhafhi_attachement_request.dart index a72bd16..e223834 100644 --- a/lib/models/mowadhafhi/mowadhafhi_attachement_request.dart +++ b/lib/models/mowadhafhi/mowadhafhi_attachement_request.dart @@ -13,7 +13,7 @@ class MowadhafhiRequestAttachment { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['Base64Data'] = this.base64Data; data['FileName'] = this.fileName; data['ContentType'] = this.contentType; diff --git a/lib/models/notification_action_model.dart b/lib/models/notification_action_model.dart index a1214e1..3398ed6 100644 --- a/lib/models/notification_action_model.dart +++ b/lib/models/notification_action_model.dart @@ -10,7 +10,7 @@ class NotificationAction { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; return data; diff --git a/lib/models/notification_get_respond_attributes_list_model.dart b/lib/models/notification_get_respond_attributes_list_model.dart index 9810e24..e85e2c8 100644 --- a/lib/models/notification_get_respond_attributes_list_model.dart +++ b/lib/models/notification_get_respond_attributes_list_model.dart @@ -14,7 +14,7 @@ class NotificationGetRespondAttributesList { } Map toJson() { - final Map data = {}; + Map data = {}; data['ATTRIBUTE_DISPLAY_NAME'] = attributeDisplayName; data['ATTRIBUTE_FORMAT'] = attributeFormat; data['ATTRIBUTE_NAME'] = attributeName; diff --git a/lib/models/payslip/get_deductions_list.dart b/lib/models/payslip/get_deductions_list.dart index 7a99447..07bf1ba 100644 --- a/lib/models/payslip/get_deductions_list.dart +++ b/lib/models/payslip/get_deductions_list.dart @@ -24,7 +24,7 @@ class GetDeductionsList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['AMOUNT'] = this.aMOUNT; data['ELEMENT_NAME'] = this.eLEMENTNAME; data['FROM_ROW_NUM'] = this.fROMROWNUM; diff --git a/lib/models/payslip/get_earnings_list.dart b/lib/models/payslip/get_earnings_list.dart index 272dab3..a374733 100644 --- a/lib/models/payslip/get_earnings_list.dart +++ b/lib/models/payslip/get_earnings_list.dart @@ -25,7 +25,7 @@ class GetEarningsList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['AMOUNT'] = this.aMOUNT; data['ELEMENT_NAME'] = this.eLEMENTNAME; data['FROM_ROW_NUM'] = this.fROMROWNUM; diff --git a/lib/models/payslip/get_payment_information.dart b/lib/models/payslip/get_payment_information.dart index 277b409..7d92eba 100644 --- a/lib/models/payslip/get_payment_information.dart +++ b/lib/models/payslip/get_payment_information.dart @@ -22,7 +22,7 @@ class GetPaymentInformationList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ACCOUNT_NUMBER'] = this.aCCOUNTNUMBER; data['AMOUNT'] = this.aMOUNT; data['BANK_NAME'] = this.bANKNAME; diff --git a/lib/models/payslip/get_payslip.dart b/lib/models/payslip/get_payslip.dart index 2bb8280..bc85d16 100644 --- a/lib/models/payslip/get_payslip.dart +++ b/lib/models/payslip/get_payslip.dart @@ -26,7 +26,7 @@ class GetPayslipList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ACTION_CONTEXT_ID'] = this.aCTIONCONTEXTID; data['PAYMENT_DATE'] = this.pAYMENTDATE; data['PAYSLIP_CHOICE'] = this.pAYSLIPCHOICE; diff --git a/lib/models/payslip/get_summary_of_payment.dart b/lib/models/payslip/get_summary_of_payment.dart index abf3dc4..e977371 100644 --- a/lib/models/payslip/get_summary_of_payment.dart +++ b/lib/models/payslip/get_summary_of_payment.dart @@ -26,7 +26,7 @@ class GetSummaryOfPaymentList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['TOTAL_DEDUCTIONS_AMOUNT'] = this.tOTALDEDUCTIONSAMOUNT; data['TOTAL_DEDUCTIONS_PERCENTAGE'] = this.tOTALDEDUCTIONSPERCENTAGE; data['TOTAL_EARNINGS_AMOUNT'] = this.tOTALEARNINGSAMOUNT; diff --git a/lib/models/pending_transactions/get_pending_transactions_details.dart b/lib/models/pending_transactions/get_pending_transactions_details.dart index 0752269..711d689 100644 --- a/lib/models/pending_transactions/get_pending_transactions_details.dart +++ b/lib/models/pending_transactions/get_pending_transactions_details.dart @@ -39,7 +39,7 @@ class GetPendingTransactionsDetails { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['CREATION_DATE'] = this.cREATIONDATE; data['FROM_ROW_NUM'] = this.fROMROWNUM; data['ITEM_KEY'] = this.iTEMKEY; diff --git a/lib/models/pending_transactions/get_req_functions.dart b/lib/models/pending_transactions/get_req_functions.dart index bfb5892..22e4ced 100644 --- a/lib/models/pending_transactions/get_req_functions.dart +++ b/lib/models/pending_transactions/get_req_functions.dart @@ -13,7 +13,7 @@ class GetPendingTransactionsFunctions { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['FUNCTION_ID'] = this.fUNCTIONID; data['FUNCTION_NAME'] = this.fUNCTIONNAME; data['FUNCTION_PROMPT'] = this.fUNCTIONPROMPT; diff --git a/lib/models/post_params_model.dart b/lib/models/post_params_model.dart index 7e62257..b44bec9 100644 --- a/lib/models/post_params_model.dart +++ b/lib/models/post_params_model.dart @@ -43,7 +43,7 @@ class PostParamsModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['VersionID'] = this.versionID; data['Channel'] = this.channel; data['LanguageID'] = this.languageID; @@ -56,7 +56,7 @@ class PostParamsModel { } Map toJsonAfterLogin() { - final Map data = new Map(); + Map data = new Map(); data['VersionID'] = this.versionID; data['Channel'] = this.channel; data['LanguageID'] = this.languageID; diff --git a/lib/models/privilege_list_model.dart b/lib/models/privilege_list_model.dart index ad83500..3d39118 100644 --- a/lib/models/privilege_list_model.dart +++ b/lib/models/privilege_list_model.dart @@ -17,7 +17,7 @@ class PrivilegeListModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ID'] = this.iD; data['ServiceName'] = this.serviceName; data['Previlege'] = this.previlege; diff --git a/lib/models/profile/basic_details_cols_structions.dart b/lib/models/profile/basic_details_cols_structions.dart index dceacd6..bb3138c 100644 --- a/lib/models/profile/basic_details_cols_structions.dart +++ b/lib/models/profile/basic_details_cols_structions.dart @@ -45,7 +45,7 @@ class GetBasicDetColsStructureList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['APPLICATION_COLUMN_NAME'] = this.aPPLICATIONCOLUMNNAME; data['DATATYPE'] = this.dATATYPE; data['DISPLAY_FLAG'] = this.dISPLAYFLAG; @@ -76,7 +76,7 @@ class ObjectValuesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['CODE'] = this.cODE; data['DESCRIPTION'] = this.dESCRIPTION; data['MEANING'] = this.mEANING; diff --git a/lib/models/profile/basic_details_dff_structure.dart b/lib/models/profile/basic_details_dff_structure.dart index 9d44b85..cb68ac5 100644 --- a/lib/models/profile/basic_details_dff_structure.dart +++ b/lib/models/profile/basic_details_dff_structure.dart @@ -142,7 +142,7 @@ class GetBasicDetDffStructureList { } Map toJson() { - final Map data = Map(); + Map data = Map(); data['ALPHANUMERIC_ALLOWED_FLAG'] = this.aLPHANUMERICALLOWEDFLAG; data['APPLICATION_COLUMN_NAME'] = this.aPPLICATIONCOLUMNNAME; data['CHILD_SEGMENTS_VS'] = this.cHILDSEGMENTSVS; diff --git a/lib/models/profile/get_address_dff_structure_list.dart b/lib/models/profile/get_address_dff_structure_list.dart index 50d9b97..786e683 100644 --- a/lib/models/profile/get_address_dff_structure_list.dart +++ b/lib/models/profile/get_address_dff_structure_list.dart @@ -137,7 +137,7 @@ class GetAddressDffStructureList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ALPHANUMERIC_ALLOWED_FLAG'] = this.aLPHANUMERICALLOWEDFLAG; data['APPLICATION_COLUMN_NAME'] = this.aPPLICATIONCOLUMNNAME; data['CHILD_SEGMENTS_VS'] = this.cHILDSEGMENTSVS; diff --git a/lib/models/profile/get_contact_clos_structure_list.dart b/lib/models/profile/get_contact_clos_structure_list.dart index 7f3ad90..29b991b 100644 --- a/lib/models/profile/get_contact_clos_structure_list.dart +++ b/lib/models/profile/get_contact_clos_structure_list.dart @@ -51,7 +51,7 @@ class GetContactColsStructureList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['APPLICATION_COLUMN_NAME'] = this.aPPLICATIONCOLUMNNAME; data['DATATYPE'] = this.dATATYPE; data['DISPLAY_FLAG'] = this.dISPLAYFLAG; @@ -84,7 +84,7 @@ class ObjectValuesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['CODE'] = this.cODE; data['DESCRIPTION'] = this.dESCRIPTION; data['MEANING'] = this.mEANING; diff --git a/lib/models/profile/get_contact_details_list.dart b/lib/models/profile/get_contact_details_list.dart index 9097291..4b8dbbc 100644 --- a/lib/models/profile/get_contact_details_list.dart +++ b/lib/models/profile/get_contact_details_list.dart @@ -38,7 +38,7 @@ class GetContactDetailsList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['APPLICATION_COLUMN_NAME'] = this.aPPLICATIONCOLUMNNAME; data['DATATYPE'] = this.dATATYPE; data['DATE_VALUE'] = this.dATEVALUE; diff --git a/lib/models/profile/get_countries_list_model.dart b/lib/models/profile/get_countries_list_model.dart index dc9e9c7..b8ae1e4 100644 --- a/lib/models/profile/get_countries_list_model.dart +++ b/lib/models/profile/get_countries_list_model.dart @@ -10,7 +10,7 @@ class GetCountriesListModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['COUNTRY_CODE'] = this.cOUNTRYCODE; data['COUNTRY_NAME'] = this.cOUNTRYNAME; return data; diff --git a/lib/models/profile/phone_number_types_model.dart b/lib/models/profile/phone_number_types_model.dart index 47b8a35..417ba87 100644 --- a/lib/models/profile/phone_number_types_model.dart +++ b/lib/models/profile/phone_number_types_model.dart @@ -12,7 +12,7 @@ class GetPhoneNumberTypesModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['CODE'] = this.cODE; data['DESCRIPTION'] = this.dESCRIPTION; data['MEANING'] = this.mEANING; diff --git a/lib/models/profile/start_address_approval_process_model.dart b/lib/models/profile/start_address_approval_process_model.dart index 717298d..6083057 100644 --- a/lib/models/profile/start_address_approval_process_model.dart +++ b/lib/models/profile/start_address_approval_process_model.dart @@ -10,7 +10,7 @@ class StartAddressApprovalProcess { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; return data; diff --git a/lib/models/profile/submit_address_transaction.dart b/lib/models/profile/submit_address_transaction.dart index 193cb68..a2cd874 100644 --- a/lib/models/profile/submit_address_transaction.dart +++ b/lib/models/profile/submit_address_transaction.dart @@ -14,7 +14,7 @@ class SubmitAddressTransaction { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_ITEM_KEY'] = this.pITEMKEY; data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; diff --git a/lib/models/profile/submit_basic_details_transaction_model.dart b/lib/models/profile/submit_basic_details_transaction_model.dart index db6ea7a..bed00ed 100644 --- a/lib/models/profile/submit_basic_details_transaction_model.dart +++ b/lib/models/profile/submit_basic_details_transaction_model.dart @@ -14,7 +14,7 @@ class SubmitBasicDetailsTransactionList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_ITEM_KEY'] = this.pITEMKEY; data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; diff --git a/lib/models/profile/submit_contact_transaction_list_model.dart b/lib/models/profile/submit_contact_transaction_list_model.dart index 3510473..531567c 100644 --- a/lib/models/profile/submit_contact_transaction_list_model.dart +++ b/lib/models/profile/submit_contact_transaction_list_model.dart @@ -19,7 +19,7 @@ class SubmitContactTransactionList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_ITEM_KEY'] = this.pITEMKEY; data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; diff --git a/lib/models/profile/submit_phone_transactions.dart b/lib/models/profile/submit_phone_transactions.dart index 6b7afd1..c9af8b0 100644 --- a/lib/models/profile/submit_phone_transactions.dart +++ b/lib/models/profile/submit_phone_transactions.dart @@ -14,7 +14,7 @@ class SubmitPhonesTransactionList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_ITEM_KEY'] = this.pITEMKEY; data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; diff --git a/lib/models/start_eit_approval_process_model.dart b/lib/models/start_eit_approval_process_model.dart index f49043b..359b882 100644 --- a/lib/models/start_eit_approval_process_model.dart +++ b/lib/models/start_eit_approval_process_model.dart @@ -10,7 +10,7 @@ class StartEitApprovalProcess { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; return data; diff --git a/lib/models/start_phone_approval_process_model.dart b/lib/models/start_phone_approval_process_model.dart index 2ce3a15..005b29a 100644 --- a/lib/models/start_phone_approval_process_model.dart +++ b/lib/models/start_phone_approval_process_model.dart @@ -10,7 +10,7 @@ class StartPhoneApprovalProcess { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; return data; diff --git a/lib/models/submit_eit_transaction_list_model.dart b/lib/models/submit_eit_transaction_list_model.dart index 288ce8e..f493f8b 100644 --- a/lib/models/submit_eit_transaction_list_model.dart +++ b/lib/models/submit_eit_transaction_list_model.dart @@ -18,7 +18,7 @@ class SubmitEITTransactionList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_ITEM_KEY'] = this.pITEMKEY; data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; diff --git a/lib/models/subordinates_on_leaves_model.dart b/lib/models/subordinates_on_leaves_model.dart index d6437f3..aac37ff 100644 --- a/lib/models/subordinates_on_leaves_model.dart +++ b/lib/models/subordinates_on_leaves_model.dart @@ -48,7 +48,7 @@ class SubordinatesLeavesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ABSENCE_ATTENDANCE_TYPE_NAME'] = this.aBSENCEATTENDANCETYPENAME; data['CALENDAR_ENTRY_DESC'] = this.cALENDARENTRYDESC; data['DATE_END'] = this.dATEEND; diff --git a/lib/models/surah_model.dart b/lib/models/surah_model.dart index acc171a..bd96e18 100644 --- a/lib/models/surah_model.dart +++ b/lib/models/surah_model.dart @@ -19,7 +19,7 @@ class SurahModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['totalItemsCount'] = totalItemsCount; data['statusCode'] = statusCode; data['message'] = message; @@ -58,7 +58,7 @@ class SurahModelData { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['id'] = this.id; data['surahID'] = this.surahID; data['nameAR'] = this.nameAR; diff --git a/lib/models/vacation_rule/create_vacation_rule_list_model.dart b/lib/models/vacation_rule/create_vacation_rule_list_model.dart index 5fd489a..cff2a49 100644 --- a/lib/models/vacation_rule/create_vacation_rule_list_model.dart +++ b/lib/models/vacation_rule/create_vacation_rule_list_model.dart @@ -10,7 +10,7 @@ class CreateVacationRuleList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; return data; diff --git a/lib/models/vacation_rule/get_item_type_notifications_list_model.dart b/lib/models/vacation_rule/get_item_type_notifications_list_model.dart index 4d80a0e..ef11453 100644 --- a/lib/models/vacation_rule/get_item_type_notifications_list_model.dart +++ b/lib/models/vacation_rule/get_item_type_notifications_list_model.dart @@ -18,7 +18,7 @@ class GetItemTypeNotificationsList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['FYI_FLAG'] = this.fYIFLAG; data['NOTIFICATION_DISPLAY_NAME'] = this.nOTIFICATIONDISPLAYNAME; data['NOTIFICATION_NAME'] = this.nOTIFICATIONNAME; diff --git a/lib/models/vacation_rule/get_notification_reassign_mode_list_model.dart b/lib/models/vacation_rule/get_notification_reassign_mode_list_model.dart index e3495d0..c111a71 100644 --- a/lib/models/vacation_rule/get_notification_reassign_mode_list_model.dart +++ b/lib/models/vacation_rule/get_notification_reassign_mode_list_model.dart @@ -13,7 +13,7 @@ class GetNotificationReassignModeList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['RADIO_BUTTON_ACTION'] = this.rADIOBUTTONACTION; data['RADIO_BUTTON_LABEL'] = this.rADIOBUTTONLABEL; data['RADIO_BUTTON_SEQ'] = this.rADIOBUTTONSEQ; diff --git a/lib/models/vacation_rule/get_vacation_rules_list_model.dart b/lib/models/vacation_rule/get_vacation_rules_list_model.dart index 5abd32a..f93fdb5 100644 --- a/lib/models/vacation_rule/get_vacation_rules_list_model.dart +++ b/lib/models/vacation_rule/get_vacation_rules_list_model.dart @@ -66,7 +66,7 @@ class GetVacationRulesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ACTION'] = this.aCTION; data['ACTION_DISPLAY'] = this.aCTIONDISPLAY; data['BEGIN_DATE'] = this.bEGINDATE; diff --git a/lib/models/vacation_rule/respond_attributes_list_model.dart b/lib/models/vacation_rule/respond_attributes_list_model.dart index ca7b2db..79de43f 100644 --- a/lib/models/vacation_rule/respond_attributes_list_model.dart +++ b/lib/models/vacation_rule/respond_attributes_list_model.dart @@ -18,7 +18,7 @@ class RespondAttributesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ATTRIBUTE_DISPLAY_NAME'] = this.aTTRIBUTEDISPLAYNAME; data['ATTRIBUTE_FORMAT'] = this.aTTRIBUTEFORMAT; data['ATTRIBUTE_NAME'] = this.aTTRIBUTENAME; diff --git a/lib/models/vacation_rule/vr_item_types_list_model.dart b/lib/models/vacation_rule/vr_item_types_list_model.dart index d31ffa6..69735db 100644 --- a/lib/models/vacation_rule/vr_item_types_list_model.dart +++ b/lib/models/vacation_rule/vr_item_types_list_model.dart @@ -10,7 +10,7 @@ class VrItemTypesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ITEM_TYPE'] = this.iTEMTYPE; data['ITEM_TYPE_DISPLAY_NAME'] = this.iTEMTYPEDISPLAYNAME; return data; diff --git a/lib/models/vacation_rule/wf_look_up_list_model.dart b/lib/models/vacation_rule/wf_look_up_list_model.dart index 25fb2ee..3b48e26 100644 --- a/lib/models/vacation_rule/wf_look_up_list_model.dart +++ b/lib/models/vacation_rule/wf_look_up_list_model.dart @@ -12,7 +12,7 @@ class WFLookUpList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['LOOKUP_CODE'] = this.lOOKUPCODE; data['LOOKUP_DESCRIPTION'] = this.lOOKUPDESCRIPTION; data['LOOKUP_MEANING'] = this.lOOKUPMEANING; diff --git a/lib/models/validate_eit_transaction_list_model.dart b/lib/models/validate_eit_transaction_list_model.dart index 02f2af0..ac35c17 100644 --- a/lib/models/validate_eit_transaction_list_model.dart +++ b/lib/models/validate_eit_transaction_list_model.dart @@ -10,7 +10,7 @@ class ValidateEITTransactionList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; return data; diff --git a/lib/models/worklist/hr/get_basic_det_ntf_body_list_model.dart b/lib/models/worklist/hr/get_basic_det_ntf_body_list_model.dart index afdcd29..0275ce5 100644 --- a/lib/models/worklist/hr/get_basic_det_ntf_body_list_model.dart +++ b/lib/models/worklist/hr/get_basic_det_ntf_body_list_model.dart @@ -14,7 +14,7 @@ class GetBasicDetNtfBodyList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['PREV_SEGMENT_VALUE_DSP'] = this.prevSegmentValueDsp; data['SEGMENT_PROMPT'] = this.segmentPrompt; data['SEGMENT_VALUE_DSP'] = this.segmentValueDsp; diff --git a/lib/models/worklist_item_type_model.dart b/lib/models/worklist_item_type_model.dart index 49346c0..b164bd0 100644 --- a/lib/models/worklist_item_type_model.dart +++ b/lib/models/worklist_item_type_model.dart @@ -24,7 +24,7 @@ class WorkListItemTypeModelData { } Map toJson() { - final Map data = {}; + Map data = {}; data['value'] = value; data['name'] = name; data['fullName'] = fullName; diff --git a/lib/models/worklist_response_model.dart b/lib/models/worklist_response_model.dart index 4899d5a..0ab44cf 100644 --- a/lib/models/worklist_response_model.dart +++ b/lib/models/worklist_response_model.dart @@ -100,7 +100,7 @@ class WorkListResponseModel { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['BEGIN_DATE'] = this.bEGINDATE; data['DUE_DATE'] = this.dUEDATE; data['END_DATE'] = this.eNDDATE; diff --git a/lib/ui/attendance/add_vacation_rule_screen.dart b/lib/ui/attendance/add_vacation_rule_screen.dart index b7f7f5d..4846053 100644 --- a/lib/ui/attendance/add_vacation_rule_screen.dart +++ b/lib/ui/attendance/add_vacation_rule_screen.dart @@ -526,8 +526,8 @@ class _AddVacationRuleScreenState extends State { ), ); } else { - final DateTime? picked = await showDatePicker(context: context, initialDate: _time, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); - final TimeOfDay? timePicked = await showTimePicker( + DateTime? picked = await showDatePicker(context: context, initialDate: _time, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); + TimeOfDay? timePicked = await showTimePicker( context: context, initialTime: TimeOfDay.fromDateTime(picked!), ); @@ -570,7 +570,7 @@ class _AddVacationRuleScreenState extends State { ), ); } else { - final DateTime? picked = + DateTime? picked = await showDatePicker(context: context, initialDate: dateInput ?? DateTime.now(), initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); if (picked != null && picked != dateInput) { time = picked; diff --git a/lib/ui/attendance/monthly_attendance_screen.dart b/lib/ui/attendance/monthly_attendance_screen.dart index 6a73f70..caaf65c 100644 --- a/lib/ui/attendance/monthly_attendance_screen.dart +++ b/lib/ui/attendance/monthly_attendance_screen.dart @@ -694,7 +694,7 @@ class _MonthlyAttendanceScreenState extends State { } List _getDataSource() { - final List meetings = []; + List meetings = []; return meetings; } @@ -792,7 +792,7 @@ class MeetingDataSource extends CalendarDataSource { } Meeting _getMeetingData(int index) { - final dynamic meeting = appointments; + dynamic meeting = appointments; Meeting meetingData; if (meeting is Meeting) { meetingData = meeting; diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index da9cb5f..4a6ad82 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -56,7 +56,7 @@ class _DashboardScreenState extends State { @override Widget build(BuildContext context) { List namesD = ["Nostalgia Perfume Perfume", "Al Nafoura", "AlJadi", "Nostalgia Perfume"]; - final GlobalKey _key = GlobalKey(); // + GlobalKey _key = GlobalKey(); // return Scaffold( key: _scaffoldState, body: Column( diff --git a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart index 051d72a..72b0567 100644 --- a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart +++ b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart @@ -736,7 +736,7 @@ class _DynamicInputScreenState extends State { ), ); } else { - final DateTime? picked = + DateTime? picked = await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); if (picked != null && picked != selectedDate) { time = picked; @@ -768,7 +768,7 @@ class _DynamicInputScreenState extends State { ), ); } else { - final TimeOfDay? picked = await showTimePicker( + TimeOfDay? picked = await showTimePicker( context: context, initialTime: time, builder: (cxt, child) { diff --git a/lib/ui/profile/add_update_family_member.dart b/lib/ui/profile/add_update_family_member.dart index 9a0bd66..6ad82d0 100644 --- a/lib/ui/profile/add_update_family_member.dart +++ b/lib/ui/profile/add_update_family_member.dart @@ -345,7 +345,7 @@ class _AddUpdateFamilyMemberState extends State { ), ); } else { - final DateTime? picked = + DateTime? picked = await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); if (picked != null && picked != selectedDate) { time = picked; diff --git a/lib/ui/profile/delete_family_member.dart b/lib/ui/profile/delete_family_member.dart index 58ec825..af4601d 100644 --- a/lib/ui/profile/delete_family_member.dart +++ b/lib/ui/profile/delete_family_member.dart @@ -141,7 +141,7 @@ class _DeleteFamilyMemberState extends State { ), ); } else { - final DateTime? picked = + DateTime? picked = await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); if (picked != null && picked != selectedDate) { time = picked; diff --git a/lib/ui/profile/dynamic_screens/dynamic_input_address_screen.dart b/lib/ui/profile/dynamic_screens/dynamic_input_address_screen.dart index c4dadd2..815db77 100644 --- a/lib/ui/profile/dynamic_screens/dynamic_input_address_screen.dart +++ b/lib/ui/profile/dynamic_screens/dynamic_input_address_screen.dart @@ -325,7 +325,7 @@ class _DynamicInputScreenState extends State { ), ); } else { - final DateTime? picked = + DateTime? picked = await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); if (picked != null && picked != selectedDate) { time = picked; diff --git a/lib/ui/profile/dynamic_screens/dynamic_input_basic_details_screen.dart b/lib/ui/profile/dynamic_screens/dynamic_input_basic_details_screen.dart index a279305..422d67b 100644 --- a/lib/ui/profile/dynamic_screens/dynamic_input_basic_details_screen.dart +++ b/lib/ui/profile/dynamic_screens/dynamic_input_basic_details_screen.dart @@ -336,7 +336,7 @@ class _DynamicInputScreenState extends State { ), ); } else { - final DateTime? picked = + DateTime? picked = await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); if (picked != null && picked != selectedDate) { time = picked; diff --git a/lib/ui/profile/profile_screen.dart b/lib/ui/profile/profile_screen.dart index cea9f11..8caf637 100644 --- a/lib/ui/profile/profile_screen.dart +++ b/lib/ui/profile/profile_screen.dart @@ -138,7 +138,7 @@ class _ProfileScreenState extends State { } void openGallery(bool isCamera) async { - final XFile? image = await _picker.pickImage(source: isCamera ? ImageSource.camera : ImageSource.gallery); + XFile? image = await _picker.pickImage(source: isCamera ? ImageSource.camera : ImageSource.gallery); if (image != null) { String img = base64.encode(await image!.readAsBytes()); diff --git a/lib/ui/screens/announcements/announcement_details.dart b/lib/ui/screens/announcements/announcement_details.dart index a8b2c2c..06af534 100644 --- a/lib/ui/screens/announcements/announcement_details.dart +++ b/lib/ui/screens/announcements/announcement_details.dart @@ -67,7 +67,7 @@ class _AnnouncementDetailsState extends State { void getRequestID() { if (currentPageNo == 0) { - final arguments = (ModalRoute.of(context)?.settings.arguments ?? {}) as Map; + Map arguments = (ModalRoute.of(context)?.settings.arguments ?? {}) as Map; currentPageNo = arguments["currentPageNo"]; rowID = arguments["rowID"]; getAnnouncementDetails(0, rowID); diff --git a/lib/ui/screens/pending_transactions/pending_transactions.dart b/lib/ui/screens/pending_transactions/pending_transactions.dart index 997ec0d..0a69c60 100644 --- a/lib/ui/screens/pending_transactions/pending_transactions.dart +++ b/lib/ui/screens/pending_transactions/pending_transactions.dart @@ -4,7 +4,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/pending_transactions_api_client.dart'; -import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/date_uitl.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.dart'; @@ -39,88 +38,74 @@ class _PendingTransactionsState extends State { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: Colors.white, - appBar: AppBarWidget( - context, - title: LocaleKeys.pendingTransactions.tr(), - ), - body: SingleChildScrollView( - child: Container( - width: double.infinity, - padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), - margin: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - children: [ - 12.height, - PopupMenuButton( - child: DynamicTextFieldWidget( - LocaleKeys.selectRequestType.tr(), - selectedFunction?.fUNCTIONPROMPT ?? "", - isEnable: false, - isPopup: true, - isInputTypeNum: true, - isReadOnly: false, - ).paddingOnly(bottom: 12), - itemBuilder: (_) => >[ - for (int i = 0; i < getPendingTransactionsFunctions!.length; i++) PopupMenuItem(child: Text(getPendingTransactionsFunctions![i].fUNCTIONPROMPT!), value: i), - ], - onSelected: (int popupIndex) { - selectedFunction = getPendingTransactionsFunctions[popupIndex]; - setState(() {}); - }), - 12.height, - DynamicTextFieldWidget( - LocaleKeys.dateFrom.tr(), - selectedDateFrom.toString().split(" ")[0], - suffixIconData: Icons.calendar_today, - isEnable: false, - onTap: () async { - selectedDateFrom = await _selectDate(context, DateTime.now()); - setState(() {}); - }, - ).paddingOnly(bottom: 12), - 12.height, - DynamicTextFieldWidget( - LocaleKeys.dateTo.tr(), - selectedDateTo.toString().split(" ")[0], - suffixIconData: Icons.calendar_today, - isEnable: false, - onTap: () async { - selectedDateTo = await _selectDate(context, DateTime.now()); + backgroundColor: Colors.white, + appBar: AppBarWidget( + context, + title: LocaleKeys.pendingTransactions.tr(), + ), + body: Column( + children: [ + Column( + children: [ + PopupMenuButton( + child: DynamicTextFieldWidget( + LocaleKeys.requestType.tr(), + selectedFunction?.fUNCTIONPROMPT ?? LocaleKeys.selectRequestType.tr(), + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, + ), + itemBuilder: (_) => >[ + for (int i = 0; i < getPendingTransactionsFunctions.length; i++) PopupMenuItem(child: Text(getPendingTransactionsFunctions![i].fUNCTIONPROMPT!), value: i), + ], + onSelected: (int popupIndex) { + selectedFunction = getPendingTransactionsFunctions[popupIndex]; setState(() {}); - }, - ).paddingOnly(bottom: 12), - ], - ), - ), - ), - bottomSheet: Container( - decoration: const BoxDecoration( - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), + }), + 12.height, + DynamicTextFieldWidget( + LocaleKeys.dateFrom.tr(), + selectedDateFrom.toString().split(" ")[0], + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + selectedDateFrom = await _selectDate(context, DateTime.now()); + setState(() {}); + }, + ), + 12.height, + DynamicTextFieldWidget( + LocaleKeys.dateTo.tr(), + selectedDateTo.toString().split(" ")[0], + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + selectedDateTo = await _selectDate(context, DateTime.now()); + setState(() {}); + }, + ) ], - ), - child: DefaultButton( + ).objectContainerView().expanded, + DefaultButton( LocaleKeys.submit.tr(), selectedFunction == null ? null : () async { - openRequestDetails(); + Navigator.pushNamed( + context, + AppRoutes.pendingTransactionsDetails, + arguments: { + "selectedFunctionID": selectedFunction?.fUNCTIONID, + "dateFrom": DateUtil.convertDateToString(selectedDateFrom), + "dateTo": DateUtil.convertDateToString(selectedDateTo) + }, + ); }) - .insideContainer, - )); + .insideContainer + ], + ), + ); } Future _selectDate(BuildContext context, DateTime selectedDate) async { @@ -144,8 +129,7 @@ class _PendingTransactionsState extends State { ), ); } else { - final DateTime? picked = - await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); + DateTime? picked = await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); if (picked != null && picked != selectedDate) { time = picked; } @@ -163,20 +147,4 @@ class _PendingTransactionsState extends State { Utils.handleException(ex, context, null); } } - - void openRequestDetails() async { - await Navigator.pushNamed(context, AppRoutes.pendingTransactionsDetails, - arguments: {"selectedFunctionID": selectedFunction?.fUNCTIONID, "dateFrom": DateUtil.convertDateToString(selectedDateFrom), "dateTo": DateUtil.convertDateToString(selectedDateTo)}); - } - - void getPendingReqDetails() async { - try { - Utils.showLoading(context); - getPendingTransactionsFunctions = await PendingTransactionsApiClient().getPendingReqFunctions(); - Utils.hideLoading(context); - } catch (ex) { - Utils.hideLoading(context); - Utils.handleException(ex, context, null); - } - } } diff --git a/lib/ui/screens/pending_transactions/pending_transactions_details.dart b/lib/ui/screens/pending_transactions/pending_transactions_details.dart index 2c8895a..0ff7f06 100644 --- a/lib/ui/screens/pending_transactions/pending_transactions_details.dart +++ b/lib/ui/screens/pending_transactions/pending_transactions_details.dart @@ -1,13 +1,13 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/pending_transactions_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/pending_transactions/get_pending_transactions_details.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; +import 'package:mohem_flutter_app/widgets/item_detail_view_widget.dart'; class PendingTransactionsDetails extends StatefulWidget { const PendingTransactionsDetails({Key? key}) : super(key: key); @@ -21,7 +21,7 @@ class _PendingTransactionsDetailsState extends State String dateFrom = ""; String dateTo = ""; - List getPendingTransactionsDetails = []; + List? getPendingTransactionsDetails; @override void initState() { @@ -30,7 +30,7 @@ class _PendingTransactionsDetailsState extends State void getFunctionID() { if (functionID == "") { - final arguments = (ModalRoute.of(context)?.settings.arguments ?? {}) as Map; + Map arguments = (ModalRoute.of(context)?.settings.arguments ?? {}) as Map; functionID = arguments["selectedFunctionID"].toString(); dateFrom = arguments["dateFrom"]; dateTo = arguments["dateTo"]; @@ -47,81 +47,27 @@ class _PendingTransactionsDetailsState extends State context, title: LocaleKeys.pendingTransactions.tr(), ), - body: getPendingTransactionsDetails.isNotEmpty - ? Container( - margin: const EdgeInsets.only(top: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Expanded( - child: ListView.separated( - physics: const BouncingScrollPhysics(), - shrinkWrap: true, - itemBuilder: (BuildContext context, int index) { - return Container( - width: double.infinity, - padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), - margin: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - "Created For ".toText14(color: MyColors.grey57Color), - getPendingTransactionsDetails[index].tRANSACTIONCREATEDFOR!.toText14(color: MyColors.grey57Color), - ], - ), - Column( - children: [ - getPendingTransactionsDetails[index].cREATIONDATE!.split(" ")[0].toText12(color: MyColors.grey70Color), - getPendingTransactionsDetails[index].cREATIONDATE!.split(" ")[1].toText12(color: MyColors.grey70Color), - ], - ), - ], - ), - Container( - child: Row( - children: [ - "Request Name: ".toText14(color: MyColors.grey57Color), - getPendingTransactionsDetails[index].uSERFUNCTIONNAME!.toText12(color: MyColors.grey57Color), - ], - ), - ), - Container( - padding: const EdgeInsets.only(top: 0.0), - child: Row( - children: [ - LocaleKeys.requestType.tr().toText14(color: MyColors.grey57Color), - getPendingTransactionsDetails[index].rEQUESTTYPE!.toText14(color: MyColors.redColor), - ], - ), - ), - ], - ), - ); - }, - separatorBuilder: (BuildContext context, int index) => 12.height, - itemCount: getPendingTransactionsDetails.length ?? 0)) - ], - ), - ) - : Utils.getNoDataWidget(context), + body: getPendingTransactionsDetails == null + ? const SizedBox() + : (getPendingTransactionsDetails!.isNotEmpty + ? ListView.separated( + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.all(21), + itemBuilder: (BuildContext context, int index) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + ItemDetailView(LocaleKeys.createdFor.tr(), getPendingTransactionsDetails![index].tRANSACTIONCREATEDFOR!), + ItemDetailView(LocaleKeys.creationDate.tr(), getPendingTransactionsDetails![index].cREATIONDATE!), + ItemDetailView(LocaleKeys.requestName.tr(), getPendingTransactionsDetails![index].uSERFUNCTIONNAME!), + ItemDetailView(LocaleKeys.requestType.tr(), getPendingTransactionsDetails![index].rEQUESTTYPE!), + ], + ).objectContainerView(); + }, + separatorBuilder: (BuildContext context, int index) => 12.height, + itemCount: getPendingTransactionsDetails!.length) + : Utils.getNoDataWidget(context)), ); } diff --git a/lib/widgets/circular_step_progress_bar.dart b/lib/widgets/circular_step_progress_bar.dart index 6789aed..b137dc6 100644 --- a/lib/widgets/circular_step_progress_bar.dart +++ b/lib/widgets/circular_step_progress_bar.dart @@ -173,7 +173,7 @@ class CircularStepProgressBar extends StatelessWidget { Widget build(BuildContext context) { // Print warning when arcSize greater than math.pi * 2 which causes steps to overlap if (arcSize > math.pi * 2) print("WARNING (step_progress_indicator): arcSize of CircularStepProgressBar is greater than 360° (math.pi * 2), this will cause some steps to overlap!"); - final TextDirection textDirection = Directionality.of(context); + TextDirection textDirection = Directionality.of(context); return LayoutBuilder( builder: (context, constraints) => SizedBox( @@ -232,7 +232,7 @@ class CircularStepProgressBar extends StatelessWidget { for (int step = 0; step < totalSteps; ++step) { // Consider max between selected and unselected case - final customSizeValue = math.max(customStepSize!(step, false), customStepSize!(step, true)); + var customSizeValue = math.max(customStepSize!(step, false), customStepSize!(step, true)); if (customSizeValue > currentMaxSize) { currentMaxSize = customSizeValue; } @@ -288,19 +288,19 @@ class _CircularIndicatorPainter implements CustomPainter { @override void paint(Canvas canvas, Size size) { - final w = size.width; - final h = size.height; + var w = size.width; + var h = size.height; // Step length is user-defined arcSize // divided by the total number of steps (each step same size) - final stepLength = arcSize / totalSteps; + var stepLength = arcSize / totalSteps; // Define general arc paint Paint paint = Paint() ..style = PaintingStyle.stroke ..strokeWidth = maxDefinedSize; - final rect = Rect.fromCenter( + var rect = Rect.fromCenter( // Rect created from the center of the widget center: Offset(w / 2, h / 2), // For both height and width, subtract maxDefinedSize to fit indicator inside the parent container @@ -313,7 +313,7 @@ class _CircularIndicatorPainter implements CustomPainter { } // Change color selected or unselected based on the circularDirection - final isClockwise = circularDirection == CircularDirection.clockwise; + var isClockwise = circularDirection == CircularDirection.clockwise; // Make a continuous arc without rendering all the steps when possible if (padding == 0 && customColor == null && customStepSize == null && roundedCap == null) { @@ -334,10 +334,10 @@ class _CircularIndicatorPainter implements CustomPainter { double stepAngle = isClockwise ? startingAngle - stepLength : startingAngle; for (; isClockwise ? step >= 0 : step < totalSteps; isClockwise ? stepAngle -= stepLength : stepAngle += stepLength, isClockwise ? --step : ++step) { // Check if the current step is selected or unselected - final isSelectedColor = _isSelectedColor(step, isClockwise); + var isSelectedColor = _isSelectedColor(step, isClockwise); // Size of the step - final indexStepSize = customStepSize != null + var indexStepSize = customStepSize != null // Consider step index inverted when counterclockwise ? customStepSize!(_indexOfStep(step, isClockwise), isSelectedColor) : isSelectedColor @@ -345,7 +345,7 @@ class _CircularIndicatorPainter implements CustomPainter { : unselectedStepSize ?? stepSize; // Use customColor if defined - final stepColor = customColor != null + var stepColor = customColor != null // Consider step index inverted when counterclockwise ? customColor!(_indexOfStep(step, isClockwise)) : isSelectedColor @@ -353,14 +353,14 @@ class _CircularIndicatorPainter implements CustomPainter { : unselectedColor!; // Apply stroke cap to each step - final hasStrokeCap = roundedCap != null ? roundedCap!(_indexOfStep(step, isClockwise), isSelectedColor) : false; - final strokeCap = hasStrokeCap ? StrokeCap.round : StrokeCap.butt; + var hasStrokeCap = roundedCap != null ? roundedCap!(_indexOfStep(step, isClockwise), isSelectedColor) : false; + var strokeCap = hasStrokeCap ? StrokeCap.round : StrokeCap.butt; // Remove extra size caused by rounded stroke cap // https://github.com/SandroMaglione/step-progress-indicator/issues/20#issue-786114745 - final extraCapSize = indexStepSize / 2; - final extraCapAngle = extraCapSize / (rect.width / 2); - final extraCapRemove = hasStrokeCap && removeRoundedCapExtraAngle; + var extraCapSize = indexStepSize / 2; + var extraCapAngle = extraCapSize / (rect.width / 2); + var extraCapRemove = hasStrokeCap && removeRoundedCapExtraAngle; // Draw arc steps of the indicator _drawArcOnCanvas( @@ -379,35 +379,35 @@ class _CircularIndicatorPainter implements CustomPainter { /// Draw optimized continuous indicator instead of multiple steps void _drawContinuousArc(Canvas canvas, Paint paint, Rect rect, bool isClockwise) { // Compute color of the selected and unselected bars - final firstStepColor = isClockwise ? selectedColor : unselectedColor; - final secondStepColor = !isClockwise ? selectedColor : unselectedColor; + var firstStepColor = isClockwise ? selectedColor : unselectedColor; + var secondStepColor = !isClockwise ? selectedColor : unselectedColor; // Selected and unselected step sizes if defined, otherwise use stepSize - final firstStepSize = isClockwise ? selectedStepSize ?? stepSize : unselectedStepSize ?? stepSize; - final secondStepSize = !isClockwise ? selectedStepSize ?? stepSize : unselectedStepSize ?? stepSize; + var firstStepSize = isClockwise ? selectedStepSize ?? stepSize : unselectedStepSize ?? stepSize; + var secondStepSize = !isClockwise ? selectedStepSize ?? stepSize : unselectedStepSize ?? stepSize; // Compute length and starting angle of the selected and unselected bars - final firstArcLength = arcSize * (currentStep / totalSteps); - final secondArcLength = arcSize - firstArcLength; + var firstArcLength = arcSize * (currentStep / totalSteps); + var secondArcLength = arcSize - firstArcLength; // firstArcStartingAngle = startingAngle - final secondArcStartingAngle = startingAngle + firstArcLength; + var secondArcStartingAngle = startingAngle + firstArcLength; // Apply stroke cap to both arcs // NOTE: For continuous circular indicator, it uses 0 and 1 as index to // apply the rounded cap - final firstArcStrokeCap = roundedCap != null + var firstArcStrokeCap = roundedCap != null ? isClockwise ? roundedCap!(0, true) : roundedCap!(1, false) : false; - final secondArcStrokeCap = roundedCap != null + var secondArcStrokeCap = roundedCap != null ? isClockwise ? roundedCap!(1, false) : roundedCap!(0, true) : false; - final firstCap = firstArcStrokeCap ? StrokeCap.round : StrokeCap.butt; - final secondCap = secondArcStrokeCap ? StrokeCap.round : StrokeCap.butt; + var firstCap = firstArcStrokeCap ? StrokeCap.round : StrokeCap.butt; + var secondCap = secondArcStrokeCap ? StrokeCap.round : StrokeCap.butt; // When clockwise, draw the second arc first and the first on top of it // Required when stroke cap is rounded to make the selected step on top of the unselected diff --git a/lib/widgets/location/Location.dart b/lib/widgets/location/Location.dart index 8456fd2..47e2238 100644 --- a/lib/widgets/location/Location.dart +++ b/lib/widgets/location/Location.dart @@ -93,7 +93,7 @@ class _Map { BitmapDescriptor? icon, VoidCallback? onTap, }) { - final MarkerId markerId = MarkerId(id); + MarkerId markerId = MarkerId(id); return Marker( icon: icon ?? BitmapDescriptor.defaultMarker, markerId: markerId, @@ -224,7 +224,7 @@ class _Map { if (bound == null) return; CameraUpdate camera = CameraUpdate.newLatLngBounds(bound, padding!); - final GoogleMapController controller = await mapController!.future; + GoogleMapController controller = await mapController!.future; controller.animateCamera(camera); } diff --git a/lib/widgets/nfc/nfc_reader_sheet.dart b/lib/widgets/nfc/nfc_reader_sheet.dart index 84397ba..53c0d4f 100644 --- a/lib/widgets/nfc/nfc_reader_sheet.dart +++ b/lib/widgets/nfc/nfc_reader_sheet.dart @@ -42,7 +42,7 @@ class _NfcLayoutState extends State { NfcManager.instance.startSession(onDiscovered: (NfcTag tag) async { print(tag.data); var f = MifareUltralight(tag: tag, identifier: tag.data["nfca"]["identifier"], type: 2, maxTransceiveLength: 252, timeout: 22); - final String identifier = f.identifier.map((e) => e.toRadixString(16).padLeft(2, '0')).join(''); + String identifier = f.identifier.map((e) => e.toRadixString(16).padLeft(2, '0')).join(''); // print(identifier); // => 0428fcf2255e81 nfcId = identifier; From c0ec2260e566991a28a5034457c3593072aae6bc Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Sun, 28 Aug 2022 11:23:07 +0300 Subject: [PATCH 19/40] mark attendance improvement. --- lib/ui/landing/today_attendance_screen.dart | 339 ++++++++++---------- lib/widgets/mark_attendance_widget.dart | 83 +++-- 2 files changed, 202 insertions(+), 220 deletions(-) diff --git a/lib/ui/landing/today_attendance_screen.dart b/lib/ui/landing/today_attendance_screen.dart index 83c3f06..cde099d 100644 --- a/lib/ui/landing/today_attendance_screen.dart +++ b/lib/ui/landing/today_attendance_screen.dart @@ -1,23 +1,16 @@ import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/material.dart'; import 'package:flutter_countdown_timer/flutter_countdown_timer.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:google_maps_flutter/google_maps_flutter.dart'; -import 'package:mohem_flutter_app/api/dashboard_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/date_uitl.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/generic_response_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/widgets/circular_step_progress_bar.dart'; -import 'package:mohem_flutter_app/widgets/location/Location.dart'; -import 'package:mohem_flutter_app/widgets/nfc/nfc_reader_sheet.dart'; -import 'package:mohem_flutter_app/widgets/qr_scanner_dialog.dart'; +import 'package:mohem_flutter_app/widgets/mark_attendance_widget.dart'; import 'package:nfc_manager/nfc_manager.dart'; import 'package:provider/provider.dart'; import 'package:wifi_iot/wifi_iot.dart'; @@ -183,62 +176,62 @@ class _TodayAttendanceScreenState extends State { ), ), //.expanded, - // MarkAttendanceWidget(model), - Container( - width: double.infinity, - decoration: BoxDecoration(borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), color: Colors.white), - // margin: EdgeInsets.only(top: 187 - 31), - padding: EdgeInsets.only(left: 21, right: 21, top: 24, bottom: 24), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - LocaleKeys.markAttendance.tr().toSectionHeading(), - LocaleKeys.selectMethodOfAttendance.tr().tr().toText11(color: Color(0xff535353)), - 24.height, - GridView( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - padding: EdgeInsets.zero, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8), - children: [ - if (isNfcEnabled) - attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () { - if (isNfcLocationEnabled) { - Location.getCurrentLocation((LatLng? latlng) { - performNfcAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); - }); - } else { - performNfcAttendance(model); - } - }), - if (isWifiEnabled) - attendanceMethod("Wifi", "assets/images/wufu.svg", isWifiEnabled, () { - if (isWifiLocationEnabled) { - Location.getCurrentLocation((LatLng? latlng) { - performWifiAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); - }); - } else { - performWifiAttendance(model); - } - // connectWifi(); - }), - if (isQrEnabled) - attendanceMethod("QR", "assets/images/ic_qr.svg", isQrEnabled, () async { - if (isQrLocationEnabled) { - Location.getCurrentLocation((LatLng? latlng) { - performQrCodeAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); - }); - } else { - performQrCodeAttendance(model); - } - // performQrCodeAttendance(model); - }), - ], - ) - ], - ), - ), + MarkAttendanceWidget(model, topPadding: 24), + // Container( + // width: double.infinity, + // decoration: BoxDecoration(borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), color: Colors.white), + // // margin: EdgeInsets.only(top: 187 - 31), + // padding: EdgeInsets.only(left: 21, right: 21, top: 24, bottom: 24), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // mainAxisSize: MainAxisSize.min, + // children: [ + // LocaleKeys.markAttendance.tr().toSectionHeading(), + // LocaleKeys.selectMethodOfAttendance.tr().tr().toText11(color: Color(0xff535353)), + // 24.height, + // GridView( + // physics: const NeverScrollableScrollPhysics(), + // shrinkWrap: true, + // padding: EdgeInsets.zero, + // gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8), + // children: [ + // if (isNfcEnabled) + // attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () { + // if (isNfcLocationEnabled) { + // Location.getCurrentLocation((LatLng? latlng) { + // performNfcAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + // }); + // } else { + // performNfcAttendance(model); + // } + // }), + // if (isWifiEnabled) + // attendanceMethod("Wifi", "assets/images/wufu.svg", isWifiEnabled, () { + // if (isWifiLocationEnabled) { + // Location.getCurrentLocation((LatLng? latlng) { + // performWifiAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + // }); + // } else { + // performWifiAttendance(model); + // } + // // connectWifi(); + // }), + // if (isQrEnabled) + // attendanceMethod("QR", "assets/images/ic_qr.svg", isQrEnabled, () async { + // if (isQrLocationEnabled) { + // Location.getCurrentLocation((LatLng? latlng) { + // performQrCodeAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + // }); + // } else { + // performQrCodeAttendance(model); + // } + // // performQrCodeAttendance(model); + // }), + // ], + // ) + // ], + // ), + // ), // Positioned( // top: 187 - 21, // child: Container( @@ -269,59 +262,59 @@ class _TodayAttendanceScreenState extends State { ); } - Future performNfcAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async { - if (isNfcLocationEnabled) { - print("nfc location enabled"); - } else { - print("nfc not location enabled"); - } - - showNfcReader(context, onNcfScan: (String? nfcId) async { - print(nfcId); - Utils.showLoading(context); - try { - GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 2, nfcValue: nfcId ?? "", isGpsRequired: isNfcLocationEnabled, lat: lat, long: lng); - bool status = await model.fetchAttendanceTracking(context); - Utils.hideLoading(context); - } catch (ex) { - print(ex); - Utils.hideLoading(context); - Utils.handleException(ex, context, (msg) { - Utils.confirmDialog(context, msg); - }); - } - }); - } - - Future performWifiAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async { - if (isWifiLocationEnabled) { - print("wifi location enabled"); - } else { - print("wifi not location enabled"); - } - - bool v = await WiFiForIoTPlugin.connect(AppState().mohemmWifiSSID ?? "", password: AppState().mohemmWifiPassword ?? "", joinOnce: true, security: NetworkSecurity.WPA, withInternet: false); - if (v) { - await WiFiForIoTPlugin.forceWifiUsage(true); - print("connected"); - Utils.showLoading(context); - try { - GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 3, nfcValue: "", isGpsRequired: isWifiLocationEnabled, lat: lat, long: lng); - bool status = await model.fetchAttendanceTracking(context); - Utils.hideLoading(context); - await closeWifiRequest(); - } catch (ex) { - print(ex); - await closeWifiRequest(); - Utils.hideLoading(context); - Utils.handleException(ex, context, (msg) { - Utils.confirmDialog(context, msg); - }); - } - } else { - Utils.confirmDialog(context, LocaleKeys.comeNearHMGWifi.tr()); - } - } + // Future performNfcAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async { + // if (isNfcLocationEnabled) { + // print("nfc location enabled"); + // } else { + // print("nfc not location enabled"); + // } + // + // showNfcReader(context, onNcfScan: (String? nfcId) async { + // print(nfcId); + // Utils.showLoading(context); + // try { + // GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 2, nfcValue: nfcId ?? "", isGpsRequired: isNfcLocationEnabled, lat: lat, long: lng); + // bool status = await model.fetchAttendanceTracking(context); + // Utils.hideLoading(context); + // } catch (ex) { + // print(ex); + // Utils.hideLoading(context); + // Utils.handleException(ex, context, (msg) { + // Utils.confirmDialog(context, msg); + // }); + // } + // }); + // } + // + // Future performWifiAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async { + // if (isWifiLocationEnabled) { + // print("wifi location enabled"); + // } else { + // print("wifi not location enabled"); + // } + // + // bool v = await WiFiForIoTPlugin.connect(AppState().mohemmWifiSSID ?? "", password: AppState().mohemmWifiPassword ?? "", joinOnce: true, security: NetworkSecurity.WPA, withInternet: false); + // if (v) { + // await WiFiForIoTPlugin.forceWifiUsage(true); + // print("connected"); + // Utils.showLoading(context); + // try { + // GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 3, nfcValue: "", isGpsRequired: isWifiLocationEnabled, lat: lat, long: lng); + // bool status = await model.fetchAttendanceTracking(context); + // Utils.hideLoading(context); + // await closeWifiRequest(); + // } catch (ex) { + // print(ex); + // await closeWifiRequest(); + // Utils.hideLoading(context); + // Utils.handleException(ex, context, (msg) { + // Utils.confirmDialog(context, msg); + // }); + // } + // } else { + // Utils.confirmDialog(context, LocaleKeys.comeNearHMGWifi.tr()); + // } + // } Future closeWifiRequest() async { await WiFiForIoTPlugin.forceWifiUsage(false); @@ -329,62 +322,62 @@ class _TodayAttendanceScreenState extends State { return v; } - Future performQrCodeAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async { - var qrCodeValue = await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => QrScannerDialog(), - ), - ); - if (qrCodeValue != null) { - print("qrCode: " + qrCodeValue); - Utils.showLoading(context); - try { - GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 1, isGpsRequired: isQrLocationEnabled, lat: lat, long: lng, QRValue: qrCodeValue); - bool status = await model.fetchAttendanceTracking(context); - Utils.hideLoading(context); - } catch (ex) { - print(ex); - Utils.hideLoading(context); - Utils.handleException(ex, context, (msg) { - Utils.confirmDialog(context, msg); - }); - } - } - } - - Widget attendanceMethod(String title, String image, bool isEnabled, VoidCallback onPress) => Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15), - gradient: const LinearGradient(transform: GradientRotation(.64), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [ - MyColors.gradiantEndColor, - MyColors.gradiantStartColor, - ]), - ), - clipBehavior: Clip.antiAlias, - child: Stack( - children: [ - Container( - padding: const EdgeInsets.only(left: 10, right: 10, top: 14, bottom: 14), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SvgPicture.asset( - image, - color: Colors.white, - ).expanded, - title.toText17(isBold: true, color: Colors.white), - ], - ), - ), - if (!isEnabled) - Container( - width: double.infinity, - height: double.infinity, - color: Colors.grey.withOpacity(0.7), - ) - ], - ), - ).onPress(onPress); + // Future performQrCodeAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async { + // var qrCodeValue = await Navigator.of(context).push( + // MaterialPageRoute( + // builder: (context) => QrScannerDialog(), + // ), + // ); + // if (qrCodeValue != null) { + // print("qrCode: " + qrCodeValue); + // Utils.showLoading(context); + // try { + // GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 1, isGpsRequired: isQrLocationEnabled, lat: lat, long: lng, QRValue: qrCodeValue); + // bool status = await model.fetchAttendanceTracking(context); + // Utils.hideLoading(context); + // } catch (ex) { + // print(ex); + // Utils.hideLoading(context); + // Utils.handleException(ex, context, (msg) { + // Utils.confirmDialog(context, msg); + // }); + // } + // } + // } + // + // Widget attendanceMethod(String title, String image, bool isEnabled, VoidCallback onPress) => Container( + // decoration: BoxDecoration( + // borderRadius: BorderRadius.circular(15), + // gradient: const LinearGradient(transform: GradientRotation(.64), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [ + // MyColors.gradiantEndColor, + // MyColors.gradiantStartColor, + // ]), + // ), + // clipBehavior: Clip.antiAlias, + // child: Stack( + // children: [ + // Container( + // padding: const EdgeInsets.only(left: 10, right: 10, top: 14, bottom: 14), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // SvgPicture.asset( + // image, + // color: Colors.white, + // ).expanded, + // title.toText17(isBold: true, color: Colors.white), + // ], + // ), + // ), + // if (!isEnabled) + // Container( + // width: double.infinity, + // height: double.infinity, + // color: Colors.grey.withOpacity(0.7), + // ) + // ], + // ), + // ).onPress(onPress); Widget commonStatusView(String title, String time) => Expanded( child: Column(mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/widgets/mark_attendance_widget.dart b/lib/widgets/mark_attendance_widget.dart index c534dee..449fd97 100644 --- a/lib/widgets/mark_attendance_widget.dart +++ b/lib/widgets/mark_attendance_widget.dart @@ -19,8 +19,9 @@ import 'package:wifi_iot/wifi_iot.dart'; class MarkAttendanceWidget extends StatefulWidget { DashboardProviderModel model; + double topPadding; - MarkAttendanceWidget(this.model, {Key? key}) : super(key: key); + MarkAttendanceWidget(this.model, {Key? key, this.topPadding = 0}) : super(key: key); @override _MarkAttendanceWidgetState createState() { @@ -70,9 +71,8 @@ class _MarkAttendanceWidgetState extends State { @override Widget build(BuildContext context) { return Container( - padding: EdgeInsets.only(left: 21, right: 21, bottom: 21), - decoration: BoxDecoration(borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), color: Colors.white), - + padding: EdgeInsets.only(left: 21, right: 21, bottom: 21, top: widget.topPadding), + decoration: const BoxDecoration(borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), color: Colors.white), width: double.infinity, child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -85,16 +85,16 @@ class _MarkAttendanceWidgetState extends State { padding: const EdgeInsets.only(bottom: 14, top: 21), gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8), children: [ - if (isNfcEnabled) - attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () { - if (isNfcLocationEnabled) { - Location.getCurrentLocation((LatLng? latlng) { - performNfcAttendance(widget.model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); - }); - } else { - performNfcAttendance(widget.model); - } - }), + // if (isNfcEnabled) + attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () { + if (isNfcLocationEnabled) { + Location.getCurrentLocation((LatLng? latlng) { + performNfcAttendance(widget.model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? ""); + }); + } else { + performNfcAttendance(widget.model); + } + }), if (isWifiEnabled) attendanceMethod("Wifi", "assets/images/wufu.svg", isWifiEnabled, () { if (isWifiLocationEnabled) { @@ -180,8 +180,7 @@ class _MarkAttendanceWidgetState extends State { Future closeWifiRequest() async { await WiFiForIoTPlugin.forceWifiUsage(false); - bool v = await WiFiForIoTPlugin.disconnect(); - return v; + return await WiFiForIoTPlugin.disconnect(); } Future performQrCodeAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async { @@ -210,40 +209,30 @@ class _MarkAttendanceWidgetState extends State { Widget attendanceMethod(String title, String image, bool isEnabled, VoidCallback onPress) => Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - gradient: const LinearGradient( - transform: GradientRotation(.64), - begin: Alignment.topRight, - end: Alignment.bottomLeft, - colors: [ - MyColors.gradiantEndColor, - MyColors.gradiantStartColor, - ], - ), + color: isEnabled ? null : Colors.grey.withOpacity(.5), + gradient: isEnabled + ? const LinearGradient( + transform: GradientRotation(.64), + begin: Alignment.topRight, + end: Alignment.bottomLeft, + colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ], + ) + : null, ), clipBehavior: Clip.antiAlias, - child: Stack( + padding: const EdgeInsets.only(left: 10, right: 10, top: 14, bottom: 14), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - padding: const EdgeInsets.only(left: 10, right: 10, top: 14, bottom: 14), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: SvgPicture.asset( - image, - color: Colors.white, - )), - title.toText17(isBold: true, color: Colors.white), - ], - ), - ), - if (!isEnabled) - Container( - width: double.infinity, - height: double.infinity, - color: Colors.grey.withOpacity(0.7), - ) + SvgPicture.asset(image, color: Colors.white).expanded, + title.toText17(isBold: true, color: Colors.white), ], ), - ).onPress(onPress); + ).onPress(() { + if (!isEnabled) return; + onPress(); + }); } From 169a9bcc600d1c71b581fe474d47784f0a913fdb Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Sun, 28 Aug 2022 12:28:39 +0300 Subject: [PATCH 20/40] leave balance cont. --- assets/langs/ar-SA.json | 6 ++ assets/langs/en-US.json | 6 ++ lib/api/leave_balance_api_client.dart | 34 +++++++ lib/config/routes.dart | 11 +++ lib/generated/codegen_loader.g.dart | 12 +++ lib/generated/locale_keys.g.dart | 6 ++ lib/ui/landing/widget/menus_widget.dart | 5 +- .../add_leave_balance_screen.dart | 51 ++++++++++ .../leave_balance/leave_balance_screen.dart | 95 +++++++++++++++++++ 9 files changed, 223 insertions(+), 3 deletions(-) create mode 100644 lib/api/leave_balance_api_client.dart create mode 100644 lib/ui/leave_balance/add_leave_balance_screen.dart create mode 100644 lib/ui/leave_balance/leave_balance_screen.dart diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 0c6ce54..da047f3 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -339,6 +339,12 @@ "pleaseSelectEmployeeForReplacement": "الرجاء تحديد موظف للاستبدال", "pleaseSelectAction": "الرجاء تحديد الإجراء", "pleaseSelectDate": "الرجاء تحديد التاريخ", + "absenceType": "نوع الغياب", + "absenceCategory": "فئة الغياب", + "days": "أيام", + "hours": "ساعات", + "approvalStatus": "حالة القبول", + "absenceStatus": "حالة الغياب", "profile": { "reset_password": { "label": "Reset Password", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 812fa49..ad1c8ee 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -339,6 +339,12 @@ "pleaseSelectEmployeeForReplacement": "Please select employee for replacement", "pleaseSelectAction": "Please select action", "pleaseSelectDate": "Please select date", + "absenceType": "Absence Type", + "absenceCategory": "Absence Category", + "days": "Days", + "hours": "Hours", + "approvalStatus": "Approval Status", + "absenceStatus": "Absence Status", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/api/leave_balance_api_client.dart b/lib/api/leave_balance_api_client.dart new file mode 100644 index 0000000..58158f9 --- /dev/null +++ b/lib/api/leave_balance_api_client.dart @@ -0,0 +1,34 @@ +import 'package:mohem_flutter_app/api/api_client.dart'; +import 'package:mohem_flutter_app/app_state/app_state.dart'; +import 'package:mohem_flutter_app/classes/consts.dart'; +import 'package:mohem_flutter_app/models/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/vacation_rule/get_vacation_rules_list_model.dart'; +import 'package:mohem_flutter_app/models/vacation_rule/vr_item_types_list_model.dart'; + +class LeaveBalanceApiClient { + static final LeaveBalanceApiClient _instance = LeaveBalanceApiClient._internal(); + + LeaveBalanceApiClient._internal(); + + factory LeaveBalanceApiClient() => _instance; + + Future> getAbsenceTransactions(int pSelectedResopID) async { + String url = "${ApiConsts.erpRest}GET_ABSENCE_TRANSACTIONS"; + Map postParams = {"P_PAGE_LIMIT": 50, "P_PAGE_NUM": 1, "P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": pSelectedResopID}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.getVacationRulesList ?? []; + }, url, postParams); + } + + Future> getVrItgetAbsenceAttendanceTypesemTypes() async { + String url = "${ApiConsts.erpRest}GET_ABSENCE_ATTENDANCE_TYPES"; + Map postParams = {}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.vrItemTypesList ?? []; + }, url, postParams); + } +} diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 91e4b56..a7fc29c 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -5,6 +5,8 @@ import 'package:mohem_flutter_app/ui/attendance/vacation_rule_screen.dart'; import 'package:mohem_flutter_app/ui/bottom_sheets/attendence_details_bottom_sheet.dart'; import 'package:mohem_flutter_app/ui/landing/dashboard_screen.dart'; import 'package:mohem_flutter_app/ui/landing/today_attendance_screen.dart'; +import 'package:mohem_flutter_app/ui/leave_balance/add_leave_balance_screen.dart'; +import 'package:mohem_flutter_app/ui/leave_balance/leave_balance_screen.dart'; import 'package:mohem_flutter_app/ui/login/forgot_password_screen.dart'; import 'package:mohem_flutter_app/ui/login/login_screen.dart'; import 'package:mohem_flutter_app/ui/login/new_password_screen.dart'; @@ -62,6 +64,10 @@ class AppRoutes { static const String itgDetail = "/itgDetail"; static const String itemHistory = "/itemHistory"; + // Leave Balance + static const String leaveBalance = "/leaveBalance"; + static const String addLeaveBalance = "/addLeaveBalance"; + static const String servicesMenuListScreen = "/servicesMenuListScreen"; static const String dynamicScreen = "/dynamicScreen"; static const String addDynamicInput = "/addDynamicInput"; @@ -126,6 +132,11 @@ class AppRoutes { itgDetail: (context) => ItgDetailScreen(), itemHistory: (context) => ItemHistoryScreen(), + // Leave Balance + + leaveBalance: (context) => LeaveBalance(), + addLeaveBalance: (context) => AddLeaveBalanceScreen(), + servicesMenuListScreen: (context) => ServicesMenuListScreen(), // workFromHome: (context) => WorkFromHomeScreen(), // addWorkFromHome: (context) => AddWorkFromHomeScreen(), diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 57323da..e77e32f 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -355,6 +355,12 @@ class CodegenLoader extends AssetLoader{ "pleaseSelectEmployeeForReplacement": "الرجاء تحديد موظف للاستبدال", "pleaseSelectAction": "الرجاء تحديد الإجراء", "pleaseSelectDate": "الرجاء تحديد التاريخ", + "absenceType": "نوع الغياب", + "absenceCategory": "فئة الغياب", + "days": "أيام", + "hours": "ساعات", + "approvalStatus": "حالة القبول", + "absenceStatus": "حالة الغياب", "profile": { "reset_password": { "label": "Reset Password", @@ -730,6 +736,12 @@ static const Map en_US = { "pleaseSelectEmployeeForReplacement": "Please select employee for replacement", "pleaseSelectAction": "Please select action", "pleaseSelectDate": "Please select date", + "absenceType": "Absence Type", + "absenceCategory": "Absence Category", + "days": "Days", + "hours": "Hours", + "approvalStatus": "Approval Status", + "absenceStatus": "Absence Status", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index d736c34..7e679fe 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -340,6 +340,12 @@ abstract class LocaleKeys { static const pleaseSelectEmployeeForReplacement = 'pleaseSelectEmployeeForReplacement'; static const pleaseSelectAction = 'pleaseSelectAction'; static const pleaseSelectDate = 'pleaseSelectDate'; + static const absenceType = 'absenceType'; + static const absenceCategory = 'absenceCategory'; + static const days = 'days'; + static const hours = 'hours'; + static const approvalStatus = 'approvalStatus'; + static const absenceStatus = 'absenceStatus'; static const profile_reset_password_label = 'profile.reset_password.label'; static const profile_reset_password_username = 'profile.reset_password.username'; static const profile_reset_password_password = 'profile.reset_password.password'; diff --git a/lib/ui/landing/widget/menus_widget.dart b/lib/ui/landing/widget/menus_widget.dart index e386295..529e649 100644 --- a/lib/ui/landing/widget/menus_widget.dart +++ b/lib/ui/landing/widget/menus_widget.dart @@ -46,8 +46,7 @@ class MenusWidget extends StatelessWidget { ) ], ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), - ).onPress(() async { - //await data.fetchWorkListCounter(context, showLoading: true); + ).onPress(() { Navigator.pushNamed(context, AppRoutes.workList); }), data.isMissingSwipeLoading @@ -102,7 +101,7 @@ class MenusWidget extends StatelessWidget { ], ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), ).onPress(() { - Navigator.pushNamed(context, AppRoutes.workList); + Navigator.pushNamed(context, AppRoutes.leaveBalance); }), data.isLeaveTicketBalanceLoading ? MenuShimmer().onPress(() { diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart new file mode 100644 index 0000000..f0b70f8 --- /dev/null +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -0,0 +1,51 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/api/leave_balance_api_client.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; +import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; + +class AddLeaveBalanceScreen extends StatefulWidget { + AddLeaveBalanceScreen({Key? key}) : super(key: key); + + @override + _AddLeaveBalanceScreenState createState() { + return _AddLeaveBalanceScreenState(); + } +} + +class _AddLeaveBalanceScreenState extends State { + @override + void initState() { + super.initState(); + getAbsenceAttendanceTypes(); + } + + void getAbsenceAttendanceTypes() async { + try { + Utils.showLoading(context); + var bac = await LeaveBalanceApiClient().getAbsenceTransactions(-999); + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + @override + void dispose() { + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBarWidget( + context, + title: LocaleKeys.leaveBalance.tr(), + ), + ); + } +} diff --git a/lib/ui/leave_balance/leave_balance_screen.dart b/lib/ui/leave_balance/leave_balance_screen.dart new file mode 100644 index 0000000..7dd4c29 --- /dev/null +++ b/lib/ui/leave_balance/leave_balance_screen.dart @@ -0,0 +1,95 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/api/leave_balance_api_client.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.dart'; +import 'package:mohem_flutter_app/extensions/int_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/widgets/app_bar_widget.dart'; +import 'package:mohem_flutter_app/widgets/item_detail_view_widget.dart'; + +class LeaveBalance extends StatefulWidget { + LeaveBalance({Key? key}) : super(key: key); + + @override + _LeaveBalanceState createState() { + return _LeaveBalanceState(); + } +} + +class _LeaveBalanceState extends State { + List list = []; + + @override + void initState() { + super.initState(); + getAbsenceTransactions(); + } + + @override + void dispose() { + super.dispose(); + } + + void getAbsenceTransactions() async { + try { + Utils.showLoading(context); + var bac = await LeaveBalanceApiClient().getAbsenceTransactions(-999); + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBarWidget( + context, + title: LocaleKeys.leaveBalance.tr(), + ), + body: list == null + ? const SizedBox() + : (list!.isEmpty + ? Utils.getNoDataWidget(context) + : ListView.separated( + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.all(21), + itemBuilder: (cxt, int parentIndex) => Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + ItemDetailView(LocaleKeys.startDateT.tr(), ""), + ItemDetailView(LocaleKeys.endDateT.tr(), ""), + ItemDetailView(LocaleKeys.absenceType.tr(), ""), + ItemDetailView(LocaleKeys.absenceCategory.tr(), ""), + ItemDetailView(LocaleKeys.days.tr(), ""), + ItemDetailView(LocaleKeys.hours.tr(), ""), + ItemDetailView(LocaleKeys.approvalStatus.tr(), ""), + ItemDetailView(LocaleKeys.absenceStatus.tr(), ""), + ], + ).objectContainerView(), + separatorBuilder: (cxt, index) => 12.height, + itemCount: list!.length + 1)), + floatingActionButton: Container( + height: 54, + width: 54, + decoration: const BoxDecoration( + shape: BoxShape.circle, + gradient: LinearGradient(transform: GradientRotation(.83), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ]), + ), + child: const Icon(Icons.add, color: Colors.white, size: 30), + ).onPress(() { + Navigator.pushNamed(context, AppRoutes.addLeaveBalance); + }), + ); + } +} From 8855eb7622fb1b7b1274bc65898b0d802c9c8cc2 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Sun, 28 Aug 2022 13:10:12 +0300 Subject: [PATCH 21/40] leave balance cont2. --- lib/api/leave_balance_api_client.dart | 12 +-- lib/main.dart | 2 - lib/models/generic_response_model.dart | 33 ++++++-- ...t_absence_attendance_types_list_model.dart | 24 ++++++ .../get_absence_transaction_list_model.dart | 80 +++++++++++++++++++ .../add_leave_balance_screen.dart | 5 +- .../leave_balance/leave_balance_screen.dart | 11 +-- 7 files changed, 147 insertions(+), 20 deletions(-) create mode 100644 lib/models/leave_balance/get_absence_attendance_types_list_model.dart create mode 100644 lib/models/leave_balance/get_absence_transaction_list_model.dart diff --git a/lib/api/leave_balance_api_client.dart b/lib/api/leave_balance_api_client.dart index 58158f9..d6f087b 100644 --- a/lib/api/leave_balance_api_client.dart +++ b/lib/api/leave_balance_api_client.dart @@ -2,8 +2,8 @@ import 'package:mohem_flutter_app/api/api_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; -import 'package:mohem_flutter_app/models/vacation_rule/get_vacation_rules_list_model.dart'; -import 'package:mohem_flutter_app/models/vacation_rule/vr_item_types_list_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/get_absence_attendance_types_list_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/get_absence_transaction_list_model.dart'; class LeaveBalanceApiClient { static final LeaveBalanceApiClient _instance = LeaveBalanceApiClient._internal(); @@ -12,23 +12,23 @@ class LeaveBalanceApiClient { factory LeaveBalanceApiClient() => _instance; - Future> getAbsenceTransactions(int pSelectedResopID) async { + Future> getAbsenceTransactions(int pSelectedResopID) async { String url = "${ApiConsts.erpRest}GET_ABSENCE_TRANSACTIONS"; Map postParams = {"P_PAGE_LIMIT": 50, "P_PAGE_NUM": 1, "P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": pSelectedResopID}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); - return responseData.getVacationRulesList ?? []; + return responseData.getAbsenceTransactionList ?? []; }, url, postParams); } - Future> getVrItgetAbsenceAttendanceTypesemTypes() async { + Future> getAbsenceAttendanceTypes() async { String url = "${ApiConsts.erpRest}GET_ABSENCE_ATTENDANCE_TYPES"; Map postParams = {}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); - return responseData.vrItemTypesList ?? []; + return responseData.getAbsenceAttendanceTypesList ?? []; }, url, postParams); } } diff --git a/lib/main.dart b/lib/main.dart index b1e74db..3ccb876 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,6 @@ import 'dart:io'; import 'package:easy_localization/easy_localization.dart'; - import 'package:flutter/material.dart'; import 'package:logger/logger.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; @@ -61,7 +60,6 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) { return Sizer( builder: (context, orientation, deviceType) { - print(AppState().postParamsObject?.toJson()); var obj = AppState().postParamsObject; obj?.languageID = EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2; AppState().setPostParamsModel(obj!); diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index 23026e3..3b60887 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -32,6 +32,8 @@ import 'package:mohem_flutter_app/models/get_schedule_shifts_details_list_model. import 'package:mohem_flutter_app/models/get_stamp_ms_notification_body_list_model.dart'; import 'package:mohem_flutter_app/models/get_stamp_ns_notification_body_list_model.dart'; import 'package:mohem_flutter_app/models/get_time_card_summary_list_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/get_absence_attendance_types_list_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/get_absence_transaction_list_model.dart'; import 'package:mohem_flutter_app/models/member_information_list_model.dart'; import 'package:mohem_flutter_app/models/member_login_list_model.dart'; import 'package:mohem_flutter_app/models/monthly_pay_slip/get_deductions_List_model.dart'; @@ -132,10 +134,10 @@ class GenericResponseModel { String? employeeQR; String? forgetPasswordTokenID; List? getAbsenceAttachmentsList; - List? getAbsenceAttendanceTypesList; + List? getAbsenceAttendanceTypesList; List? getAbsenceCollectionNotificationBodyList; List? getAbsenceDffStructureList; - List? getAbsenceTransactionList; + List? getAbsenceTransactionList; List? getAccrualBalancesList; List? getActionHistoryList; List? getAddressDffStructureList; @@ -671,7 +673,13 @@ class GenericResponseModel { employeeQR = json['EmployeeQR']; forgetPasswordTokenID = json['ForgetPasswordTokenID']; getAbsenceAttachmentsList = json['GetAbsenceAttachmentsList']; - getAbsenceAttendanceTypesList = json['GetAbsenceAttendanceTypesList']; + + if (json['GetAbsenceAttendanceTypesList'] != null) { + getAbsenceAttendanceTypesList = []; + json['GetAbsenceAttendanceTypesList'].forEach((v) { + getAbsenceAttendanceTypesList!.add(new GetAbsenceAttendanceTypesList.fromJson(v)); + }); + } if (json['GetAbsenceCollectionNotificationBodyList'] != null) { getAbsenceCollectionNotificationBodyList = []; @@ -681,7 +689,14 @@ class GenericResponseModel { } getAbsenceDffStructureList = json['GetAbsenceDffStructureList']; - getAbsenceTransactionList = json['GetAbsenceTransactionList']; + + if (json['GetAbsenceTransactionList'] != null) { + getAbsenceTransactionList = []; + json['GetAbsenceTransactionList'].forEach((v) { + getAbsenceTransactionList!.add(new GetAbsenceTransactionList.fromJson(v)); + }); + } + getAccrualBalancesList = json["GetAccrualBalancesList"] == null ? null : List.from(json["GetAccrualBalancesList"].map((x) => GetAccrualBalancesList.fromJson(x))); if (json['GetActionHistoryList'] != null) { @@ -1311,14 +1326,20 @@ class GenericResponseModel { data['EmployeeQR'] = this.employeeQR; data['ForgetPasswordTokenID'] = this.forgetPasswordTokenID; data['GetAbsenceAttachmentsList'] = this.getAbsenceAttachmentsList; - data['GetAbsenceAttendanceTypesList'] = this.getAbsenceAttendanceTypesList; + + if (this.getAbsenceAttendanceTypesList != null) { + data['GetAbsenceAttendanceTypesList'] = this.getAbsenceAttendanceTypesList!.map((v) => v.toJson()).toList(); + } if (this.getAbsenceCollectionNotificationBodyList != null) { data['GetAbsenceCollectionNotificationBodyList'] = this.getAbsenceCollectionNotificationBodyList!.map((v) => v.toJson()).toList(); } data['GetAbsenceDffStructureList'] = this.getAbsenceDffStructureList; - data['GetAbsenceTransactionList'] = this.getAbsenceTransactionList; + + if (this.getAbsenceTransactionList != null) { + data['GetAbsenceTransactionList'] = this.getAbsenceTransactionList!.map((v) => v.toJson()).toList(); + } data['GetAccrualBalancesList'] = this.getAccrualBalancesList; if (this.getActionHistoryList != null) { diff --git a/lib/models/leave_balance/get_absence_attendance_types_list_model.dart b/lib/models/leave_balance/get_absence_attendance_types_list_model.dart new file mode 100644 index 0000000..ccfb0dc --- /dev/null +++ b/lib/models/leave_balance/get_absence_attendance_types_list_model.dart @@ -0,0 +1,24 @@ +class GetAbsenceAttendanceTypesList { + int? aBSENCEATTENDANCETYPEID; + String? aBSENCEATTENDANCETYPENAME; + String? dESCFLEXCONTEXTCODE; + String? hOURSORDAYS; + + GetAbsenceAttendanceTypesList({this.aBSENCEATTENDANCETYPEID, this.aBSENCEATTENDANCETYPENAME, this.dESCFLEXCONTEXTCODE, this.hOURSORDAYS}); + + GetAbsenceAttendanceTypesList.fromJson(Map json) { + aBSENCEATTENDANCETYPEID = json['ABSENCE_ATTENDANCE_TYPE_ID']; + aBSENCEATTENDANCETYPENAME = json['ABSENCE_ATTENDANCE_TYPE_NAME']; + dESCFLEXCONTEXTCODE = json['DESC_FLEX_CONTEXT_CODE']; + hOURSORDAYS = json['HOURS_OR_DAYS']; + } + + Map toJson() { + Map data = new Map(); + data['ABSENCE_ATTENDANCE_TYPE_ID'] = this.aBSENCEATTENDANCETYPEID; + data['ABSENCE_ATTENDANCE_TYPE_NAME'] = this.aBSENCEATTENDANCETYPENAME; + data['DESC_FLEX_CONTEXT_CODE'] = this.dESCFLEXCONTEXTCODE; + data['HOURS_OR_DAYS'] = this.hOURSORDAYS; + return data; + } +} diff --git a/lib/models/leave_balance/get_absence_transaction_list_model.dart b/lib/models/leave_balance/get_absence_transaction_list_model.dart new file mode 100644 index 0000000..d61cf2f --- /dev/null +++ b/lib/models/leave_balance/get_absence_transaction_list_model.dart @@ -0,0 +1,80 @@ +class GetAbsenceTransactionList { + int? aBSENCEATTENDANCEID; + int? aBSENCEATTENDANCETYPEID; + String? aBSENCECATEGORY; + double? aBSENCEDAYS; + double? aBSENCEHOURS; + String? aBSENCESTATUS; + String? aBSENCETYPE; + String? aPPROVALSTATUS; + String? aTTACHMENTEXIST; + String? dELETEBUTTON; + String? eNDDATE; + int? fROMROWNUM; + int? nOOFROWS; + int? rOWNUM; + String? sTARTDATE; + int? tOROWNUM; + String? uPDATEBUTTON; + + GetAbsenceTransactionList( + {this.aBSENCEATTENDANCEID, + this.aBSENCEATTENDANCETYPEID, + this.aBSENCECATEGORY, + this.aBSENCEDAYS, + this.aBSENCEHOURS, + this.aBSENCESTATUS, + this.aBSENCETYPE, + this.aPPROVALSTATUS, + this.aTTACHMENTEXIST, + this.dELETEBUTTON, + this.eNDDATE, + this.fROMROWNUM, + this.nOOFROWS, + this.rOWNUM, + this.sTARTDATE, + this.tOROWNUM, + this.uPDATEBUTTON}); + + GetAbsenceTransactionList.fromJson(Map json) { + aBSENCEATTENDANCEID = json['ABSENCE_ATTENDANCE_ID']; + aBSENCEATTENDANCETYPEID = json['ABSENCE_ATTENDANCE_TYPE_ID']; + aBSENCECATEGORY = json['ABSENCE_CATEGORY']; + aBSENCEDAYS = json['ABSENCE_DAYS']; + aBSENCEHOURS = json['ABSENCE_HOURS']; + aBSENCESTATUS = json['ABSENCE_STATUS']; + aBSENCETYPE = json['ABSENCE_TYPE']; + aPPROVALSTATUS = json['APPROVAL_STATUS']; + aTTACHMENTEXIST = json['ATTACHMENT_EXIST']; + dELETEBUTTON = json['DELETE_BUTTON']; + eNDDATE = json['END_DATE']; + fROMROWNUM = json['FROM_ROW_NUM']; + nOOFROWS = json['NO_OF_ROWS']; + rOWNUM = json['ROW_NUM']; + sTARTDATE = json['START_DATE']; + tOROWNUM = json['TO_ROW_NUM']; + uPDATEBUTTON = json['UPDATE_BUTTON']; + } + + Map toJson() { + Map data = new Map(); + data['ABSENCE_ATTENDANCE_ID'] = this.aBSENCEATTENDANCEID; + data['ABSENCE_ATTENDANCE_TYPE_ID'] = this.aBSENCEATTENDANCETYPEID; + data['ABSENCE_CATEGORY'] = this.aBSENCECATEGORY; + data['ABSENCE_DAYS'] = this.aBSENCEDAYS; + data['ABSENCE_HOURS'] = this.aBSENCEHOURS; + data['ABSENCE_STATUS'] = this.aBSENCESTATUS; + data['ABSENCE_TYPE'] = this.aBSENCETYPE; + data['APPROVAL_STATUS'] = this.aPPROVALSTATUS; + data['ATTACHMENT_EXIST'] = this.aTTACHMENTEXIST; + data['DELETE_BUTTON'] = this.dELETEBUTTON; + data['END_DATE'] = this.eNDDATE; + data['FROM_ROW_NUM'] = this.fROMROWNUM; + data['NO_OF_ROWS'] = this.nOOFROWS; + data['ROW_NUM'] = this.rOWNUM; + data['START_DATE'] = this.sTARTDATE; + data['TO_ROW_NUM'] = this.tOROWNUM; + data['UPDATE_BUTTON'] = this.uPDATEBUTTON; + return data; + } +} diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index f0b70f8..b4278af 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/leave_balance_api_client.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; +import 'package:mohem_flutter_app/models/leave_balance/get_absence_attendance_types_list_model.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; class AddLeaveBalanceScreen extends StatefulWidget { @@ -15,6 +16,8 @@ class AddLeaveBalanceScreen extends StatefulWidget { } class _AddLeaveBalanceScreenState extends State { + List absenceList = []; + @override void initState() { super.initState(); @@ -24,7 +27,7 @@ class _AddLeaveBalanceScreenState extends State { void getAbsenceAttendanceTypes() async { try { Utils.showLoading(context); - var bac = await LeaveBalanceApiClient().getAbsenceTransactions(-999); + absenceList = await LeaveBalanceApiClient().getAbsenceAttendanceTypes(); Utils.hideLoading(context); setState(() {}); } catch (ex) { diff --git a/lib/ui/leave_balance/leave_balance_screen.dart b/lib/ui/leave_balance/leave_balance_screen.dart index 7dd4c29..8b00ce8 100644 --- a/lib/ui/leave_balance/leave_balance_screen.dart +++ b/lib/ui/leave_balance/leave_balance_screen.dart @@ -7,6 +7,7 @@ import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/extensions/int_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/leave_balance/get_absence_transaction_list_model.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/item_detail_view_widget.dart'; @@ -20,7 +21,7 @@ class LeaveBalance extends StatefulWidget { } class _LeaveBalanceState extends State { - List list = []; + List? absenceTransList; @override void initState() { @@ -36,7 +37,7 @@ class _LeaveBalanceState extends State { void getAbsenceTransactions() async { try { Utils.showLoading(context); - var bac = await LeaveBalanceApiClient().getAbsenceTransactions(-999); + absenceTransList = await LeaveBalanceApiClient().getAbsenceTransactions(-999); Utils.hideLoading(context); setState(() {}); } catch (ex) { @@ -53,9 +54,9 @@ class _LeaveBalanceState extends State { context, title: LocaleKeys.leaveBalance.tr(), ), - body: list == null + body: absenceTransList == null ? const SizedBox() - : (list!.isEmpty + : (absenceTransList!.isEmpty ? Utils.getNoDataWidget(context) : ListView.separated( physics: const BouncingScrollPhysics(), @@ -75,7 +76,7 @@ class _LeaveBalanceState extends State { ], ).objectContainerView(), separatorBuilder: (cxt, index) => 12.height, - itemCount: list!.length + 1)), + itemCount: absenceTransList!.length)), floatingActionButton: Container( height: 54, width: 54, From 028caf1379247bf1c7b166fa6f954648e26b2ea2 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 28 Aug 2022 22:11:35 +0300 Subject: [PATCH 22/40] Offers & Discounts implemented --- lib/api/offers_and_discounts_api_client.dart | 69 +++++ lib/config/routes.dart | 9 + lib/extensions/string_extensions.dart | 15 +- .../get_categories_list.dart | 49 ++++ .../offers_and_discounts/get_offers_list.dart | 96 +++++++ lib/provider/dashboard_provider_model.dart | 17 ++ lib/ui/landing/dashboard_screen.dart | 99 +++++-- .../fragments/items_for_sale.dart | 1 - .../offers_and_discounts_details.dart | 239 +++++++++++++++ .../offers_and_discounts_home.dart | 271 ++++++++++++++++++ .../shimmer/offers_shimmer_widget.dart | 46 +++ pubspec.yaml | 6 +- 12 files changed, 877 insertions(+), 40 deletions(-) create mode 100644 lib/api/offers_and_discounts_api_client.dart create mode 100644 lib/models/offers_and_discounts/get_categories_list.dart create mode 100644 lib/models/offers_and_discounts/get_offers_list.dart create mode 100644 lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart create mode 100644 lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart create mode 100644 lib/widgets/shimmer/offers_shimmer_widget.dart diff --git a/lib/api/offers_and_discounts_api_client.dart b/lib/api/offers_and_discounts_api_client.dart new file mode 100644 index 0000000..2f5714b --- /dev/null +++ b/lib/api/offers_and_discounts_api_client.dart @@ -0,0 +1,69 @@ +import 'dart:convert'; + +import 'package:mohem_flutter_app/api/api_client.dart'; +import 'package:mohem_flutter_app/app_state/app_state.dart'; +import 'package:mohem_flutter_app/classes/consts.dart'; +import 'package:mohem_flutter_app/models/offers_and_discounts/get_categories_list.dart'; +import 'package:mohem_flutter_app/models/offers_and_discounts/get_offers_list.dart'; + +class OffersAndDiscountsApiClient { + static final OffersAndDiscountsApiClient _instance = OffersAndDiscountsApiClient._internal(); + + OffersAndDiscountsApiClient._internal(); + + factory OffersAndDiscountsApiClient() => _instance; + + Future> getSaleCategories() async { + List getSaleCategoriesList = []; + + String url = "${ApiConsts.cocRest}Mohemm_ITG_GetCategories"; + Map postParams = {"EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER, "ItgPageSize": 100, "ItgPageNo": 1}; + + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject( + (response) { + final body = json.decode(response['Mohemm_ITG_ResponseItem']); + + GetCategoriesList getSaleCategoriesListObj = GetCategoriesList(); + getSaleCategoriesListObj.id = 0; + getSaleCategoriesListObj.categoryNameEn = "All"; + getSaleCategoriesListObj.categoryNameAr = "الجميع"; + getSaleCategoriesListObj.isActive = true; + getSaleCategoriesListObj.content = + ''; + + getSaleCategoriesList.add(getSaleCategoriesListObj); + + body['result']['data'].forEach((v) { + getSaleCategoriesList.add(GetCategoriesList.fromJson(v)); + }); + return getSaleCategoriesList; + }, + url, + postParams, + ); + } + + Future> getOffersList(int categoryID, int pageSize) async { + List getSaleCategoriesList = []; + + String url = "${ApiConsts.cocRest}GetOfferDiscountsConfigData"; + Map postParams = {"EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER, "ItgPageSize": pageSize, "ItgPageNo": 1, "ItgCategoryID": categoryID}; + + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject( + (response) { + final body = json.decode(response['Mohemm_ITG_ResponseItem']); + + final bodyData = json.decode(body['result']['data']); + + bodyData.forEach((v) { + getSaleCategoriesList.add(OffersListModel.fromJson(v)); + }); + return getSaleCategoriesList; + }, + url, + postParams, + ); + } +} diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 6928f09..270cb48 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -36,6 +36,8 @@ import 'package:mohem_flutter_app/ui/screens/mowadhafhi/mowadhafhi_hr_request.da import 'package:mohem_flutter_app/ui/screens/mowadhafhi/request_details.dart'; import 'package:mohem_flutter_app/ui/screens/my_requests/my_requests.dart'; import 'package:mohem_flutter_app/ui/screens/my_requests/new_request.dart'; +import 'package:mohem_flutter_app/ui/screens/offers_and_discounts/offers_and_discounts_details.dart'; +import 'package:mohem_flutter_app/ui/screens/offers_and_discounts/offers_and_discounts_home.dart'; import 'package:mohem_flutter_app/ui/screens/pending_transactions/pending_transactions.dart'; import 'package:mohem_flutter_app/ui/screens/pending_transactions/pending_transactions_details.dart'; import 'package:mohem_flutter_app/ui/screens/profile/profile_screen.dart'; @@ -117,6 +119,10 @@ class AppRoutes { static const String itemsForSaleDetail = "/itemsForSaleDetail"; static const String addNewItemForSale = "/addNewItemForSale"; + // Offers & Discounts + static const String offersAndDiscounts = "/offersAndDiscounts"; + static const String offersAndDiscountsDetails = "/offersAndDiscountsDetails"; + //Pay slip static const String monthlyPaySlip = "/monthlyPaySlip"; @@ -188,6 +194,9 @@ class AppRoutes { itemsForSaleDetail: (context) => ItemForSaleDetailPage(), addNewItemForSale: (context) => AddNewItemForSale(), + // Offers & Discounts + offersAndDiscounts: (context) => OffersAndDiscountsHome(), + offersAndDiscountsDetails: (context) => OffersAndDiscountsDetails(), //pay slip monthlyPaySlip: (context) => MonthlyPaySlipScreen(), diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index 869b61c..8f280b1 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -15,8 +15,9 @@ extension CapExtension on String { extension EmailValidator on String { Widget get toWidget => Text(this); - Widget toText10({Color? color, bool isBold = false}) => Text( + Widget toText10({Color? color, bool isBold = false, int maxLine = 0}) => Text( this, + maxLines: (maxLine > 0) ? maxLine : null, style: TextStyle(fontSize: 10, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.4), ); @@ -49,15 +50,21 @@ extension EmailValidator on String { style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.52, decoration: isUnderLine ? TextDecoration.underline : null), ); - Widget toText14({Color? color, bool isBold = false}) => Text( + Widget toText14({Color? color, bool isBold = false, int? maxlines}) => Text( this, + maxLines: maxlines, style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 14, letterSpacing: -0.48, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), ); - Widget toText16({Color? color, bool isBold = false, int? maxlines}) => Text( + Widget toText16({Color? color, bool isBold = false, int? maxlines, bool isUnderLine = false}) => Text( this, maxLines: maxlines, - style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 16, letterSpacing: -0.64, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), + style: TextStyle( + color: color ?? MyColors.darkTextColor, + fontSize: 16, + letterSpacing: -0.64, + fontWeight: isBold ? FontWeight.bold : FontWeight.w600, + decoration: isUnderLine ? TextDecoration.underline : TextDecoration.none), ); Widget toText17({Color? color, bool isBold = false}) => Text( diff --git a/lib/models/offers_and_discounts/get_categories_list.dart b/lib/models/offers_and_discounts/get_categories_list.dart new file mode 100644 index 0000000..502a850 --- /dev/null +++ b/lib/models/offers_and_discounts/get_categories_list.dart @@ -0,0 +1,49 @@ +class GetCategoriesList { + int? id; + String? categoryNameEn; + String? content; + String? categoryNameAr; + int? channelId; + bool? isActive; + int? pageSize; + int? pageNo; + int? languageId; + + GetCategoriesList({ + this.id, + this.categoryNameEn, + this.content, + this.categoryNameAr, + this.channelId, + this.isActive, + this.pageSize, + this.pageNo, + this.languageId, + }); + + GetCategoriesList.fromJson(Map json) { + id = json['id']; + categoryNameEn = json['categoryName_en']; + content = json['content']; + categoryNameAr = json['categoryName_ar']; + channelId = json['channelId']; + isActive = json['isActive']; + pageSize = json['pageSize']; + pageNo = json['pageNo']; + languageId = json['languageId']; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['categoryName_en'] = categoryNameEn; + data['content'] = content; + data['categoryName_ar'] = categoryNameAr; + data['channelId'] = channelId; + data['isActive'] = isActive; + data['pageSize'] = pageSize; + data['pageNo'] = pageNo; + data['languageId'] = languageId; + return data; + } +} diff --git a/lib/models/offers_and_discounts/get_offers_list.dart b/lib/models/offers_and_discounts/get_offers_list.dart new file mode 100644 index 0000000..2b08ba6 --- /dev/null +++ b/lib/models/offers_and_discounts/get_offers_list.dart @@ -0,0 +1,96 @@ +class OffersListModel { + String? title; + String? titleAR; + String? description; + String? descriptionAR; + String? startDate; + String? endDate; + String? logo; + String? bannerImage; + String? discount; + String? rowID; + String? categoryNameEn; + String? categoryNameAr; + String? categoryID; + String? isHasLocation; + String? created; + String? publishedDesc; + String? published; + String? expireAfter; + String? status; + String? isActive; + String? totalItems; + + OffersListModel( + {this.title, + this.titleAR, + this.description, + this.descriptionAR, + this.startDate, + this.endDate, + this.logo, + this.bannerImage, + this.discount, + this.rowID, + this.categoryNameEn, + this.categoryNameAr, + this.categoryID, + this.isHasLocation, + this.created, + this.publishedDesc, + this.published, + this.expireAfter, + this.status, + this.isActive, + this.totalItems}); + + OffersListModel.fromJson(Map json) { + title = json['Title']; + titleAR = json['Title_AR']; + description = json['Description']; + descriptionAR = json['Description_AR']; + startDate = json['Start Date']; + endDate = json['End Date']; + logo = json['Logo']; + bannerImage = json['Banner_Image']; + discount = json['Discount']; + rowID = json['rowID']; + categoryNameEn = json['categoryName_en']; + categoryNameAr = json['categoryName_ar']; + categoryID = json['categoryID']; + isHasLocation = json['IsHasLocation']; + created = json['created']; + publishedDesc = json['PublishedDesc']; + published = json['Published']; + expireAfter = json['ExpireAfter']; + status = json['Status']; + isActive = json['IsActive']; + totalItems = json['TotalItems']; + } + + Map toJson() { + final Map data = new Map(); + data['Title'] = this.title; + data['Title_AR'] = this.titleAR; + data['Description'] = this.description; + data['Description_AR'] = this.descriptionAR; + data['Start Date'] = this.startDate; + data['End Date'] = this.endDate; + data['Logo'] = this.logo; + data['Banner_Image'] = this.bannerImage; + data['Discount'] = this.discount; + data['rowID'] = this.rowID; + data['categoryName_en'] = this.categoryNameEn; + data['categoryName_ar'] = this.categoryNameAr; + data['categoryID'] = this.categoryID; + data['IsHasLocation'] = this.isHasLocation; + data['created'] = this.created; + data['PublishedDesc'] = this.publishedDesc; + data['Published'] = this.published; + data['ExpireAfter'] = this.expireAfter; + data['Status'] = this.status; + data['IsActive'] = this.isActive; + data['TotalItems'] = this.totalItems; + return data; + } +} diff --git a/lib/provider/dashboard_provider_model.dart b/lib/provider/dashboard_provider_model.dart index 511fc03..ddb245d 100644 --- a/lib/provider/dashboard_provider_model.dart +++ b/lib/provider/dashboard_provider_model.dart @@ -4,6 +4,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/dashboard_api_client.dart'; +import 'package:mohem_flutter_app/api/offers_and_discounts_api_client.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/main.dart'; @@ -13,6 +14,7 @@ import 'package:mohem_flutter_app/models/dashboard/itg_forms_model.dart'; import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart'; import 'package:mohem_flutter_app/models/dashboard/menus.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/offers_and_discounts/get_offers_list.dart'; /// Mix-in [DiagnosticableTreeMixin] to have access to [debugFillProperties] for the devtool // ignore: prefer_mixin @@ -41,6 +43,9 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { List? homeMenus; List? getMenuEntriesList; + //Offers And Discounts + List getOffersList = []; + //Attendance Tracking API's & Methods Future fetchAttendanceTracking(context) async { try { @@ -175,6 +180,18 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } } + void getCategoryOffersListAPI(BuildContext context) async { + try { + // Utils.showLoading(context); + getOffersList = await OffersAndDiscountsApiClient().getOffersList(0, 6); + notifyListeners(); + } catch (ex) { + // Utils.hideLoading(context); + notifyListeners(); + Utils.handleException(ex, context, null); + } + } + List parseMenus(List getMenuEntriesList) { List menus = []; for (int i = 0; i < getMenuEntriesList.length; i++) { diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index d5acce6..4d2cc38 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -13,11 +13,13 @@ 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/offers_and_discounts/get_offers_list.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/ui/landing/widget/app_drawer.dart'; import 'package:mohem_flutter_app/ui/landing/widget/menus_widget.dart'; import 'package:mohem_flutter_app/ui/landing/widget/services_widget.dart'; import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart'; +import 'package:mohem_flutter_app/widgets/shimmer/offers_shimmer_widget.dart'; import 'package:provider/provider.dart'; class DashboardScreen extends StatefulWidget { @@ -44,6 +46,7 @@ class _DashboardScreenState extends State { data.fetchMissingSwipe(context); data.fetchLeaveTicketBalance(context); data.fetchMenuEntries(); + data.getCategoryOffersListAPI(context); } @override @@ -267,7 +270,11 @@ class _DashboardScreenState extends State { ], ), ), - LocaleKeys.viewAllOffers.tr().toText12(isUnderLine: true), + InkWell( + onTap: () { + Navigator.pushNamed(context, AppRoutes.offersAndDiscounts); + }, + child: LocaleKeys.viewAllOffers.tr().toText12(isUnderLine: true)), ], ).paddingOnly(left: 21, right: 21), SizedBox( @@ -278,37 +285,50 @@ class _DashboardScreenState extends State { padding: const EdgeInsets.only(left: 21, right: 21, top: 13), scrollDirection: Axis.horizontal, itemBuilder: (cxt, index) { - return SizedBox( - width: 73, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - width: 73, - height: 73, - decoration: BoxDecoration( - borderRadius: const BorderRadius.all( - Radius.circular(100), - ), - border: Border.all(color: MyColors.lightGreyEDColor, width: 1), - ), - child: ClipRRect( - borderRadius: const BorderRadius.all( - Radius.circular(50), - ), - child: Image.network( - "https://play-lh.googleusercontent.com/NPo88ojmhah4HDiposucJmfQIop4z4xc8kqJK9ITO9o-yCab2zxIp7PPB_XPj2iUojo", - fit: BoxFit.cover, + return data.getOffersList.isNotEmpty + ? InkWell( + onTap: () { + navigateToDetails(data.getOffersList[index]); + }, + child: SizedBox( + width: 73, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: 73, + height: 73, + decoration: BoxDecoration( + borderRadius: const BorderRadius.all( + Radius.circular(100), + ), + border: Border.all(color: MyColors.lightGreyEDColor, width: 1), + ), + child: ClipRRect( + borderRadius: const BorderRadius.all( + Radius.circular(50), + ), + child: Hero( + tag: "ItemImage" + data.getOffersList[index].rowID!, + transitionOnUserGestures: true, + child: Image.network( + data.getOffersList[index].bannerImage!, + fit: BoxFit.contain, + ), + ), + ), + ), + 4.height, + Expanded( + child: AppState().isArabic(context) + ? data.getOffersList[index].titleAR!.toText12(isCenter: true, maxLine: 1) + : data.getOffersList[index].title!.toText12(isCenter: true, maxLine: 1), + ), + ], ), ), - ), - 4.height, - Expanded( - child: namesD[6 % (index + 1)].toText12(isCenter: true, maxLine: 2), - ), - ], - ), - ); + ) + : const OffersShimmerWidget(); }, separatorBuilder: (cxt, index) => 8.width, itemCount: 6), @@ -397,4 +417,23 @@ class _DashboardScreenState extends State { ), ); } + + void navigateToDetails(OffersListModel offersListModelObj) { + List getOffersDetailList = []; + getOffersDetailList.clear(); + int counter = 1; + + getOffersDetailList.add(offersListModelObj); + + data.getOffersList.forEach((element) { + if (counter <= 4) { + if (element.rowID != offersListModelObj.rowID) { + getOffersDetailList.add(element); + counter++; + } + } + }); + + Navigator.pushNamed(context, AppRoutes.offersAndDiscountsDetails, arguments: getOffersDetailList); + } } diff --git a/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart b/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart index ffb45e0..93ea8e9 100644 --- a/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart +++ b/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart @@ -195,7 +195,6 @@ class _ItemsForSaleFragmentState extends State { ), 10.height, getItemsForSaleList.title!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), - 10.height, getItemsForSaleList.description!.toText12(maxLine: 2, color: const Color(0xff535353)), 16.height, getItemsForSaleList.status!.toText14(isBold: true, color: getItemsForSaleList.status == 'Approved' ? MyColors.greenColor : MyColors.yellowColor), diff --git a/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart b/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart new file mode 100644 index 0000000..e5b7f11 --- /dev/null +++ b/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart @@ -0,0 +1,239 @@ +import 'dart:io'; +import 'dart:typed_data'; +import 'dart:ui' as ui; + +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_html/flutter_html.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:mohem_flutter_app/app_state/app_state.dart'; +import 'package:mohem_flutter_app/classes/colors.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/models/offers_and_discounts/get_offers_list.dart'; +import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:share/share.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class OffersAndDiscountsDetails extends StatefulWidget { + const OffersAndDiscountsDetails({Key? key}) : super(key: key); + + @override + State createState() => _OffersAndDiscountsDetailsState(); +} + +class _OffersAndDiscountsDetailsState extends State { + // late OffersListModel getOffersList; + late List getOffersList; + late ScrollController _scrollController; + + GlobalKey _globalKey = GlobalKey(); + + @override + void initState() { + _scrollController = ScrollController(); + super.initState(); + } + + @override + Widget build(BuildContext context) { + getOffersList = ModalRoute.of(context)?.settings.arguments as List; + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBarWidget( + context, + // title: LocaleKeys.mowadhafhiRequest.tr(), + title: "Offers & Discounts", + showHomeButton: true, + ), + body: SingleChildScrollView( + controller: _scrollController, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Hero( + tag: "ItemImage" + getOffersList[0].rowID!, + // transitionOnUserGestures: true, + child: RepaintBoundary( + key: _globalKey, + child: ClipRRect( + borderRadius: BorderRadius.circular(6), + child: Image.network( + getOffersList[0].bannerImage!, + fit: BoxFit.contain, + ), + ).paddingAll(12), + ), + ), + 8.height, + AppState().isArabic(context) + ? getOffersList[0].titleAR!.toText22(isBold: true, color: const Color(0xff2B353E)).center + : getOffersList[0].title!.toText22(isBold: true, color: const Color(0xff2B353E)).center, + Html( + data: AppState().isArabic(context) ? getOffersList[0].descriptionAR! : getOffersList[0].description ?? "", + onLinkTap: (String? url, RenderContext context, Map attributes, _) { + launchUrl(Uri.parse(url!)); + }, + ), + checkDate(getOffersList[0].endDate!).paddingOnly(left: 8), + 10.height, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + getOffersList[0].discount!.toText16(isBold: true), + InkWell( + onTap: () { + _shareOfferAsImage(); + }, + child: const Icon(Icons.share, color: MyColors.darkIconColor).paddingOnly(bottom: 4)) + ], + ).paddingOnly(left: 8, right: 8), + getOffersList[0].isHasLocation == "true" + ? InkWell( + onTap: () {}, + child: Row( + children: [const Icon(Icons.map_sharp, color: MyColors.darkIconColor).paddingOnly(bottom: 4), "Offer Location".toText16(isUnderLine: true).paddingOnly(left: 8)], + ).paddingOnly(left: 8, right: 8, top: 8), + ) + : 12.height, + ], + ), + ).paddingOnly(left: 21, right: 21, top: 21), + "Related Offers".toText22(isBold: true, color: const Color(0xff2B353E)).paddingAll(21.0), + GridView( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 162 / 266, crossAxisSpacing: 12, mainAxisSpacing: 12), + padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 21), + shrinkWrap: true, + primary: false, + physics: const ScrollPhysics(), + children: getItemsForSaleWidgets(), + ), + 50.height, + ], + ), + ), + ); + } + + void _shareOfferAsImage() async { + try { + RenderRepaintBoundary? boundary = _globalKey.currentContext?.findRenderObject() as RenderRepaintBoundary; + ui.Image? image = await boundary.toImage(pixelRatio: 3.0); + ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png); + Uint8List pngBytes = byteData!.buffer.asUint8List(); + + Directory tempDir = await getTemporaryDirectory(); + File file = await File('${tempDir.path}/${DateTime.now().toString()}.png').create(); + await file.writeAsBytes(pngBytes); + await Share.shareFiles([(file.path)], text: AppState().isArabic(context) ? getOffersList[0].titleAR : getOffersList[0].title); + } catch (ex) { + debugPrint(ex.toString()); + } + } + + void _scrollToTop() { + _scrollController.animateTo( + 0, + duration: const Duration(milliseconds: 500), + curve: Curves.linear, + ); + } + + List getItemsForSaleWidgets() { + List itemsList = []; + for (int i = 1; i < 5; i++) { + itemsList.add(getItemCard(getOffersList[i])); + } + return itemsList; + } + + Widget getItemCard(OffersListModel getOffersList) { + return InkWell( + onTap: () { + this.getOffersList[0] = getOffersList; + _scrollToTop(); + setState(() {}); + }, + child: Container( + padding: const EdgeInsets.all(10.0), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Hero( + tag: "ItemImage" + getOffersList.rowID!, + transitionOnUserGestures: true, + child: AspectRatio( + aspectRatio: 148 / 127, + child: ClipRRect( + borderRadius: BorderRadius.circular(6), + child: Image.network( + getOffersList.bannerImage!, + fit: BoxFit.contain, + ), + ), + ), + ), + 5.height, + getOffersList.title!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), + // Html( + // data: AppState().isArabic(context) ? getOffersList.descriptionAR! : getOffersList.description ?? "", + // // onLinkTap: (String? url, RenderContext context, Map attributes, _) { + // // launchUrl(Uri.parse(url!)); + // // } + // ), + getOffersList.description!.toText12(maxLine: 2, color: const Color(0xff535353)), + 16.height, + getOffersList.discount!.toText14(isBold: true, maxlines: 1), + 10.height, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [checkDate(getOffersList.endDate!), SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)], + ), + ], + ), + ), + ); + } + + void getOfferLocation() {} + + Widget checkDate(String endDate) { + DateTime endDateObj = DateFormat("yyyy-MM-dd").parse(endDate); + if (endDateObj.isAfter(DateTime.now())) { + return "Offer Valid".toText16(isBold: true, color: MyColors.greenColor); + } else { + return "Offer Expired".toText16(isBold: true, color: MyColors.redColor); + } + } +} diff --git a/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart b/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart new file mode 100644 index 0000000..bdf6ed5 --- /dev/null +++ b/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart @@ -0,0 +1,271 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:mohem_flutter_app/api/offers_and_discounts_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/config/routes.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/models/offers_and_discounts/get_categories_list.dart'; +import 'package:mohem_flutter_app/models/offers_and_discounts/get_offers_list.dart'; +import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; +import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; + +class OffersAndDiscountsHome extends StatefulWidget { + const OffersAndDiscountsHome({Key? key}) : super(key: key); + + @override + State createState() => _OffersAndDiscountsHomeState(); +} + +class _OffersAndDiscountsHomeState extends State { + List getCategoriesList = []; + List getOffersList = []; + + int currentCategoryID = 0; + + @override + void initState() { + getCategoriesListAPI(); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBarWidget( + context, + // title: LocaleKeys.mowadhafhiRequest.tr(), + title: "Offers & Discounts", + showHomeButton: true, + ), + body: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + DynamicTextFieldWidget( + "Search", + "Search Items", + isEnable: true, + suffixIconData: Icons.search, + isPopup: false, + lines: 1, + isInputTypeNum: false, + isReadOnly: false, + onChange: (String value) { + // _runFilter(value); + }, + ).paddingOnly(left: 21, right: 21, top: 21, bottom: 18), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + "Browse Categories".toText17(), + IconButton( + icon: const Icon(Icons.filter_alt_sharp, color: MyColors.darkIconColor, size: 28.0), + onPressed: () => Navigator.pop(context), + ), + ], + ).paddingOnly(left: 21, right: 21), + SizedBox( + height: 110.0, + child: getCategoriesList.isNotEmpty + ? ListView.separated( + shrinkWrap: true, + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), + scrollDirection: Axis.horizontal, + itemBuilder: (cxt, index) { + return AspectRatio( + aspectRatio: 1 / 1, + child: InkWell( + onTap: () { + setState(() { + currentCategoryID = getCategoriesList[index].id!; + // getItemsForSaleList.clear(); + // currentPageNo = 1; + // getItemsForSale(currentPageNo, currentCategoryID); + }); + }, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(15), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SvgPicture.string( + getCategoriesList[index].content!, + fit: BoxFit.contain, + width: 25, + height: 25, + ), + currentCategoryID == getCategoriesList[index].id ? const Icon(Icons.check_circle_rounded, color: MyColors.greenColor, size: 16.0) : Container(), + ], + ).expanded, + AppState().isArabic(context) ? getCategoriesList[index].categoryNameAr!.toText10(maxLine: 1) : getCategoriesList[index].categoryNameEn!.toText10(maxLine: 1) + ], + ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), + ), + ), + ); + }, + separatorBuilder: (cxt, index) => 12.width, + itemCount: getCategoriesList.length, + ) + : Container(), + ), + getOffersList.isNotEmpty + ? GridView( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 162 / 266, crossAxisSpacing: 12, mainAxisSpacing: 12), + padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 21), + shrinkWrap: true, + primary: false, + physics: const ScrollPhysics(), + children: getItemsForSaleWidgets(), + ) + : Utils.getNoDataWidget(context).paddingOnly(top: 50), + ], + ), + ), + ); + } + + List getItemsForSaleWidgets() { + List itemsList = []; + + for (var element in getOffersList) { + itemsList.add(getItemCard(element)); + } + + return itemsList; + } + + Widget getItemCard(OffersListModel getOffersList) { + return InkWell( + onTap: () { + navigateToDetails(getOffersList); + }, + child: Container( + padding: const EdgeInsets.all(10.0), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Hero( + tag: "ItemImage" + getOffersList.rowID!, + transitionOnUserGestures: true, + child: AspectRatio( + aspectRatio: 148 / 127, + child: ClipRRect( + borderRadius: BorderRadius.circular(6), + child: Image.network( + getOffersList.bannerImage!, + fit: BoxFit.contain, + ), + ), + ), + ), + 10.height, + AppState().isArabic(context) ? getOffersList.titleAR!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1) : getOffersList.title!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), + // Html( + // data: AppState().isArabic(context) ? getOffersList.descriptionAR! : getOffersList.description ?? "", + // // onLinkTap: (String? url, RenderContext context, Map attributes, _) { + // // launchUrl(Uri.parse(url!)); + // // } + // ), + getOffersList.description!.toText12(maxLine: 2, color: const Color(0xff535353)), + 16.height, + getOffersList.discount!.toText14(isBold: true, maxlines: 1), + 10.height, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [checkDate(getOffersList.endDate!), SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)], + ), + ], + ), + ), + ); + } + + void navigateToDetails(OffersListModel offersListModelObj) { + List getOffersDetailList = []; + getOffersDetailList.clear(); + int counter = 1; + + getOffersDetailList.add(offersListModelObj); + + getOffersList.forEach((element) { + if(counter <= 4) { + if(element.rowID != offersListModelObj.rowID) { + getOffersDetailList.add(element); + counter++; + } + } + }); + + Navigator.pushNamed(context, AppRoutes.offersAndDiscountsDetails, arguments: getOffersDetailList); + } + + Widget checkDate(String endDate) { + DateTime endDateObj = DateFormat("yyyy-MM-dd").parse(endDate); + if (endDateObj.isAfter(DateTime.now())) { + return "Offer Valid".toText14(isBold: true, color: MyColors.greenColor); + } else { + return "Offer Expired".toText14(isBold: true, color: MyColors.redColor); + } + } + + void getCategoriesListAPI() async { + try { + Utils.showLoading(context); + getCategoriesList = await OffersAndDiscountsApiClient().getSaleCategories(); + Utils.hideLoading(context); + setState(() {}); + getCategoryOffersListAPI(); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getCategoryOffersListAPI() async { + try { + Utils.showLoading(context); + getOffersList = await OffersAndDiscountsApiClient().getOffersList(currentCategoryID, 100); + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } +} diff --git a/lib/widgets/shimmer/offers_shimmer_widget.dart b/lib/widgets/shimmer/offers_shimmer_widget.dart new file mode 100644 index 0000000..8e090d1 --- /dev/null +++ b/lib/widgets/shimmer/offers_shimmer_widget.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/classes/colors.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'; + +class OffersShimmerWidget extends StatelessWidget { + const OffersShimmerWidget({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + child: SizedBox( + width: 73, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: 73, + height: 73, + decoration: BoxDecoration( + borderRadius: const BorderRadius.all( + Radius.circular(100), + ), + border: Border.all(color: MyColors.lightGreyEDColor, width: 1), + ), + child: ClipRRect( + borderRadius: const BorderRadius.all( + Radius.circular(50), + ), + child: Image.network( + "https://play-lh.googleusercontent.com/NPo88ojmhah4HDiposucJmfQIop4z4xc8kqJK9ITO9o-yCab2zxIp7PPB_XPj2iUojo", + fit: BoxFit.cover, + ).toShimmer(), + ), + ), + 8.height, + Container( + child: "Offers And Discounts".toText12(isCenter: true, maxLine: 1).toShimmer(), + ), + ], + ), + ), + ); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 8346c5c..fcd8742 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -71,12 +71,8 @@ dependencies: # flutter_barcode_scanner: ^2.0.0 qr_code_scanner: ^1.0.0 qr_flutter: ^4.0.0 - - - - - url_launcher: ^6.0.15 + share: 2.0.4 dev_dependencies: flutter_test: From 52438ce711821197727ea2c1bfa9cf43ae0f28da Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 29 Aug 2022 09:59:56 +0300 Subject: [PATCH 23/40] offers & discounts implemented --- lib/provider/dashboard_provider_model.dart | 2 + lib/ui/landing/dashboard_screen.dart | 108 +++++++++++---------- 2 files changed, 58 insertions(+), 52 deletions(-) diff --git a/lib/provider/dashboard_provider_model.dart b/lib/provider/dashboard_provider_model.dart index ddb245d..289ab33 100644 --- a/lib/provider/dashboard_provider_model.dart +++ b/lib/provider/dashboard_provider_model.dart @@ -44,6 +44,7 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { List? getMenuEntriesList; //Offers And Discounts + bool isOffersLoading = true; List getOffersList = []; //Attendance Tracking API's & Methods @@ -184,6 +185,7 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { try { // Utils.showLoading(context); getOffersList = await OffersAndDiscountsApiClient().getOffersList(0, 6); + isOffersLoading = false; notifyListeners(); } catch (ex) { // Utils.hideLoading(context); diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 4d2cc38..3630660 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -277,61 +277,65 @@ class _DashboardScreenState extends State { child: LocaleKeys.viewAllOffers.tr().toText12(isUnderLine: true)), ], ).paddingOnly(left: 21, right: 21), - SizedBox( - height: 103 + 33, - child: ListView.separated( - shrinkWrap: true, - physics: const BouncingScrollPhysics(), - padding: const EdgeInsets.only(left: 21, right: 21, top: 13), - scrollDirection: Axis.horizontal, - itemBuilder: (cxt, index) { - return data.getOffersList.isNotEmpty - ? InkWell( - onTap: () { - navigateToDetails(data.getOffersList[index]); - }, - child: SizedBox( - width: 73, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - width: 73, - height: 73, - decoration: BoxDecoration( - borderRadius: const BorderRadius.all( - Radius.circular(100), - ), - border: Border.all(color: MyColors.lightGreyEDColor, width: 1), - ), - child: ClipRRect( - borderRadius: const BorderRadius.all( - Radius.circular(50), - ), - child: Hero( - tag: "ItemImage" + data.getOffersList[index].rowID!, - transitionOnUserGestures: true, - child: Image.network( - data.getOffersList[index].bannerImage!, - fit: BoxFit.contain, + Consumer( + builder: (context, model, child) { + return SizedBox( + height: 103 + 33, + child: ListView.separated( + shrinkWrap: true, + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.only(left: 21, right: 21, top: 13), + scrollDirection: Axis.horizontal, + itemBuilder: (cxt, index) { + return model.isOffersLoading + ? const OffersShimmerWidget() + : InkWell( + onTap: () { + navigateToDetails(data.getOffersList[index]); + }, + child: SizedBox( + width: 73, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: 73, + height: 73, + decoration: BoxDecoration( + borderRadius: const BorderRadius.all( + Radius.circular(100), + ), + border: Border.all(color: MyColors.lightGreyEDColor, width: 1), + ), + child: ClipRRect( + borderRadius: const BorderRadius.all( + Radius.circular(50), + ), + child: Hero( + tag: "ItemImage" + data.getOffersList[index].rowID!, + transitionOnUserGestures: true, + child: Image.network( + data.getOffersList[index].bannerImage!, + fit: BoxFit.contain, + ), + ), ), ), - ), - ), - 4.height, - Expanded( - child: AppState().isArabic(context) - ? data.getOffersList[index].titleAR!.toText12(isCenter: true, maxLine: 1) - : data.getOffersList[index].title!.toText12(isCenter: true, maxLine: 1), + 4.height, + Expanded( + child: AppState().isArabic(context) + ? data.getOffersList[index].titleAR!.toText12(isCenter: true, maxLine: 1) + : data.getOffersList[index].title!.toText12(isCenter: true, maxLine: 1), + ), + ], ), - ], - ), - ), - ) - : const OffersShimmerWidget(); - }, - separatorBuilder: (cxt, index) => 8.width, - itemCount: 6), + ), + ); + }, + separatorBuilder: (cxt, index) => 8.width, + itemCount: 6), + ); + }, ), ], ), From 7c0589ef323c3363b45e2ca3d86f89c614417bcc Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 29 Aug 2022 10:15:41 +0300 Subject: [PATCH 24/40] Announcement details fixes --- lib/api/pending_transactions_api_client.dart | 15 +++++++++++++++ .../announcements/announcement_details.dart | 6 +----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/api/pending_transactions_api_client.dart b/lib/api/pending_transactions_api_client.dart index b8ddd60..44b2363 100644 --- a/lib/api/pending_transactions_api_client.dart +++ b/lib/api/pending_transactions_api_client.dart @@ -1,7 +1,10 @@ +import 'dart:convert'; + import 'package:mohem_flutter_app/api/api_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/get_announcement_details.dart'; import 'package:mohem_flutter_app/models/pending_transactions/get_pending_transactions_details.dart'; import 'package:mohem_flutter_app/models/pending_transactions/get_req_functions.dart'; @@ -45,4 +48,16 @@ class PendingTransactionsApiClient { return responseData.mohemmITGResponseItem ?? ""; }, url, postParams); } + + Future getAnnouncementDetails(int itgAwarenessID, int itgPageNo, int itgRowID) async { + String url = "${ApiConsts.cocRest}GetAnnouncementDiscountsConfigData"; + Map postParams = {"EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER.toString(), "ItgAwarenessID": itgAwarenessID, "ItgPageNo": itgPageNo, "ItgPageSize": 5, "ItgRowID": itgRowID}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + var jsonDecodedData = jsonDecode(jsonDecode(responseData.mohemmITGResponseItem!)['result']['data']); + return GetAnnouncementDetails.fromJson(jsonDecodedData[0]); + }, url, postParams); + } + } diff --git a/lib/ui/screens/announcements/announcement_details.dart b/lib/ui/screens/announcements/announcement_details.dart index 3b11cdf..c9645ec 100644 --- a/lib/ui/screens/announcements/announcement_details.dart +++ b/lib/ui/screens/announcements/announcement_details.dart @@ -106,11 +106,7 @@ class _AnnouncementDetailsState extends State { Future getAnnouncementDetails(int itgAwarenessID, int itgRowID) async { try { Utils.showLoading(context); - jsonResponse = await PendingTransactionsApiClient().getAnnouncements(itgAwarenessID, currentPageNo, itgRowID); - // todo '@haroon' move below post processing code to above method and get exact model which you need, - - var jsonDecodedData = jsonDecode(jsonDecode(jsonResponse)['result']['data']); - getAnnouncementDetailsObj = GetAnnouncementDetails.fromJson(jsonDecodedData[0]); + getAnnouncementDetailsObj = await PendingTransactionsApiClient().getAnnouncementDetails(itgAwarenessID, currentPageNo, itgRowID); Utils.hideLoading(context); setState(() {}); } catch (ex) { From a14103b859aff937d72ae2ba4463eb249e5b446e Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 29 Aug 2022 10:17:59 +0300 Subject: [PATCH 25/40] leave balance cont3. --- lib/api/leave_balance_api_client.dart | 11 + lib/models/generic_response_model.dart | 138 +++++++------ .../get_absence_dff_structure_list_model.dart | 193 ++++++++++++++++++ .../add_leave_balance_screen.dart | 15 ++ 4 files changed, 292 insertions(+), 65 deletions(-) create mode 100644 lib/models/leave_balance/get_absence_dff_structure_list_model.dart diff --git a/lib/api/leave_balance_api_client.dart b/lib/api/leave_balance_api_client.dart index d6f087b..186c730 100644 --- a/lib/api/leave_balance_api_client.dart +++ b/lib/api/leave_balance_api_client.dart @@ -3,6 +3,7 @@ import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_attendance_types_list_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/get_absence_dff_structure_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_transaction_list_model.dart'; class LeaveBalanceApiClient { @@ -31,4 +32,14 @@ class LeaveBalanceApiClient { return responseData.getAbsenceAttendanceTypesList ?? []; }, url, postParams); } + + Future> getAbsenceDffStructure(String pDescFlexContextCode, String pFunctionName, int pSelectedResopID) async { + String url = "${ApiConsts.erpRest}GET_ABSENCE_DFF_STRUCTURE"; + Map postParams = {"P_DESC_FLEX_CONTEXT_CODE": pDescFlexContextCode, "P_FUNCTION_NAME": pFunctionName, "P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": pSelectedResopID}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.getAbsenceDffStructureList ?? []; + }, url, postParams); + } } diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index 3b60887..219a80b 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -33,6 +33,7 @@ import 'package:mohem_flutter_app/models/get_stamp_ms_notification_body_list_mod import 'package:mohem_flutter_app/models/get_stamp_ns_notification_body_list_model.dart'; import 'package:mohem_flutter_app/models/get_time_card_summary_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_attendance_types_list_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/get_absence_dff_structure_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_transaction_list_model.dart'; import 'package:mohem_flutter_app/models/member_information_list_model.dart'; import 'package:mohem_flutter_app/models/member_login_list_model.dart'; @@ -136,7 +137,7 @@ class GenericResponseModel { List? getAbsenceAttachmentsList; List? getAbsenceAttendanceTypesList; List? getAbsenceCollectionNotificationBodyList; - List? getAbsenceDffStructureList; + List? getAbsenceDffStructureList; List? getAbsenceTransactionList; List? getAccrualBalancesList; List? getActionHistoryList; @@ -642,13 +643,13 @@ class GenericResponseModel { if (json['AddAttSuccessList'] != null) { addAttSuccessList = []; json['AddAttSuccessList'].forEach((v) { - addAttSuccessList!.add(new AddAttSuccessList.fromJson(v)); + addAttSuccessList!.add(AddAttSuccessList.fromJson(v)); }); } - addAttachmentList = json['AddAttachment_List'] != null ? new AddAttachmentList.fromJson(json['AddAttachment_List']) : null; + addAttachmentList = json['AddAttachment_List'] != null ? AddAttachmentList.fromJson(json['AddAttachment_List']) : null; bCDomain = json['BC_Domain']; bCLogo = json['BC_Logo']; - basicMemberInformation = json['BasicMemberInformation'] != null ? new BasicMemberInformationModel.fromJson(json['BasicMemberInformation']) : null; + basicMemberInformation = json['BasicMemberInformation'] != null ? BasicMemberInformationModel.fromJson(json['BasicMemberInformation']) : null; businessCardPrivilege = json['BusinessCardPrivilege']; calculateAbsenceDuration = json['CalculateAbsenceDuration']; cancelHRTransactionLIst = json['CancelHRTransactionLIst']; @@ -662,11 +663,11 @@ class GenericResponseModel { if (json['CountryList'] != null) { countryList = []; json['CountryList'].forEach((v) { - countryList!.add(new GetCountriesListModel.fromJson(v)); + countryList!.add(GetCountriesListModel.fromJson(v)); }); } - createVacationRuleList = json['CreateVacationRuleList'] != null ? new CreateVacationRuleList.fromJson(json['CreateVacationRuleList']) : null; + createVacationRuleList = json['CreateVacationRuleList'] != null ? CreateVacationRuleList.fromJson(json['CreateVacationRuleList']) : null; deleteAttachmentList = json['DeleteAttachmentList']; deleteVacationRuleList = json['DeleteVacationRuleList']; disableSessionList = json['DisableSessionList']; @@ -677,23 +678,28 @@ class GenericResponseModel { if (json['GetAbsenceAttendanceTypesList'] != null) { getAbsenceAttendanceTypesList = []; json['GetAbsenceAttendanceTypesList'].forEach((v) { - getAbsenceAttendanceTypesList!.add(new GetAbsenceAttendanceTypesList.fromJson(v)); + getAbsenceAttendanceTypesList!.add(GetAbsenceAttendanceTypesList.fromJson(v)); }); } if (json['GetAbsenceCollectionNotificationBodyList'] != null) { getAbsenceCollectionNotificationBodyList = []; json['GetAbsenceCollectionNotificationBodyList'].forEach((v) { - getAbsenceCollectionNotificationBodyList!.add(new GetAbsenceCollectionNotificationBodyList.fromJson(v)); + getAbsenceCollectionNotificationBodyList!.add(GetAbsenceCollectionNotificationBodyList.fromJson(v)); }); } - getAbsenceDffStructureList = json['GetAbsenceDffStructureList']; + if (json['GetAbsenceDffStructureList'] != null) { + getAbsenceDffStructureList = []; + json['GetAbsenceDffStructureList'].forEach((v) { + getAbsenceDffStructureList!.add(GetAbsenceDffStructureList.fromJson(v)); + }); + } if (json['GetAbsenceTransactionList'] != null) { getAbsenceTransactionList = []; json['GetAbsenceTransactionList'].forEach((v) { - getAbsenceTransactionList!.add(new GetAbsenceTransactionList.fromJson(v)); + getAbsenceTransactionList!.add(GetAbsenceTransactionList.fromJson(v)); }); } @@ -709,7 +715,7 @@ class GenericResponseModel { if (json['GetAddressDffStructureList'] != null) { getAddressDffStructureList = []; json['GetAddressDffStructureList'].forEach((v) { - getAddressDffStructureList!.add(new GetAddressDffStructureList.fromJson(v)); + getAddressDffStructureList!.add(GetAddressDffStructureList.fromJson(v)); }); } getAddressNotificationBodyList = json['GetAddressNotificationBodyList']; @@ -717,41 +723,41 @@ class GenericResponseModel { if (json['GetApprovesList'] != null) { getApprovesList = []; json['GetApprovesList'].forEach((v) { - getApprovesList!.add(new GetApprovesList.fromJson(v)); + getApprovesList!.add(GetApprovesList.fromJson(v)); }); } if (json['GetAttachementList'] != null) { getAttachementList = []; json['GetAttachementList'].forEach((v) { - getAttachementList!.add(new GetAttachementList.fromJson(v)); + getAttachementList!.add(GetAttachementList.fromJson(v)); }); } getAttendanceTrackingList = json["GetAttendanceTrackingList"] == null ? null : GetAttendanceTracking.fromMap(json["GetAttendanceTrackingList"]); if (json['GetBasicDetColsStructureList'] != null) { getBasicDetColsStructureList = []; json['GetBasicDetColsStructureList'].forEach((v) { - getBasicDetColsStructureList!.add(new GetBasicDetColsStructureList.fromJson(v)); + getBasicDetColsStructureList!.add(GetBasicDetColsStructureList.fromJson(v)); }); } // getBasicDetDffStructureList = json['GetBasicDetDffStructureList']; if (json['GetBasicDetDffStructureList'] != null) { getBasicDetDffStructureList = []; json['GetBasicDetDffStructureList'].forEach((v) { - getBasicDetDffStructureList!.add(new GetBasicDetDffStructureList.fromJson(v)); + getBasicDetDffStructureList!.add(GetBasicDetDffStructureList.fromJson(v)); }); } if (json['GetContactDffStructureList'] != null) { getContactDffStructureList = []; json['GetContactDffStructureList'].forEach((v) { - getContactDffStructureList!.add(new GetContactDffStructureList.fromJson(v)); + getContactDffStructureList!.add(GetContactDffStructureList.fromJson(v)); }); } if (json['GetBasicDetNtfBodyList'] != null) { getBasicDetNtfBodyList = []; json['GetBasicDetNtfBodyList'].forEach((v) { - getBasicDetNtfBodyList!.add(new GetBasicDetNtfBodyList.fromJson(v)); + getBasicDetNtfBodyList!.add(GetBasicDetNtfBodyList.fromJson(v)); }); } @@ -766,13 +772,13 @@ class GenericResponseModel { if (json['GetContactDetailsList'] != null) { getContactDetailsList = []; json['GetContactDetailsList'].forEach((v) { - getContactDetailsList!.add(new GetContactDetailsList.fromJson(v)); + getContactDetailsList!.add(GetContactDetailsList.fromJson(v)); }); } if (json['GetContactColsStructureList'] != null) { getContactColsStructureList = []; json['GetContactColsStructureList'].forEach((v) { - getContactColsStructureList!.add(new GetContactColsStructureList.fromJson(v)); + getContactColsStructureList!.add(GetContactColsStructureList.fromJson(v)); }); } getContactNotificationBodyList = json["GetContactNotificationBodyList"] == null ? null : GetContactNotificationBodyList.fromJson(json["GetContactNotificationBodyList"]); @@ -780,21 +786,21 @@ class GenericResponseModel { if (json['GetCountriesList'] != null) { getCountriesList = []; json['GetCountriesList'].forEach((v) { - getCountriesList!.add(new GetCountriesListModel.fromJson(v)); + getCountriesList!.add(GetCountriesListModel.fromJson(v)); }); } if (json['GetDayHoursTypeDetailsList'] != null) { getDayHoursTypeDetailsList = []; json['GetDayHoursTypeDetailsList'].forEach((v) { - getDayHoursTypeDetailsList!.add(new GetDayHoursTypeDetailsList.fromJson(v)); + getDayHoursTypeDetailsList!.add(GetDayHoursTypeDetailsList.fromJson(v)); }); } if (json['GetDeductionsList'] != null) { getDeductionsList = []; json['GetDeductionsList'].forEach((v) { - getDeductionsList!.add(new GetDeductionsList.fromJson(v)); + getDeductionsList!.add(GetDeductionsList.fromJson(v)); }); } getDefaultValueList = json['GetDefaultValueList'] != null ? GetDefaultValueList.fromJson(json['GetDefaultValueList']) : null; @@ -804,44 +810,44 @@ class GenericResponseModel { if (json['GetEITDFFStructureList'] != null) { getEITDFFStructureList = []; json['GetEITDFFStructureList'].forEach((v) { - getEITDFFStructureList!.add(new GetEITDFFStructureList.fromJson(v)); + getEITDFFStructureList!.add(GetEITDFFStructureList.fromJson(v)); }); } if (json['GetEITTransactionList'] != null) { getEITTransactionList = []; json['GetEITTransactionList'].forEach((v) { - getEITTransactionList!.add(new GetEITTransactionList.fromJson(v)); + getEITTransactionList!.add(GetEITTransactionList.fromJson(v)); }); } if (json['GetEarningsList'] != null) { getEarningsList = []; json['GetEarningsList'].forEach((v) { - getEarningsList!.add(new GetEarningsList.fromJson(v)); + getEarningsList!.add(GetEarningsList.fromJson(v)); }); } if (json['GetEmployeeAddressList'] != null) { getEmployeeAddressList = []; json['GetEmployeeAddressList'].forEach((v) { - getEmployeeAddressList!.add(new GetEmployeeAddressList.fromJson(v)); + getEmployeeAddressList!.add(GetEmployeeAddressList.fromJson(v)); }); } if (json['GetEmployeeBasicDetailsList'] != null) { getEmployeeBasicDetailsList = []; json['GetEmployeeBasicDetailsList'].forEach((v) { - getEmployeeBasicDetailsList!.add(new GetEmployeeBasicDetailsList.fromJson(v)); + getEmployeeBasicDetailsList!.add(GetEmployeeBasicDetailsList.fromJson(v)); }); } if (json['GetEmployeeContactsList'] != null) { getEmployeeContactsList = []; json['GetEmployeeContactsList'].forEach((v) { - getEmployeeContactsList!.add(new GetEmployeeContactsList.fromJson(v)); + getEmployeeContactsList!.add(GetEmployeeContactsList.fromJson(v)); }); } if (json['GetEmployeePhonesList'] != null) { getEmployeePhonesList = []; json['GetEmployeePhonesList'].forEach((v) { - getEmployeePhonesList!.add(new GetEmployeePhonesList.fromJson(v)); + getEmployeePhonesList!.add(GetEmployeePhonesList.fromJson(v)); }); } getEmployeeSubordinatesList = json['GetEmployeeSubordinatesList']; @@ -849,12 +855,12 @@ class GenericResponseModel { getHrCollectionNotificationBodyList = json['GetHrCollectionNotificationBodyList']; getHrTransactionList = json['GetHrTransactionList']; - getItemCreationNtfBodyList = json['GetItemCreationNtfBodyList'] != null ? new GetItemCreationNtfBodyList.fromJson(json['GetItemCreationNtfBodyList']) : null; + getItemCreationNtfBodyList = json['GetItemCreationNtfBodyList'] != null ? GetItemCreationNtfBodyList.fromJson(json['GetItemCreationNtfBodyList']) : null; if (json['GetItemTypeNotificationsList'] != null) { getItemTypeNotificationsList = []; json['GetItemTypeNotificationsList'].forEach((v) { - getItemTypeNotificationsList!.add(new GetItemTypeNotificationsList.fromJson(v)); + getItemTypeNotificationsList!.add(GetItemTypeNotificationsList.fromJson(v)); }); } @@ -864,14 +870,14 @@ class GenericResponseModel { if (json['GetMoItemHistoryList'] != null) { getMoItemHistoryList = []; json['GetMoItemHistoryList'].forEach((v) { - getMoItemHistoryList!.add(new GetMoItemHistoryList.fromJson(v)); + getMoItemHistoryList!.add(GetMoItemHistoryList.fromJson(v)); }); } if (json['GetMoNotificationBodyList'] != null) { getMoNotificationBodyList = []; json['GetMoNotificationBodyList'].forEach((v) { - getMoNotificationBodyList!.add(new GetMoNotificationBodyList.fromJson(v)); + getMoNotificationBodyList!.add(GetMoNotificationBodyList.fromJson(v)); }); } @@ -905,14 +911,14 @@ class GenericResponseModel { if (json['GetPaymentInformationList'] != null) { getPaymentInformationList = []; json['GetPaymentInformationList'].forEach((v) { - getPaymentInformationList!.add(new GetPaymentInformationList.fromJson(v)); + getPaymentInformationList!.add(GetPaymentInformationList.fromJson(v)); }); } if (json['GetPayslipList'] != null) { getPayslipList = []; json['GetPayslipList'].forEach((v) { - getPayslipList!.add(new GetPayslipList.fromJson(v)); + getPayslipList!.add(GetPayslipList.fromJson(v)); }); } // getPendingReqDetailsList = json['GetPendingReqDetailsList']; @@ -923,15 +929,15 @@ class GenericResponseModel { if (json['GetPoItemHistoryList'] != null) { getPoItemHistoryList = []; json['GetPoItemHistoryList'].forEach((v) { - getPoItemHistoryList!.add(new GetPoItemHistoryList.fromJson(v)); + getPoItemHistoryList!.add(GetPoItemHistoryList.fromJson(v)); }); } - getPoNotificationBodyList = json['GetPoNotificationBodyList'] != null ? new GetPoNotificationBodyList.fromJson(json['GetPoNotificationBodyList']) : null; + getPoNotificationBodyList = json['GetPoNotificationBodyList'] != null ? GetPoNotificationBodyList.fromJson(json['GetPoNotificationBodyList']) : null; getPrNotificationBodyList = json['GetPrNotificationBodyList']; if (json['GetQuotationAnalysisList'] != null) { getQuotationAnalysisList = []; json['GetQuotationAnalysisList'].forEach((v) { - getQuotationAnalysisList!.add(new GetQuotationAnalysisList.fromJson(v)); + getQuotationAnalysisList!.add(GetQuotationAnalysisList.fromJson(v)); }); } getRFCEmployeeListList = json['GetRFCEmployeeListList']; @@ -942,7 +948,7 @@ class GenericResponseModel { if (json['GetScheduleShiftsDetailsList'] != null) { getScheduleShiftsDetailsList = []; json['GetScheduleShiftsDetailsList'].forEach((v) { - getScheduleShiftsDetailsList!.add(new GetScheduleShiftsDetailsList.fromJson(v)); + getScheduleShiftsDetailsList!.add(GetScheduleShiftsDetailsList.fromJson(v)); }); } getShiftTypesList = json['GetShiftTypesList']; @@ -950,13 +956,13 @@ class GenericResponseModel { if (json['GetStampMsNotificationBodyList'] != null) { getStampMsNotificationBodyList = []; json['GetStampMsNotificationBodyList'].forEach((v) { - getStampMsNotificationBodyList!.add(new GetStampMsNotificationBodyList.fromJson(v)); + getStampMsNotificationBodyList!.add(GetStampMsNotificationBodyList.fromJson(v)); }); } if (json['GetStampNsNotificationBodyList'] != null) { getStampNsNotificationBodyList = []; json['GetStampNsNotificationBodyList'].forEach((v) { - getStampNsNotificationBodyList!.add(new GetStampNsNotificationBodyList.fromJson(v)); + getStampNsNotificationBodyList!.add(GetStampNsNotificationBodyList.fromJson(v)); }); } @@ -973,7 +979,7 @@ class GenericResponseModel { if (json['GetSummaryOfPaymentList'] != null) { getSummaryOfPaymentList = []; json['GetSummaryOfPaymentList'].forEach((v) { - getSummaryOfPaymentList!.add(new GetSummaryOfPaymentList.fromJson(v)); + getSummaryOfPaymentList!.add(GetSummaryOfPaymentList.fromJson(v)); }); } getSwipesList = json['GetSwipesList']; @@ -984,77 +990,77 @@ class GenericResponseModel { if (json['GetTimeCardSummaryList'] != null) { getTimeCardSummaryList = []; json['GetTimeCardSummaryList'].forEach((v) { - getTimeCardSummaryList!.add(new GetTimeCardSummaryList.fromJson(v)); + getTimeCardSummaryList!.add(GetTimeCardSummaryList.fromJson(v)); }); } if (json['Mohemm_ITG_TicketsByEmployeeList'] != null) { getTicketsByEmployeeList = []; json['Mohemm_ITG_TicketsByEmployeeList'].forEach((v) { - getTicketsByEmployeeList!.add(new GetTicketsByEmployeeList.fromJson(v)); + getTicketsByEmployeeList!.add(GetTicketsByEmployeeList.fromJson(v)); }); } if (json['Mohemm_ITG_TicketDetailsList'] != null) { getTicketDetailsByEmployee = []; json['Mohemm_ITG_TicketDetailsList'].forEach((v) { - getTicketDetailsByEmployee!.add(new GetTicketDetailsByEmployee.fromJson(v)); + getTicketDetailsByEmployee!.add(GetTicketDetailsByEmployee.fromJson(v)); }); } if (json['Mohemm_ITG_TicketTransactionsList'] != null) { getTicketTransactions = []; json['Mohemm_ITG_TicketTransactionsList'].forEach((v) { - getTicketTransactions!.add(new GetTicketTransactions.fromJson(v)); + getTicketTransactions!.add(GetTicketTransactions.fromJson(v)); }); } if (json['Mohemm_Itg_TicketTypesList'] != null) { getTicketTypes = []; json['Mohemm_Itg_TicketTypesList'].forEach((v) { - getTicketTypes!.add(new GetTicketTypes.fromJson(v)); + getTicketTypes!.add(GetTicketTypes.fromJson(v)); }); } if (json['Mohemm_Itg_ProjectsList'] != null) { getMowadhafhiProjects = []; json['Mohemm_Itg_ProjectsList'].forEach((v) { - getMowadhafhiProjects!.add(new GetMowadhafhiProjects.fromJson(v)); + getMowadhafhiProjects!.add(GetMowadhafhiProjects.fromJson(v)); }); } if (json['Mohemm_ITG_ProjectDepartmentsList'] != null) { getProjectDepartments = []; json['Mohemm_ITG_ProjectDepartmentsList'].forEach((v) { - getProjectDepartments!.add(new GetProjectDepartments.fromJson(v)); + getProjectDepartments!.add(GetProjectDepartments.fromJson(v)); }); } if (json['Mohemm_ITG_DepartmentSectionsList'] != null) { getDepartmentSections = []; json['Mohemm_ITG_DepartmentSectionsList'].forEach((v) { - getDepartmentSections!.add(new GetDepartmentSections.fromJson(v)); + getDepartmentSections!.add(GetDepartmentSections.fromJson(v)); }); } if (json['Mohemm_ITG_SectionTopicsList'] != null) { getSectionTopics = []; json['Mohemm_ITG_SectionTopicsList'].forEach((v) { - getSectionTopics!.add(new GetSectionTopics.fromJson(v)); + getSectionTopics!.add(GetSectionTopics.fromJson(v)); }); } if (json['GetPendingReqFunctionsList'] != null) { getPendingTransactionsFunctions = []; json['GetPendingReqFunctionsList'].forEach((v) { - getPendingTransactionsFunctions!.add(new GetPendingTransactionsFunctions.fromJson(v)); + getPendingTransactionsFunctions!.add(GetPendingTransactionsFunctions.fromJson(v)); }); } if (json['GetPendingReqDetailsList'] != null) { getPendingTransactionsDetails = []; json['GetPendingReqDetailsList'].forEach((v) { - getPendingTransactionsDetails!.add(new GetPendingTransactionsDetails.fromJson(v)); + getPendingTransactionsDetails!.add(GetPendingTransactionsDetails.fromJson(v)); }); } @@ -1177,7 +1183,7 @@ class GenericResponseModel { if (json['RespondAttributesList'] != null) { respondAttributesList = []; json['RespondAttributesList'].forEach((v) { - respondAttributesList!.add(new RespondAttributesList.fromJson(v)); + respondAttributesList!.add(RespondAttributesList.fromJson(v)); }); } if (json['RespondRolesList'] != null) { @@ -1192,25 +1198,25 @@ class GenericResponseModel { sFHGetPoNotificationBodyList = json['SFH_GetPoNotificationBodyList']; sFHGetPrNotificationBodyList = json['SFH_GetPrNotificationBodyList']; startAbsenceApprovalProccess = json['StartAbsenceApprovalProccess']; - startAddressApprovalProcessList = json['StartAddressApprovalProcessList'] != null ? new StartAddressApprovalProcess.fromJson(json['StartAddressApprovalProcessList']) : null; + startAddressApprovalProcessList = json['StartAddressApprovalProcessList'] != null ? StartAddressApprovalProcess.fromJson(json['StartAddressApprovalProcessList']) : null; startBasicDetApprProcessList = json['StartBasicDetApprProcessList']; startCeiApprovalProcess = json['StartCeiApprovalProcess']; startContactApprovalProcessList = json['StartContactApprovalProcessList']; - startEitApprovalProcess = json['StartEitApprovalProcess'] != null ? new StartEitApprovalProcess.fromJson(json['StartEitApprovalProcess']) : null; + startEitApprovalProcess = json['StartEitApprovalProcess'] != null ? StartEitApprovalProcess.fromJson(json['StartEitApprovalProcess']) : null; startHrApprovalProcessList = json['StartHrApprovalProcessList']; - startPhonesApprovalProcessList = json['StartPhonesApprovalProcessList'] != null ? new StartPhoneApprovalProcess.fromJson(json['startPhonesApprovalProcessList']) : null; + startPhonesApprovalProcessList = json['StartPhonesApprovalProcessList'] != null ? StartPhoneApprovalProcess.fromJson(json['startPhonesApprovalProcessList']) : null; startSitApprovalProcess = json['StartSitApprovalProcess']; startTermApprovalProcessList = json['StartTermApprovalProcessList']; - submitAddressTransactionList = json['SubmitAddressTransactionList'] != null ? new SubmitAddressTransaction.fromJson(json['SubmitAddressTransactionList']) : null; - submitBasicDetTransactionList = json['SubmitBasicDetTransactionList'] != null ? new SubmitBasicDetailsTransactionList.fromJson(json['SubmitBasicDetTransactionList']) : null; + submitAddressTransactionList = json['SubmitAddressTransactionList'] != null ? SubmitAddressTransaction.fromJson(json['SubmitAddressTransactionList']) : null; + submitBasicDetTransactionList = json['SubmitBasicDetTransactionList'] != null ? SubmitBasicDetailsTransactionList.fromJson(json['SubmitBasicDetTransactionList']) : null; submitCEITransactionList = json['SubmitCEITransactionList']; submitCcpTransactionList = json['SubmitCcpTransactionList']; - submitContactTransactionList = json['SubmitContactTransactionList'] != null ? new SubmitContactTransactionList.fromJson(json['SubmitContactTransactionList']) : null; - submitEITTransactionList = json['SubmitEITTransactionList'] != null ? new SubmitEITTransactionList.fromJson(json['SubmitEITTransactionList']) : null; + submitContactTransactionList = json['SubmitContactTransactionList'] != null ? SubmitContactTransactionList.fromJson(json['SubmitContactTransactionList']) : null; + submitEITTransactionList = json['SubmitEITTransactionList'] != null ? SubmitEITTransactionList.fromJson(json['SubmitEITTransactionList']) : null; submitHrTransactionList = json['SubmitHrTransactionList']; submitPhonesTransactionList = json['SubmitPhonesTransactionList']; @@ -1239,7 +1245,7 @@ class GenericResponseModel { vHRIsVerificationCodeValid = json['VHR_IsVerificationCodeValid']; validateAbsenceTransactionList = json['ValidateAbsenceTransactionList']; - validateEITTransactionList = json['ValidateEITTransactionList'] != null ? new ValidateEITTransactionList.fromJson(json['ValidateEITTransactionList']) : null; + validateEITTransactionList = json['ValidateEITTransactionList'] != null ? ValidateEITTransactionList.fromJson(json['ValidateEITTransactionList']) : null; validatePhonesTransactionList = json['ValidatePhonesTransactionList']; if (json['VrItemTypesList'] != null) { @@ -1251,7 +1257,7 @@ class GenericResponseModel { if (json['WFLookUpList'] != null) { wFLookUpList = []; json['WFLookUpList'].forEach((v) { - wFLookUpList!.add(new WFLookUpList.fromJson(v)); + wFLookUpList!.add(WFLookUpList.fromJson(v)); }); } eLearningGETEMPLOYEEPROFILEList = json['eLearning_GET_EMPLOYEE_PROFILEList']; @@ -1264,7 +1270,7 @@ class GenericResponseModel { } Map toJson() { - Map data = new Map(); + Map data = Map(); data['Date'] = this.date; data['LanguageID'] = this.languageID; data['ServiceName'] = this.serviceName; @@ -1335,7 +1341,9 @@ class GenericResponseModel { data['GetAbsenceCollectionNotificationBodyList'] = this.getAbsenceCollectionNotificationBodyList!.map((v) => v.toJson()).toList(); } - data['GetAbsenceDffStructureList'] = this.getAbsenceDffStructureList; + if (this.getAbsenceDffStructureList != null) { + data['GetAbsenceDffStructureList'] = this.getAbsenceDffStructureList!.map((v) => v.toJson()).toList(); + } if (this.getAbsenceTransactionList != null) { data['GetAbsenceTransactionList'] = this.getAbsenceTransactionList!.map((v) => v.toJson()).toList(); diff --git a/lib/models/leave_balance/get_absence_dff_structure_list_model.dart b/lib/models/leave_balance/get_absence_dff_structure_list_model.dart new file mode 100644 index 0000000..a7d04bb --- /dev/null +++ b/lib/models/leave_balance/get_absence_dff_structure_list_model.dart @@ -0,0 +1,193 @@ +import 'package:mohem_flutter_app/models/get_eit_dff_structure_list_model.dart'; + +class GetAbsenceDffStructureList { + String? aLPHANUMERICALLOWEDFLAG; + String? aPPLICATIONCOLUMNNAME; + String? cHILDSEGMENTSDV; + List? cHILDSEGMENTSDVSplited; + String? cHILDSEGMENTSVS; + List? cHILDSEGMENTSVSSplited; + String? dEFAULTTYPE; + String? dEFAULTVALUE; + String? dESCFLEXCONTEXTCODE; + String? dESCFLEXCONTEXTNAME; + String? dESCFLEXNAME; + String? dISPLAYFLAG; + String? eNABLEDFLAG; + ESERVICESDV? eSERVICESDV; + List? eSERVICESVS; + String? fLEXVALUESETNAME; + String? fORMATTYPE; + String? fORMATTYPEDSP; + bool? isEmptyOption; + String? lONGLISTFLAG; + int? mAXIMUMSIZE; + String? mAXIMUMVALUE; + String? mINIMUMVALUE; + String? mOBILEENABLED; + String? nUMBERPRECISION; + String? nUMERICMODEENABLEDFLAG; + String? pARENTSEGMENTSDV; + List? pARENTSEGMENTSDVSplited; + String? pARENTSEGMENTSVS; + List? pARENTSEGMENTSVSSplitedVS; + String? rEADONLY; + String? rEQUIREDFLAG; + String? sEGMENTNAME; + String? sEGMENTPROMPT; + int? sEGMENTSEQNUM; + String? uPPERCASEONLYFLAG; + String? uSEDFLAG; + String? vALIDATIONTYPE; + String? vALIDATIONTYPEDSP; + + GetAbsenceDffStructureList( + {this.aLPHANUMERICALLOWEDFLAG, + this.aPPLICATIONCOLUMNNAME, + this.cHILDSEGMENTSDV, + this.cHILDSEGMENTSDVSplited, + this.cHILDSEGMENTSVS, + this.cHILDSEGMENTSVSSplited, + this.dEFAULTTYPE, + this.dEFAULTVALUE, + this.dESCFLEXCONTEXTCODE, + this.dESCFLEXCONTEXTNAME, + this.dESCFLEXNAME, + this.dISPLAYFLAG, + this.eNABLEDFLAG, + this.eSERVICESDV, + this.eSERVICESVS, + this.fLEXVALUESETNAME, + this.fORMATTYPE, + this.fORMATTYPEDSP, + this.isEmptyOption, + this.lONGLISTFLAG, + this.mAXIMUMSIZE, + this.mAXIMUMVALUE, + this.mINIMUMVALUE, + this.mOBILEENABLED, + this.nUMBERPRECISION, + this.nUMERICMODEENABLEDFLAG, + this.pARENTSEGMENTSDV, + this.pARENTSEGMENTSDVSplited, + this.pARENTSEGMENTSVS, + this.pARENTSEGMENTSVSSplitedVS, + this.rEADONLY, + this.rEQUIREDFLAG, + this.sEGMENTNAME, + this.sEGMENTPROMPT, + this.sEGMENTSEQNUM, + this.uPPERCASEONLYFLAG, + this.uSEDFLAG, + this.vALIDATIONTYPE, + this.vALIDATIONTYPEDSP}); + + GetAbsenceDffStructureList.fromJson(Map json) { + aLPHANUMERICALLOWEDFLAG = json['ALPHANUMERIC_ALLOWED_FLAG']; + aPPLICATIONCOLUMNNAME = json['APPLICATION_COLUMN_NAME']; + cHILDSEGMENTSDV = json['CHILD_SEGMENTS_DV']; + cHILDSEGMENTSDVSplited = json['CHILD_SEGMENTS_DV_Splited'] == null ? [] : json['CHILD_SEGMENTS_DV_Splited'].cast(); + cHILDSEGMENTSVS = json['CHILD_SEGMENTS_VS']; + cHILDSEGMENTSVSSplited = json['CHILD_SEGMENTS_VS_Splited'].cast(); + dEFAULTTYPE = json['DEFAULT_TYPE']; + dEFAULTVALUE = json['DEFAULT_VALUE']; + dESCFLEXCONTEXTCODE = json['DESC_FLEX_CONTEXT_CODE']; + dESCFLEXCONTEXTNAME = json['DESC_FLEX_CONTEXT_NAME']; + dESCFLEXNAME = json['DESC_FLEX_NAME']; + dISPLAYFLAG = json['DISPLAY_FLAG']; + eNABLEDFLAG = json['ENABLED_FLAG']; + eSERVICESDV = json['E_SERVICES_DV'] != null ? new ESERVICESDV.fromJson(json['E_SERVICES_DV']) : null; + if (json['E_SERVICES_VS'] != null) { + eSERVICESVS = []; + json['E_SERVICES_VS'].forEach((v) { + eSERVICESVS!.add(new ESERVICESVS.fromJson(v)); + }); + } + fLEXVALUESETNAME = json['FLEX_VALUE_SET_NAME']; + fORMATTYPE = json['FORMAT_TYPE']; + fORMATTYPEDSP = json['FORMAT_TYPE_DSP']; + isEmptyOption = json['IsEmptyOption']; + lONGLISTFLAG = json['LONGLIST_FLAG']; + mAXIMUMSIZE = json['MAXIMUM_SIZE']; + mAXIMUMVALUE = json['MAXIMUM_VALUE']; + mINIMUMVALUE = json['MINIMUM_VALUE']; + mOBILEENABLED = json['MOBILE_ENABLED']; + nUMBERPRECISION = json['NUMBER_PRECISION']; + nUMERICMODEENABLEDFLAG = json['NUMERIC_MODE_ENABLED_FLAG']; + pARENTSEGMENTSDV = json['PARENT_SEGMENTS_DV']; + if (json['PARENT_SEGMENTS_DV_Splited'] != null) { + pARENTSEGMENTSDVSplited = []; + json['PARENT_SEGMENTS_DV_Splited'].forEach((v) { + pARENTSEGMENTSDVSplited!.add(PARENTSEGMENTSDVSplited.fromJson(v)); + }); + } + pARENTSEGMENTSVS = json['PARENT_SEGMENTS_VS']; + if (json['PARENT_SEGMENTS_VS_SplitedVS'] != null) { + pARENTSEGMENTSVSSplitedVS = []; + json['PARENT_SEGMENTS_VS_SplitedVS'].forEach((v) { + pARENTSEGMENTSVSSplitedVS!.add(new PARENTSEGMENTSVSSplitedVS.fromJson(v)); + }); + } + rEADONLY = json['READ_ONLY']; + rEQUIREDFLAG = json['REQUIRED_FLAG']; + sEGMENTNAME = json['SEGMENT_NAME']; + sEGMENTPROMPT = json['SEGMENT_PROMPT']; + sEGMENTSEQNUM = json['SEGMENT_SEQ_NUM']; + uPPERCASEONLYFLAG = json['UPPERCASE_ONLY_FLAG']; + uSEDFLAG = json['USED_FLAG']; + vALIDATIONTYPE = json['VALIDATION_TYPE']; + vALIDATIONTYPEDSP = json['VALIDATION_TYPE_DSP']; + } + + Map toJson() { + Map data = new Map(); + data['ALPHANUMERIC_ALLOWED_FLAG'] = this.aLPHANUMERICALLOWEDFLAG; + data['APPLICATION_COLUMN_NAME'] = this.aPPLICATIONCOLUMNNAME; + data['CHILD_SEGMENTS_DV'] = this.cHILDSEGMENTSDV; + data['CHILD_SEGMENTS_DV_Splited'] = this.cHILDSEGMENTSDVSplited; + data['CHILD_SEGMENTS_VS'] = this.cHILDSEGMENTSVS; + data['CHILD_SEGMENTS_VS_Splited'] = this.cHILDSEGMENTSVSSplited; + data['DEFAULT_TYPE'] = this.dEFAULTTYPE; + data['DEFAULT_VALUE'] = this.dEFAULTVALUE; + data['DESC_FLEX_CONTEXT_CODE'] = this.dESCFLEXCONTEXTCODE; + data['DESC_FLEX_CONTEXT_NAME'] = this.dESCFLEXCONTEXTNAME; + data['DESC_FLEX_NAME'] = this.dESCFLEXNAME; + data['DISPLAY_FLAG'] = this.dISPLAYFLAG; + data['ENABLED_FLAG'] = this.eNABLEDFLAG; + if (this.eSERVICESDV != null) { + data['E_SERVICES_DV'] = this.eSERVICESDV!.toJson(); + } + if (this.eSERVICESVS != null) { + data['E_SERVICES_VS'] = this.eSERVICESVS!.map((v) => v.toJson()).toList(); + } + data['FLEX_VALUE_SET_NAME'] = this.fLEXVALUESETNAME; + data['FORMAT_TYPE'] = this.fORMATTYPE; + data['FORMAT_TYPE_DSP'] = this.fORMATTYPEDSP; + data['IsEmptyOption'] = this.isEmptyOption; + data['LONGLIST_FLAG'] = this.lONGLISTFLAG; + data['MAXIMUM_SIZE'] = this.mAXIMUMSIZE; + data['MAXIMUM_VALUE'] = this.mAXIMUMVALUE; + data['MINIMUM_VALUE'] = this.mINIMUMVALUE; + data['MOBILE_ENABLED'] = this.mOBILEENABLED; + data['NUMBER_PRECISION'] = this.nUMBERPRECISION; + data['NUMERIC_MODE_ENABLED_FLAG'] = this.nUMERICMODEENABLEDFLAG; + data['PARENT_SEGMENTS_DV'] = this.pARENTSEGMENTSDV; + if (this.pARENTSEGMENTSDVSplited != null) { + data['PARENT_SEGMENTS_DV_Splited'] = this.pARENTSEGMENTSDVSplited!.map((v) => v.toJson()).toList(); + } + data['PARENT_SEGMENTS_VS'] = this.pARENTSEGMENTSVS; + if (this.pARENTSEGMENTSVSSplitedVS != null) { + data['PARENT_SEGMENTS_VS_SplitedVS'] = this.pARENTSEGMENTSVSSplitedVS!.map((v) => v.toJson()).toList(); + } + data['READ_ONLY'] = this.rEADONLY; + data['REQUIRED_FLAG'] = this.rEQUIREDFLAG; + data['SEGMENT_NAME'] = this.sEGMENTNAME; + data['SEGMENT_PROMPT'] = this.sEGMENTPROMPT; + data['SEGMENT_SEQ_NUM'] = this.sEGMENTSEQNUM; + data['UPPERCASE_ONLY_FLAG'] = this.uPPERCASEONLYFLAG; + data['USED_FLAG'] = this.uSEDFLAG; + data['VALIDATION_TYPE'] = this.vALIDATIONTYPE; + data['VALIDATION_TYPE_DSP'] = this.vALIDATIONTYPEDSP; + return data; + } +} diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index b4278af..be0e3b5 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -4,6 +4,7 @@ import 'package:mohem_flutter_app/api/leave_balance_api_client.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_attendance_types_list_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/get_absence_dff_structure_list_model.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; class AddLeaveBalanceScreen extends StatefulWidget { @@ -16,6 +17,7 @@ class AddLeaveBalanceScreen extends StatefulWidget { } class _AddLeaveBalanceScreenState extends State { + List absenceDff = []; List absenceList = []; @override @@ -36,6 +38,19 @@ class _AddLeaveBalanceScreenState extends State { } } + void getAbsenceDffStructure(String flexCode) async { + try { + Utils.showLoading(context); + absenceDff.clear(); + absenceDff = await LeaveBalanceApiClient().getAbsenceDffStructure(flexCode, "HR_LOA_SS", -999); + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + @override void dispose() { super.dispose(); From d5c8604f3299f48a725d1cb621cf09a873ab716d Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 29 Aug 2022 10:19:00 +0300 Subject: [PATCH 26/40] leave balance cont3. --- .../get_absence_transaction_list_model.dart | 4 +- .../add_leave_balance_screen.dart | 145 ++++++++++++++++++ .../leave_balance/leave_balance_screen.dart | 36 ++--- 3 files changed, 166 insertions(+), 19 deletions(-) diff --git a/lib/models/leave_balance/get_absence_transaction_list_model.dart b/lib/models/leave_balance/get_absence_transaction_list_model.dart index d61cf2f..ca9777d 100644 --- a/lib/models/leave_balance/get_absence_transaction_list_model.dart +++ b/lib/models/leave_balance/get_absence_transaction_list_model.dart @@ -37,10 +37,12 @@ class GetAbsenceTransactionList { this.uPDATEBUTTON}); GetAbsenceTransactionList.fromJson(Map json) { + print("json:$json"); + print("type:ABSENCE_DAYS:${(json['ABSENCE_DAYS']).runtimeType}"); aBSENCEATTENDANCEID = json['ABSENCE_ATTENDANCE_ID']; aBSENCEATTENDANCETYPEID = json['ABSENCE_ATTENDANCE_TYPE_ID']; aBSENCECATEGORY = json['ABSENCE_CATEGORY']; - aBSENCEDAYS = json['ABSENCE_DAYS']; + aBSENCEDAYS = double.parse(json['ABSENCE_DAYS'].toString() ?? "0.0"); aBSENCEHOURS = json['ABSENCE_HOURS']; aBSENCESTATUS = json['ABSENCE_STATUS']; aBSENCETYPE = json['ABSENCE_TYPE']; diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index b4278af..ef14a09 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -1,10 +1,20 @@ +import 'dart:io'; + import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/leave_balance_api_client.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/extensions/int_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/leave_balance/get_absence_attendance_types_list_model.dart'; +import 'package:mohem_flutter_app/models/worklist/replacement_list_model.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; +import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; +import 'package:mohem_flutter_app/widgets/bottom_sheets/search_employee_bottom_sheet.dart'; +import 'package:mohem_flutter_app/widgets/button/default_button.dart'; +import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; class AddLeaveBalanceScreen extends StatefulWidget { AddLeaveBalanceScreen({Key? key}) : super(key: key); @@ -18,6 +28,13 @@ class AddLeaveBalanceScreen extends StatefulWidget { class _AddLeaveBalanceScreenState extends State { List absenceList = []; + GetAbsenceAttendanceTypesList? selectedAbsenceType; + DateTime? startTime; + DateTime? endTime; + int totalDays = 0; + String comment = ""; + ReplacementList? selectedReplacementEmployee; + @override void initState() { super.initState(); @@ -49,6 +66,134 @@ class _AddLeaveBalanceScreenState extends State { context, title: LocaleKeys.leaveBalance.tr(), ), + body: Column( + children: [ + ListView( + padding: const EdgeInsets.all(21), + children: [ + PopupMenuButton( + child: DynamicTextFieldWidget( + LocaleKeys.absenceType.tr() + "*", + selectedAbsenceType == null ? LocaleKeys.selectTypeT.tr() : selectedAbsenceType!.aBSENCEATTENDANCETYPENAME!, + isEnable: false, + isPopup: true, + ), + itemBuilder: (_) => >[ + for (int i = 0; i < absenceList.length; i++) PopupMenuItem(value: i, child: Text(absenceList[i].aBSENCEATTENDANCETYPENAME!)), + ], + onSelected: (int popupIndex) { + if (selectedAbsenceType == absenceList[popupIndex]) { + return; + } + selectedAbsenceType = absenceList[popupIndex]; + setState(() {}); + }, + ), + 12.height, + DynamicTextFieldWidget( + LocaleKeys.startDateT.tr() + "*", + startTime == null ? "Select date" : startTime.toString(), + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + var start = await _selectDate(context, startTime); + if (start != startTime) { + startTime = start; + setState(() {}); + } + }, + ), + 12.height, + DynamicTextFieldWidget( + LocaleKeys.endDateT.tr() + "*", + endTime == null ? "Select date" : endTime.toString(), + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + var end = await _selectDate(context, endTime); + if (end != endTime) { + endTime = end; + setState(() {}); + } + }, + ), + 12.height, + DynamicTextFieldWidget( + "totla dsays", + "days", + isInputTypeNum: true, + onChange: (input) { + totalDays = int.parse(input); + }, + ), + 12.height, + DynamicTextFieldWidget( + LocaleKeys.selectEmployee.tr(), + selectedReplacementEmployee == null ? LocaleKeys.searchForEmployee.tr() : selectedReplacementEmployee!.employeeDisplayName ?? "", + isEnable: false, + onTap: () { + showMyBottomSheet( + context, + child: SearchEmployeeBottomSheet( + title: LocaleKeys.searchForEmployee.tr(), + apiMode: LocaleKeys.delegate.tr(), + onSelectEmployee: (_selectedEmployee) { + // Navigator.pop(context); + selectedReplacementEmployee = _selectedEmployee; + setState(() {}); + }, + ), + ); + }, + ), + 12.height, + DynamicTextFieldWidget( + LocaleKeys.comments.tr(), + LocaleKeys.writeComment.tr(), + lines: 2, + onChange: (input) { + comment = input; + }, + ), + ], + ).expanded, + DefaultButton( + LocaleKeys.next.tr(), + (selectedAbsenceType == null || startTime == null || endTime == null) ? null : () {}, + ).insideContainer + ], + ), ); } + + Future _selectDate(BuildContext context, DateTime? dateInput) async { + DateTime time = dateInput ?? DateTime.now(); + if (Platform.isIOS) { + await showCupertinoModalPopup( + context: context, + builder: (cxt) => Container( + height: 250, + color: Colors.white, + child: CupertinoDatePicker( + backgroundColor: Colors.white, + mode: CupertinoDatePickerMode.date, + onDateTimeChanged: (value) { + if (value != dateInput) { + time = value; + } + }, + initialDateTime: dateInput, + ), + ), + ); + } else { + DateTime? picked = + await showDatePicker(context: context, initialDate: dateInput ?? DateTime.now(), initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); + if (picked != null && picked != dateInput) { + time = picked; + } + } + time = DateTime(time.year, time.month, time.day); + return time; + } } diff --git a/lib/ui/leave_balance/leave_balance_screen.dart b/lib/ui/leave_balance/leave_balance_screen.dart index 8b00ce8..70a7f7c 100644 --- a/lib/ui/leave_balance/leave_balance_screen.dart +++ b/lib/ui/leave_balance/leave_balance_screen.dart @@ -35,15 +35,15 @@ class _LeaveBalanceState extends State { } void getAbsenceTransactions() async { - try { - Utils.showLoading(context); - absenceTransList = await LeaveBalanceApiClient().getAbsenceTransactions(-999); - Utils.hideLoading(context); - setState(() {}); - } catch (ex) { - Utils.hideLoading(context); - Utils.handleException(ex, context, null); - } + // try { + Utils.showLoading(context); + absenceTransList = await LeaveBalanceApiClient().getAbsenceTransactions(-999); + Utils.hideLoading(context); + setState(() {}); + // } catch (ex) { + // Utils.hideLoading(context); + // Utils.handleException(ex, context, null); + // } } @override @@ -61,18 +61,18 @@ class _LeaveBalanceState extends State { : ListView.separated( physics: const BouncingScrollPhysics(), padding: const EdgeInsets.all(21), - itemBuilder: (cxt, int parentIndex) => Column( + itemBuilder: (cxt, int index) => Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - ItemDetailView(LocaleKeys.startDateT.tr(), ""), - ItemDetailView(LocaleKeys.endDateT.tr(), ""), - ItemDetailView(LocaleKeys.absenceType.tr(), ""), - ItemDetailView(LocaleKeys.absenceCategory.tr(), ""), - ItemDetailView(LocaleKeys.days.tr(), ""), - ItemDetailView(LocaleKeys.hours.tr(), ""), - ItemDetailView(LocaleKeys.approvalStatus.tr(), ""), - ItemDetailView(LocaleKeys.absenceStatus.tr(), ""), + ItemDetailView(LocaleKeys.startDateT.tr(), absenceTransList![index].sTARTDATE ?? ""), + ItemDetailView(LocaleKeys.endDateT.tr(), absenceTransList![index].eNDDATE ?? ""), + ItemDetailView(LocaleKeys.absenceType.tr(), absenceTransList![index].aBSENCETYPE ?? ""), + ItemDetailView(LocaleKeys.absenceCategory.tr(), absenceTransList![index].aBSENCECATEGORY ?? ""), + ItemDetailView(LocaleKeys.days.tr(), absenceTransList![index].aBSENCEDAYS?.toString() ?? ""), + ItemDetailView(LocaleKeys.hours.tr(), absenceTransList![index].aBSENCEHOURS?.toString() ?? ""), + ItemDetailView(LocaleKeys.approvalStatus.tr(), absenceTransList![index].aPPROVALSTATUS ?? ""), + ItemDetailView(LocaleKeys.absenceStatus.tr(), absenceTransList![index].aBSENCESTATUS ?? ""), ], ).objectContainerView(), separatorBuilder: (cxt, index) => 12.height, From 171735202bca8255de6b0f640a574c6aee6d87c2 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 29 Aug 2022 10:20:52 +0300 Subject: [PATCH 27/40] leave balance cont3. --- lib/ui/leave_balance/add_leave_balance_screen.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index ca6054b..e9ab981 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -10,6 +10,7 @@ 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/leave_balance/get_absence_attendance_types_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_dff_structure_list_model.dart'; +import 'package:mohem_flutter_app/models/worklist/replacement_list_model.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheets/search_employee_bottom_sheet.dart'; From 50f203cd558fe9c5dd93710af71db282522425ea Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 29 Aug 2022 13:44:04 +0300 Subject: [PATCH 28/40] Updates & fixes --- .../items_for_sale/get_employee_ads_list.dart | 10 +- .../get_ccp_dff_structure_model.dart | 20 -- .../items_for_sale/item_for_sale_detail.dart | 184 +++++++------- lib/ui/screens/my_requests/my_requests.dart | 236 +++++++++--------- lib/ui/screens/my_requests/new_request.dart | 29 +-- .../offers_and_discounts_details.dart | 91 +++---- 6 files changed, 267 insertions(+), 303 deletions(-) diff --git a/lib/models/items_for_sale/get_employee_ads_list.dart b/lib/models/items_for_sale/get_employee_ads_list.dart index 17a2180..68aa805 100644 --- a/lib/models/items_for_sale/get_employee_ads_list.dart +++ b/lib/models/items_for_sale/get_employee_ads_list.dart @@ -22,11 +22,10 @@ class EmployeePostedAds { String? status; List? itemAttachments; String? created; - dynamic? comments; - dynamic? isActive; + bool? isActive; int? pageSize; int? pageNo; - dynamic? languageId; + int? languageId; EmployeePostedAds( {this.itemSaleID, @@ -52,7 +51,6 @@ class EmployeePostedAds { this.status, this.itemAttachments, this.created, - this.comments, this.isActive, this.pageSize, this.pageNo, @@ -87,7 +85,6 @@ class EmployeePostedAds { }); } created = json['created']; - comments = json['comments']; isActive = json['isActive']; pageSize = json['pageSize']; pageNo = json['pageNo']; @@ -122,7 +119,6 @@ class EmployeePostedAds { this.itemAttachments!.map((v) => v.toJson()).toList(); } data['created'] = this.created; - data['comments'] = this.comments; data['isActive'] = this.isActive; data['pageSize'] = this.pageSize; data['pageNo'] = this.pageNo; @@ -137,7 +133,7 @@ class ItemAttachments { String? contentType; String? attachFileStream; String? base64String; - dynamic? isActive; + bool? isActive; int? referenceItemId; String? content; String? filePath; diff --git a/lib/models/my_requests/get_ccp_dff_structure_model.dart b/lib/models/my_requests/get_ccp_dff_structure_model.dart index 878cec4..f5e80cf 100644 --- a/lib/models/my_requests/get_ccp_dff_structure_model.dart +++ b/lib/models/my_requests/get_ccp_dff_structure_model.dart @@ -13,7 +13,6 @@ class GetCCPDFFStructureModel { String? dISPLAYFLAG; String? eNABLEDFLAG; ESERVICESDV? eSERVICESDV; - // List? eSERVICESVS; String? fLEXVALUESETNAME; String? fORMATTYPE; String? fORMATTYPEDSP; @@ -95,12 +94,6 @@ class GetCCPDFFStructureModel { eSERVICESDV = json['E_SERVICES_DV'] != null ? new ESERVICESDV.fromJson(json['E_SERVICES_DV']) : null; - // if (json['E_SERVICES_VS'] != null) { - // eSERVICESVS = []; - // json['E_SERVICES_VS'].forEach((v) { - // eSERVICESVS!.add(new Null.fromJson(v)); - // }); - // } fLEXVALUESETNAME = json['FLEX_VALUE_SET_NAME']; fORMATTYPE = json['FORMAT_TYPE']; fORMATTYPEDSP = json['FORMAT_TYPE_DSP']; @@ -112,19 +105,6 @@ class GetCCPDFFStructureModel { nUMBERPRECISION = json['NUMBER_PRECISION']; nUMERICMODEENABLEDFLAG = json['NUMERIC_MODE_ENABLED_FLAG']; pARENTSEGMENTSDV = json['PARENT_SEGMENTS_DV']; - // if (json['PARENT_SEGMENTS_DV_Splited'] != null) { - // pARENTSEGMENTSDVSplited = []; - // json['PARENT_SEGMENTS_DV_Splited'].forEach((v) { - // pARENTSEGMENTSDVSplited!.add(new Null.fromJson(v)); - // }); - // } - // pARENTSEGMENTSVS = json['PARENT_SEGMENTS_VS']; - // if (json['PARENT_SEGMENTS_VS_SplitedVS'] != null) { - // pARENTSEGMENTSVSSplitedVS = []; - // json['PARENT_SEGMENTS_VS_SplitedVS'].forEach((v) { - // pARENTSEGMENTSVSSplitedVS!.add(new Null.fromJson(v)); - // }); - // } rEADONLY = json['READ_ONLY']; rEQUIREDFLAG = json['REQUIRED_FLAG']; sEGMENTNAME = json['SEGMENT_NAME']; diff --git a/lib/ui/screens/items_for_sale/item_for_sale_detail.dart b/lib/ui/screens/items_for_sale/item_for_sale_detail.dart index 01c60a6..c85f4e0 100644 --- a/lib/ui/screens/items_for_sale/item_for_sale_detail.dart +++ b/lib/ui/screens/items_for_sale/item_for_sale_detail.dart @@ -29,105 +29,109 @@ class _ItemForSaleDetailPageState extends State { appBar: AppBarWidget(context, // title: LocaleKeys.mowadhafhiRequest.tr(), title: "Items for sale", - showHomeButton: true), + showHomeButton: true,), body: SingleChildScrollView( - child: AspectRatio( - aspectRatio: 336 / 554, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), + child: Column( + children: [ + AspectRatio( + aspectRatio: 336 / 554, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], ), - ], - ), - // color: Colors.red, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Container( - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: const Color(0xffEBEBEB).withOpacity(1.0), - blurRadius: 26, - offset: const Offset(0, -3), + // color: Colors.red, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: const Color(0xffEBEBEB).withOpacity(1.0), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], ), - ], - ), - child: Hero( - tag: "ItemImage" + getItemsForSaleList.itemSaleID.toString(), - transitionOnUserGestures: true, - child: AspectRatio( - aspectRatio: 148 / 127, - child: ClipRRect( - borderRadius: BorderRadius.circular(6), - child: Image.memory( - base64Decode(getItemsForSaleList.itemAttachments![0].content!), - fit: BoxFit.cover, - ), + child: Hero( + tag: "ItemImage" + getItemsForSaleList.itemSaleID.toString(), + transitionOnUserGestures: true, + child: AspectRatio( + aspectRatio: 148 / 127, + child: ClipRRect( + borderRadius: BorderRadius.circular(6), + child: Image.memory( + base64Decode(getItemsForSaleList.itemAttachments![0].content!), + fit: BoxFit.cover, + ), + ), + ).paddingAll(8), ), - ).paddingAll(8), - ), - ), - getItemsForSaleList.title!.toText20(isBold: true, color: const Color(0xff2B353E)).paddingOnly(left: 21, right: 21), - getItemsForSaleList.description!.toText12(maxLine: 5, color: const Color(0xff535353)).paddingOnly(left: 21, right: 21, bottom: 21), - getItemsForSaleList.status!.toText16(isBold: true, color: getItemsForSaleList.status == 'Approved' ? MyColors.greenColor : MyColors.yellowColor).paddingOnly(left: 21, right: 21), - "${getItemsForSaleList.quotePrice} ${getItemsForSaleList.currencyCode!}".toText20(isBold: true).paddingOnly(left: 21, right: 21, bottom: 15), - const Divider().paddingOnly(left: 21, right: 21), - Row( - children: [ - CircularAvatar( - height: 40, - width: 40, - ).paddingOnly(left: 21, top: 21), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, + ), + getItemsForSaleList.title!.toText20(isBold: true, color: const Color(0xff2B353E)).paddingOnly(left: 21, right: 21), + getItemsForSaleList.description!.toText12(maxLine: 5, color: const Color(0xff535353)).paddingOnly(left: 21, right: 21, bottom: 21), + getItemsForSaleList.status!.toText16(isBold: true, color: getItemsForSaleList.status == 'Approved' ? MyColors.greenColor : MyColors.yellowColor).paddingOnly(left: 21, right: 21), + "${getItemsForSaleList.quotePrice} ${getItemsForSaleList.currencyCode!}".toText20(isBold: true).paddingOnly(left: 21, right: 21, bottom: 15), + const Divider().paddingOnly(left: 21, right: 21), + Row( children: [ - getItemsForSaleList.fullName!.toText14(isBold: true).paddingOnly(left: 7, right: 7), - "Posted on: ${DateUtil.formatDateToDate(DateTime.parse(getItemsForSaleList.created!), false)}".toText12().paddingOnly(left: 7, right: 7), + CircularAvatar( + height: 40, + width: 40, + ).paddingOnly(left: 21, top: 21), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + getItemsForSaleList.fullName!.toText14(isBold: true).paddingOnly(left: 7, right: 7), + "Posted on: ${DateUtil.formatDateToDate(DateTime.parse(getItemsForSaleList.created!), false)}".toText12().paddingOnly(left: 7, right: 7), + ], + ).paddingOnly(top: 18), ], - ).paddingOnly(top: 18), + ), ], ), - ], + ).paddingAll(21), + ), + Container( + decoration: const BoxDecoration( + color: MyColors.white, + boxShadow: [ + BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 1), + ], + ), + child: Row( + children: [ + DefaultButton("Email", () async { + Uri emailLaunchUri = Uri( + scheme: 'mailto', + path: getItemsForSaleList.emailAddress, + ); + launchUrl(emailLaunchUri); + }, iconData: Icons.email_sharp, isTextExpanded: false) + .insideContainer + .expanded, + DefaultButton("Call", () async { + Uri callLaunchUri = Uri( + scheme: 'tel', + path: getItemsForSaleList.mobileNumber, + ); + launchUrl(callLaunchUri); + }, iconData: Icons.call_sharp, isTextExpanded: false) + .insideContainer + .expanded, + ], + ), ), - ).paddingAll(21), - ), - ), - bottomSheet: Container( - decoration: const BoxDecoration( - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 1), - ], - ), - child: Row( - children: [ - DefaultButton("Email", () async { - Uri emailLaunchUri = Uri( - scheme: 'mailto', - path: getItemsForSaleList.emailAddress, - ); - launchUrl(emailLaunchUri); - }, iconData: Icons.email_sharp, isTextExpanded: false) - .insideContainer - .expanded, - DefaultButton("Call", () async { - Uri callLaunchUri = Uri( - scheme: 'tel', - path: getItemsForSaleList.mobileNumber, - ); - launchUrl(callLaunchUri); - }, iconData: Icons.call_sharp, isTextExpanded: false) - .insideContainer - .expanded, ], ), ), diff --git a/lib/ui/screens/my_requests/my_requests.dart b/lib/ui/screens/my_requests/my_requests.dart index 82bc38b..ebeff43 100644 --- a/lib/ui/screens/my_requests/my_requests.dart +++ b/lib/ui/screens/my_requests/my_requests.dart @@ -13,7 +13,6 @@ 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_eit_dff_structure_list_model.dart'; import 'package:mohem_flutter_app/models/my_requests/get_ccp_output_model.dart'; import 'package:mohem_flutter_app/models/my_requests/get_ccp_transactions_model.dart'; import 'package:mohem_flutter_app/models/my_requests/get_concurrent_programs_model.dart'; @@ -45,127 +44,128 @@ class _MyRequestsState extends State { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: Colors.white, - appBar: AppBarWidget( - context, - title: "Concurrent Reports", + backgroundColor: Colors.white, + appBar: AppBarWidget( + context, + title: "Concurrent Reports", + ), + body: Container( + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], ), - body: Container( - width: double.infinity, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - children: [ - 12.height, - Container( - padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 0), - margin: const EdgeInsets.only(left: 12, right: 12, top: 0, bottom: 0), - child: PopupMenuButton( - child: DynamicTextFieldWidget( - "Template Name", - selectedConcurrentProgramList?.uSERCONCURRENTPROGRAMNAME ?? "", - isEnable: false, - isPopup: true, - isInputTypeNum: true, - isReadOnly: false, - ).paddingOnly(bottom: 12), - itemBuilder: (_) => >[ - for (int i = 0; i < getConcurrentProgramsList!.length; i++) PopupMenuItem(child: Text(getConcurrentProgramsList![i].uSERCONCURRENTPROGRAMNAME!), value: i), - ], - onSelected: (int popupIndex) { - selectedConcurrentProgramList = getConcurrentProgramsList![popupIndex]; - getCCPTransactions(selectedConcurrentProgramList?.cONCURRENTPROGRAMNAME); - setState(() {}); - }), - ), - 12.height, - Expanded( - child: ListView.separated( - physics: const BouncingScrollPhysics(), - shrinkWrap: true, - itemBuilder: (BuildContext context, int index) { - return Container( - width: double.infinity, - padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 12), - margin: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 0), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - ("Request ID: " + getCCPTransactionsList[index].rEQUESTID.toString()).toText12(color: MyColors.grey57Color), - DateUtil.formatDateToDate(DateUtil.convertStringToDate(getCCPTransactionsList[index].rEQUESTDATE!), false).toText12(color: MyColors.grey70Color), - ], - ), - Container( - padding: const EdgeInsets.only(top: 10.0), - child: ("Phase: " + getCCPTransactionsList[index].cCPPHASE!).toText12(color: MyColors.grey57Color, isBold: true), - ), - Container( - padding: const EdgeInsets.only(top: 10.0), - child: "Program Name: ".toText12(color: MyColors.grey57Color, isBold: true), - ), - getCCPTransactionsList[index].cONCURRENTPROGRAMNAME!.toText12(color: MyColors.gradiantEndColor), - Container( - padding: const EdgeInsets.only(top: 10.0), - child: InkWell( - onTap: () { - getCCPOutput(getCCPTransactionsList[index].rEQUESTID.toString()); - }, - child: Row( - children: [ - "Output: ".toText12(color: MyColors.grey57Color), - 8.width, - "Open PDF".toText12(color: MyColors.grey57Color), - 6.width, - const Icon(Icons.launch, size: 16.0), - ], - ), + child: Column( + children: [ + 12.height, + Container( + padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 0), + margin: const EdgeInsets.only(left: 12, right: 12, top: 0, bottom: 0), + child: PopupMenuButton( + child: DynamicTextFieldWidget( + "Template Name", + selectedConcurrentProgramList?.uSERCONCURRENTPROGRAMNAME ?? "", + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + for (int i = 0; i < getConcurrentProgramsList!.length; i++) PopupMenuItem(child: Text(getConcurrentProgramsList![i].uSERCONCURRENTPROGRAMNAME!), value: i), + ], + onSelected: (int popupIndex) { + selectedConcurrentProgramList = getConcurrentProgramsList![popupIndex]; + getCCPTransactions(selectedConcurrentProgramList?.cONCURRENTPROGRAMNAME); + setState(() {}); + }), + ), + 12.height, + Expanded( + child: ListView.separated( + physics: const BouncingScrollPhysics(), + shrinkWrap: true, + itemBuilder: (BuildContext context, int index) { + return Container( + width: double.infinity, + padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 12), + margin: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 0), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + ("Request ID: " + getCCPTransactionsList[index].rEQUESTID.toString()).toText12(color: MyColors.grey57Color), + DateUtil.formatDateToDate(DateUtil.convertStringToDate(getCCPTransactionsList[index].rEQUESTDATE!), false).toText12(color: MyColors.grey70Color), + ], + ), + Container( + padding: const EdgeInsets.only(top: 10.0), + child: ("Phase: " + getCCPTransactionsList[index].cCPPHASE!).toText12(color: MyColors.grey57Color, isBold: true), + ), + Container( + padding: const EdgeInsets.only(top: 10.0), + child: "Program Name: ".toText12(color: MyColors.grey57Color, isBold: true), + ), + getCCPTransactionsList[index].cONCURRENTPROGRAMNAME!.toText12(color: MyColors.gradiantEndColor), + Container( + padding: const EdgeInsets.only(top: 10.0), + child: InkWell( + onTap: () { + getCCPOutput(getCCPTransactionsList[index].rEQUESTID.toString()); + }, + child: Row( + children: [ + "Output: ".toText12(color: MyColors.grey57Color), + 8.width, + "Open PDF".toText12(color: MyColors.grey57Color), + 6.width, + const Icon(Icons.launch, size: 16.0), + ], ), ), - ], - ), - ); - }, - separatorBuilder: (BuildContext context, int index) => 12.height, - itemCount: getCCPTransactionsList.length ?? 0)), - 80.height - ], - ), + ), + ], + ), + ); + }, + separatorBuilder: (BuildContext context, int index) => 12.height, + itemCount: getCCPTransactionsList.length ?? 0)), + 80.height, + Container( + decoration: const BoxDecoration( + color: MyColors.white, + boxShadow: [ + BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), + ], + ), + child: DefaultButton(LocaleKeys.createRequest.tr(), () async { + openNewRequest(); + }).insideContainer, + ) + ], ), - bottomSheet: Container( - decoration: const BoxDecoration( - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), - ], - ), - child: DefaultButton(LocaleKeys.createRequest.tr(), () async { - openNewRequest(); - }).insideContainer, - )); + ), + ); } void openNewRequest() async { diff --git a/lib/ui/screens/my_requests/new_request.dart b/lib/ui/screens/my_requests/new_request.dart index 9577944..4cc2b20 100644 --- a/lib/ui/screens/my_requests/new_request.dart +++ b/lib/ui/screens/my_requests/new_request.dart @@ -78,21 +78,23 @@ class _NewRequestState extends State { itemBuilder: (cxt, int parentIndex) => parseDynamicFormatType(getCCPDFFStructureModelList[parentIndex], parentIndex), separatorBuilder: (cxt, index) => 0.height, itemCount: getCCPDFFStructureModelList.length)) - .expanded + .expanded, + Container( + decoration: const BoxDecoration( + color: MyColors.white, + boxShadow: [ + BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), + ], + ), + child: DefaultButton(LocaleKeys.submit.tr(), () async { + // openNewRequest(); + }) + .insideContainer, + ) ], ), ), - bottomSheet: Container( - decoration: const BoxDecoration( - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), - ], - ), - child: DefaultButton(LocaleKeys.submit.tr(), () async { - // openNewRequest(); - }).insideContainer, - ) + // bottomSheet: ); } @@ -412,8 +414,7 @@ class _NewRequestState extends State { ), ); } else { - DateTime? picked = - await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); + DateTime? picked = await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); if (picked != null && picked != selectedDate) { time = picked; } diff --git a/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart b/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart index e5b7f11..e1e216d 100644 --- a/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart +++ b/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart @@ -167,63 +167,46 @@ class _OffersAndDiscountsDetailsState extends State { } Widget getItemCard(OffersListModel getOffersList) { - return InkWell( - onTap: () { - this.getOffersList[0] = getOffersList; - _scrollToTop(); - setState(() {}); - }, - child: Container( - padding: const EdgeInsets.all(10.0), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Hero( - tag: "ItemImage" + getOffersList.rowID!, - transitionOnUserGestures: true, - child: AspectRatio( - aspectRatio: 148 / 127, - child: ClipRRect( - borderRadius: BorderRadius.circular(6), - child: Image.network( - getOffersList.bannerImage!, - fit: BoxFit.contain, - ), - ), + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Hero( + tag: "ItemImage" + getOffersList.rowID!, + transitionOnUserGestures: true, + child: AspectRatio( + aspectRatio: 148 / 127, + child: ClipRRect( + borderRadius: BorderRadius.circular(6), + child: Image.network( + getOffersList.bannerImage!, + fit: BoxFit.contain, ), ), - 5.height, - getOffersList.title!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), - // Html( - // data: AppState().isArabic(context) ? getOffersList.descriptionAR! : getOffersList.description ?? "", - // // onLinkTap: (String? url, RenderContext context, Map attributes, _) { - // // launchUrl(Uri.parse(url!)); - // // } - // ), - getOffersList.description!.toText12(maxLine: 2, color: const Color(0xff535353)), - 16.height, - getOffersList.discount!.toText14(isBold: true, maxlines: 1), - 10.height, - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [checkDate(getOffersList.endDate!), SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)], - ), - ], + ), ), - ), - ); + 5.height, + getOffersList.title!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), + // Html( + // data: AppState().isArabic(context) ? getOffersList.descriptionAR! : getOffersList.description ?? "", + // // onLinkTap: (String? url, RenderContext context, Map attributes, _) { + // // launchUrl(Uri.parse(url!)); + // // } + // ), + getOffersList.description!.toText12(maxLine: 2, color: const Color(0xff535353)), + 16.height, + getOffersList.discount!.toText14(isBold: true, maxlines: 1), + 8.height, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [checkDate(getOffersList.endDate!), SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)], + ), + ], + ).objectContainerView().onPress(() { + this.getOffersList[0] = getOffersList; + _scrollToTop(); + setState(() {}); + }); } void getOfferLocation() {} From 416a33b2fdc663fe0b0a5318fa99d110c237fe9a Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Mon, 29 Aug 2022 14:12:13 +0300 Subject: [PATCH 29/40] fix design --- assets/images/call.svg | 7 + assets/images/create_request.svg | 6 + assets/images/profile_details.svg | 14 + assets/images/team.svg | 34 ++ assets/images/view_attendance.svg | 8 + assets/langs/ar-SA.json | 11 + assets/langs/en-US.json | 11 + lib/classes/colors.dart | 5 + lib/config/routes.dart | 2 +- lib/generated/codegen_loader.g.dart | 20 ++ lib/generated/locale_keys.g.dart | 10 + lib/models/profile_menu.model.dart | 6 +- .../attendance/monthly_attendance_screen.dart | 4 +- lib/ui/login/login_screen.dart | 2 +- lib/ui/my_team/employee_details.dart | 129 +++---- lib/ui/my_team/my_team.dart | 241 +++++-------- lib/ui/my_team/profile_details.dart | 36 +- lib/ui/my_team/team_members.dart | 156 +++------ lib/ui/my_team/view_attendance.dart | 32 +- lib/ui/profile/add_update_family_member.dart | 28 +- lib/ui/profile/basic_details.dart | 111 +++--- lib/ui/profile/contact_details.dart | 2 +- lib/ui/profile/delete_family_member.dart | 39 ++- lib/ui/profile/family_members.dart | 317 ++++++++---------- lib/ui/work_list/worklist_settings.dart | 131 ++++---- 25 files changed, 645 insertions(+), 717 deletions(-) create mode 100644 assets/images/call.svg create mode 100644 assets/images/create_request.svg create mode 100644 assets/images/profile_details.svg create mode 100644 assets/images/team.svg create mode 100644 assets/images/view_attendance.svg diff --git a/assets/images/call.svg b/assets/images/call.svg new file mode 100644 index 0000000..f98d059 --- /dev/null +++ b/assets/images/call.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/images/create_request.svg b/assets/images/create_request.svg new file mode 100644 index 0000000..c5bdeea --- /dev/null +++ b/assets/images/create_request.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/images/profile_details.svg b/assets/images/profile_details.svg new file mode 100644 index 0000000..9daf5ad --- /dev/null +++ b/assets/images/profile_details.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/assets/images/team.svg b/assets/images/team.svg new file mode 100644 index 0000000..aff9c19 --- /dev/null +++ b/assets/images/team.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/images/view_attendance.svg b/assets/images/view_attendance.svg new file mode 100644 index 0000000..256bf7a --- /dev/null +++ b/assets/images/view_attendance.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 0c6ce54..c14d655 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -339,6 +339,17 @@ "pleaseSelectEmployeeForReplacement": "الرجاء تحديد موظف للاستبدال", "pleaseSelectAction": "الرجاء تحديد الإجراء", "pleaseSelectDate": "الرجاء تحديد التاريخ", + "todayAttendance": "حضور اليوم", + "viewAttendance": "عرض الحضور", + "teamMembers":"اعضاءالفريق", + "profileDetails": "الملف الشخصي", + "noResultsFound" : "لايوجد نتائج", + "searchBy": "بحث بواسطة", + "myTeamMembers": "اعضاء فريقي", + "save": "حفظ", + "itemType": "نوع العنصر", + "TurnNotificationsFor": "تفعيل الاشعارات", + "worklistSettings": "اعدادات الاشعارات", "profile": { "reset_password": { "label": "Reset Password", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 812fa49..69adbf2 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -339,6 +339,17 @@ "pleaseSelectEmployeeForReplacement": "Please select employee for replacement", "pleaseSelectAction": "Please select action", "pleaseSelectDate": "Please select date", + "todayAttendance": "Today's Attendance", + "viewAttendance": "View Attendance", + "teamMembers":"Team Members", + "profileDetails": "Profile Details", + "noResultsFound" : "No Results Found", + "searchBy": "Search by", + "myTeamMembers": "My Team Members", + "save": "Save", + "itemType": "Item Type", + "TurnNotificationsFor": "Turn on notifications for", + "worklistSettings": "Worklist Settings", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/classes/colors.dart b/lib/classes/colors.dart index feabaea..322bac6 100644 --- a/lib/classes/colors.dart +++ b/lib/classes/colors.dart @@ -43,4 +43,9 @@ class MyColors { static const Color lightGrayColor = Color(0xff808080); static const Color DarkRedColor = Color(0xffD02127); static const Color lightGreyColor = Color(0xffC7C7C7); + static const Color green69Color = Color(0xff1FA169); + static const Color redA3Color = Color(0xffCA3332); + static const Color green9CColor = Color(0xff259CB8); + static const Color green2DColor = Color(0xff32D892); + static const Color greyC4Color = Color(0xffC4C4C4); } diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 4742b0d..92d39ab 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -14,7 +14,7 @@ import 'package:mohem_flutter_app/ui/misc/request_submit_screen.dart'; import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart'; import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart'; import 'package:mohem_flutter_app/ui/my_attendance/services_menu_list_screen.dart'; -import 'package:mohem_flutter_app/ui/my_attendance/my_attendance_screen.dart'; +// import 'package:mohem_flutter_app/ui/my_attendance/my_attendance_screen.dart'; import 'package:mohem_flutter_app/ui/my_team/create_request.dart'; import 'package:mohem_flutter_app/ui/my_team/employee_details.dart'; import 'package:mohem_flutter_app/ui/my_team/my_team.dart'; diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 57323da..ae25a1e 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -355,6 +355,16 @@ class CodegenLoader extends AssetLoader{ "pleaseSelectEmployeeForReplacement": "الرجاء تحديد موظف للاستبدال", "pleaseSelectAction": "الرجاء تحديد الإجراء", "pleaseSelectDate": "الرجاء تحديد التاريخ", + "todayAttendance": "حضور اليوم", + "viewAttendance": "عرض الحضور", + "teamMembers": "اعضاءالفريق", + "profileDetails": "الملف الشخصي", + "noResultsFound": "لايوجد نتائج", + "searchBy": "بحث بواسطة", + "myTeamMembers": "اعضاء فريقي", + "save": "حفظ", + "TurnNotificationsFor": "تفعيل الاشعارات", + "worklistSettings": "اعدادات الاشعارات", "profile": { "reset_password": { "label": "Reset Password", @@ -730,6 +740,16 @@ static const Map en_US = { "pleaseSelectEmployeeForReplacement": "Please select employee for replacement", "pleaseSelectAction": "Please select action", "pleaseSelectDate": "Please select date", + "todayAttendance": "Today's Attendance", + "viewAttendance": "View Attendance", + "teamMembers": "Team Members", + "profileDetails": "Profile Details", + "noResultsFound": "No Results Found", + "searchBy": "Search by", + "myTeamMembers": "My Team Members", + "save": "Save", + "TurnNotificationsFor": "Turn on notifications for", + "worklistSettings": "Worklist Settings", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index d736c34..c3e3081 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -340,6 +340,16 @@ abstract class LocaleKeys { static const pleaseSelectEmployeeForReplacement = 'pleaseSelectEmployeeForReplacement'; static const pleaseSelectAction = 'pleaseSelectAction'; static const pleaseSelectDate = 'pleaseSelectDate'; + static const todayAttendance = 'todayAttendance'; + static const viewAttendance = 'viewAttendance'; + static const teamMembers = 'teamMembers'; + static const profileDetails = 'profileDetails'; + static const noResultsFound = 'noResultsFound'; + static const searchBy = 'searchBy'; + static const myTeamMembers = 'myTeamMembers'; + static const save = 'save'; + static const TurnNotificationsFor = 'TurnNotificationsFor'; + static const worklistSettings = 'worklistSettings'; static const profile_reset_password_label = 'profile.reset_password.label'; static const profile_reset_password_username = 'profile.reset_password.username'; static const profile_reset_password_password = 'profile.reset_password.password'; diff --git a/lib/models/profile_menu.model.dart b/lib/models/profile_menu.model.dart index b14198f..0fdfb6b 100644 --- a/lib/models/profile_menu.model.dart +++ b/lib/models/profile_menu.model.dart @@ -2,10 +2,6 @@ class ProfileMenu { final String name; final String icon; final String route; - final String dynamicUrl; - final String functionName; - final String requestID; - final GetMenuEntriesList menuEntries; final dynamic arguments; - ProfileMenu({this.name = '', this.icon = '', this.route = '', this.arguments = '', this.dynamicUrl = '', this.functionName = '', this.requestID = '', required this.menuEntries}); + ProfileMenu({this.name = '', this.icon = '', this.route = '', this.arguments = ''}); } diff --git a/lib/ui/attendance/monthly_attendance_screen.dart b/lib/ui/attendance/monthly_attendance_screen.dart index 6a73f70..614fc94 100644 --- a/lib/ui/attendance/monthly_attendance_screen.dart +++ b/lib/ui/attendance/monthly_attendance_screen.dart @@ -113,8 +113,8 @@ class _MonthlyAttendanceScreenState extends State { LocaleKeys.attendance.tr().toText24(isBold: true, color: MyColors.darkIconColor), Row( children: [ - "${DateFormat("MMMM-yyyy").format(formattedDate)}".toText16(color: MyColors.greyACColor), - const Icon(Icons.keyboard_arrow_down_rounded, color: MyColors.greyACColor), + "${DateFormat("MMMM-yyyy").format(formattedDate)}".toText16(color: MyColors.grey3AColor), + const Icon(Icons.keyboard_arrow_down_rounded, color: MyColors.grey3AColor), ], ).onPress(() async { showMonthPicker( diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index a2ef87a..7cccca8 100644 --- a/lib/ui/login/login_screen.dart +++ b/lib/ui/login/login_screen.dart @@ -135,7 +135,7 @@ class _LoginScreenState extends State { @override Widget build(BuildContext context) { username.text = "15153"; - password.text = "Abcd@1234"; + password.text = "Abcd@12345"; // username.text = "15444"; return Scaffold( diff --git a/lib/ui/my_team/employee_details.dart b/lib/ui/my_team/employee_details.dart index 064158c..2ef488b 100644 --- a/lib/ui/my_team/employee_details.dart +++ b/lib/ui/my_team/employee_details.dart @@ -2,6 +2,7 @@ import 'dart:collection'; import 'dart:ui'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_html/html_parser.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:mohem_flutter_app/api/my_team/my_team_api_client.dart'; import 'package:mohem_flutter_app/api/worklist/worklist_api_client.dart'; @@ -42,7 +43,7 @@ class _EmployeeDetailsState extends State { @override void initState() { super.initState(); - setState(() {}); + // setState(() {}); } //favorite @@ -126,67 +127,67 @@ class _EmployeeDetailsState extends State { width: _width, //height: 150, margin: EdgeInsets.only(top: 50), - padding: EdgeInsets.only(top: 50), + //padding: EdgeInsets.only(right: 17, left: 17), decoration: BoxDecoration( - color: Colors.white, + color: MyColors.whiteColor, borderRadius: const BorderRadius.all(Radius.circular(15)), boxShadow: [BoxShadow(color: MyColors.lightGreyColor, blurRadius: 15, spreadRadius: 3)], ), - child: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - /// card header - customLabel(getEmployeeSubordinates!.eMPLOYEENAME.toString(), 22, Colors.black, true), - customLabel(getEmployeeSubordinates!.eMPLOYEENUMBER.toString() + ' | ' + getEmployeeSubordinates!.jOBNAME.toString(), 14, Colors.grey, false), - customLabel(getEmployeeSubordinates!.eMPLOYEEEMAILADDRESS.toString(), 13, Colors.black, true), - ], - ).paddingOnly(top: 10, bottom: 10), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + onPressed: (){ + if(getEmployeeSubordinates!.isFavorite != true){ + showFavoriteAlertDialog(context); + setState(() {}); + }else{ + fetchChangeFav( + email: getEmployeeSubordinates?.eMPLOYEEEMAILADDRESS ?? "", + employeName: getEmployeeSubordinates!.eMPLOYEENAME ?? "", + image: getEmployeeSubordinates!.eMPLOYEEIMAGE ?? "", + userName: getEmployeeSubordinates!.eMPLOYEENUMBER ?? "", + isFav: false,); + setState(() {}); + } }, + icon: getEmployeeSubordinates!.isFavorite != true + ? Icon( + Icons.star_outline, + size: 35, + color: MyColors.green9CColor, + ) + : Icon( + Icons.star_outlined, + size: 35, + color: MyColors.green9CColor, + ), + ), + // Container(height: 100, alignment: Alignment.center, child: ProfileImage()), + InkWell( + onTap:() { + launchUrl(phoneNumber); + }, + child: SvgPicture.asset("assets/images/call.svg"), + ), + ], + ).paddingOnly(left:6, right: 17, top: 16), + Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + /// card header + customLabel(getEmployeeSubordinates!.eMPLOYEENAME.toString(), 21, MyColors.grey3AColor, true), + customLabel(getEmployeeSubordinates!.eMPLOYEENUMBER.toString() + ' | ' + getEmployeeSubordinates!.jOBNAME.toString(), 13, MyColors.grey80Color, true), + customLabel(getEmployeeSubordinates!.eMPLOYEEEMAILADDRESS.toString(), 13, MyColors.grey3AColor, true), + ], + ).paddingOnly(bottom: 10), + ], ), ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - IconButton( - onPressed: (){ - if(getEmployeeSubordinates!.isFavorite != true){ - showFavoriteAlertDialog(context); - setState(() {}); - }else{ - fetchChangeFav( - email: getEmployeeSubordinates?.eMPLOYEEEMAILADDRESS ?? "", - employeName: getEmployeeSubordinates!.eMPLOYEENAME ?? "", - image: getEmployeeSubordinates!.eMPLOYEEIMAGE ?? "", - userName: getEmployeeSubordinates!.eMPLOYEENUMBER ?? "", - isFav: false,); - setState(() {}); - } }, - icon: getEmployeeSubordinates!.isFavorite != true - ? Icon( - Icons.star_outline, - size: 35, - color: Colors.green, - ) - : Icon( - Icons.star_outlined, - size: 35, - color: Colors.green, - ), - ).paddingOnly(top: 50), - Container(height: 100, alignment: Alignment.center, child: ProfileImage()), - IconButton( - onPressed: () { - launchUrl(phoneNumber); - }, - icon: Icon( - Icons.whatsapp, - color: Colors.green, - size: 30, - ).paddingOnly(top: 30), - ), - ], - ) - ])), + Container(height: 100, alignment: Alignment.center, child: ProfileImage()), + ]) + ), Container( margin: EdgeInsets.fromLTRB(21, 8, 21, 10), height: 260, @@ -228,17 +229,21 @@ class _EmployeeDetailsState extends State { }, child: ListTile( leading: SvgPicture.asset('assets/images/' + obj.icon), - title: Text(obj.name), - trailing: Icon(Icons.arrow_forward), + title: Text(obj.name, + style: TextStyle(color: MyColors.grey3AColor, + fontWeight: FontWeight.w600, + fontSize: 16)), + trailing: Icon(Icons.arrow_forward, + color: MyColors.grey3AColor,), ), ); } void setMenu(){ menu = [ - ProfileMenu(name: "Profile Details", icon: 'personal-info.svg', route: AppRoutes.profileDetails, arguments:getEmployeeSubordinates, dynamicUrl: '', menuEntries: getMenuEntries('')), - ProfileMenu(name: "Create Request", icon: 'personal-info.svg', route: AppRoutes.createRequest,arguments: getEmployeeSubordinates, menuEntries: getMenuEntries('')), - ProfileMenu(name: "View Attendance", icon: 'personal-info.svg', route: AppRoutes.viewAttendance, arguments: getEmployeeSubordinates, dynamicUrl: '', menuEntries: getMenuEntries('')), - ProfileMenu(name: "Team Members", icon: 'family-members.svg', route: AppRoutes.teamMembers, arguments: getEmployeeSubordinates, dynamicUrl: '', menuEntries: getMenuEntries('')), + ProfileMenu(name: "Profile Details", icon: "profile_details.svg", route: AppRoutes.profileDetails, arguments:getEmployeeSubordinates), + ProfileMenu(name: "Create Request", icon: "create_request.svg", route: AppRoutes.createRequest,arguments: getEmployeeSubordinates), + ProfileMenu(name: "View Attendance", icon: "view_attendance.svg", route: AppRoutes.viewAttendance, arguments: getEmployeeSubordinates), + ProfileMenu(name: "Team Members", icon: "team.svg", route: AppRoutes.teamMembers, arguments: getEmployeeSubordinates), ]; } diff --git a/lib/ui/my_team/my_team.dart b/lib/ui/my_team/my_team.dart index 5cb89ef..7366128 100644 --- a/lib/ui/my_team/my_team.dart +++ b/lib/ui/my_team/my_team.dart @@ -1,16 +1,18 @@ - +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:mohem_flutter_app/api/my_team/my_team_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.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/my_team/get_employee_subordinates_list.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:url_launcher/url_launcher.dart'; - class MyTeam extends StatefulWidget { const MyTeam({Key? key}) : super(key: key); @@ -19,8 +21,8 @@ class MyTeam extends StatefulWidget { } class _MyTeamState extends State { - String searchEmpEmail =""; - String searchEmpName =""; + String searchEmpEmail = ""; + String searchEmpName = ""; String searchEmpNo = ""; String? empId; List getEmployeeSubordinatesList = []; @@ -38,7 +40,7 @@ class _MyTeamState extends State { try { Utils.showLoading(context); getEmployeeSubordinatesList = await MyTeamApiClient().getEmployeeSubordinates(searchEmpEmail.toString(), searchEmpName.toString(), searchEmpNo.toString()); - getEmployeeSListOnSearch =getEmployeeSubordinatesList; + getEmployeeSListOnSearch = getEmployeeSubordinatesList; Utils.hideLoading(context); setState(() {}); } catch (ex) { @@ -51,191 +53,132 @@ class _MyTeamState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBarWidget( - context, - title:"My Team Members", + context, + title: LocaleKeys.myTeamMembers.tr(), ), - backgroundColor: MyColors.backgroundColor, + backgroundColor: MyColors.backgroundColor, body: SingleChildScrollView( child: Column( children: [ - Container( - width: double.infinity, - margin: EdgeInsets.only( - top: 28, - left: 18, - right: 18, - // bottom: 28 - ), - padding: EdgeInsets.only( left: 10, right: 10), - height: 65, - 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: - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children : [ - Expanded( - child: - TextField( - onChanged: dropdownValue =="Name" ? - (String value){ - getEmployeeSListOnSearch = getEmployeeSubordinatesList.where((GetEmployeeSubordinatesList element) - => element.eMPLOYEENAME!.toLowerCase().contains(value.toLowerCase())).toList(); + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Expanded( + child: TextField( + onChanged: dropdownValue == "Name" + ? (String value) { + getEmployeeSListOnSearch = + getEmployeeSubordinatesList.where((GetEmployeeSubordinatesList element) => element.eMPLOYEENAME!.toLowerCase().contains(value.toLowerCase())).toList(); + setState(() {}); + } + : (String value) { + getEmployeeSListOnSearch = + getEmployeeSubordinatesList.where((GetEmployeeSubordinatesList element) => element.eMPLOYEEEMAILADDRESS!.toLowerCase().contains(value.toLowerCase())).toList(); setState(() {}); - }: (String value){ - getEmployeeSListOnSearch = getEmployeeSubordinatesList.where((GetEmployeeSubordinatesList element) - => element.eMPLOYEEEMAILADDRESS!.toLowerCase().contains(value.toLowerCase())).toList(); - setState(() {}); }, - controller: _textEditingController, - decoration: InputDecoration( - filled: true, - fillColor: Colors.white, - border: InputBorder.none, - enabledBorder: InputBorder.none, - focusedBorder: InputBorder.none, - // contentPadding: EdgeInsets.fromLTRB(10, 15, 10, 15), - hintText: 'Search by $dropdownValue', - hintStyle: TextStyle(fontSize: 16.0, color: Colors.black,), - ), - )), - dropDown() - ]), - ), + controller: _textEditingController, + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + border: InputBorder.none, + enabledBorder: InputBorder.none, + focusedBorder: InputBorder.none, + // contentPadding: EdgeInsets.fromLTRB(10, 15, 10, 15), + hintText: LocaleKeys.searchBy.tr() + " $dropdownValue", + hintStyle: TextStyle(fontSize: 14.0, color: MyColors.grey57Color, fontWeight: FontWeight.w600), + ), + )), + Row( + children: [ + "|".toText16(color: MyColors.greyC4Color), + 10.width, + dropDown(), + ], + ) + ]).objectContainerBorderView(), + // ), Container( + margin: EdgeInsets.only(left: 21, right: 21), width: MediaQuery.of(context).size.width, child: SingleChildScrollView( scrollDirection: Axis.vertical, child: Column( children: [ - _textEditingController!.text.isNotEmpty && getEmployeeSListOnSearch.isEmpty ? - Container( - child: "No Results found".toText16(color: MyColors.blackColor),).paddingOnly(top: 10) - : ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: ScrollPhysics(), - itemCount: _textEditingController!.text.isNotEmpty ? getEmployeeSListOnSearch.length : getEmployeeSubordinatesList.length, - itemBuilder: (context, index) { - var phoneNumber = Uri.parse('tel:${getEmployeeSListOnSearch[index].eMPLOYEEMOBILENUMBER}'); - return Container( - width: double.infinity, - margin: EdgeInsets.only( - top: 18, - left: 18, - right: 18, - ), - padding: EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10), - // height: 110, - 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: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( + _textEditingController!.text.isNotEmpty && getEmployeeSListOnSearch.isEmpty + ? Container( + child: LocaleKeys.noResultsFound.tr().toText16(color: MyColors.blackColor), + ).paddingOnly(top: 10) + : ListView.separated( + scrollDirection: Axis.vertical, + shrinkWrap: true, + // padding: EdgeInsets.only(left: 21, right: 21), + physics: ScrollPhysics(), + separatorBuilder: (cxt, index) => 12.height, + itemCount: _textEditingController!.text.isNotEmpty ? getEmployeeSListOnSearch.length : getEmployeeSubordinatesList.length, + itemBuilder: (context, index) { + var phoneNumber = Uri.parse('tel:${getEmployeeSListOnSearch[index].eMPLOYEEMOBILENUMBER}'); + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + CircleAvatar( + radius: 25, + backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSListOnSearch[index].eMPLOYEEIMAGE)), + backgroundColor: Colors.black, + ), + 10.width, Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - - CircleAvatar( - radius: 25, - backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSListOnSearch[index].eMPLOYEEIMAGE)), - backgroundColor: Colors.black, - ), + // "Present".toText13(color: MyColors.greenColor), + "${getEmployeeSListOnSearch[index].eMPLOYEENAME}".toText16(isBold: true, color: MyColors.grey3AColor), + "${getEmployeeSListOnSearch[index].pOSITIONNAME}".toText10(isBold: true, color: MyColors.grey57Color), ], - ), - SizedBox( - width: 10, - ), + ).expanded, Column( - crossAxisAlignment: CrossAxisAlignment.start, children: [ - "Present".toText13(color: MyColors.greenColor), - "${getEmployeeSListOnSearch[index].eMPLOYEENAME}".toText16(color: MyColors.blackColor), - "${getEmployeeSListOnSearch[index].pOSITIONNAME}".toText13(color: MyColors.blackColor), - + InkWell( + onTap: () { + launchUrl(phoneNumber); + }, + child: SvgPicture.asset("assets/images/call.svg"), + ), + 21.height, + InkWell( + onTap: () async { + Navigator.pushNamed(context, AppRoutes.employeeDetails, arguments: getEmployeeSListOnSearch[index]); + }, + child: Icon(Icons.arrow_forward_outlined, color: MyColors.grey3AColor), + ), ], ), ], - ), - Column( - children: [ - IconButton( - onPressed: () { - launchUrl(phoneNumber); - }, - icon: Icon( - Icons.whatsapp, - color: Colors.green, - ), - ), - IconButton( - onPressed: () async{ - Navigator.pushNamed(context,AppRoutes.employeeDetails,arguments: getEmployeeSListOnSearch[index]); - // Navigator.of(context).push(MaterialPageRoute(builder: (context)=> EmployeeDetails(getEmployeeSubordinates: getEmployeeSubordinatesList[index])),); - }, - icon: Icon( - Icons.arrow_forward_outlined, - color: Colors.grey, - ), - ), - - - ], - ), - ], - ), - ); - }) + ).objectContainerView(); + }) ], ), - ) + ), ) ], ), - ) - ); + )); } - Widget dropDown(){ + Widget dropDown() { return DropdownButton( value: dropdownValue, - icon: const Icon(Icons.keyboard_arrow_down), + icon: const Icon(Icons.keyboard_arrow_down, + color: MyColors.grey57Color), elevation: 16, onChanged: (String? newValue) { setState(() { dropdownValue = newValue!; }); }, - items: ['Name', 'Email'] - .map>((String value) { + items: ['Name', 'Email'].map>((String value) { return DropdownMenuItem( value: value, child: Text(value), ); }).toList(), + style: TextStyle(fontSize: 14.0, color: MyColors.grey57Color, fontWeight: FontWeight.w600), ); } - } - diff --git a/lib/ui/my_team/profile_details.dart b/lib/ui/my_team/profile_details.dart index 49690f0..419f897 100644 --- a/lib/ui/my_team/profile_details.dart +++ b/lib/ui/my_team/profile_details.dart @@ -2,6 +2,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/get_employee_basic_details.model.dart'; @@ -33,7 +34,7 @@ class _ProfileDetailsState extends State { return Scaffold( appBar: AppBarWidget( context, - title: "Profile Details", + title: LocaleKeys.profileDetails.tr(), ), backgroundColor: MyColors.backgroundColor, body: Column( @@ -41,12 +42,11 @@ class _ProfileDetailsState extends State { Container( width: double.infinity, margin: EdgeInsets.only( - top: 28, - left: 26, - right: 26, + top: 20, + left: 21, + right: 21, ), padding: EdgeInsets.only(left: 14, right: 14, top: 13, bottom: 20), - height: 350, decoration: BoxDecoration( boxShadow: [ BoxShadow( @@ -61,27 +61,19 @@ class _ProfileDetailsState extends State { ), child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ LocaleKeys.category.tr().toText13(color: MyColors.lightGrayColor), - "${getEmployeeSubordinates?.eMPLOYMENTCATEGORYMEANING}".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20, - ), + "${getEmployeeSubordinates?.eMPLOYMENTCATEGORYMEANING}".toText16(isBold: true, color: MyColors.darkTextColor), + 23.height, LocaleKeys.address.tr().toText13(color: MyColors.lightGrayColor), - "${getEmployeeSubordinates?.lOCATIONNAME}".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20, - ), + "${getEmployeeSubordinates?.lOCATIONNAME}".toText16(isBold: true, color: MyColors.darkTextColor), + 23.height, LocaleKeys.phoneNumber.tr().toText13(color: MyColors.lightGrayColor), - "${getEmployeeSubordinates?.eMPLOYEEMOBILENUMBER}".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20, - ), + "${getEmployeeSubordinates?.eMPLOYEEMOBILENUMBER}".toText16(isBold: true, color: MyColors.darkTextColor), + 23.height, LocaleKeys.businessGroup.tr().toText13(color: MyColors.lightGrayColor), - "${getEmployeeSubordinates?.bUSINESSGROUPNAME}".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20, - ), + "${getEmployeeSubordinates?.bUSINESSGROUPNAME}".toText16(isBold: true, color: MyColors.darkTextColor), + 23.height, LocaleKeys.Payroll.tr().toText13(color: MyColors.lightGrayColor), - "${getEmployeeSubordinates?.pAYROLLNAME}".toText16(isBold: true, color: MyColors.blackColor), + "${getEmployeeSubordinates?.pAYROLLNAME}".toText16(isBold: true, color: MyColors.darkTextColor), ]), ), ], diff --git a/lib/ui/my_team/team_members.dart b/lib/ui/my_team/team_members.dart index 7dccf5e..f36a13b 100644 --- a/lib/ui/my_team/team_members.dart +++ b/lib/ui/my_team/team_members.dart @@ -1,9 +1,13 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/my_team/my_team_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.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/my_team/get_employee_subordinates_list.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -26,8 +30,6 @@ class _TeamMembersState extends State { void initState() { super.initState(); employeeSubordinates(); - setState(() {}); - } void employeeSubordinates() async { @@ -49,108 +51,58 @@ class _TeamMembersState extends State { return Scaffold( appBar: AppBarWidget( context, - title: "Team Members", + title: LocaleKeys.teamMembers.tr(), ), backgroundColor: MyColors.backgroundColor, body: SingleChildScrollView( - child: Column( - children: [ - Container( - width: MediaQuery.of(context).size.width, - child: SingleChildScrollView( - scrollDirection: Axis.vertical, - child: Column( - children: [ - if(getEmployeeSubordinatesList != 0) - ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: ScrollPhysics(), - itemCount: getEmployeeSubordinatesList.length, - itemBuilder: (context, index) { - var phoneNumber = Uri.parse('tel:${getEmployeeSubordinatesList[index].eMPLOYEENUMBER}'); - return Container( - width: double.infinity, - margin: EdgeInsets.only( - top: 18, - left: 18, - right: 18, - ), - padding: EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10), - 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: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Column( - children: [ - CircleAvatar( - radius: 25, - backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSubordinatesList[index].eMPLOYEEIMAGE)), - backgroundColor: Colors.black, - ), - // MyTeamImage() - ], - ), - SizedBox( - width: 10, - ), - Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - "Present".toText13(color: MyColors.greenColor), - "${getEmployeeSubordinatesList[index].eMPLOYEENAME}".toText16(color: MyColors.blackColor), - "${getEmployeeSubordinatesList[index].pOSITIONNAME}".toText13(color: MyColors.blackColor), - ], - ), - ], - ), - Column( - children: [ - IconButton( - onPressed: () { - launchUrl(phoneNumber); - }, - icon: Icon( - Icons.whatsapp, - color: Colors.green, - ), - ), - ], - ), - ], - ), - ); - }), - Container( - margin: EdgeInsets.only(top:30), - child: "No Members".toText16(isBold: true, color: MyColors.black), - ) - ], - ), - ) - // SizedBox(height: 20), - ) - ], - ), - )); + scrollDirection: Axis.vertical, + child: Column( + children: [ + getEmployeeSubordinatesList != 0 + ? ListView.separated( + scrollDirection: Axis.vertical, + shrinkWrap: true, + padding: EdgeInsets.all(21), + physics: ScrollPhysics(), + separatorBuilder: (cxt, index) => 12.height, + itemCount: getEmployeeSubordinatesList.length, + itemBuilder: (context, index) { + var phoneNumber = Uri.parse('tel:${getEmployeeSubordinatesList[index].eMPLOYEEMOBILENUMBER}'); + return Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + CircleAvatar( + radius: 25, + backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSubordinatesList[index].eMPLOYEEIMAGE)), + backgroundColor: Colors.black, + ), + SizedBox(width: 10,), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // "Present".toText13(color: MyColors.greenColor), + "${getEmployeeSubordinatesList[index].eMPLOYEENAME}".toText16(isBold: true, color: MyColors.grey3AColor), + "${getEmployeeSubordinatesList[index].pOSITIONNAME}".toText10(isBold: true, color: MyColors.grey57Color), + ], + ).expanded, + Column( + children: [ + IconButton( + onPressed: () { + launchUrl(phoneNumber); + }, + icon: Icon( + Icons.whatsapp, + color: Colors.green, + ),),], + ),], + ),).objectContainerView(); + }): Container( + child: LocaleKeys.noResultsFound.tr().toText16(color: MyColors.blackColor), + ).paddingOnly(top: 10), + ], + ) + )); } - - Widget MyTeamImage() => CircleAvatar( - radius: 30, - //backgroundImage: MemoryImage(Utils.getPostBytes(memberInformationList.eMPLOYEEIMAGE)), - backgroundColor: Colors.black, - ); } diff --git a/lib/ui/my_team/view_attendance.dart b/lib/ui/my_team/view_attendance.dart index f08ca3b..b24a895 100644 --- a/lib/ui/my_team/view_attendance.dart +++ b/lib/ui/my_team/view_attendance.dart @@ -91,7 +91,7 @@ class _ViewAttendanceState extends State { return Scaffold( appBar: AppBarWidget( context, - title: "View Attendance", + title: LocaleKeys.viewAttendance.tr(), ), backgroundColor: MyColors.backgroundColor, body: SingleChildScrollView( @@ -99,11 +99,11 @@ class _ViewAttendanceState extends State { Container( width: double.infinity, margin: EdgeInsets.only( - top: 28, - left: 18, - right: 18, + top: 21, + left: 21, + right: 21, ), - padding: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 16), + padding: EdgeInsets.only(left: 14, right: 14, top: 15, bottom: 15), // height: 120, decoration: BoxDecoration( boxShadow: [ @@ -120,7 +120,7 @@ class _ViewAttendanceState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - "Today's Attendance".toText20(color: MyColors.blackColor), + LocaleKeys.todayAttendance.tr().toText16(isBold: true, color: MyColors.darkColor), SizedBox( height: 10, ), @@ -129,20 +129,20 @@ class _ViewAttendanceState extends State { children: [ Column( children: [ - LocaleKeys.checkIn.tr().toText12(isBold: true, color: MyColors.greenColor), - "${(attendanceTracking?.pSwipeIn)?? "- - : - -"}".toText16(isBold: true, color: MyColors.grey57Color), + LocaleKeys.checkIn.tr().toText10(isBold: true, color: MyColors.green69Color), + "${(attendanceTracking?.pSwipeIn)?? "- - : - -"}".toText14(isBold: true, color: MyColors.grey57Color), ], ), Column( children: [ - LocaleKeys.checkOut.tr().toText12(isBold: true, color: MyColors.redColor), - "${(attendanceTracking?.pSwipeOut)?? "- - : - -"}".toText16(isBold: true, color: MyColors.grey57Color), + LocaleKeys.checkOut.tr().toText10(isBold: true, color: MyColors.redA3Color), + "${(attendanceTracking?.pSwipeOut)?? "- - : - -"}".toText14(isBold: true, color: MyColors.grey57Color), ], ), Column( children: [ - LocaleKeys.lateIn.tr().toText12(isBold: true, color: MyColors.blackColor), - "${(attendanceTracking?.pLateInHours)?? "- - : - -"}".toText16(isBold: true, color: MyColors.grey57Color), + LocaleKeys.lateIn.tr().toText10(isBold: true, color: MyColors.darkGreyColor), + "${(attendanceTracking?.pLateInHours)?? "- - : - -"}".toText14(isBold: true, color: MyColors.grey57Color), ], ), ], @@ -179,8 +179,8 @@ class _ViewAttendanceState extends State { children: [ Row( children: [ - "${DateFormat("MMMM-yyyy").format(formattedDate)}".toText16(color: MyColors.blackColor), - const Icon(Icons.keyboard_arrow_down_rounded, color: MyColors.blackColor), + "${DateFormat("MMMM-yyyy").format(formattedDate)}".toText16(color: MyColors.grey3AColor), + const Icon(Icons.keyboard_arrow_down_rounded, color: MyColors.grey3AColor), ], ).onPress(() async { showMonthPicker( @@ -438,10 +438,6 @@ class _ViewAttendanceState extends State { ), ), ); - // return Container( - // alignment: Alignment.center, - // child: Text("$val"), - // ); } else { return const SizedBox(); } diff --git a/lib/ui/profile/add_update_family_member.dart b/lib/ui/profile/add_update_family_member.dart index 9a0bd66..107f289 100644 --- a/lib/ui/profile/add_update_family_member.dart +++ b/lib/ui/profile/add_update_family_member.dart @@ -19,6 +19,7 @@ import 'package:mohem_flutter_app/ui/misc/request_submit_screen.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'dart:io'; import 'package:flutter/cupertino.dart'; +import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; import 'package:easy_localization/src/public_ext.dart'; @@ -37,13 +38,12 @@ class _AddUpdateFamilyMemberState extends State { SubmitContactTransactionList? submitContactTransactionList; dynamic args; String? date = "MM/DD/YYYY"; - // String actionType = "UPDATE"; + GetApprovesList? getApprovesList; @override void initState() { - // super.initState(); } @@ -89,15 +89,12 @@ class _AddUpdateFamilyMemberState extends State { Widget build(BuildContext context) { if (args == null) { args = ModalRoute.of(context)!.settings.arguments; - callAddAndUpdateFamilyMember(); - } + callAddAndUpdateFamilyMember();} return Scaffold( appBar: AppBarWidget( context, - title: LocaleKeys.profile_familyDetails.tr(), - ), + title: LocaleKeys.profile_familyDetails.tr(),), backgroundColor: MyColors.backgroundColor, - bottomSheet: footer(), body: args['flag'] == 1 ? Column( children: [ @@ -128,9 +125,11 @@ class _AddUpdateFamilyMemberState extends State { separatorBuilder: (cxt, index) => 0.height, itemCount: getContactDffStructureList!.length), ]).expanded, - SizedBox( - height: 50, - ), + DefaultButton( + LocaleKeys.next.tr(), () async { + submitUpdateForm(); + } + ).insideContainer, ], ) : args['flag'] == 2 @@ -165,9 +164,11 @@ class _AddUpdateFamilyMemberState extends State { separatorBuilder: (cxt, index) => 0.height, itemCount: getContactDffStructureList!.length), ]).expanded, - SizedBox( - height: 50, - ), + DefaultButton( + LocaleKeys.next.tr(), () async { + submitUpdateForm(); + } + ).insideContainer, ], ) : Container(), @@ -405,7 +406,6 @@ class _AddUpdateFamilyMemberState extends State { return ValidateEitTransactionModel(dATEVALUE: dateVal, nAME: e.aPPLICATIONCOLUMNNAME, nUMBERVALUE: numberVal, tRANSACTIONNUMBER: 1, vARCHAR2VALUE: vatcherVal.toString()).toJson(); }).toList(); List> values2 = getContactDffStructureList!.map((e) { - //String tempVar = e!.getContactDetailsList!.vARCHAR2VALUE ?? ""; String? dateVal = ''; String? vatcherVal = ''; int? numberVal; diff --git a/lib/ui/profile/basic_details.dart b/lib/ui/profile/basic_details.dart index eae5c3d..35f2071 100644 --- a/lib/ui/profile/basic_details.dart +++ b/lib/ui/profile/basic_details.dart @@ -6,6 +6,7 @@ import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.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/dashboard/menu_entries.dart'; import 'package:mohem_flutter_app/models/get_employee_basic_details.model.dart'; @@ -43,7 +44,6 @@ class _BasicDetailsState extends State { menuEntries = menuData.where((e) => e.requestType == 'BASIC_DETAILS').toList()[0]; getEmployeeBasicDetails(); - basicDetails(); } void getEmployeeBasicDetails() async { @@ -51,7 +51,6 @@ class _BasicDetailsState extends State { Utils.showLoading(context); getEmployeeBasicDetailsList = await ProfileApiClient().getEmployeeBasicDetails(); Utils.hideLoading(context); - basicDetails(); setState(() {}); } catch (ex) { Utils.hideLoading(context); @@ -59,23 +58,6 @@ class _BasicDetailsState extends State { } } - void basicDetails() { - for (int i = 0; i < getEmployeeBasicDetailsList.length; i++) { - if (getEmployeeBasicDetailsList[i].aPPLICATIONCOLUMNNAME == 'FULL_NAME') { - fullName = getEmployeeBasicDetailsList[i].sEGMENTVALUEDSP; - } else if (getEmployeeBasicDetailsList[i].aPPLICATIONCOLUMNNAME == 'MARITAL_STATUS') { - maritalStatus = getEmployeeBasicDetailsList[i].sEGMENTVALUEDSP; - } else if (getEmployeeBasicDetailsList[i].aPPLICATIONCOLUMNNAME == 'DATE_OF_BIRTH') { - birthDate = getEmployeeBasicDetailsList[i].sEGMENTVALUEDSP; - } else if (getEmployeeBasicDetailsList[i].aPPLICATIONCOLUMNNAME == 'NATIONAL_IDENTIFIER') { - civilIdentityNumber = getEmployeeBasicDetailsList[i].sEGMENTVALUEDSP; - } else if (getEmployeeBasicDetailsList[i].aPPLICATIONCOLUMNNAME == 'EMAIL_ADDRESS') { - emailAddress = getEmployeeBasicDetailsList[i].sEGMENTVALUEDSP; - } else if (getEmployeeBasicDetailsList[i].aPPLICATIONCOLUMNNAME == 'EMPLOYEE_NUMBER') { - employeeNo = getEmployeeBasicDetailsList[i].sEGMENTVALUEDSP; - } - } - } Widget build(BuildContext context) { return Scaffold( @@ -84,69 +66,54 @@ class _BasicDetailsState extends State { title: LocaleKeys.profile_basicDetails.tr(), ), backgroundColor: MyColors.backgroundColor, - bottomSheet: footer(), body: Column( children: [ - Container( - width: double.infinity, - margin: EdgeInsets.only(top: 20, left: 21, right: 21, bottom: 20), - padding: EdgeInsets.only(left: 14, right: 14, top: 13, bottom: 5), - height: 280, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 5, - blurRadius: 26, - offset: Offset(0, 3), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: double.infinity, + margin: EdgeInsets.only(top: 20, left: 21, right: 21, bottom: 20), + padding: EdgeInsets.only(left: 14, right: 14, top: 13, bottom: 5), + height: 300, + 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: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: getEmployeeBasicDetailsList.map((e) => + Column( + children: [ + e.dISPLAYFLAG == "Y" ? Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + "${e.sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), + "${e.sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), + SizedBox(height: 12,) + ]): Container(), + ], + )).toList()), ), ], - color: Colors.white, - borderRadius: BorderRadius.circular(10.0), ), - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - LocaleKeys.fullName.tr().toText13(color: MyColors.lightGrayColor), - "$fullName".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20, - ), - LocaleKeys.maritalStatus.tr().toText13(color: MyColors.lightGrayColor), - "$maritalStatus".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20, - ), - LocaleKeys.dateOfBirth.tr().toText13(color: MyColors.lightGrayColor), - "$birthDate".toText16(isBold: true, color: MyColors.blackColor), - SizedBox( - height: 20, - ), - LocaleKeys.civilIdentityNumber.tr().toText13(color: MyColors.lightGrayColor), - "$civilIdentityNumber".toText16(isBold: true, color: MyColors.blackColor), - ]), ), + DefaultButton( + LocaleKeys.update.tr(), + menuEntries.updateButton == 'Y' ? () async { + showAlertDialog(context);} + : null).insideContainer, ], )); } - Widget footer() { - return Container( - decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(10), - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), - ], - ), - child: DefaultButton( - LocaleKeys.update.tr(), - menuEntries.updateButton == 'Y' - ? () async { - showAlertDialog(context); - } - : null) - .insideContainer, - ); - } void showAlertDialog(BuildContext context) { Widget cancelButton = TextButton( diff --git a/lib/ui/profile/contact_details.dart b/lib/ui/profile/contact_details.dart index c0af0c5..9eda586 100644 --- a/lib/ui/profile/contact_details.dart +++ b/lib/ui/profile/contact_details.dart @@ -134,7 +134,7 @@ class _ContactDetailsState extends State { ])) .toList()) ])), - Container( + Container( width: double.infinity, margin: EdgeInsets.only( top: 20, diff --git a/lib/ui/profile/delete_family_member.dart b/lib/ui/profile/delete_family_member.dart index 58ec825..ab4e1d2 100644 --- a/lib/ui/profile/delete_family_member.dart +++ b/lib/ui/profile/delete_family_member.dart @@ -12,6 +12,7 @@ import 'package:mohem_flutter_app/ui/misc/request_submit_screen.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'dart:io'; import 'package:flutter/cupertino.dart'; +import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; class DeleteFamilyMember extends StatefulWidget { @@ -66,25 +67,29 @@ class _DeleteFamilyMemberState extends State { title: LocaleKeys.profile_familyDetails.tr(), ), backgroundColor: MyColors.backgroundColor, - bottomSheet: footer(), body: Column( children: [ - DynamicTextFieldWidget( - LocaleKeys.endDate.tr(), date.toString(), - // suffixIconData: Icons.calendar_today, - isEnable: false, - onTap: () async { - DateTime dateValue = await _selectDate(context); - // DateTime date1 = DateTime(dateValue.year, dateValue.month, dateValue.day); - date = DateFormat('yyyy/MM/dd').format(dateValue); - datePar = DateFormat('yyyy/MM/dd hh:mm:ss').format(dateValue); - setState(() {}); - // if (date !=null) { - // print(datePar); - // deleteFamilyMember(datePar); - // } - }, - ).paddingOnly(bottom: 12) + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + DynamicTextFieldWidget( + LocaleKeys.endDate.tr(), date.toString(), + isEnable: false, + onTap: () async { + DateTime dateValue = await _selectDate(context); + date = DateFormat('yyyy/MM/dd').format(dateValue); + datePar = DateFormat('yyyy/MM/dd hh:mm:ss').format(dateValue); + setState(() {}); + }, + ).paddingOnly(bottom: 12), + ], + ), + ), + DefaultButton( + LocaleKeys.next.tr(), () async { + deleteFamilyMember(datePar);} + ).insideContainer, ], )); } diff --git a/lib/ui/profile/family_members.dart b/lib/ui/profile/family_members.dart index 6b30347..3aef900 100644 --- a/lib/ui/profile/family_members.dart +++ b/lib/ui/profile/family_members.dart @@ -34,7 +34,6 @@ class _FamilyMembersState extends State { super.initState(); List menuData = Provider.of(context, listen: false).getMenuEntriesList!; menuEntries = menuData.where((GetMenuEntriesList e) => e.requestType == 'CONTACT').toList()[0]; - setState(() {}); getEmployeeContacts(); } @@ -57,196 +56,164 @@ class _FamilyMembersState extends State { title: LocaleKeys.profile_familyDetails.tr(), ), backgroundColor: MyColors.backgroundColor, - bottomSheet: footer(), - body: Container( - width: MediaQuery.of(context).size.width, - child: getEmployeeContactsList.length != 0 - ? SingleChildScrollView( - scrollDirection: Axis.vertical, - child: Column( - children: [ - ListView.builder( + body: Column( + children: [ + Expanded( + child: getEmployeeContactsList.length != 0 + ? SingleChildScrollView( + scrollDirection: Axis.vertical, + child: ListView.builder( scrollDirection: Axis.vertical, shrinkWrap: true, physics: ScrollPhysics(), itemCount: getEmployeeContactsList.length, itemBuilder: (context, index) { - return Container( - child: Column( - children: [ - Container( - width: double.infinity, - margin: EdgeInsets.only( - top: 20, - left: 21, - right: 21, + return Container( + width: double.infinity, + margin: EdgeInsets.only( + top: 20, + left: 21, + right: 21, + ), + padding: EdgeInsets.only( + left: 14, + right: 14, + top: 13, + ), + height: 110, + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 5, + blurRadius: 26, + offset: Offset(0, 3), ), - padding: EdgeInsets.only( - left: 14, - right: 14, - top: 13, - ), - height: 110, - 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: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - "${getEmployeeContactsList[index].cONTACTNAME}".toText16(color: MyColors.blackColor), - "${getEmployeeContactsList[index].rELATIONSHIP}".toText11(isBold: true, color: MyColors.textMixColor), - SizedBox( - height: 5, - ), - Divider( - color: MyColors.lightGreyEFColor, - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - child: menuEntries.updateButton == 'Y' - ? InkWell( - onTap: () async{ - relationId = getEmployeeContactsList[index]!.cONTACTRELATIONSHIPID!.toInt(); - showUpdateAlertDialog(context, relationId!.toInt(), 2, LocaleKeys.update.tr()); - }, - child: RichText( - text: TextSpan( - children: [ - WidgetSpan( - child: Icon( - Icons.edit, - size: 15, - color: MyColors.grey67Color, - ), - ), - TextSpan( - text: LocaleKeys.update.tr(), - style: TextStyle( - color: MyColors.grey67Color, - fontSize: 12, - fontWeight: FontWeight.bold, - ), - ), - ], + ], + color: MyColors.whiteColor, + borderRadius: BorderRadius.circular(10.0), + ), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + "${getEmployeeContactsList[index].cONTACTNAME}".toText16(isBold: true, color: MyColors.grey3AColor), + "${getEmployeeContactsList[index].rELATIONSHIP}".toText11(isBold: true, color: MyColors.textMixColor), + SizedBox( + height: 5, + ), + Divider( + color: MyColors.lightGreyEFColor, + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + child: menuEntries.updateButton == 'Y' + ? InkWell( + onTap: () async{ + relationId = getEmployeeContactsList[index]!.cONTACTRELATIONSHIPID!.toInt(); + showUpdateAlertDialog(context, relationId!.toInt(), 2, LocaleKeys.update.tr()); + }, + child: RichText( + text: TextSpan( + children: [ + WidgetSpan( + child: Icon( + Icons.edit, + size: 15, + color: MyColors.grey67Color, + ), ), - ), - ) - : RichText( - text: TextSpan( - children: [ - WidgetSpan( - child: Icon( - Icons.edit, - size: 15, - color: MyColors.lightGreyColor, - ), - ), - TextSpan( - text: LocaleKeys.update.tr(), - style: TextStyle( - color: MyColors.lightGreyColor, - fontSize: 12, - fontWeight: FontWeight.bold, - ), - ), - ], + TextSpan( + text: LocaleKeys.update.tr(), + style: TextStyle( + color: MyColors.grey67Color, + fontSize: 12, + fontWeight: FontWeight.bold, ), - ) ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 8), - child: SizedBox( - child: Container( - width: 3, - color: MyColors.lightGreyEFColor, ), - ), + ], ), - Container( - child: InkWell( - onTap: () { - relationId = getEmployeeContactsList[index]!.cONTACTRELATIONSHIPID!.toInt(); - showRemoveAlertDialog(context, relationId!.toInt()); - }, - child: RichText( - text: TextSpan( - children: [ - WidgetSpan( - child: Icon( - Icons.delete, - size: 15, - color: Color(0x99FF0000), - ), + ), + ) + : RichText( + text: TextSpan( + children: [ + WidgetSpan( + child: Icon( + Icons.edit, + size: 15, + color: MyColors.lightGreyColor, ), - TextSpan( - text: LocaleKeys.remove.tr(), - style: TextStyle( - color: MyColors.DarkRedColor, - fontSize: 12, - fontWeight: FontWeight.bold, - ), + ), + TextSpan( + text: LocaleKeys.update.tr(), + style: TextStyle( + color: MyColors.lightGreyColor, + fontSize: 12, + fontWeight: FontWeight.bold, ), - ], - ), + ), + ], ), - )), - // ElevatedButton.icon( - // icon: Icon( - // Icons.delete, - // size: 15, - // color: Color(0x99FF0000), - // ), - // style: ElevatedButton.styleFrom( - // shadowColor: Colors.white, - // primary: Colors.white, - // ), - // label: "remove".toText12(color: MyColors.DarkRedColor), - // onPressed: (){}, - // ), - ], + ) ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: SizedBox( + child: Container( + width: 3, + color: MyColors.lightGreyEFColor, + ), + ), ), - ]), + Container( + child: InkWell( + onTap: () { + relationId = getEmployeeContactsList[index]!.cONTACTRELATIONSHIPID!.toInt(); + showRemoveAlertDialog(context, relationId!.toInt()); + }, + child: RichText( + text: TextSpan( + children: [ + WidgetSpan( + child: Icon( + Icons.delete, + size: 15, + color: MyColors.redColor, + ), + ), + TextSpan( + text: LocaleKeys.remove.tr(), + style: TextStyle( + color: MyColors.redColor, + fontSize: 12, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + )), + ], ), - ], - )); - }) - ], - ), - ) - : Container(), - // SizedBox(height: 20), + ]), + ); + }), + ) + : Container(), + ), + DefaultButton( + LocaleKeys.addNewFamilyMember.tr(), () async { + Navigator.pushNamed(context, AppRoutes.addUpdateFamilyMember, arguments: {"relationID": relationId, "flag": 1, "actionType": "ADD"}); + ProfileScreen(); + } + ).insideContainer, + ], )); } - Widget footer() { - return Container( - decoration: BoxDecoration( - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), - ], - ), - child: DefaultButton( - LocaleKeys.addNewFamilyMember.tr(), () async { - Navigator.pushNamed(context, AppRoutes.addUpdateFamilyMember, arguments: {"relationID": relationId, "flag": 1, "actionType": "ADD"}); - ProfileScreen(); - } - ) - .insideContainer, - ); - } void showUpdateAlertDialog(BuildContext context, int relationId, int flag, String actionType) { Widget cancelButton = TextButton( @@ -323,7 +290,5 @@ class _FamilyMembersState extends State { ); } - // void continueDynamicForms() { - // Navigator.pushNamed(context, AppRoutes.addDynamicInputProfile, arguments: DynamicFamilyMembersParams(LocaleKeys.profile_familyDetails.tr(), getEmployeeContactsList: getEmployeeContactsList)); - // } + } diff --git a/lib/ui/work_list/worklist_settings.dart b/lib/ui/work_list/worklist_settings.dart index 8c72d71..47771ee 100644 --- a/lib/ui/work_list/worklist_settings.dart +++ b/lib/ui/work_list/worklist_settings.dart @@ -2,7 +2,6 @@ import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; import 'package:mohem_flutter_app/api/worklist/worklist_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; @@ -10,7 +9,6 @@ import 'package:mohem_flutter_app/config/routes.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/generic_response_model.dart'; import 'package:mohem_flutter_app/models/get_user_item_type_list.dart'; import 'package:mohem_flutter_app/models/update_user_item_type_list.dart'; import 'package:mohem_flutter_app/models/worklist/update_user_type_list.dart'; @@ -46,13 +44,11 @@ class _WorklistSettingsState extends State { } } - void updateUserItem() async { try { Utils.showLoading(context); List> itemList=[]; for (var element in getUserItemTypesList) { - itemList.add(UpdateUserTypesList(itemID: element.uSERITEMTYPEID, pITEMTYPE: element.iTEMTYPE,pFYAENABLEDFALG: element.fYAENABLEDFALG, pFYIENABLEDFALG: element.fYIENABLEDFLAG).toJson()); } @@ -66,86 +62,71 @@ class _WorklistSettingsState extends State { } } - - @override Widget build(BuildContext context) { return Scaffold(backgroundColor: Colors.white, appBar: AppBarWidget( context, - title: "Worklist Settings", + title: LocaleKeys.worklistSettings.tr(), ), - body:Container( - margin: const EdgeInsets.only(top: 21, left: 21, right: 21), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: "Turn on notifications for".tr().toText22(color: MyColors.blackColor), - ).paddingOnly(top: 10, bottom: 50), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: "Item Type".tr().toText14(color: MyColors.blackColor) , - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Container( - child: "FYA".tr().toText14(color: MyColors.blackColor) , - ), - Container( - child: "FYI".tr().toText14(color: MyColors.blackColor) , - ).paddingOnly(left: 30, right: 30), - ], - ) - ], - ), - Divider( - color: MyColors.greyA5Color, + body:Column( + children: [ + Expanded( + child: Container( + margin: const EdgeInsets.only(top: 21, left: 21, right: 21), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: LocaleKeys.TurnNotificationsFor.tr().toText22(color: MyColors.blackColor), + ).paddingOnly(top: 10, bottom: 50), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: LocaleKeys.itemType.tr().toText14(color: MyColors.blackColor) , + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Container( + child: "FYA".tr().toText14(color: MyColors.blackColor) , + ), + Container( + child: "FYI".tr().toText14(color: MyColors.blackColor) , + ).paddingOnly(left: 30, right: 30), + ], + ) + ], + ), + Divider(color: MyColors.greyA5Color,), + SingleChildScrollView( + scrollDirection: Axis.vertical, + child: ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: ScrollPhysics(), + itemCount: getUserItemTypesList == null ? 0 : getUserItemTypesList.length, + itemBuilder: (BuildContext context,int index) { + return Column( + children:[ + customSwitch(getUserItemTypesList[index]), + Divider( + color: MyColors.greyC4Color, + thickness: 0.5,), + ]); + } + ), + ), + ], + ), ), - Container( - width: MediaQuery.of(context).size.width, - child: SingleChildScrollView( - scrollDirection: Axis.vertical, - child: ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: ScrollPhysics(), - itemCount: getUserItemTypesList == null ? 0 : getUserItemTypesList.length, - itemBuilder: (BuildContext context,int index) { - return Container( - child: Column( - children:[ - - customSwitch(getUserItemTypesList[index]), - ] ), - ); - } - ), - ) - ), - SizedBox( - height: 30, - ), - Container( - decoration: BoxDecoration( - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), + DefaultButton( + LocaleKeys.save.tr(), () async { + updateUserItem(); + }).insideContainer, ], - ), - child: DefaultButton( - LocaleKeys.submit.tr(), () async { - updateUserItem(); - } - ) - .insideContainer, - ), - ], - ), ) ); From 41a1ba125ef5221e049e58326eaaa4be6fcff141 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 29 Aug 2022 16:24:25 +0300 Subject: [PATCH 30/40] code improvements. --- lib/models/get_user_item_type_list.dart | 2 +- .../get_absence_dff_structure_list_model.dart | 2 +- .../get_attendance_tracking_list_model.dart | 2 +- .../get_employee_subordinates_list.dart | 153 +++++---- lib/models/update_item_type_success_list.dart | 2 +- lib/models/update_user_item_type_list.dart | 2 +- .../worklist/update_user_type_list.dart | 8 +- .../add_leave_balance_screen.dart | 298 +++++++++++++++++- lib/ui/my_team/view_attendance.dart | 4 +- lib/ui/profile/basic_details.dart | 80 +++-- lib/ui/profile/contact_details.dart | 168 ++++------ 11 files changed, 478 insertions(+), 243 deletions(-) diff --git a/lib/models/get_user_item_type_list.dart b/lib/models/get_user_item_type_list.dart index a197c2e..b21748e 100644 --- a/lib/models/get_user_item_type_list.dart +++ b/lib/models/get_user_item_type_list.dart @@ -25,7 +25,7 @@ class GetUserItemTypesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['FYA_ENABLED_FALG'] = this.fYAENABLEDFALG; data['FYI_ENABLED_FLAG'] = this.fYIENABLEDFLAG; data['ITEM_TYPE'] = this.iTEMTYPE; diff --git a/lib/models/leave_balance/get_absence_dff_structure_list_model.dart b/lib/models/leave_balance/get_absence_dff_structure_list_model.dart index a7d04bb..3619311 100644 --- a/lib/models/leave_balance/get_absence_dff_structure_list_model.dart +++ b/lib/models/leave_balance/get_absence_dff_structure_list_model.dart @@ -88,7 +88,7 @@ class GetAbsenceDffStructureList { cHILDSEGMENTSDV = json['CHILD_SEGMENTS_DV']; cHILDSEGMENTSDVSplited = json['CHILD_SEGMENTS_DV_Splited'] == null ? [] : json['CHILD_SEGMENTS_DV_Splited'].cast(); cHILDSEGMENTSVS = json['CHILD_SEGMENTS_VS']; - cHILDSEGMENTSVSSplited = json['CHILD_SEGMENTS_VS_Splited'].cast(); + cHILDSEGMENTSVSSplited = json['CHILD_SEGMENTS_VS_Splited']== null ? [] : json['CHILD_SEGMENTS_VS_Splited'].cast(); dEFAULTTYPE = json['DEFAULT_TYPE']; dEFAULTVALUE = json['DEFAULT_VALUE']; dESCFLEXCONTEXTCODE = json['DESC_FLEX_CONTEXT_CODE']; diff --git a/lib/models/my_team/get_attendance_tracking_list_model.dart b/lib/models/my_team/get_attendance_tracking_list_model.dart index 7670702..10d9d52 100644 --- a/lib/models/my_team/get_attendance_tracking_list_model.dart +++ b/lib/models/my_team/get_attendance_tracking_list_model.dart @@ -41,7 +41,7 @@ class GetAttendanceTrackingList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_BREAK_HOURS'] = this.pBREAKHOURS; data['P_LATE_IN_HOURS'] = this.pLATEINHOURS; data['P_REMAINING_HOURS'] = this.pREMAININGHOURS; diff --git a/lib/models/my_team/get_employee_subordinates_list.dart b/lib/models/my_team/get_employee_subordinates_list.dart index b90034b..e0178eb 100644 --- a/lib/models/my_team/get_employee_subordinates_list.dart +++ b/lib/models/my_team/get_employee_subordinates_list.dart @@ -1,4 +1,3 @@ - class GetEmployeeSubordinatesList { String? aCTUALTERMINATIONDATE; String? aSSIGNMENTENDDATE; @@ -78,80 +77,80 @@ class GetEmployeeSubordinatesList { GetEmployeeSubordinatesList( {this.aCTUALTERMINATIONDATE, - this.aSSIGNMENTENDDATE, - this.aSSIGNMENTID, - this.aSSIGNMENTNUMBER, - this.aSSIGNMENTSTARTDATE, - this.aSSIGNMENTSTATUSTYPEID, - this.aSSIGNMENTTYPE, - this.bUSINESSGROUPID, - this.bUSINESSGROUPNAME, - this.cURRENTEMPLOYEEFLAG, - this.eMPLOYEEDISPLAYNAME, - this.eMPLOYEEEMAILADDRESS, - this.eMPLOYEEIMAGE, - this.eMPLOYEEMOBILENUMBER, - this.eMPLOYEENAME, - this.eMPLOYEENUMBER, - this.eMPLOYEEWORKNUMBER, - this.eMPLOYMENTCATEGORY, - this.eMPLOYMENTCATEGORYMEANING, - this.fREQUENCY, - this.fREQUENCYMEANING, - this.fROMROWNUM, - this.gRADEID, - this.gRADENAME, - this.genderCode, - this.genderMeaning, - this.hIREDATE, - this.isFavorite, - this.jOBID, - this.jOBNAME, - this.lOCATIONID, - this.lOCATIONNAME, - this.mANUALTIMECARDFLAG, - this.mANUALTIMECARDMEANING, - this.nATIONALITYCODE, - this.nATIONALITYMEANING, - this.nATIONALIDENTIFIER, - this.nORMALHOURS, - this.nOOFROWS, - this.nUMOFSUBORDINATES, - this.oRGANIZATIONID, - this.oRGANIZATIONNAME, - this.pAYROLLCODE, - this.pAYROLLID, - this.pAYROLLNAME, - this.pERSONID, - this.pERSONTYPE, - this.pERSONTYPEID, - this.pERINFORMATIONCATEGORY, - this.pOSITIONID, - this.pOSITIONNAME, - this.pRIMARYFLAG, - this.rOWNUM, - this.sERVICEDAYS, - this.sERVICEMONTHS, - this.sERVICEYEARS, - this.sUPERVISORASSIGNMENTID, - this.sUPERVISORDISPLAYNAME, - this.sUPERVISOREMAILADDRESS, - this.sUPERVISORID, - this.sUPERVISORMOBILENUMBER, - this.sUPERVISORNAME, - this.sUPERVISORNUMBER, - this.sUPERVISORWORKNUMBER, - this.sWIPESEXEMPTEDFLAG, - this.sWIPESEXEMPTEDMEANING, - this.sYSTEMPERSONTYPE, - this.tKEMAILADDRESS, - this.tKEMPLOYEEDISPLAYNAME, - this.tKEMPLOYEENAME, - this.tKEMPLOYEENUMBER, - this.tKPERSONID, - this.tOROWNUM, - this.uNITNUMBER, - this.uSERSTATUS}); + this.aSSIGNMENTENDDATE, + this.aSSIGNMENTID, + this.aSSIGNMENTNUMBER, + this.aSSIGNMENTSTARTDATE, + this.aSSIGNMENTSTATUSTYPEID, + this.aSSIGNMENTTYPE, + this.bUSINESSGROUPID, + this.bUSINESSGROUPNAME, + this.cURRENTEMPLOYEEFLAG, + this.eMPLOYEEDISPLAYNAME, + this.eMPLOYEEEMAILADDRESS, + this.eMPLOYEEIMAGE, + this.eMPLOYEEMOBILENUMBER, + this.eMPLOYEENAME, + this.eMPLOYEENUMBER, + this.eMPLOYEEWORKNUMBER, + this.eMPLOYMENTCATEGORY, + this.eMPLOYMENTCATEGORYMEANING, + this.fREQUENCY, + this.fREQUENCYMEANING, + this.fROMROWNUM, + this.gRADEID, + this.gRADENAME, + this.genderCode, + this.genderMeaning, + this.hIREDATE, + this.isFavorite, + this.jOBID, + this.jOBNAME, + this.lOCATIONID, + this.lOCATIONNAME, + this.mANUALTIMECARDFLAG, + this.mANUALTIMECARDMEANING, + this.nATIONALITYCODE, + this.nATIONALITYMEANING, + this.nATIONALIDENTIFIER, + this.nORMALHOURS, + this.nOOFROWS, + this.nUMOFSUBORDINATES, + this.oRGANIZATIONID, + this.oRGANIZATIONNAME, + this.pAYROLLCODE, + this.pAYROLLID, + this.pAYROLLNAME, + this.pERSONID, + this.pERSONTYPE, + this.pERSONTYPEID, + this.pERINFORMATIONCATEGORY, + this.pOSITIONID, + this.pOSITIONNAME, + this.pRIMARYFLAG, + this.rOWNUM, + this.sERVICEDAYS, + this.sERVICEMONTHS, + this.sERVICEYEARS, + this.sUPERVISORASSIGNMENTID, + this.sUPERVISORDISPLAYNAME, + this.sUPERVISOREMAILADDRESS, + this.sUPERVISORID, + this.sUPERVISORMOBILENUMBER, + this.sUPERVISORNAME, + this.sUPERVISORNUMBER, + this.sUPERVISORWORKNUMBER, + this.sWIPESEXEMPTEDFLAG, + this.sWIPESEXEMPTEDMEANING, + this.sYSTEMPERSONTYPE, + this.tKEMAILADDRESS, + this.tKEMPLOYEEDISPLAYNAME, + this.tKEMPLOYEENAME, + this.tKEMPLOYEENUMBER, + this.tKPERSONID, + this.tOROWNUM, + this.uNITNUMBER, + this.uSERSTATUS}); GetEmployeeSubordinatesList.fromJson(Map json) { aCTUALTERMINATIONDATE = json['ACTUAL_TERMINATION_DATE']; @@ -232,7 +231,7 @@ class GetEmployeeSubordinatesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ACTUAL_TERMINATION_DATE'] = this.aCTUALTERMINATIONDATE; data['ASSIGNMENT_END_DATE'] = this.aSSIGNMENTENDDATE; data['ASSIGNMENT_ID'] = this.aSSIGNMENTID; @@ -310,4 +309,4 @@ class GetEmployeeSubordinatesList { data['USER_STATUS'] = this.uSERSTATUS; return data; } -} \ No newline at end of file +} diff --git a/lib/models/update_item_type_success_list.dart b/lib/models/update_item_type_success_list.dart index f133e38..81d0132 100644 --- a/lib/models/update_item_type_success_list.dart +++ b/lib/models/update_item_type_success_list.dart @@ -15,7 +15,7 @@ class UpdateItemTypeSuccessList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ItemID'] = this.itemID; data['UpdateError'] = this.updateError; data['UpdateSuccess'] = this.updateSuccess; diff --git a/lib/models/update_user_item_type_list.dart b/lib/models/update_user_item_type_list.dart index 58f4714..2253ebb 100644 --- a/lib/models/update_user_item_type_list.dart +++ b/lib/models/update_user_item_type_list.dart @@ -12,7 +12,7 @@ class UpdateUserItemTypesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; return data; diff --git a/lib/models/worklist/update_user_type_list.dart b/lib/models/worklist/update_user_type_list.dart index 4ff377f..1637880 100644 --- a/lib/models/worklist/update_user_type_list.dart +++ b/lib/models/worklist/update_user_type_list.dart @@ -1,13 +1,9 @@ - - - class UpdateUserTypesList { int? itemID; String? pFYAENABLEDFALG; String? pFYIENABLEDFALG; String? pITEMTYPE; - UpdateUserTypesList({this.itemID, this.pFYAENABLEDFALG, this.pFYIENABLEDFALG, this.pITEMTYPE}); UpdateUserTypesList.fromJson(Map json) { @@ -18,11 +14,11 @@ class UpdateUserTypesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ItemID'] = this.itemID; data['P_FYAENABLED_FALG'] = this.pFYAENABLEDFALG; data['P_FYIENABLED_FALG'] = this.pFYIENABLEDFALG; data['P_ITEM_TYPE'] = this.pITEMTYPE; return data; } -} \ No newline at end of file +} diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index e9ab981..ae7b2e2 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -27,7 +27,7 @@ class AddLeaveBalanceScreen extends StatefulWidget { } class _AddLeaveBalanceScreenState extends State { - List absenceDff = []; + List getabsenceDffStructureList = []; List absenceList = []; GetAbsenceAttendanceTypesList? selectedAbsenceType; @@ -58,8 +58,8 @@ class _AddLeaveBalanceScreenState extends State { void getAbsenceDffStructure(String flexCode) async { try { Utils.showLoading(context); - absenceDff.clear(); - absenceDff = await LeaveBalanceApiClient().getAbsenceDffStructure(flexCode, "HR_LOA_SS", -999); + getabsenceDffStructureList.clear(); + getabsenceDffStructureList = await LeaveBalanceApiClient().getAbsenceDffStructure(flexCode, "HR_LOA_SS", -999); Utils.hideLoading(context); setState(() {}); } catch (ex) { @@ -102,6 +102,7 @@ class _AddLeaveBalanceScreenState extends State { } selectedAbsenceType = absenceList[popupIndex]; setState(() {}); + getAbsenceDffStructure(selectedAbsenceType!.dESCFLEXCONTEXTCODE!); }, ), 12.height, @@ -134,8 +135,8 @@ class _AddLeaveBalanceScreenState extends State { ), 12.height, DynamicTextFieldWidget( - "totla dsays", - "days", + "Total Days", + "Days", isInputTypeNum: true, onChange: (input) { totalDays = int.parse(input); @@ -181,6 +182,293 @@ class _AddLeaveBalanceScreenState extends State { ); } + // Widget parseDynamicFormatType(GetAbsenceDffStructureList model, int index) { + // if (model.dISPLAYFLAG != "N") { + // if (model.vALIDATIONTYPE == "N") { + // if (model.fORMATTYPE == "C") { + // return DynamicTextFieldWidget( + // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + // model.eSERVICESDV?.pIDCOLUMNNAME ?? "", + // isReadOnly: model.rEADONLY == "Y", + // onChange: (text) { + // model.eSERVICESDV ??= ESERVICESDV(); + // model.eSERVICESDV!.pIDCOLUMNNAME = text; + // }, + // ).paddingOnly(bottom: 12); + // } else if (model.fORMATTYPE == "N") { + // return DynamicTextFieldWidget( + // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + // model.eSERVICESDV?.pIDCOLUMNNAME ?? "", + // isReadOnly: model.rEADONLY == "Y", + // isInputTypeNum: true, + // onChange: (text) { + // model.eSERVICESDV ??= ESERVICESDV(); + // model.eSERVICESDV!.pIDCOLUMNNAME = text; + // }, + // ).paddingOnly(bottom: 12); + // } else if (model.fORMATTYPE == "X") { + // String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? (getabsenceDffStructureList![index].fieldAnswer ?? ""); + // + // if (getabsenceDffStructureList[index].isDefaultTypeIsCDPS) { + // if (displayText.contains(" 00:00:00")) { + // displayText = displayText.replaceAll(" 00:00:00", ""); + // } + // if (displayText.contains("/")) { + // displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); + // } + // } + // return DynamicTextFieldWidget( + // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + // displayText, + // suffixIconData: Icons.calendar_today, + // isEnable: false, + // onTap: () async { + // if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + // selectedDate = DateFormat("yyyy/MM/dd").parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!.replaceAll('/"', '').replaceAll(" 00:00:00", "")); + // } else { + // selectedDate = DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + // } + // } + // DateTime date = await _selectDate(context); + // String dateString = date.toString().split(' ').first; + // // DateTime date1 = DateTime(date.year, date.month, date.day); + // // getabsenceDffStructureList![index].fieldAnswer = date.toString(); + // ESERVICESDV eservicesdv; + // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + // eservicesdv = ESERVICESDV( + // pIDCOLUMNNAME: formatDate(dateString), + // pRETURNMSG: "null", + // pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, + // pVALUECOLUMNNAME: getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + // } else { + // eservicesdv = ESERVICESDV( + // pIDCOLUMNNAME: dateString, + // pRETURNMSG: "null", + // pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, + // pVALUECOLUMNNAME: getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + // } + // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + // setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + // }, + // ).paddingOnly(bottom: 12); + // } else if (model.fORMATTYPE == "Y") { + // String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? (getabsenceDffStructureList![index].fieldAnswer ?? ""); + // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + // displayText = reverseFormatDate(displayText); + // // if (displayText.contains(" 00:00:00")) { + // // displayText = displayText.replaceAll(" 00:00:00", ""); + // // } + // // if (!displayText.contains("-")) { + // // displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); + // // } + // } + // return DynamicTextFieldWidget( + // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + // displayText, + // suffixIconData: Icons.calendar_today, + // isEnable: false, + // onTap: () async { + // if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + // String tempDate = getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!; + // if (tempDate.contains("00:00:00")) { + // tempDate = tempDate.replaceAll("00:00:00", '').trim(); + // } + // if (tempDate.contains("/")) { + // selectedDate = DateFormat("yyyy/MM/dd").parse(tempDate); + // } else { + // selectedDate = DateFormat("yyyy-MM-dd").parse(tempDate); + // } + // } else { + // selectedDate = DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + // } + // } + // DateTime date = await _selectDate(context); + // String dateString = date.toString().split(' ').first; + // // getabsenceDffStructureList![index].fieldAnswer = date.toString(); + // ESERVICESDV eservicesdv; + // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + // eservicesdv = ESERVICESDV( + // pIDCOLUMNNAME: formatDate(dateString), + // pRETURNMSG: "null", + // pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, + // pVALUECOLUMNNAME: getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + // } else { + // eservicesdv = ESERVICESDV( + // pIDCOLUMNNAME: dateString, + // pRETURNMSG: "null", + // pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, + // pVALUECOLUMNNAME: getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + // } + // + // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + // setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + // }, + // ).paddingOnly(bottom: 12); + // } + // } else { + // return PopupMenuButton( + // child: DynamicTextFieldWidget( + // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + // model.eSERVICESDV?.pVALUECOLUMNNAME ?? "", + // isEnable: false, + // isPopup: true, + // isInputTypeNum: true, + // isReadOnly: model.rEADONLY == "Y", + // ).paddingOnly(bottom: 12), + // itemBuilder: (_) => >[ + // if (model.rEADONLY != "Y") + // for (int i = 0; i < model.eSERVICESVS!.length; i++) PopupMenuItem(child: Text(model.eSERVICESVS![i].vALUECOLUMNNAME!), value: i), + // ], + // onSelected: (int popipIndex) async { + // ESERVICESDV eservicesdv = ESERVICESDV( + // pIDCOLUMNNAME: model.eSERVICESVS![popipIndex].iDCOLUMNNAME, + // pRETURNMSG: "null", + // pRETURNSTATUS: "null", //getabsenceDffStructureList![popipIndex].dEFAULTVALUE, + // pVALUECOLUMNNAME: model.eSERVICESVS![popipIndex].vALUECOLUMNNAME); + // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + // setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + // }); + // } + // } else { + // return const SizedBox(); + // } + // if (model.fORMATTYPE == "N") { + // if (model.eSERVICESVS?.isNotEmpty ?? false) { + // return PopupMenuButton( + // child: DynamicTextFieldWidget( + // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + // model.eSERVICESDV?.pVALUECOLUMNNAME ?? "", + // isEnable: false, + // isPopup: true, + // isInputTypeNum: true, + // isReadOnly: model.rEADONLY == "Y", + // ).paddingOnly(bottom: 12), + // itemBuilder: (_) => >[ + // if (model.rEADONLY != "Y") + // for (int i = 0; i < model.eSERVICESVS!.length; i++) PopupMenuItem(value: i, child: Text(model.eSERVICESVS![i].vALUECOLUMNNAME!)), + // ], + // onSelected: (int popipIndex) async { + // ESERVICESDV eservicesdv = + // ESERVICESDV(pIDCOLUMNNAME: model.eSERVICESVS![popipIndex].iDCOLUMNNAME, pRETURNMSG: "null", pRETURNSTATUS: "null", pVALUECOLUMNNAME: model.eSERVICESVS![popipIndex].vALUECOLUMNNAME); + // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + // setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + // }); + // } + // + // return DynamicTextFieldWidget( + // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + // model.eSERVICESDV?.pIDCOLUMNNAME ?? "", + // isReadOnly: model.rEADONLY == "Y", + // onChange: (text) { + // model.fieldAnswer = text; + // }, + // ).paddingOnly(bottom: 12); + // } else if (model.fORMATTYPE == "X" || model.fORMATTYPE == "Y") { + // String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? (getabsenceDffStructureList![index].fieldAnswer ?? ""); + // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + // if (displayText.contains(" 00:00:00")) { + // displayText = displayText.replaceAll(" 00:00:00", ""); + // } + // if (!displayText.contains("-")) { + // displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); + // } + // } + // return DynamicTextFieldWidget( + // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + // displayText, + // suffixIconData: Icons.calendar_today, + // isEnable: false, + // onTap: () async { + // if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + // selectedDate = DateFormat("yyyy/MM/dd").parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!.replaceAll('/"', '').replaceAll(" 00:00:00", "")); + // } else { + // selectedDate = DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + // } + // } + // DateTime date = await _selectDate(context); + // String dateString = date.toString().split(' ').first; + // getabsenceDffStructureList![index].fieldAnswer = date.toString(); + // ESERVICESDV eservicesdv = ESERVICESDV( + // pIDCOLUMNNAME: dateString, + // pRETURNMSG: "null", + // pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, + // pVALUECOLUMNNAME: getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + // setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + // }, + // ).paddingOnly(bottom: 12); + // } else if (model.fORMATTYPE == "I") { + // return DynamicTextFieldWidget( + // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + // model.eSERVICESDV?.pIDCOLUMNNAME ?? (getabsenceDffStructureList![index].fieldAnswer ?? ""), + // suffixIconData: Icons.access_time_filled_rounded, + // isEnable: false, + // onTap: () async { + // if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + // var timeString = getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!.split(":"); + // selectedDate = DateTime(0, 0, 0, int.parse(timeString[0]), int.parse(timeString[1])); + // + // //DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + // } + // TimeOfDay _time = await _selectTime(context); + // DateTime tempTime = DateTime(0, 1, 1, _time.hour, _time.minute); + // String time = DateFormat('HH:mm').format(tempTime).trim(); + // + // // DateTime date1 = DateTime(date.year, date.month, date.day); + // // getabsenceDffStructureList![index].fieldAnswer = date.toString(); + // ESERVICESDV eservicesdv = ESERVICESDV(pIDCOLUMNNAME: time, pRETURNMSG: "null", pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, pVALUECOLUMNNAME: time); + // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + // setState(() {}); + // // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // // await calGetValueSetValues(model); + // // } + // // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // // await getDefaultValues(model); + // // } + // }, + // ).paddingOnly(bottom: 12); + // } + // + // return Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // mainAxisSize: MainAxisSize.min, + // children: [], + // ).objectContainerView(); + // } + Future _selectDate(BuildContext context, DateTime? dateInput) async { DateTime time = dateInput ?? DateTime.now(); if (Platform.isIOS) { diff --git a/lib/ui/my_team/view_attendance.dart b/lib/ui/my_team/view_attendance.dart index b24a895..06b0bce 100644 --- a/lib/ui/my_team/view_attendance.dart +++ b/lib/ui/my_team/view_attendance.dart @@ -447,7 +447,7 @@ class _ViewAttendanceState extends State { List _getDataSource() { - final List meetings = []; + List meetings = []; return meetings; } @@ -545,7 +545,7 @@ class MeetingDataSource extends CalendarDataSource { } Meeting _getMeetingData(int index) { - final dynamic meeting = appointments; + dynamic meeting = appointments; Meeting meetingData; if (meeting is Meeting) { meetingData = meeting; diff --git a/lib/ui/profile/basic_details.dart b/lib/ui/profile/basic_details.dart index 35f2071..a2896a5 100644 --- a/lib/ui/profile/basic_details.dart +++ b/lib/ui/profile/basic_details.dart @@ -5,6 +5,7 @@ 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/config/routes.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'; @@ -33,9 +34,11 @@ class _BasicDetailsState extends State { String? emailAddress = ""; String? employeeNo = ""; int correctOrNew = 1; - List getEmployeeBasicDetailsList = []; + List? getEmployeeBasicDetailsList; + late MemberInformationListModel memberInformationList; GetMenuEntriesList menuEntries = GetMenuEntriesList(); + @override void initState() { super.initState(); @@ -58,7 +61,6 @@ class _BasicDetailsState extends State { } } - Widget build(BuildContext context) { return Scaffold( appBar: AppBarWidget( @@ -68,53 +70,43 @@ class _BasicDetailsState extends State { backgroundColor: MyColors.backgroundColor, body: Column( children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: double.infinity, - margin: EdgeInsets.only(top: 20, left: 21, right: 21, bottom: 20), - padding: EdgeInsets.only(left: 14, right: 14, top: 13, bottom: 5), - height: 300, - 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: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: getEmployeeBasicDetailsList.map((e) => - Column( - children: [ - e.dISPLAYFLAG == "Y" ? Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - "${e.sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), - "${e.sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), - SizedBox(height: 12,) - ]): Container(), - ], - )).toList()), - ), - ], - ), - ), + ListView( + padding: const EdgeInsets.all(21), + children: [ + getEmployeeBasicDetailsList == null + ? const SizedBox().expanded + : (getEmployeeBasicDetailsList!.isEmpty + ? Utils.getNoDataWidget(context).expanded + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: getEmployeeBasicDetailsList! + .map((e) => Column( + children: [ + e.dISPLAYFLAG == "Y" + ? Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + "${e.sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), + "${e.sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), + 12.height + ]) + : Container(), + ], + )) + .toList()) + .objectContainerView()) + ], + ).expanded, DefaultButton( - LocaleKeys.update.tr(), - menuEntries.updateButton == 'Y' ? () async { - showAlertDialog(context);} - : null).insideContainer, + LocaleKeys.update.tr(), + menuEntries.updateButton == 'Y' + ? () async { + showAlertDialog(context); + } + : null) + .insideContainer, ], )); } - void showAlertDialog(BuildContext context) { Widget cancelButton = TextButton( child: Text(LocaleKeys.cancel.tr()), diff --git a/lib/ui/profile/contact_details.dart b/lib/ui/profile/contact_details.dart index 9eda586..4bc3fa1 100644 --- a/lib/ui/profile/contact_details.dart +++ b/lib/ui/profile/contact_details.dart @@ -4,7 +4,9 @@ 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/config/routes.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/dashboard/menu_entries.dart'; import 'package:mohem_flutter_app/models/get_employee_address_model.dart'; @@ -13,9 +15,7 @@ import 'package:mohem_flutter_app/models/get_employee_phones_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/ui/profile/dynamic_screens/dynamic_input_address_screen.dart'; import 'package:mohem_flutter_app/ui/profile/phone_numbers.dart'; -import 'package:mohem_flutter_app/ui/profile/profile_screen.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; -import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:provider/provider.dart'; class ContactDetails extends StatefulWidget { @@ -47,26 +47,12 @@ class _ContactDetailsState extends State { menuEntriesPhone = menuData.where((GetMenuEntriesList e) => e.requestType == 'PHONE_NUMBERS').toList()[0]; menuEntriesAddress = menuData.where((GetMenuEntriesList e) => e.requestType == 'ADDRESS').toList()[0]; getEmployeePhones(); - - setState(() {}); } void getEmployeePhones() async { try { Utils.showLoading(context); getEmployeePhonesList = await ProfileApiClient().getEmployeePhones(); - getEmployeeAddress(); - Utils.hideLoading(context); - setState(() {}); - } catch (ex) { - Utils.hideLoading(context); - Utils.handleException(ex, context, null); - } - } - - void getEmployeeAddress() async { - try { - Utils.showLoading(context); getEmployeeAddressList = await ProfileApiClient().getEmployeeAddress(); Utils.hideLoading(context); setState(() {}); @@ -78,37 +64,18 @@ class _ContactDetailsState extends State { Widget build(BuildContext context) { return Scaffold( - appBar: AppBarWidget( - context, - title: LocaleKeys.profile_contactDetails.tr(), - ), - backgroundColor: MyColors.backgroundColor, - // bottomSheet: footer(), - body: SingleChildScrollView( - child: Column(children: [ - Container( - width: double.infinity, - margin: EdgeInsets.only( - top: 20, - left: 26, - right: 26, - ), - padding: EdgeInsets.all(15), - - ///height: 200, - 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: Stack(children: [ + appBar: AppBarWidget( + context, + title: LocaleKeys.profile_contactDetails.tr(), + ), + backgroundColor: MyColors.backgroundColor, + // bottomSheet: footer(), + body: ListView( + padding: const EdgeInsets.all(21), + children: [ + if (getEmployeePhonesList.isNotEmpty) + Stack( + children: [ Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -125,37 +92,33 @@ class _ContactDetailsState extends State { : Container() ], ), - 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()) - ])), - Container( - width: double.infinity, - margin: EdgeInsets.only( - top: 20, - left: 26, - right: 26, - ), - padding: EdgeInsets.all(15), - // 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: Stack(children: [ + ListView.separated( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.zero, + itemBuilder: (cxt, index) => Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "${getEmployeePhonesList[index].pHONETYPEMEANING}".toText13(color: MyColors.lightGrayColor), + ("${getEmployeePhonesList[index].pHONENUMBER}" ?? "").toText16(isBold: true, color: MyColors.blackColor), + ], + ), + separatorBuilder: (cxt, index) => 12.height, + itemCount: getEmployeePhonesList.length), + // 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()) + ], + ).objectContainerView(), + 12.height, + if (getEmployeeAddressList.isNotEmpty) + Stack( + children: [ Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -172,34 +135,31 @@ class _ContactDetailsState extends State { : Container() ], ), - 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()) - ])) - ]))); - } - - Widget footer() { - return Container( - decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(10), - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), + ListView.separated( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.zero, + itemBuilder: (cxt, index) => Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "${getEmployeeAddressList[index].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), + ("${getEmployeeAddressList[index].sEGMENTVALUEDSP}" ?? "").toText16(isBold: true, color: MyColors.blackColor), + ], + ), + separatorBuilder: (cxt, index) => 12.height, + itemCount: getEmployeeAddressList.length), + // 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), + // ])) + // .toList()) + ], + ).objectContainerView() ], ), - child: DefaultButton(LocaleKeys.update.tr(), () async { - // context.setLocale(const Locale("en", "US")); // to change Loacle - ProfileScreen(); - }).insideContainer, ); } From af170b2b024fa03d4726c8f415e716e6087ba98d Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 30 Aug 2022 10:08:39 +0300 Subject: [PATCH 31/40] missing swipe,ticket balance home screen item linked with corresponding screen. --- lib/ui/landing/widget/menus_widget.dart | 243 ++++++++++++------------ 1 file changed, 124 insertions(+), 119 deletions(-) diff --git a/lib/ui/landing/widget/menus_widget.dart b/lib/ui/landing/widget/menus_widget.dart index 529e649..91723ee 100644 --- a/lib/ui/landing/widget/menus_widget.dart +++ b/lib/ui/landing/widget/menus_widget.dart @@ -6,6 +6,7 @@ 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/provider/dashboard_provider_model.dart'; +import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart'; import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart'; import 'package:provider/provider.dart'; @@ -14,124 +15,128 @@ class MenusWidget extends StatelessWidget { Widget build(BuildContext context) { List namesColor = [0xff125765, 0xff239D8F, 0xff2BB8A8, 0xff1D92AA]; - return Consumer(builder: (cxt, data, child) { - return GridView( - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 2 / 2, crossAxisSpacing: 9, mainAxisSpacing: 9), - padding: EdgeInsets.zero, - shrinkWrap: true, - primary: false, - physics: const NeverScrollableScrollPhysics(), - children: [ - data.isWorkListLoading - ? MenuShimmer().onPress(() { - data.fetchWorkListCounter(context, showLoading: true); - }) - : Container( - decoration: BoxDecoration( - color: Color(namesColor[0]), - borderRadius: BorderRadius.circular(10), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LocaleKeys.workList.tr().toText12(color: Colors.white), - Row( - children: [ - Expanded( - child: data.workListCounter.toString().toText16(color: Colors.white, isBold: true,maxlines: 1), - ), - SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white) - ], - ) - ], - ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), - ).onPress(() { - Navigator.pushNamed(context, AppRoutes.workList); - }), - data.isMissingSwipeLoading - ? MenuShimmer().onPress(() { - data.fetchWorkListCounter(context); - }) - : Container( - decoration: BoxDecoration( - color: Color(namesColor[1]), - borderRadius: BorderRadius.circular(10), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LocaleKeys.missingSwipes.tr().toText12(color: Colors.white), - Row( - children: [ - Expanded( - child: data.missingSwipeCounter.toString().toText16(color: Colors.white, isBold: true,maxlines: 1), - ), - SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white) - ], - ) - ], - ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), - ).onPress(() { - Navigator.pushNamed(context, AppRoutes.workList); - }), - data.isLeaveTicketBalanceLoading - ? MenuShimmer().onPress(() { - data.fetchWorkListCounter(context); - }) - : Container( - decoration: BoxDecoration( - color: Color(namesColor[2]), - borderRadius: BorderRadius.circular(10), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LocaleKeys.leaveBalance.tr().toText12(color: Colors.white), - Row( - children: [ - Expanded( - child: data.leaveBalance.toString().toText16(color: Colors.white, isBold: true,maxlines: 1), - ), - SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white) - ], - ) - ], - ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), - ).onPress(() { - Navigator.pushNamed(context, AppRoutes.leaveBalance); - }), - data.isLeaveTicketBalanceLoading - ? MenuShimmer().onPress(() { - data.fetchWorkListCounter(context); - }) - : Container( - decoration: BoxDecoration( - color: Color(namesColor[3]), - borderRadius: BorderRadius.circular(10), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LocaleKeys.ticketBalance.tr().toText12(color: Colors.white), - Row( - children: [ - Expanded( - child: data.ticketBalance.toString().toText16(color: Colors.white, isBold: true,maxlines: 1), - ), - SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white) - ], - ) - ], - ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), - ).onPress(() { - Navigator.pushNamed(context, AppRoutes.workList); - }) - ], - ); - }); + return Consumer( + builder: (cxt, data, child) { + return GridView( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 2 / 2, crossAxisSpacing: 9, mainAxisSpacing: 9), + padding: EdgeInsets.zero, + shrinkWrap: true, + primary: false, + physics: const NeverScrollableScrollPhysics(), + children: [ + data.isWorkListLoading + ? MenuShimmer().onPress(() { + data.fetchWorkListCounter(context, showLoading: true); + }) + : Container( + decoration: BoxDecoration( + color: Color(namesColor[0]), + borderRadius: BorderRadius.circular(10), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.workList.tr().toText12(color: Colors.white), + Row( + children: [ + Expanded( + child: data.workListCounter.toString().toText16(color: Colors.white, isBold: true, maxlines: 1), + ), + SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white) + ], + ) + ], + ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ).onPress(() { + Navigator.pushNamed(context, AppRoutes.workList); + }), + data.isMissingSwipeLoading + ? MenuShimmer().onPress(() { + data.fetchWorkListCounter(context); + }) + : Container( + decoration: BoxDecoration( + color: Color(namesColor[1]), + borderRadius: BorderRadius.circular(10), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.missingSwipes.tr().toText12(color: Colors.white), + Row( + children: [ + Expanded( + child: data.missingSwipeCounter.toString().toText16(color: Colors.white, isBold: true, maxlines: 1), + ), + SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white) + ], + ) + ], + ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ).onPress(() { + Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(LocaleKeys.missingSwipes.tr(), "HMG_OTL_MISSING_SWIPE_EIT_SS")); + }), + data.isLeaveTicketBalanceLoading + ? MenuShimmer().onPress(() { + data.fetchWorkListCounter(context); + }) + : Container( + decoration: BoxDecoration( + color: Color(namesColor[2]), + borderRadius: BorderRadius.circular(10), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.leaveBalance.tr().toText12(color: Colors.white), + Row( + children: [ + Expanded( + child: data.leaveBalance.toString().toText16(color: Colors.white, isBold: true, maxlines: 1), + ), + SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white) + ], + ) + ], + ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ).onPress(() { + Navigator.pushNamed(context, AppRoutes.leaveBalance); + }), + data.isLeaveTicketBalanceLoading + ? MenuShimmer().onPress(() { + data.fetchWorkListCounter(context); + }) + : Container( + decoration: BoxDecoration( + color: Color(namesColor[3]), + borderRadius: BorderRadius.circular(10), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.ticketBalance.tr().toText12(color: Colors.white), + Row( + children: [ + Expanded( + child: data.ticketBalance.toString().toText16(color: Colors.white, isBold: true, maxlines: 1), + ), + SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white) + ], + ) + ], + ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ).onPress( + () { + Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(LocaleKeys.ticketBalance.tr(), "HMG_TKT_NEW_EIT_SS")); + }, + ) + ], + ); + }, + ); } } From 9186e3cdaa7c2601b6775edfcc8ea6b4ebc1895f Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 30 Aug 2022 12:34:00 +0300 Subject: [PATCH 32/40] leave balance validate model added. --- lib/api/leave_balance_api_client.dart | 73 +++++++++++++++++++ lib/models/generic_response_model.dart | 28 ++++--- .../calculate_absence_duration_model.dart | 24 ++++++ 3 files changed, 110 insertions(+), 15 deletions(-) create mode 100644 lib/models/leave_balance/calculate_absence_duration_model.dart diff --git a/lib/api/leave_balance_api_client.dart b/lib/api/leave_balance_api_client.dart index 186c730..73793b3 100644 --- a/lib/api/leave_balance_api_client.dart +++ b/lib/api/leave_balance_api_client.dart @@ -2,6 +2,7 @@ import 'package:mohem_flutter_app/api/api_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/calculate_absence_duration_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_attendance_types_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_dff_structure_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_transaction_list_model.dart'; @@ -33,6 +34,24 @@ class LeaveBalanceApiClient { }, url, postParams); } + Future calculateAbsenceDuration(int pAbsenceAttendanceTypeID, String pDateStart, String pDateEnd, int pSelectedResopID) async { + String url = "${ApiConsts.erpRest}CALCULATE_ABSENCE_DURATION"; + Map postParams = { + "P_ABSENCE_ATTENDANCE_TYPE_ID": pAbsenceAttendanceTypeID, + "P_DATE_END": pDateStart, //"29-Sep-2022", + "P_DATE_START": pDateEnd, + "P_SELECTED_RESP_ID": pSelectedResopID, + "P_MENU_TYPE": "E", + "P_TIME_END": null, + "P_TIME_START": null, + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.calculateAbsenceDuration!; + }, url, postParams); + } + Future> getAbsenceDffStructure(String pDescFlexContextCode, String pFunctionName, int pSelectedResopID) async { String url = "${ApiConsts.erpRest}GET_ABSENCE_DFF_STRUCTURE"; Map postParams = {"P_DESC_FLEX_CONTEXT_CODE": pDescFlexContextCode, "P_FUNCTION_NAME": pFunctionName, "P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": pSelectedResopID}; @@ -42,4 +61,58 @@ class LeaveBalanceApiClient { return responseData.getAbsenceDffStructureList ?? []; }, url, postParams); } + + Future validateAbsenceTransaction( + String pDescFlexContextCode, String pFunctionName, int pAbsenceAttendanceTypeID, String pReplacementUserName, String pDateStart, String pDateEnd, int pSelectedResopID, Map data, + {String comments = ""}) async { + String url = "${ApiConsts.erpRest}VALIDATE_ABSENCE_TRANSACTION"; + Map postParams = { + "P_DESC_FLEX_CONTEXT_CODE": pDescFlexContextCode, + "P_FUNCTION_NAME": pFunctionName, + "P_REPLACEMENT_USER_NAME": pReplacementUserName, + "P_ABSENCE_ACTION": "CREATE", + "P_ABSENCE_COMMENTS": comments, + "P_ABSENCE_ATTENDANCE_ID": pAbsenceAttendanceTypeID, + "P_ABSENCE_ATTENDANCE_TYPE_ID": pAbsenceAttendanceTypeID, + "P_DATE_END": pDateStart, //"29-Sep-2022", + "P_DATE_START": pDateEnd, + "P_SELECTED_RESP_ID": pSelectedResopID, + "P_MENU_TYPE": "E", + "P_TIME_END": null, + "P_TIME_START": null, + }; + postParams.addAll(data); + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData; + }, url, postParams); + } + + Future submitAbsenceTransaction( + String pDescFlexContextCode, String pFunctionName, int pAbsenceAttendanceTypeID, String pReplacementUserName, String pDateStart, String pDateEnd, int pSelectedResopID, Map data, + {String comments = ""}) async { + String url = "${ApiConsts.erpRest}SUBMIT_ABSENCE_TRANSACTION"; + Map postParams = { + "P_DESC_FLEX_CONTEXT_CODE": pDescFlexContextCode, + "P_FUNCTION_NAME": pFunctionName, + "P_REPLACEMENT_USER_NAME": pReplacementUserName, + "P_ABSENCE_ACTION": "CREATE", + "P_ABSENCE_COMMENTS": comments, + "P_ABSENCE_ATTENDANCE_ID": pAbsenceAttendanceTypeID, + "P_ABSENCE_ATTENDANCE_TYPE_ID": pAbsenceAttendanceTypeID, + "P_DATE_END": pDateStart, //"29-Sep-2022", + "P_DATE_START": pDateEnd, + "P_SELECTED_RESP_ID": pSelectedResopID, + "P_MENU_TYPE": "E", + "P_TIME_END": null, + "P_TIME_START": null, + }; + postParams.addAll(data); + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData; + }, url, postParams); + } } diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index c8cc86f..97d005c 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -33,6 +33,7 @@ import 'package:mohem_flutter_app/models/get_stamp_ms_notification_body_list_mod import 'package:mohem_flutter_app/models/get_stamp_ns_notification_body_list_model.dart'; import 'package:mohem_flutter_app/models/get_time_card_summary_list_model.dart'; import 'package:mohem_flutter_app/models/get_user_item_type_list.dart'; +import 'package:mohem_flutter_app/models/leave_balance/calculate_absence_duration_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_attendance_types_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_dff_structure_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_transaction_list_model.dart'; @@ -72,9 +73,9 @@ import 'package:mohem_flutter_app/models/start_eit_approval_process_model.dart'; import 'package:mohem_flutter_app/models/start_phone_approval_process_model.dart'; import 'package:mohem_flutter_app/models/submit_eit_transaction_list_model.dart'; import 'package:mohem_flutter_app/models/subordinates_on_leaves_model.dart'; -import 'package:mohem_flutter_app/models/vacation_rule/create_vacation_rule_list_model.dart'; import 'package:mohem_flutter_app/models/update_item_type_success_list.dart'; import 'package:mohem_flutter_app/models/update_user_item_type_list.dart'; +import 'package:mohem_flutter_app/models/vacation_rule/create_vacation_rule_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_item_type_notifications_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_notification_reassign_mode_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_vacation_rules_list_model.dart'; @@ -123,7 +124,7 @@ class GenericResponseModel { String? bCLogo; BasicMemberInformationModel? basicMemberInformation; bool? businessCardPrivilege; - String? calculateAbsenceDuration; + CalculateAbsenceDuration? calculateAbsenceDuration; String? cancelHRTransactionLIst; String? chatEmployeeLoginList; String? companyBadge; @@ -655,7 +656,7 @@ class GenericResponseModel { bCLogo = json['BC_Logo']; basicMemberInformation = json['BasicMemberInformation'] != null ? BasicMemberInformationModel.fromJson(json['BasicMemberInformation']) : null; businessCardPrivilege = json['BusinessCardPrivilege']; - calculateAbsenceDuration = json['CalculateAbsenceDuration']; + calculateAbsenceDuration = json['CalculateAbsenceDuration'] != null ? new CalculateAbsenceDuration.fromJson(json['CalculateAbsenceDuration']) : null; cancelHRTransactionLIst = json['CancelHRTransactionLIst']; chatEmployeeLoginList = json['Chat_EmployeeLoginList']; companyBadge = json['CompanyBadge']; @@ -857,8 +858,7 @@ class GenericResponseModel { if (json['GetEmployeeSubordinatesList'] != null) { getEmployeeSubordinatesList = []; json['GetEmployeeSubordinatesList'].forEach((v) { - getEmployeeSubordinatesList! - .add(new GetEmployeeSubordinatesList.fromJson(v)); + getEmployeeSubordinatesList!.add(new GetEmployeeSubordinatesList.fromJson(v)); }); } getFliexfieldStructureList = json['GetFliexfieldStructureList']; @@ -1253,13 +1253,10 @@ class GenericResponseModel { if (json['UpdateItemTypeSuccessList'] != null) { updateItemTypeSuccessList = []; json['UpdateItemTypeSuccessList'].forEach((v) { - updateItemTypeSuccessList! - .add(new UpdateItemTypeSuccessList.fromJson(v)); + updateItemTypeSuccessList!.add(new UpdateItemTypeSuccessList.fromJson(v)); }); } - updateUserItemTypesList = json['UpdateUserItemTypesList'] != null - ? new UpdateUserItemTypesList.fromJson(json['UpdateUserItemTypesList']) - : null; + updateUserItemTypesList = json['UpdateUserItemTypesList'] != null ? new UpdateUserItemTypesList.fromJson(json['UpdateUserItemTypesList']) : null; updateVacationRuleList = json['UpdateVacationRuleList']; vHREmployeeLoginList = json['VHR_EmployeeLoginList']; vHRGetEmployeeDetailsList = json['VHR_GetEmployeeDetailsList']; @@ -1334,7 +1331,10 @@ class GenericResponseModel { data['BasicMemberInformation'] = this.basicMemberInformation!.toJson(); } data['BusinessCardPrivilege'] = this.businessCardPrivilege; - data['CalculateAbsenceDuration'] = this.calculateAbsenceDuration; + + if (this.calculateAbsenceDuration != null) { + data['CalculateAbsenceDuration'] = this.calculateAbsenceDuration!.toJson(); + } data['CancelHRTransactionLIst'] = this.cancelHRTransactionLIst; data['Chat_EmployeeLoginList'] = this.chatEmployeeLoginList; data['CompanyBadge'] = this.companyBadge; @@ -1449,8 +1449,7 @@ class GenericResponseModel { data['GetEmployeePhonesList'] = this.getEmployeePhonesList!.map((v) => v.toJson()).toList(); } if (this.getEmployeeSubordinatesList != null) { - data['GetEmployeeSubordinatesList'] = - this.getEmployeeSubordinatesList!.map((v) => v.toJson()).toList(); + data['GetEmployeeSubordinatesList'] = this.getEmployeeSubordinatesList!.map((v) => v.toJson()).toList(); } data['GetFliexfieldStructureList'] = this.getFliexfieldStructureList; data['GetHrCollectionNotificationBodyList'] = this.getHrCollectionNotificationBodyList; @@ -1689,8 +1688,7 @@ class GenericResponseModel { data['UpdateAttachmentList'] = this.updateAttachmentList; data['UpdateEmployeeImageList'] = this.updateEmployeeImageList; if (this.updateItemTypeSuccessList != null) { - data['UpdateItemTypeSuccessList'] = - this.updateItemTypeSuccessList!.map((v) => v.toJson()).toList(); + data['UpdateItemTypeSuccessList'] = this.updateItemTypeSuccessList!.map((v) => v.toJson()).toList(); } if (this.updateUserItemTypesList != null) { data['UpdateUserItemTypesList'] = this.updateUserItemTypesList!.toJson(); diff --git a/lib/models/leave_balance/calculate_absence_duration_model.dart b/lib/models/leave_balance/calculate_absence_duration_model.dart new file mode 100644 index 0000000..b16b4c3 --- /dev/null +++ b/lib/models/leave_balance/calculate_absence_duration_model.dart @@ -0,0 +1,24 @@ +class CalculateAbsenceDuration { + int? pABSENCEDAYS; + int? pABSENCEHOURS; + String? pRETURNMSG; + String? pRETURNSTATUS; + + CalculateAbsenceDuration({this.pABSENCEDAYS, this.pABSENCEHOURS, this.pRETURNMSG, this.pRETURNSTATUS}); + + CalculateAbsenceDuration.fromJson(Map json) { + pABSENCEDAYS = json['P_ABSENCE_DAYS']; + pABSENCEHOURS = json['P_ABSENCE_HOURS']; + pRETURNMSG = json['P_RETURN_MSG']; + pRETURNSTATUS = json['P_RETURN_STATUS']; + } + + Map toJson() { + Map data = new Map(); + data['P_ABSENCE_DAYS'] = this.pABSENCEDAYS; + data['P_ABSENCE_HOURS'] = this.pABSENCEHOURS; + data['P_RETURN_MSG'] = this.pRETURNMSG; + data['P_RETURN_STATUS'] = this.pRETURNSTATUS; + return data; + } +} From 2f6e40da46b0c77f5e89676a13e428678915dfb1 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 31 Aug 2022 09:34:47 +0300 Subject: [PATCH 33/40] add leave balance cont. --- lib/classes/utils.dart | 62 ++ .../get_absence_dff_structure_list_model.dart | 2 + .../get_absence_transaction_list_model.dart | 2 - .../add_leave_balance_screen.dart | 690 ++++++++++-------- .../dynamic_screens/dynamic_input_screen.dart | 85 +-- 5 files changed, 465 insertions(+), 376 deletions(-) diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index 292bc4c..cf2ef23 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -192,4 +192,66 @@ class Utils { ], ); } + + /// EIT Forms date formats + + static String getMonthNamedFormat(DateTime date) { + /// it will return like "29-Sep-2022" + return DateFormat('dd-MMM-yyyy').format(date); + } + + static String reverseFormatDate(String date) { + String formattedDate; + if (date.isNotEmpty) { + formattedDate = date.replaceAll('/', '-'); + formattedDate = formattedDate.replaceAll(' 00:00:00', ''); + } else { + formattedDate = date; + } + return formattedDate; + } + + static String formatStandardDate(String date) { + String formattedDate; + if (date.isNotEmpty) { + formattedDate = date.replaceAll('-', '/'); + } else { + formattedDate = date; + } + return formattedDate; + } + + static String reverseFormatStandardDate(String date) { + String formattedDate; + if (date.isNotEmpty) { + formattedDate = date.replaceAll('/', '-'); + } else { + formattedDate = date; + } + return formattedDate; + } + + static String formatDate(String date) { + String formattedDate; + + if (date.isNotEmpty) { + date = date.substring(0, 10); + formattedDate = date.replaceAll('-', '/'); + formattedDate = formattedDate + ' 00:00:00'; + } else { + formattedDate = date; + } + return formattedDate; + } + + static String formatDateNew(String date) { + String formattedDate; + if (date.isNotEmpty) { + formattedDate = date.split('T')[0]; + formattedDate = formattedDate + ' 00:00:00'; + } else { + formattedDate = date; + } + return formattedDate; + } } diff --git a/lib/models/leave_balance/get_absence_dff_structure_list_model.dart b/lib/models/leave_balance/get_absence_dff_structure_list_model.dart index 3619311..81bc671 100644 --- a/lib/models/leave_balance/get_absence_dff_structure_list_model.dart +++ b/lib/models/leave_balance/get_absence_dff_structure_list_model.dart @@ -190,4 +190,6 @@ class GetAbsenceDffStructureList { data['VALIDATION_TYPE_DSP'] = this.vALIDATIONTYPEDSP; return data; } + + bool get isDefaultTypeIsCDPS => (dEFAULTTYPE == "C" || dEFAULTTYPE == "D" || dEFAULTTYPE == "P" || dEFAULTTYPE == "S"); } diff --git a/lib/models/leave_balance/get_absence_transaction_list_model.dart b/lib/models/leave_balance/get_absence_transaction_list_model.dart index ca9777d..74fb733 100644 --- a/lib/models/leave_balance/get_absence_transaction_list_model.dart +++ b/lib/models/leave_balance/get_absence_transaction_list_model.dart @@ -37,8 +37,6 @@ class GetAbsenceTransactionList { this.uPDATEBUTTON}); GetAbsenceTransactionList.fromJson(Map json) { - print("json:$json"); - print("type:ABSENCE_DAYS:${(json['ABSENCE_DAYS']).runtimeType}"); aBSENCEATTENDANCEID = json['ABSENCE_ATTENDANCE_ID']; aBSENCEATTENDANCETYPEID = json['ABSENCE_ATTENDANCE_TYPE_ID']; aBSENCECATEGORY = json['ABSENCE_CATEGORY']; diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index ae7b2e2..d87fa88 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -8,6 +8,8 @@ import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/extensions/int_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_eit_dff_structure_list_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/calculate_absence_duration_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_attendance_types_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_dff_structure_list_model.dart'; import 'package:mohem_flutter_app/models/worklist/replacement_list_model.dart'; @@ -31,12 +33,14 @@ class _AddLeaveBalanceScreenState extends State { List absenceList = []; GetAbsenceAttendanceTypesList? selectedAbsenceType; - DateTime? startTime; - DateTime? endTime; - int totalDays = 0; + DateTime? startDateTime; + DateTime? endDateTime; + int? totalDays; String comment = ""; ReplacementList? selectedReplacementEmployee; + DateTime selectedDate = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day); + @override void initState() { super.initState(); @@ -68,6 +72,21 @@ class _AddLeaveBalanceScreenState extends State { } } + void getCalculatedAbsenceDuration() async { + try { + Utils.showLoading(context); + CalculateAbsenceDuration duration = await LeaveBalanceApiClient() + .calculateAbsenceDuration(selectedAbsenceType!.aBSENCEATTENDANCETYPEID!, Utils.getMonthNamedFormat(startDateTime!), Utils.getMonthNamedFormat(endDateTime!), -999); + print(duration.toJson()); + totalDays = duration.pABSENCEDAYS; + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + @override void dispose() { super.dispose(); @@ -108,13 +127,13 @@ class _AddLeaveBalanceScreenState extends State { 12.height, DynamicTextFieldWidget( LocaleKeys.startDateT.tr() + "*", - startTime == null ? "Select date" : startTime.toString(), + startDateTime == null ? "Select date" : startDateTime.toString().split(' ')[0], suffixIconData: Icons.calendar_today, isEnable: false, onTap: () async { - var start = await _selectDate(context, startTime); - if (start != startTime) { - startTime = start; + var start = await _selectDate(context); + if (start != startDateTime) { + startDateTime = start; setState(() {}); } }, @@ -122,22 +141,26 @@ class _AddLeaveBalanceScreenState extends State { 12.height, DynamicTextFieldWidget( LocaleKeys.endDateT.tr() + "*", - endTime == null ? "Select date" : endTime.toString(), + endDateTime == null ? "Select date" : endDateTime.toString().split(' ')[0], suffixIconData: Icons.calendar_today, isEnable: false, + isReadOnly: selectedAbsenceType == null || startDateTime == null, onTap: () async { - var end = await _selectDate(context, endTime); - if (end != endTime) { - endTime = end; + if (selectedAbsenceType == null || startDateTime == null) return; + var end = await _selectDate(context); + if (end != endDateTime) { + endDateTime = end; setState(() {}); + getCalculatedAbsenceDuration(); } }, ), 12.height, DynamicTextFieldWidget( "Total Days", - "Days", + totalDays?.toString() ?? "Calculated days", isInputTypeNum: true, + isEnable: false, onChange: (input) { totalDays = int.parse(input); }, @@ -171,306 +194,321 @@ class _AddLeaveBalanceScreenState extends State { comment = input; }, ), + ListView.separated( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: const EdgeInsets.only(top: 12), + itemBuilder: (cxt, int parentIndex) => parseDynamicFormatType(getabsenceDffStructureList[parentIndex], parentIndex), + separatorBuilder: (cxt, index) => 0.height, + itemCount: getabsenceDffStructureList.length, + ) ], ).expanded, DefaultButton( LocaleKeys.next.tr(), - (selectedAbsenceType == null || startTime == null || endTime == null) ? null : () {}, + (selectedAbsenceType == null || startDateTime == null || endDateTime == null) ? null : () {}, ).insideContainer ], ), ); } - // Widget parseDynamicFormatType(GetAbsenceDffStructureList model, int index) { - // if (model.dISPLAYFLAG != "N") { - // if (model.vALIDATIONTYPE == "N") { - // if (model.fORMATTYPE == "C") { - // return DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // model.eSERVICESDV?.pIDCOLUMNNAME ?? "", - // isReadOnly: model.rEADONLY == "Y", - // onChange: (text) { - // model.eSERVICESDV ??= ESERVICESDV(); - // model.eSERVICESDV!.pIDCOLUMNNAME = text; - // }, - // ).paddingOnly(bottom: 12); - // } else if (model.fORMATTYPE == "N") { - // return DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // model.eSERVICESDV?.pIDCOLUMNNAME ?? "", - // isReadOnly: model.rEADONLY == "Y", - // isInputTypeNum: true, - // onChange: (text) { - // model.eSERVICESDV ??= ESERVICESDV(); - // model.eSERVICESDV!.pIDCOLUMNNAME = text; - // }, - // ).paddingOnly(bottom: 12); - // } else if (model.fORMATTYPE == "X") { - // String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? (getabsenceDffStructureList![index].fieldAnswer ?? ""); - // - // if (getabsenceDffStructureList[index].isDefaultTypeIsCDPS) { - // if (displayText.contains(" 00:00:00")) { - // displayText = displayText.replaceAll(" 00:00:00", ""); - // } - // if (displayText.contains("/")) { - // displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); - // } - // } - // return DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // displayText, - // suffixIconData: Icons.calendar_today, - // isEnable: false, - // onTap: () async { - // if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { - // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { - // selectedDate = DateFormat("yyyy/MM/dd").parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!.replaceAll('/"', '').replaceAll(" 00:00:00", "")); - // } else { - // selectedDate = DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); - // } - // } - // DateTime date = await _selectDate(context); - // String dateString = date.toString().split(' ').first; - // // DateTime date1 = DateTime(date.year, date.month, date.day); - // // getabsenceDffStructureList![index].fieldAnswer = date.toString(); - // ESERVICESDV eservicesdv; - // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { - // eservicesdv = ESERVICESDV( - // pIDCOLUMNNAME: formatDate(dateString), - // pRETURNMSG: "null", - // pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, - // pVALUECOLUMNNAME: getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); - // } else { - // eservicesdv = ESERVICESDV( - // pIDCOLUMNNAME: dateString, - // pRETURNMSG: "null", - // pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, - // pVALUECOLUMNNAME: getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); - // } - // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; - // setState(() {}); - // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { - // await calGetValueSetValues(model); - // } - // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { - // await getDefaultValues(model); - // } - // }, - // ).paddingOnly(bottom: 12); - // } else if (model.fORMATTYPE == "Y") { - // String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? (getabsenceDffStructureList![index].fieldAnswer ?? ""); - // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { - // displayText = reverseFormatDate(displayText); - // // if (displayText.contains(" 00:00:00")) { - // // displayText = displayText.replaceAll(" 00:00:00", ""); - // // } - // // if (!displayText.contains("-")) { - // // displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); - // // } - // } - // return DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // displayText, - // suffixIconData: Icons.calendar_today, - // isEnable: false, - // onTap: () async { - // if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { - // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { - // String tempDate = getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!; - // if (tempDate.contains("00:00:00")) { - // tempDate = tempDate.replaceAll("00:00:00", '').trim(); - // } - // if (tempDate.contains("/")) { - // selectedDate = DateFormat("yyyy/MM/dd").parse(tempDate); - // } else { - // selectedDate = DateFormat("yyyy-MM-dd").parse(tempDate); - // } - // } else { - // selectedDate = DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); - // } - // } - // DateTime date = await _selectDate(context); - // String dateString = date.toString().split(' ').first; - // // getabsenceDffStructureList![index].fieldAnswer = date.toString(); - // ESERVICESDV eservicesdv; - // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { - // eservicesdv = ESERVICESDV( - // pIDCOLUMNNAME: formatDate(dateString), - // pRETURNMSG: "null", - // pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, - // pVALUECOLUMNNAME: getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); - // } else { - // eservicesdv = ESERVICESDV( - // pIDCOLUMNNAME: dateString, - // pRETURNMSG: "null", - // pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, - // pVALUECOLUMNNAME: getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); - // } - // - // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; - // setState(() {}); - // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { - // await calGetValueSetValues(model); - // } - // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { - // await getDefaultValues(model); - // } - // }, - // ).paddingOnly(bottom: 12); - // } - // } else { - // return PopupMenuButton( - // child: DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // model.eSERVICESDV?.pVALUECOLUMNNAME ?? "", - // isEnable: false, - // isPopup: true, - // isInputTypeNum: true, - // isReadOnly: model.rEADONLY == "Y", - // ).paddingOnly(bottom: 12), - // itemBuilder: (_) => >[ - // if (model.rEADONLY != "Y") - // for (int i = 0; i < model.eSERVICESVS!.length; i++) PopupMenuItem(child: Text(model.eSERVICESVS![i].vALUECOLUMNNAME!), value: i), - // ], - // onSelected: (int popipIndex) async { - // ESERVICESDV eservicesdv = ESERVICESDV( - // pIDCOLUMNNAME: model.eSERVICESVS![popipIndex].iDCOLUMNNAME, - // pRETURNMSG: "null", - // pRETURNSTATUS: "null", //getabsenceDffStructureList![popipIndex].dEFAULTVALUE, - // pVALUECOLUMNNAME: model.eSERVICESVS![popipIndex].vALUECOLUMNNAME); - // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; - // setState(() {}); - // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { - // await calGetValueSetValues(model); - // } - // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { - // await getDefaultValues(model); - // } - // }); - // } - // } else { - // return const SizedBox(); - // } - // if (model.fORMATTYPE == "N") { - // if (model.eSERVICESVS?.isNotEmpty ?? false) { - // return PopupMenuButton( - // child: DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // model.eSERVICESDV?.pVALUECOLUMNNAME ?? "", - // isEnable: false, - // isPopup: true, - // isInputTypeNum: true, - // isReadOnly: model.rEADONLY == "Y", - // ).paddingOnly(bottom: 12), - // itemBuilder: (_) => >[ - // if (model.rEADONLY != "Y") - // for (int i = 0; i < model.eSERVICESVS!.length; i++) PopupMenuItem(value: i, child: Text(model.eSERVICESVS![i].vALUECOLUMNNAME!)), - // ], - // onSelected: (int popipIndex) async { - // ESERVICESDV eservicesdv = - // ESERVICESDV(pIDCOLUMNNAME: model.eSERVICESVS![popipIndex].iDCOLUMNNAME, pRETURNMSG: "null", pRETURNSTATUS: "null", pVALUECOLUMNNAME: model.eSERVICESVS![popipIndex].vALUECOLUMNNAME); - // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; - // setState(() {}); - // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { - // await calGetValueSetValues(model); - // } - // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { - // await getDefaultValues(model); - // } - // }); - // } - // - // return DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // model.eSERVICESDV?.pIDCOLUMNNAME ?? "", - // isReadOnly: model.rEADONLY == "Y", - // onChange: (text) { - // model.fieldAnswer = text; - // }, - // ).paddingOnly(bottom: 12); - // } else if (model.fORMATTYPE == "X" || model.fORMATTYPE == "Y") { - // String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? (getabsenceDffStructureList![index].fieldAnswer ?? ""); - // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { - // if (displayText.contains(" 00:00:00")) { - // displayText = displayText.replaceAll(" 00:00:00", ""); - // } - // if (!displayText.contains("-")) { - // displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); - // } - // } - // return DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // displayText, - // suffixIconData: Icons.calendar_today, - // isEnable: false, - // onTap: () async { - // if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { - // if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { - // selectedDate = DateFormat("yyyy/MM/dd").parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!.replaceAll('/"', '').replaceAll(" 00:00:00", "")); - // } else { - // selectedDate = DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); - // } - // } - // DateTime date = await _selectDate(context); - // String dateString = date.toString().split(' ').first; - // getabsenceDffStructureList![index].fieldAnswer = date.toString(); - // ESERVICESDV eservicesdv = ESERVICESDV( - // pIDCOLUMNNAME: dateString, - // pRETURNMSG: "null", - // pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, - // pVALUECOLUMNNAME: getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); - // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; - // setState(() {}); - // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { - // await calGetValueSetValues(model); - // } - // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { - // await getDefaultValues(model); - // } - // }, - // ).paddingOnly(bottom: 12); - // } else if (model.fORMATTYPE == "I") { - // return DynamicTextFieldWidget( - // (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - // model.eSERVICESDV?.pIDCOLUMNNAME ?? (getabsenceDffStructureList![index].fieldAnswer ?? ""), - // suffixIconData: Icons.access_time_filled_rounded, - // isEnable: false, - // onTap: () async { - // if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { - // var timeString = getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!.split(":"); - // selectedDate = DateTime(0, 0, 0, int.parse(timeString[0]), int.parse(timeString[1])); - // - // //DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); - // } - // TimeOfDay _time = await _selectTime(context); - // DateTime tempTime = DateTime(0, 1, 1, _time.hour, _time.minute); - // String time = DateFormat('HH:mm').format(tempTime).trim(); - // - // // DateTime date1 = DateTime(date.year, date.month, date.day); - // // getabsenceDffStructureList![index].fieldAnswer = date.toString(); - // ESERVICESDV eservicesdv = ESERVICESDV(pIDCOLUMNNAME: time, pRETURNMSG: "null", pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, pVALUECOLUMNNAME: time); - // getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; - // setState(() {}); - // // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { - // // await calGetValueSetValues(model); - // // } - // // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { - // // await getDefaultValues(model); - // // } - // }, - // ).paddingOnly(bottom: 12); - // } - // - // return Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // mainAxisSize: MainAxisSize.min, - // children: [], - // ).objectContainerView(); - // } + Widget parseDynamicFormatType(GetAbsenceDffStructureList model, int index) { + if (model.dISPLAYFLAG != "N") { + if (model.vALIDATIONTYPE == "N") { + if (model.fORMATTYPE == "C") { + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pIDCOLUMNNAME ?? "", + isReadOnly: model.rEADONLY == "Y", + onChange: (text) { + model.eSERVICESDV ??= ESERVICESDV(); + model.eSERVICESDV!.pIDCOLUMNNAME = text; + }, + ).paddingOnly(bottom: 12); + } else if (model.fORMATTYPE == "N") { + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pIDCOLUMNNAME ?? "", + isReadOnly: model.rEADONLY == "Y", + isInputTypeNum: true, + onChange: (text) { + model.eSERVICESDV ??= ESERVICESDV(); + model.eSERVICESDV!.pIDCOLUMNNAME = text; + }, + ).paddingOnly(bottom: 12); + } else if (model.fORMATTYPE == "X") { + String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? ""; + + if (getabsenceDffStructureList[index].isDefaultTypeIsCDPS) { + if (displayText.contains(" 00:00:00")) { + displayText = displayText.replaceAll(" 00:00:00", ""); + } + if (displayText.contains("/")) { + displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); + } + } + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + displayText, + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + selectedDate = DateFormat("yyyy/MM/dd").parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!.replaceAll('/"', '').replaceAll(" 00:00:00", "")); + } else { + selectedDate = DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + } + } + DateTime date = await _selectDate(context); + String dateString = date.toString().split(' ').first; + // DateTime date1 = DateTime(date.year, date.month, date.day); + // getabsenceDffStructureList![index].fieldAnswer = date.toString(); + ESERVICESDV eservicesdv; + if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: Utils.formatDate(dateString), + pRETURNMSG: "null", + pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, + pVALUECOLUMNNAME: + getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + } else { + eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: dateString, + pRETURNMSG: "null", + pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, + pVALUECOLUMNNAME: + getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + } + getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + }, + ).paddingOnly(bottom: 12); + } else if (model.fORMATTYPE == "Y") { + String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? ""; + if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + displayText = Utils.reverseFormatDate(displayText); + // if (displayText.contains(" 00:00:00")) { + // displayText = displayText.replaceAll(" 00:00:00", ""); + // } + // if (!displayText.contains("-")) { + // displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); + // } + } + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + displayText, + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + String tempDate = getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!; + if (tempDate.contains("00:00:00")) { + tempDate = tempDate.replaceAll("00:00:00", '').trim(); + } + if (tempDate.contains("/")) { + selectedDate = DateFormat("yyyy/MM/dd").parse(tempDate); + } else { + selectedDate = DateFormat("yyyy-MM-dd").parse(tempDate); + } + } else { + selectedDate = DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + } + } + DateTime date = await _selectDate(context); + String dateString = date.toString().split(' ').first; + // getabsenceDffStructureList![index].fieldAnswer = date.toString(); + ESERVICESDV eservicesdv; + if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: Utils.formatDate(dateString), + pRETURNMSG: "null", + pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, + pVALUECOLUMNNAME: + getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + } else { + eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: dateString, + pRETURNMSG: "null", + pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, + pVALUECOLUMNNAME: + getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + } + + getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + }, + ).paddingOnly(bottom: 12); + } + } else { + return PopupMenuButton( + child: DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pVALUECOLUMNNAME ?? "", + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: model.rEADONLY == "Y", + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + if (model.rEADONLY != "Y") + for (int i = 0; i < model.eSERVICESVS!.length; i++) PopupMenuItem(child: Text(model.eSERVICESVS![i].vALUECOLUMNNAME!), value: i), + ], + onSelected: (int popipIndex) async { + ESERVICESDV eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: model.eSERVICESVS![popipIndex].iDCOLUMNNAME, + pRETURNMSG: "null", + pRETURNSTATUS: "null", //getabsenceDffStructureList![popipIndex].dEFAULTVALUE, + pVALUECOLUMNNAME: model.eSERVICESVS![popipIndex].vALUECOLUMNNAME); + getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + }); + } + } else { + return const SizedBox(); + } + if (model.fORMATTYPE == "N") { + if (model.eSERVICESVS?.isNotEmpty ?? false) { + return PopupMenuButton( + child: DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pVALUECOLUMNNAME ?? "", + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: model.rEADONLY == "Y", + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + if (model.rEADONLY != "Y") + for (int i = 0; i < model.eSERVICESVS!.length; i++) PopupMenuItem(value: i, child: Text(model.eSERVICESVS![i].vALUECOLUMNNAME!)), + ], + onSelected: (int popipIndex) async { + ESERVICESDV eservicesdv = + ESERVICESDV(pIDCOLUMNNAME: model.eSERVICESVS![popipIndex].iDCOLUMNNAME, pRETURNMSG: "null", pRETURNSTATUS: "null", pVALUECOLUMNNAME: model.eSERVICESVS![popipIndex].vALUECOLUMNNAME); + getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + }); + } + + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pIDCOLUMNNAME ?? "", + isReadOnly: model.rEADONLY == "Y", + onChange: (text) { + //model.fieldAnswer = text; + }, + ).paddingOnly(bottom: 12); + } else if (model.fORMATTYPE == "X" || model.fORMATTYPE == "Y") { + String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? ""; + if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + if (displayText.contains(" 00:00:00")) { + displayText = displayText.replaceAll(" 00:00:00", ""); + } + if (!displayText.contains("-")) { + displayText = DateFormat('yyyy-MM-dd').format(DateFormat("yyyy/MM/dd").parse(displayText)); + } + } + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + displayText, + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + if (getabsenceDffStructureList![index].isDefaultTypeIsCDPS) { + selectedDate = DateFormat("yyyy/MM/dd").parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!.replaceAll('/"', '').replaceAll(" 00:00:00", "")); + } else { + selectedDate = DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + } + } + DateTime date = await _selectDate(context); + String dateString = date.toString().split(' ').first; + // getabsenceDffStructureList![index].fieldAnswer = date.toString(); + ESERVICESDV eservicesdv = ESERVICESDV( + pIDCOLUMNNAME: dateString, + pRETURNMSG: "null", + pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, + pVALUECOLUMNNAME: + getabsenceDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + }, + ).paddingOnly(bottom: 12); + } else if (model.fORMATTYPE == "I") { + return DynamicTextFieldWidget( + (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), + model.eSERVICESDV?.pIDCOLUMNNAME ?? "", + suffixIconData: Icons.access_time_filled_rounded, + isEnable: false, + onTap: () async { + if (getabsenceDffStructureList[index].mOBILEENABLED != "Y") return; + + if ((getabsenceDffStructureList![index].eSERVICESDV?.pVALUECOLUMNNAME != null)) { + var timeString = getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!.split(":"); + selectedDate = DateTime(0, 0, 0, int.parse(timeString[0]), int.parse(timeString[1])); + + //DateTime.parse(getabsenceDffStructureList![index].eSERVICESDV!.pVALUECOLUMNNAME!); + } + TimeOfDay _time = await _selectTime(context); + DateTime tempTime = DateTime(0, 1, 1, _time.hour, _time.minute); + String time = DateFormat('HH:mm').format(tempTime).trim(); + + // DateTime date1 = DateTime(date.year, date.month, date.day); + // getabsenceDffStructureList![index].fieldAnswer = date.toString(); + ESERVICESDV eservicesdv = ESERVICESDV(pIDCOLUMNNAME: time, pRETURNMSG: "null", pRETURNSTATUS: getabsenceDffStructureList![index].dEFAULTVALUE, pVALUECOLUMNNAME: time); + getabsenceDffStructureList![index].eSERVICESDV = eservicesdv; + setState(() {}); + // if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { + // await calGetValueSetValues(model); + // } + // if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) { + // await getDefaultValues(model); + // } + }, + ).paddingOnly(bottom: 12); + } + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [], + ).objectContainerView(); + } - Future _selectDate(BuildContext context, DateTime? dateInput) async { - DateTime time = dateInput ?? DateTime.now(); + Future _selectDate(BuildContext context) async { + DateTime time = selectedDate; if (Platform.isIOS) { await showCupertinoModalPopup( context: context, @@ -481,22 +519,62 @@ class _AddLeaveBalanceScreenState extends State { backgroundColor: Colors.white, mode: CupertinoDatePickerMode.date, onDateTimeChanged: (value) { - if (value != dateInput) { + if (value != null && value != selectedDate) { time = value; } }, - initialDateTime: dateInput, + initialDateTime: selectedDate, ), ), ); } else { - DateTime? picked = - await showDatePicker(context: context, initialDate: dateInput ?? DateTime.now(), initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); - if (picked != null && picked != dateInput) { + DateTime? picked = await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); + if (picked != null && picked != selectedDate) { time = picked; } } time = DateTime(time.year, time.month, time.day); return time; } + + Future _selectTime(BuildContext context) async { + TimeOfDay time = TimeOfDay(hour: selectedDate.hour, minute: selectedDate.minute); + if (Platform.isIOS) { + await showCupertinoModalPopup( + context: context, + builder: (cxt) => Container( + height: 250, + color: Colors.white, + child: CupertinoDatePicker( + backgroundColor: Colors.white, + mode: CupertinoDatePickerMode.time, + use24hFormat: true, + onDateTimeChanged: (value) { + if (value != null && value != selectedDate) { + time = TimeOfDay(hour: value.hour, minute: value.minute); + } + }, + initialDateTime: selectedDate, + ), + ), + ); + } else { + TimeOfDay? picked = await showTimePicker( + context: context, + initialTime: time, + builder: (cxt, child) { + return MediaQuery(data: MediaQuery.of(context).copyWith(alwaysUse24HourFormat: true), child: child ?? Container()); + }); + + if (picked != null && picked != time) { + time = picked; + } + // final DateTime? picked = + // await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); + // if (picked != null && picked != selectedDate) { + // time = picked; + // } + } + return time; + } } diff --git a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart index 72b0567..4f6e527 100644 --- a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart +++ b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart @@ -281,7 +281,7 @@ class _DynamicInputScreenState extends State { // idColName = DateFormat('yyyy/MM/dd HH:mm:ss').format(DateTime(date.year, date.month, date.day)); // } - idColName = formatStandardDate(idColName!); + idColName = Utils.formatStandardDate(idColName!); } } else { val = getEitDffStructureList![j].eSERVICESDV?.pVALUECOLUMNNAME; @@ -293,7 +293,7 @@ class _DynamicInputScreenState extends State { idColName = val; if (getEitDffStructureList![j].fORMATTYPE == "X") { - idColName = formatDateNew(idColName!); + idColName = Utils.formatDateNew(idColName!); // commenting to test // DateTime date = DateFormat('yyyy-MM-dd').parse(idColName!); // idColName = DateFormat('yyyy-MM-dd HH:mm:ss').format(date); @@ -406,7 +406,8 @@ class _DynamicInputScreenState extends State { padding: const EdgeInsets.all(21), itemBuilder: (cxt, int parentIndex) => parseDynamicFormatType(getEitDffStructureList![parentIndex], parentIndex), separatorBuilder: (cxt, index) => 0.height, - itemCount: getEitDffStructureList!.length))) + itemCount: getEitDffStructureList!.length, + ))) .expanded, // 12.height, DefaultButton( @@ -481,16 +482,18 @@ class _DynamicInputScreenState extends State { ESERVICESDV eservicesdv; if (getEitDffStructureList![index].isDefaultTypeIsCDPS) { eservicesdv = ESERVICESDV( - pIDCOLUMNNAME: formatDate(dateString), + pIDCOLUMNNAME: Utils.formatDate(dateString), pRETURNMSG: "null", pRETURNSTATUS: getEitDffStructureList![index].dEFAULTVALUE, - pVALUECOLUMNNAME: getEitDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + pVALUECOLUMNNAME: + getEitDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); } else { eservicesdv = ESERVICESDV( pIDCOLUMNNAME: dateString, pRETURNMSG: "null", pRETURNSTATUS: getEitDffStructureList![index].dEFAULTVALUE, - pVALUECOLUMNNAME: getEitDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + pVALUECOLUMNNAME: + getEitDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); } getEitDffStructureList![index].eSERVICESDV = eservicesdv; setState(() {}); @@ -505,7 +508,7 @@ class _DynamicInputScreenState extends State { } else if (model.fORMATTYPE == "Y") { String displayText = model.eSERVICESDV?.pIDCOLUMNNAME ?? (getEitDffStructureList![index].fieldAnswer ?? ""); if (getEitDffStructureList![index].isDefaultTypeIsCDPS) { - displayText = reverseFormatDate(displayText); + displayText = Utils.reverseFormatDate(displayText); // if (displayText.contains(" 00:00:00")) { // displayText = displayText.replaceAll(" 00:00:00", ""); // } @@ -540,16 +543,18 @@ class _DynamicInputScreenState extends State { ESERVICESDV eservicesdv; if (getEitDffStructureList![index].isDefaultTypeIsCDPS) { eservicesdv = ESERVICESDV( - pIDCOLUMNNAME: formatDate(dateString), + pIDCOLUMNNAME: Utils.formatDate(dateString), pRETURNMSG: "null", pRETURNSTATUS: getEitDffStructureList![index].dEFAULTVALUE, - pVALUECOLUMNNAME: getEitDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + pVALUECOLUMNNAME: + getEitDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); } else { eservicesdv = ESERVICESDV( pIDCOLUMNNAME: dateString, pRETURNMSG: "null", pRETURNSTATUS: getEitDffStructureList![index].dEFAULTVALUE, - pVALUECOLUMNNAME: getEitDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + pVALUECOLUMNNAME: + getEitDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); } getEitDffStructureList![index].eSERVICESDV = eservicesdv; @@ -663,7 +668,7 @@ class _DynamicInputScreenState extends State { pIDCOLUMNNAME: dateString, pRETURNMSG: "null", pRETURNSTATUS: getEitDffStructureList![index].dEFAULTVALUE, - pVALUECOLUMNNAME: getEitDffStructureList![index].isDefaultTypeIsCDPS ? reverseFormatStandardDate(formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); + pVALUECOLUMNNAME: getEitDffStructureList![index].isDefaultTypeIsCDPS ? Utils.reverseFormatStandardDate(Utils.formatDate(dateString)) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); getEitDffStructureList![index].eSERVICESDV = eservicesdv; setState(() {}); if (model.cHILDSEGMENTSVSSplited?.isNotEmpty ?? false) { @@ -736,8 +741,7 @@ class _DynamicInputScreenState extends State { ), ); } else { - DateTime? picked = - await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); + DateTime? picked = await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); if (picked != null && picked != selectedDate) { time = picked; } @@ -786,59 +790,4 @@ class _DynamicInputScreenState extends State { } return time; } - - String reverseFormatDate(String date) { - String formattedDate; - if (date.isNotEmpty) { - formattedDate = date.replaceAll('/', '-'); - formattedDate = formattedDate.replaceAll(' 00:00:00', ''); - } else { - formattedDate = date; - } - return formattedDate; - } - - String formatStandardDate(String date) { - String formattedDate; - if (date.isNotEmpty) { - formattedDate = date.replaceAll('-', '/'); - } else { - formattedDate = date; - } - return formattedDate; - } - - String reverseFormatStandardDate(String date) { - String formattedDate; - if (date.isNotEmpty) { - formattedDate = date.replaceAll('/', '-'); - } else { - formattedDate = date; - } - return formattedDate; - } - - String formatDate(String date) { - String formattedDate; - - if (date.isNotEmpty) { - date = date.substring(0, 10); - formattedDate = date.replaceAll('-', '/'); - formattedDate = formattedDate + ' 00:00:00'; - } else { - formattedDate = date; - } - return formattedDate; - } - - String formatDateNew(String date) { - String formattedDate; - if (date.isNotEmpty) { - formattedDate = date.split('T')[0]; - formattedDate = formattedDate + ' 00:00:00'; - } else { - formattedDate = date; - } - return formattedDate; - } } From d640ce29dec6adb2fde277f96d7505547d418d06 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Wed, 31 Aug 2022 09:36:26 +0300 Subject: [PATCH 34/40] fix issue --- lib/api/my_team/my_team_api_client.dart | 14 ++ lib/config/routes.dart | 3 + lib/models/generic_response_model.dart | 19 +- lib/models/get_user_item_type_list.dart | 2 +- .../get_attendance_tracking_list_model.dart | 2 +- .../get_employee_subordinates_list.dart | 2 +- ...tes_leaves_total_vacations_list_model.dart | 62 +++++++ lib/models/update_item_type_success_list.dart | 2 +- lib/models/update_user_item_type_list.dart | 2 +- .../worklist/update_user_type_list.dart | 2 +- lib/ui/my_team/employee_details.dart | 8 +- lib/ui/my_team/my_team.dart | 112 ++++++----- lib/ui/my_team/subordinate_leave.dart | 175 ++++++++++++++++++ lib/ui/my_team/view_attendance.dart | 4 +- lib/ui/profile/contact_details.dart | 31 ++-- lib/ui/profile/family_members.dart | 97 +++++----- lib/widgets/app_bar_widget.dart | 14 +- 17 files changed, 416 insertions(+), 135 deletions(-) create mode 100644 lib/models/my_team/get_subordinates_leaves_total_vacations_list_model.dart create mode 100644 lib/ui/my_team/subordinate_leave.dart diff --git a/lib/api/my_team/my_team_api_client.dart b/lib/api/my_team/my_team_api_client.dart index 4a843c1..c5a78c6 100644 --- a/lib/api/my_team/my_team_api_client.dart +++ b/lib/api/my_team/my_team_api_client.dart @@ -9,6 +9,7 @@ import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:mohem_flutter_app/models/get_day_hours_type_details_list_model.dart'; import 'package:mohem_flutter_app/models/get_time_card_summary_list_model.dart'; import 'package:mohem_flutter_app/models/my_team/get_employee_subordinates_list.dart'; +import 'package:mohem_flutter_app/models/my_team/get_subordinates_leaves_total_vacations_list_model.dart'; import 'package:mohem_flutter_app/models/worklist/get_favorite_replacements_model.dart'; class MyTeamApiClient { @@ -145,5 +146,18 @@ class MyTeamApiClient { return responseData; }, url, postParams); } + + Future> getSubordinatesLeavesList(String dateFrom, String dateTo) async { + String url = "${ApiConsts.erpRest}GET_SUBORDINATES_LEAVES_TOTAL_VACATIONS"; + Map postParams = { + "P_DATE_FROM": dateFrom, + "P_DATE_TO": dateTo, + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + return responseData.getSubordinatesLeavesTotalVacationsList ?? []; + }, url, postParams); + } } diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 023b9b9..76d5d40 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -19,6 +19,7 @@ import 'package:mohem_flutter_app/ui/my_team/create_request.dart'; import 'package:mohem_flutter_app/ui/my_team/employee_details.dart'; import 'package:mohem_flutter_app/ui/my_team/my_team.dart'; import 'package:mohem_flutter_app/ui/my_team/profile_details.dart'; +import 'package:mohem_flutter_app/ui/my_team/subordinate_leave.dart'; import 'package:mohem_flutter_app/ui/my_team/team_members.dart'; import 'package:mohem_flutter_app/ui/my_team/view_attendance.dart'; import 'package:mohem_flutter_app/ui/payslip/monthly_pay_slip_screen.dart'; @@ -124,6 +125,7 @@ class AppRoutes { static const String viewAttendance = "/viewAttendance"; static const String teamMembers = "/teamMembers"; static const String createRequest = "/createRequest"; + static const String subordinateLeave = "/subordinateLeave"; static final Map routes = { @@ -196,6 +198,7 @@ class AppRoutes { viewAttendance: (context) => ViewAttendance(), teamMembers: (context) => TeamMembers(), createRequest: (context) => CreateRequest(), + subordinateLeave: (context) => SubordinateLeave(), diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index 9ac23fc..436fe6c 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -49,6 +49,7 @@ import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_transactions.dart import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_types.dart'; import 'package:mohem_flutter_app/models/mowadhafhi/get_tickets_list.dart'; import 'package:mohem_flutter_app/models/my_team/get_employee_subordinates_list.dart'; +import 'package:mohem_flutter_app/models/my_team/get_subordinates_leaves_total_vacations_list_model.dart'; 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/pending_transactions/get_pending_transactions_details.dart'; @@ -215,7 +216,7 @@ class GenericResponseModel { List? getStampNsNotificationBodyList; List? getSubordinatesAttdStatusList; List? getSubordinatesLeavesList; - List? getSubordinatesLeavesTotalVacationsList; + List?getSubordinatesLeavesTotalVacationsList; List? getSummaryOfPaymentList; List? getSwipesList; List? getTermColsStructureList; @@ -964,7 +965,14 @@ class GenericResponseModel { }); } - getSubordinatesLeavesTotalVacationsList = json['GetSubordinatesLeavesTotalVacationsList']; + if (json['GetSubordinatesLeavesTotalVacationsList'] != null) { + getSubordinatesLeavesTotalVacationsList = + []; + json['GetSubordinatesLeavesTotalVacationsList'].forEach((v) { + getSubordinatesLeavesTotalVacationsList! + .add(new GetSubordinatesLeavesTotalVacationsList.fromJson(v)); + }); + } if (json['GetSummaryOfPaymentList'] != null) { getSummaryOfPaymentList = []; json['GetSummaryOfPaymentList'].forEach((v) { @@ -1507,7 +1515,12 @@ class GenericResponseModel { data['GetSubordinatesLeavesList'] = this.getSubordinatesLeavesList!.map((v) => v.toJson()).toList(); } - data['GetSubordinatesLeavesTotalVacationsList'] = this.getSubordinatesLeavesTotalVacationsList; + if (this.getSubordinatesLeavesTotalVacationsList != null) { + data['GetSubordinatesLeavesTotalVacationsList'] = this + .getSubordinatesLeavesTotalVacationsList! + .map((v) => v.toJson()) + .toList(); + } if (this.getSummaryOfPaymentList != null) { data['GetSummaryOfPaymentList'] = this.getSummaryOfPaymentList!.map((v) => v.toJson()).toList(); } diff --git a/lib/models/get_user_item_type_list.dart b/lib/models/get_user_item_type_list.dart index a197c2e..29892f1 100644 --- a/lib/models/get_user_item_type_list.dart +++ b/lib/models/get_user_item_type_list.dart @@ -25,7 +25,7 @@ class GetUserItemTypesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['FYA_ENABLED_FALG'] = this.fYAENABLEDFALG; data['FYI_ENABLED_FLAG'] = this.fYIENABLEDFLAG; data['ITEM_TYPE'] = this.iTEMTYPE; diff --git a/lib/models/my_team/get_attendance_tracking_list_model.dart b/lib/models/my_team/get_attendance_tracking_list_model.dart index 7670702..0fbc5f3 100644 --- a/lib/models/my_team/get_attendance_tracking_list_model.dart +++ b/lib/models/my_team/get_attendance_tracking_list_model.dart @@ -41,7 +41,7 @@ class GetAttendanceTrackingList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_BREAK_HOURS'] = this.pBREAKHOURS; data['P_LATE_IN_HOURS'] = this.pLATEINHOURS; data['P_REMAINING_HOURS'] = this.pREMAININGHOURS; diff --git a/lib/models/my_team/get_employee_subordinates_list.dart b/lib/models/my_team/get_employee_subordinates_list.dart index b90034b..1158f7d 100644 --- a/lib/models/my_team/get_employee_subordinates_list.dart +++ b/lib/models/my_team/get_employee_subordinates_list.dart @@ -232,7 +232,7 @@ class GetEmployeeSubordinatesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ACTUAL_TERMINATION_DATE'] = this.aCTUALTERMINATIONDATE; data['ASSIGNMENT_END_DATE'] = this.aSSIGNMENTENDDATE; data['ASSIGNMENT_ID'] = this.aSSIGNMENTID; diff --git a/lib/models/my_team/get_subordinates_leaves_total_vacations_list_model.dart b/lib/models/my_team/get_subordinates_leaves_total_vacations_list_model.dart new file mode 100644 index 0000000..04837d8 --- /dev/null +++ b/lib/models/my_team/get_subordinates_leaves_total_vacations_list_model.dart @@ -0,0 +1,62 @@ + + +class GetSubordinatesLeavesTotalVacationsList { + String? aBSENCEATTENDANCETYPENAME; + String? cALENDARENTRYDESC; + String? dATEEND; + String? dATESTART; + String? eMPLOYEENAME; + String? eMPLOYEENUMBER; + String? lEAVETYPE; + int? oRGANIZATIONID; + String? oRGANIZATIONNAME; + String? pOSITIONTITLE; + String? rEPLACEMENTNAME; + String? sTATUS; + + GetSubordinatesLeavesTotalVacationsList( + {this.aBSENCEATTENDANCETYPENAME, + this.cALENDARENTRYDESC, + this.dATEEND, + this.dATESTART, + this.eMPLOYEENAME, + this.eMPLOYEENUMBER, + this.lEAVETYPE, + this.oRGANIZATIONID, + this.oRGANIZATIONNAME, + this.pOSITIONTITLE, + this.rEPLACEMENTNAME, + this.sTATUS}); + + GetSubordinatesLeavesTotalVacationsList.fromJson(Map json) { + aBSENCEATTENDANCETYPENAME = json['ABSENCE_ATTENDANCE_TYPE_NAME']; + cALENDARENTRYDESC = json['CALENDAR_ENTRY_DESC']; + dATEEND = json['DATE_END']; + dATESTART = json['DATE_START']; + eMPLOYEENAME = json['EMPLOYEE_NAME']; + eMPLOYEENUMBER = json['EMPLOYEE_NUMBER']; + lEAVETYPE = json['LEAVE_TYPE']; + oRGANIZATIONID = json['ORGANIZATION_ID']; + oRGANIZATIONNAME = json['ORGANIZATION_NAME']; + pOSITIONTITLE = json['POSITION_TITLE']; + rEPLACEMENTNAME = json['REPLACEMENT_NAME']; + sTATUS = json['STATUS']; + } + + Map toJson() { + Map data = new Map(); + data['ABSENCE_ATTENDANCE_TYPE_NAME'] = this.aBSENCEATTENDANCETYPENAME; + data['CALENDAR_ENTRY_DESC'] = this.cALENDARENTRYDESC; + data['DATE_END'] = this.dATEEND; + data['DATE_START'] = this.dATESTART; + data['EMPLOYEE_NAME'] = this.eMPLOYEENAME; + data['EMPLOYEE_NUMBER'] = this.eMPLOYEENUMBER; + data['LEAVE_TYPE'] = this.lEAVETYPE; + data['ORGANIZATION_ID'] = this.oRGANIZATIONID; + data['ORGANIZATION_NAME'] = this.oRGANIZATIONNAME; + data['POSITION_TITLE'] = this.pOSITIONTITLE; + data['REPLACEMENT_NAME'] = this.rEPLACEMENTNAME; + data['STATUS'] = this.sTATUS; + return data; + } +} \ No newline at end of file diff --git a/lib/models/update_item_type_success_list.dart b/lib/models/update_item_type_success_list.dart index f133e38..556fa42 100644 --- a/lib/models/update_item_type_success_list.dart +++ b/lib/models/update_item_type_success_list.dart @@ -15,7 +15,7 @@ class UpdateItemTypeSuccessList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ItemID'] = this.itemID; data['UpdateError'] = this.updateError; data['UpdateSuccess'] = this.updateSuccess; diff --git a/lib/models/update_user_item_type_list.dart b/lib/models/update_user_item_type_list.dart index 58f4714..ceff62a 100644 --- a/lib/models/update_user_item_type_list.dart +++ b/lib/models/update_user_item_type_list.dart @@ -12,7 +12,7 @@ class UpdateUserItemTypesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['P_RETURN_MSG'] = this.pRETURNMSG; data['P_RETURN_STATUS'] = this.pRETURNSTATUS; return data; diff --git a/lib/models/worklist/update_user_type_list.dart b/lib/models/worklist/update_user_type_list.dart index 4ff377f..dc05fde 100644 --- a/lib/models/worklist/update_user_type_list.dart +++ b/lib/models/worklist/update_user_type_list.dart @@ -18,7 +18,7 @@ class UpdateUserTypesList { } Map toJson() { - final Map data = new Map(); + Map data = new Map(); data['ItemID'] = this.itemID; data['P_FYAENABLED_FALG'] = this.pFYAENABLEDFALG; data['P_FYIENABLED_FALG'] = this.pFYIENABLEDFALG; diff --git a/lib/ui/my_team/employee_details.dart b/lib/ui/my_team/employee_details.dart index 2ef488b..b1252aa 100644 --- a/lib/ui/my_team/employee_details.dart +++ b/lib/ui/my_team/employee_details.dart @@ -65,8 +65,12 @@ class _EmployeeDetailsState extends State { @override Widget build(BuildContext context) { - getEmployeeSubordinates = ModalRoute.of(context)?.settings.arguments as GetEmployeeSubordinatesList; - setMenu(); + if(getEmployeeSubordinates == null) { + getEmployeeSubordinates = ModalRoute.of(context)?.settings.arguments as GetEmployeeSubordinatesList; + setMenu(); + } + + return Scaffold( extendBody: true, backgroundColor: MyColors.lightGreyEFColor, diff --git a/lib/ui/my_team/my_team.dart b/lib/ui/my_team/my_team.dart index 7366128..37ab561 100644 --- a/lib/ui/my_team/my_team.dart +++ b/lib/ui/my_team/my_team.dart @@ -55,46 +55,60 @@ class _MyTeamState extends State { appBar: AppBarWidget( context, title: LocaleKeys.myTeamMembers.tr(), + showMemberButton: true, ), backgroundColor: MyColors.backgroundColor, body: SingleChildScrollView( child: Column( children: [ - Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Expanded( - child: TextField( - onChanged: dropdownValue == "Name" - ? (String value) { - getEmployeeSListOnSearch = - getEmployeeSubordinatesList.where((GetEmployeeSubordinatesList element) => element.eMPLOYEENAME!.toLowerCase().contains(value.toLowerCase())).toList(); - setState(() {}); - } - : (String value) { - getEmployeeSListOnSearch = - getEmployeeSubordinatesList.where((GetEmployeeSubordinatesList element) => element.eMPLOYEEEMAILADDRESS!.toLowerCase().contains(value.toLowerCase())).toList(); - setState(() {}); - }, - controller: _textEditingController, - decoration: InputDecoration( - filled: true, - fillColor: Colors.white, - border: InputBorder.none, - enabledBorder: InputBorder.none, - focusedBorder: InputBorder.none, - // contentPadding: EdgeInsets.fromLTRB(10, 15, 10, 15), - hintText: LocaleKeys.searchBy.tr() + " $dropdownValue", - hintStyle: TextStyle(fontSize: 14.0, color: MyColors.grey57Color, fontWeight: FontWeight.w600), + Container( + margin: EdgeInsets.only(left: 21, right: 21, top: 20, bottom: 6), + padding: EdgeInsets.only(left: 14, right: 14, top: 21, bottom: 21), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Color(0xffFFFFFF), + border: Border.all( + color: Color(0xffefefef), + width: 1, ), - )), - Row( + ), + child: Row( children: [ - "|".toText16(color: MyColors.greyC4Color), + Expanded( + child: TextField( + onChanged: dropdownValue == "Name" + ? (String value) { + getEmployeeSListOnSearch = + getEmployeeSubordinatesList.where((GetEmployeeSubordinatesList element) => element.eMPLOYEENAME!.toLowerCase().contains(value.toLowerCase())).toList(); + setState(() {}); + } + : (String value) { + getEmployeeSListOnSearch = + getEmployeeSubordinatesList.where((GetEmployeeSubordinatesList element) => element.eMPLOYEEEMAILADDRESS!.toLowerCase().contains(value.toLowerCase())).toList(); + setState(() {}); + }, + controller: _textEditingController, + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + border: InputBorder.none, + enabledBorder: InputBorder.none, + focusedBorder: InputBorder.none, + // contentPadding: EdgeInsets.fromLTRB(10, 15, 10, 15), + hintText: LocaleKeys.searchBy.tr() + " $dropdownValue", + hintStyle: TextStyle(fontSize: 14.0, color: MyColors.grey57Color, fontWeight: FontWeight.w600), + ), + )), + Container( + height: 36, + width: 1, + color: Color(0xffC4C4C4), + ), 10.width, dropDown(), ], - ) - ]).objectContainerBorderView(), - // ), + ), + ), Container( margin: EdgeInsets.only(left: 21, right: 21), width: MediaQuery.of(context).size.width, @@ -162,23 +176,25 @@ class _MyTeamState extends State { } Widget dropDown() { - return DropdownButton( - value: dropdownValue, - icon: const Icon(Icons.keyboard_arrow_down, - color: MyColors.grey57Color), - elevation: 16, - onChanged: (String? newValue) { - setState(() { - dropdownValue = newValue!; - }); - }, - items: ['Name', 'Email'].map>((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }).toList(), - style: TextStyle(fontSize: 14.0, color: MyColors.grey57Color, fontWeight: FontWeight.w600), - ); + return + DropdownButton( + value: dropdownValue, + icon: const Icon(Icons.keyboard_arrow_down, + color: MyColors.grey57Color).paddingOnly(left: 4), + elevation: 16, + onChanged: (String? newValue) { + setState(() { + dropdownValue = newValue!; + }); + }, + items: ['Name', 'Email'].map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + style: TextStyle(fontSize: 14.0, color: MyColors.grey57Color, + fontWeight: FontWeight.w600), + ); } } diff --git a/lib/ui/my_team/subordinate_leave.dart b/lib/ui/my_team/subordinate_leave.dart new file mode 100644 index 0000000..c5adb17 --- /dev/null +++ b/lib/ui/my_team/subordinate_leave.dart @@ -0,0 +1,175 @@ + +import 'dart:io'; + +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:mohem_flutter_app/api/my_team/my_team_api_client.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/date_uitl.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.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/my_team/get_subordinates_leaves_total_vacations_list_model.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 SubordinateLeave extends StatefulWidget { + const SubordinateLeave({Key? key}) : super(key: key); + + @override + _SubordinateLeaveState createState() => _SubordinateLeaveState(); +} + +class _SubordinateLeaveState extends State { + List getSubordinatesLeavesTotalList = []; + DateTime selectedDateFrom = DateTime.now(); + DateTime selectedDateTo = DateTime.now(); + bool showList = false; + // DateTime dateFrom = DateFormat("MMM/DD/YYYY").format(selectedDateFrom) as DateTime; + // DateTime dateTo = DateFormat("MMM/DD/YYYY").format(selectedDateTo) as DateTime; + + + + @override + void initState() { + super.initState(); + } + + void getSubordinatesLeaves()async { + try { + Utils.showLoading(context); + getSubordinatesLeavesTotalList = await MyTeamApiClient().getSubordinatesLeavesList(selectedDateFrom.toIso8601String(), selectedDateTo.toIso8601String()); + Utils.hideLoading(context); + } catch (ex) {da + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBarWidget( + context, + title: "Subordinate Leave", + ), + backgroundColor: MyColors.backgroundColor, + body: Column( + children: [ + Expanded( + child: Column( + children: [ + Column( + children: [ + DynamicTextFieldWidget( + LocaleKeys.dateFrom.tr(), + selectedDateFrom.toString().split(" ")[0], + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + selectedDateFrom = await _selectDate(context, DateTime.now()); + setState(() {}); + }, + ), + 12.height, + DynamicTextFieldWidget( + LocaleKeys.dateTo.tr(), + selectedDateTo.toString().split(" ")[0], + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + selectedDateTo = await _selectDate(context, DateTime.now()); + setState(() {}); + }, + ) + ], + ).objectContainerView(), + !showList? + SingleChildScrollView( + child: ListView.separated( + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: ScrollPhysics(), + separatorBuilder: (cxt, index) => 12.height, + itemCount: getSubordinatesLeavesTotalList.length, + itemBuilder: (context, index) { + var diffDays = selectedDateTo.difference(selectedDateFrom).inDays; + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // CircleAvatar( + // radius: 25, + // backgroundImage: MemoryImage(Utils.getPostBytes(getSubordinatesLeavesTotalList[index].eMPLOYEEIMAGE)), + // backgroundColor: Colors.black, + // ), + SvgPicture.asset("assets/images/clock.svg"), + 10.width, + "${getSubordinatesLeavesTotalList[index].eMPLOYEENAME}".toText16(isBold: true, color: MyColors.grey3AColor), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + "From: ${getSubordinatesLeavesTotalList[index].dATESTART}".toText10(isBold: true, color: MyColors.grey57Color), + "To: ${getSubordinatesLeavesTotalList[index].dATEEND}".toText10(isBold: true, color: MyColors.grey57Color), + ], + ).expanded, + "Number of days: $diffDays".toText13(color: MyColors.grey3AColor), + ], + ).objectContainerView(); + }), + ).objectContainerView() + :Container(), + ], + ), + ), + DefaultButton( + LocaleKeys.submit.tr(), () async { + getSubordinatesLeaves(); + setState(() { + showList= true; + }); + showList= true; + }).insideContainer + ], + ), + ); + } + + + + Future _selectDate(BuildContext context, DateTime selectedDate) async { + DateTime time = selectedDate; + if (!Platform.isIOS) { + await showCupertinoModalPopup( + context: context, + builder: (cxt) => Container( + height: 250, + color: Colors.white, + child: CupertinoDatePicker( + backgroundColor: Colors.white, + mode: CupertinoDatePickerMode.date, + onDateTimeChanged: (value) { + if (value != null && value != selectedDate) { + time = value; + } + }, + initialDateTime: selectedDate, + ), + ), + ); + } else { + DateTime? picked = await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); + if (picked != null && picked != selectedDate) { + time = picked; + } + } + return time; + } +} diff --git a/lib/ui/my_team/view_attendance.dart b/lib/ui/my_team/view_attendance.dart index b24a895..3f978c3 100644 --- a/lib/ui/my_team/view_attendance.dart +++ b/lib/ui/my_team/view_attendance.dart @@ -447,7 +447,7 @@ class _ViewAttendanceState extends State { List _getDataSource() { - final List meetings = []; + List meetings = []; return meetings; } @@ -545,7 +545,7 @@ class MeetingDataSource extends CalendarDataSource { } Meeting _getMeetingData(int index) { - final dynamic meeting = appointments; + dynamic meeting = appointments; Meeting meetingData; if (meeting is Meeting) { meetingData = meeting; diff --git a/lib/ui/profile/contact_details.dart b/lib/ui/profile/contact_details.dart index 9eda586..4d223cf 100644 --- a/lib/ui/profile/contact_details.dart +++ b/lib/ui/profile/contact_details.dart @@ -83,7 +83,6 @@ class _ContactDetailsState extends State { title: LocaleKeys.profile_contactDetails.tr(), ), backgroundColor: MyColors.backgroundColor, - // bottomSheet: footer(), body: SingleChildScrollView( child: Column(children: [ Container( @@ -187,21 +186,21 @@ class _ContactDetailsState extends State { ]))); } - Widget 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 - ProfileScreen(); - }).insideContainer, - ); - } + // Widget 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 + // ProfileScreen(); + // }).insideContainer, + // ); + // } void updatePhone() { Navigator.push( diff --git a/lib/ui/profile/family_members.dart b/lib/ui/profile/family_members.dart index 3aef900..c2b1e2f 100644 --- a/lib/ui/profile/family_members.dart +++ b/lib/ui/profile/family_members.dart @@ -4,7 +4,9 @@ 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/config/routes.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/dashboard/menu_entries.dart'; import 'package:mohem_flutter_app/models/get_employee_contacts.model.dart'; @@ -58,29 +60,23 @@ class _FamilyMembersState extends State { backgroundColor: MyColors.backgroundColor, body: Column( children: [ + 20.height, Expanded( child: getEmployeeContactsList.length != 0 ? SingleChildScrollView( scrollDirection: Axis.vertical, - child: ListView.builder( + child: ListView.separated( scrollDirection: Axis.vertical, shrinkWrap: true, physics: ScrollPhysics(), + separatorBuilder: (cxt, index) => 12.height, itemCount: getEmployeeContactsList.length, itemBuilder: (context, index) { return Container( width: double.infinity, - margin: EdgeInsets.only( - top: 20, - left: 21, - right: 21, + margin: EdgeInsets.only(left: 21, right: 21, ), - padding: EdgeInsets.only( - left: 14, - right: 14, - top: 13, - ), - height: 110, + // padding: EdgeInsets.only(left: 14, right: 14, top: 13, bottom: 10), decoration: BoxDecoration( boxShadow: [ BoxShadow( @@ -90,32 +86,33 @@ class _FamilyMembersState extends State { offset: Offset(0, 3), ), ], - color: MyColors.whiteColor, + color: Colors.white, borderRadius: BorderRadius.circular(10.0), ), - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - "${getEmployeeContactsList[index].cONTACTNAME}".toText16(isBold: true, color: MyColors.grey3AColor), - "${getEmployeeContactsList[index].rELATIONSHIP}".toText11(isBold: true, color: MyColors.textMixColor), - SizedBox( - height: 5, - ), - Divider( - color: MyColors.lightGreyEFColor, - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - child: menuEntries.updateButton == 'Y' + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "${getEmployeeContactsList[index].cONTACTNAME}".toText16(isBold: true, color: MyColors.grey3AColor), + "${getEmployeeContactsList[index].rELATIONSHIP}".toText11(isBold: true, color: MyColors.textMixColor), + ]).paddingOnly(left: 14, right: 14, top: 13, bottom: 11), + const Divider( + color: Color(0xffEFEFEF), + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + menuEntries.updateButton == 'Y' ? InkWell( onTap: () async{ relationId = getEmployeeContactsList[index]!.cONTACTRELATIONSHIPID!.toInt(); showUpdateAlertDialog(context, relationId!.toInt(), 2, LocaleKeys.update.tr()); - }, + }, child: RichText( text: TextSpan( children: [ @@ -136,8 +133,8 @@ class _FamilyMembersState extends State { ), ], ), - ), - ) + ), + ) : RichText( text: TextSpan( children: [ @@ -158,23 +155,18 @@ class _FamilyMembersState extends State { ), ], ), - ) ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 8), - child: SizedBox( - child: Container( - width: 3, - color: MyColors.lightGreyEFColor, ), - ), - ), - Container( - child: InkWell( - onTap: () { + Container( + height: 35, + width: 1, + color: Color(0xffEFEFEF), + ), + InkWell( + onTap: () { relationId = getEmployeeContactsList[index]!.cONTACTRELATIONSHIPID!.toInt(); showRemoveAlertDialog(context, relationId!.toInt()); - }, - child: RichText( + }, + child: RichText( text: TextSpan( children: [ WidgetSpan( @@ -194,11 +186,12 @@ class _FamilyMembersState extends State { ), ], ), - ), - )), - ], - ), - ]), + ), + ), + ], + ).paddingOnly(left: 14, right: 14), + ], + ), ); }), ) diff --git a/lib/widgets/app_bar_widget.dart b/lib/widgets/app_bar_widget.dart index 806fe6b..770494e 100644 --- a/lib/widgets/app_bar_widget.dart +++ b/lib/widgets/app_bar_widget.dart @@ -5,7 +5,7 @@ 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'; -AppBar AppBarWidget(BuildContext context, {required String title, bool showHomeButton = false, bool showNotificationButton = false}) { +AppBar AppBarWidget(BuildContext context, {required String title, bool showHomeButton = false, bool showNotificationButton = false, bool showMemberButton = false}) { return AppBar( leadingWidth: 0, // leading: GestureDetector( @@ -44,14 +44,16 @@ AppBar AppBarWidget(BuildContext context, {required String title, bool showHomeB IconButton( onPressed: () { Navigator.pushNamed(context, AppRoutes.worklistSettings); - // Navigator.pushAndRemoveUntil( - // context, - // MaterialPageRoute(builder: (context) => LandingPage()), - // (Route route) => false, - // ); }, icon: const Icon(Icons.notifications, color: MyColors.textMixColor), ), + if(showMemberButton) + IconButton( + onPressed: () { + Navigator.pushNamed(context, AppRoutes.subordinateLeave); + }, + icon: const Icon(Icons.people, color: MyColors.textMixColor), + ), ], ); } From cf7843191bb5830fe48873be08ae849c19be077a Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 31 Aug 2022 16:15:57 +0300 Subject: [PATCH 35/40] leave balance added. --- lib/api/leave_balance_api_client.dart | 32 ++++++--- lib/models/generic_response_model.dart | 30 ++++++--- .../cancel_hr_transaction_list_model.dart | 18 +++++ ...sumbit_absence_transaction_list_model.dart | 22 +++++++ ...lidate_absence_transaction_list_model.dart | 18 +++++ lib/models/update_user_item_type_list.dart | 2 - .../add_leave_balance_screen.dart | 65 +++++++++++++++++-- .../leave_balance/leave_balance_screen.dart | 10 +-- lib/ui/misc/request_submit_screen.dart | 16 ++--- 9 files changed, 174 insertions(+), 39 deletions(-) create mode 100644 lib/models/leave_balance/cancel_hr_transaction_list_model.dart create mode 100644 lib/models/leave_balance/sumbit_absence_transaction_list_model.dart create mode 100644 lib/models/leave_balance/validate_absence_transaction_list_model.dart diff --git a/lib/api/leave_balance_api_client.dart b/lib/api/leave_balance_api_client.dart index 73793b3..e24b47d 100644 --- a/lib/api/leave_balance_api_client.dart +++ b/lib/api/leave_balance_api_client.dart @@ -3,9 +3,11 @@ import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/calculate_absence_duration_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/cancel_hr_transaction_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_attendance_types_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_dff_structure_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_transaction_list_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/sumbit_absence_transaction_list_model.dart'; class LeaveBalanceApiClient { static final LeaveBalanceApiClient _instance = LeaveBalanceApiClient._internal(); @@ -38,8 +40,8 @@ class LeaveBalanceApiClient { String url = "${ApiConsts.erpRest}CALCULATE_ABSENCE_DURATION"; Map postParams = { "P_ABSENCE_ATTENDANCE_TYPE_ID": pAbsenceAttendanceTypeID, - "P_DATE_END": pDateStart, //"29-Sep-2022", - "P_DATE_START": pDateEnd, + "P_DATE_START": pDateStart, + "P_DATE_END": pDateEnd, "P_SELECTED_RESP_ID": pSelectedResopID, "P_MENU_TYPE": "E", "P_TIME_END": null, @@ -63,7 +65,7 @@ class LeaveBalanceApiClient { } Future validateAbsenceTransaction( - String pDescFlexContextCode, String pFunctionName, int pAbsenceAttendanceTypeID, String pReplacementUserName, String pDateStart, String pDateEnd, int pSelectedResopID, Map data, + String pDescFlexContextCode, String pFunctionName, int pAbsenceAttendanceTypeID, String pReplacementUserName, String pDateStart, String pDateEnd, int pSelectedResopID, Map data, {String comments = ""}) async { String url = "${ApiConsts.erpRest}VALIDATE_ABSENCE_TRANSACTION"; Map postParams = { @@ -74,8 +76,8 @@ class LeaveBalanceApiClient { "P_ABSENCE_COMMENTS": comments, "P_ABSENCE_ATTENDANCE_ID": pAbsenceAttendanceTypeID, "P_ABSENCE_ATTENDANCE_TYPE_ID": pAbsenceAttendanceTypeID, - "P_DATE_END": pDateStart, //"29-Sep-2022", - "P_DATE_START": pDateEnd, + "P_DATE_START": pDateStart, + "P_DATE_END": pDateEnd, //"29-Sep-2022", "P_SELECTED_RESP_ID": pSelectedResopID, "P_MENU_TYPE": "E", "P_TIME_END": null, @@ -89,8 +91,8 @@ class LeaveBalanceApiClient { }, url, postParams); } - Future submitAbsenceTransaction( - String pDescFlexContextCode, String pFunctionName, int pAbsenceAttendanceTypeID, String pReplacementUserName, String pDateStart, String pDateEnd, int pSelectedResopID, Map data, + Future submitAbsenceTransaction( + String pDescFlexContextCode, String pFunctionName, int pAbsenceAttendanceTypeID, String pReplacementUserName, String pDateStart, String pDateEnd, int pSelectedResopID, Map data, {String comments = ""}) async { String url = "${ApiConsts.erpRest}SUBMIT_ABSENCE_TRANSACTION"; Map postParams = { @@ -101,8 +103,8 @@ class LeaveBalanceApiClient { "P_ABSENCE_COMMENTS": comments, "P_ABSENCE_ATTENDANCE_ID": pAbsenceAttendanceTypeID, "P_ABSENCE_ATTENDANCE_TYPE_ID": pAbsenceAttendanceTypeID, - "P_DATE_END": pDateStart, //"29-Sep-2022", - "P_DATE_START": pDateEnd, + "P_DATE_START": pDateStart, + "P_DATE_END": pDateEnd, //"29-Sep-2022", "P_SELECTED_RESP_ID": pSelectedResopID, "P_MENU_TYPE": "E", "P_TIME_END": null, @@ -112,7 +114,17 @@ class LeaveBalanceApiClient { postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); - return responseData; + return responseData.sumbitAbsenceTransactionList!; + }, url, postParams); + } + + Future cancelHrTransaction(int pTransactionID) async { + String url = "${ApiConsts.erpRest}CANCEL_HR_TRANSACTION"; + Map postParams = {"P_TRANSACTION_ID": pTransactionID}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.cancelHRTransactionLIst!; }, url, postParams); } } diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index 97d005c..31e52fb 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -34,9 +34,12 @@ import 'package:mohem_flutter_app/models/get_stamp_ns_notification_body_list_mod import 'package:mohem_flutter_app/models/get_time_card_summary_list_model.dart'; import 'package:mohem_flutter_app/models/get_user_item_type_list.dart'; import 'package:mohem_flutter_app/models/leave_balance/calculate_absence_duration_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/cancel_hr_transaction_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_attendance_types_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_dff_structure_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_transaction_list_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/sumbit_absence_transaction_list_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/validate_absence_transaction_list_model.dart'; import 'package:mohem_flutter_app/models/member_information_list_model.dart'; import 'package:mohem_flutter_app/models/member_login_list_model.dart'; import 'package:mohem_flutter_app/models/monthly_pay_slip/get_deductions_List_model.dart'; @@ -125,7 +128,7 @@ class GenericResponseModel { BasicMemberInformationModel? basicMemberInformation; bool? businessCardPrivilege; CalculateAbsenceDuration? calculateAbsenceDuration; - String? cancelHRTransactionLIst; + CancelHRTransactionLIst? cancelHRTransactionLIst; String? chatEmployeeLoginList; String? companyBadge; String? companyImage; @@ -330,7 +333,7 @@ class GenericResponseModel { String? submitSITTransactionList; String? submitTermTransactionList; List? subordinatesOnLeavesList; - String? sumbitAbsenceTransactionList; + SumbitAbsenceTransactionList? sumbitAbsenceTransactionList; String? tokenID; String? updateAttachmentList; String? updateEmployeeImageList; @@ -342,7 +345,7 @@ class GenericResponseModel { String? vHRGetManagersDetailsList; String? vHRGetProjectByCodeList; bool? vHRIsVerificationCodeValid; - String? validateAbsenceTransactionList; + ValidateAbsenceTransactionList? validateAbsenceTransactionList; ValidateEITTransactionList? validateEITTransactionList; String? validatePhonesTransactionList; List? vrItemTypesList; @@ -657,7 +660,7 @@ class GenericResponseModel { basicMemberInformation = json['BasicMemberInformation'] != null ? BasicMemberInformationModel.fromJson(json['BasicMemberInformation']) : null; businessCardPrivilege = json['BusinessCardPrivilege']; calculateAbsenceDuration = json['CalculateAbsenceDuration'] != null ? new CalculateAbsenceDuration.fromJson(json['CalculateAbsenceDuration']) : null; - cancelHRTransactionLIst = json['CancelHRTransactionLIst']; + cancelHRTransactionLIst = json['CancelHRTransactionLIst'] != null ? new CancelHRTransactionLIst.fromJson(json['CancelHRTransactionLIst']) : null; chatEmployeeLoginList = json['Chat_EmployeeLoginList']; companyBadge = json['CompanyBadge']; companyImage = json['CompanyImage']; @@ -1246,7 +1249,8 @@ class GenericResponseModel { }); } - sumbitAbsenceTransactionList = json['SumbitAbsenceTransactionList']; + sumbitAbsenceTransactionList = json['SumbitAbsenceTransactionList'] != null ? new SumbitAbsenceTransactionList.fromJson(json['SumbitAbsenceTransactionList']) : null; + tokenID = json['TokenID']; updateAttachmentList = json['UpdateAttachmentList']; updateEmployeeImageList = json['UpdateEmployeeImageList']; @@ -1263,7 +1267,8 @@ class GenericResponseModel { vHRGetManagersDetailsList = json['VHR_GetManagersDetailsList']; vHRGetProjectByCodeList = json['VHR_GetProjectByCodeList']; vHRIsVerificationCodeValid = json['VHR_IsVerificationCodeValid']; - validateAbsenceTransactionList = json['ValidateAbsenceTransactionList']; + + validateAbsenceTransactionList = json['ValidateAbsenceTransactionList'] != null ? ValidateAbsenceTransactionList.fromJson(json['ValidateAbsenceTransactionList']) : null; validateEITTransactionList = json['ValidateEITTransactionList'] != null ? ValidateEITTransactionList.fromJson(json['ValidateEITTransactionList']) : null; @@ -1331,11 +1336,12 @@ class GenericResponseModel { data['BasicMemberInformation'] = this.basicMemberInformation!.toJson(); } data['BusinessCardPrivilege'] = this.businessCardPrivilege; - if (this.calculateAbsenceDuration != null) { data['CalculateAbsenceDuration'] = this.calculateAbsenceDuration!.toJson(); } - data['CancelHRTransactionLIst'] = this.cancelHRTransactionLIst; + if (this.cancelHRTransactionLIst != null) { + data['CancelHRTransactionLIst'] = this.calculateAbsenceDuration!.toJson(); + } data['Chat_EmployeeLoginList'] = this.chatEmployeeLoginList; data['CompanyBadge'] = this.companyBadge; data['CompanyImage'] = this.companyImage; @@ -1683,7 +1689,9 @@ class GenericResponseModel { data['SubordinatesOnLeavesList'] = this.subordinatesOnLeavesList!.map((v) => v.toJson()).toList(); } - data['SumbitAbsenceTransactionList'] = this.sumbitAbsenceTransactionList; + if (this.sumbitAbsenceTransactionList != null) { + data['SumbitAbsenceTransactionList'] = this.sumbitAbsenceTransactionList!.toJson(); + } data['TokenID'] = this.tokenID; data['UpdateAttachmentList'] = this.updateAttachmentList; data['UpdateEmployeeImageList'] = this.updateEmployeeImageList; @@ -1699,8 +1707,10 @@ class GenericResponseModel { data['VHR_GetManagersDetailsList'] = this.vHRGetManagersDetailsList; data['VHR_GetProjectByCodeList'] = this.vHRGetProjectByCodeList; data['VHR_IsVerificationCodeValid'] = this.vHRIsVerificationCodeValid; - data['ValidateAbsenceTransactionList'] = this.validateAbsenceTransactionList; + if (validateAbsenceTransactionList != null) { + data['ValidateAbsenceTransactionList'] = validateAbsenceTransactionList!.toJson(); + } if (validateEITTransactionList != null) { data['ValidateEITTransactionList'] = validateEITTransactionList!.toJson(); } diff --git a/lib/models/leave_balance/cancel_hr_transaction_list_model.dart b/lib/models/leave_balance/cancel_hr_transaction_list_model.dart new file mode 100644 index 0000000..86383ee --- /dev/null +++ b/lib/models/leave_balance/cancel_hr_transaction_list_model.dart @@ -0,0 +1,18 @@ +class CancelHRTransactionLIst { + String? pRETURNMSG; + String? pRETURNSTATUS; + + CancelHRTransactionLIst({this.pRETURNMSG, this.pRETURNSTATUS}); + + CancelHRTransactionLIst.fromJson(Map json) { + pRETURNMSG = json['P_RETURN_MSG']; + pRETURNSTATUS = json['P_RETURN_STATUS']; + } + + Map toJson() { + Map data = new Map(); + data['P_RETURN_MSG'] = this.pRETURNMSG; + data['P_RETURN_STATUS'] = this.pRETURNSTATUS; + return data; + } +} diff --git a/lib/models/leave_balance/sumbit_absence_transaction_list_model.dart b/lib/models/leave_balance/sumbit_absence_transaction_list_model.dart new file mode 100644 index 0000000..3f5a2c4 --- /dev/null +++ b/lib/models/leave_balance/sumbit_absence_transaction_list_model.dart @@ -0,0 +1,22 @@ +class SumbitAbsenceTransactionList { + String? pRETURNMSG; + String? pRETURNSTATUS; + int? pTRANSACTIONID; + + SumbitAbsenceTransactionList( + {this.pRETURNMSG, this.pRETURNSTATUS, this.pTRANSACTIONID}); + + SumbitAbsenceTransactionList.fromJson(Map json) { + pRETURNMSG = json['P_RETURN_MSG']; + pRETURNSTATUS = json['P_RETURN_STATUS']; + pTRANSACTIONID = json['P_TRANSACTION_ID']; + } + + Map toJson() { + Map data = new Map(); + data['P_RETURN_MSG'] = this.pRETURNMSG; + data['P_RETURN_STATUS'] = this.pRETURNSTATUS; + data['P_TRANSACTION_ID'] = this.pTRANSACTIONID; + return data; + } +} \ No newline at end of file diff --git a/lib/models/leave_balance/validate_absence_transaction_list_model.dart b/lib/models/leave_balance/validate_absence_transaction_list_model.dart new file mode 100644 index 0000000..e75d18e --- /dev/null +++ b/lib/models/leave_balance/validate_absence_transaction_list_model.dart @@ -0,0 +1,18 @@ +class ValidateAbsenceTransactionList { + String? pRETURNMSG; + String? pRETURNSTATUS; + + ValidateAbsenceTransactionList({this.pRETURNMSG, this.pRETURNSTATUS}); + + ValidateAbsenceTransactionList.fromJson(Map json) { + pRETURNMSG = json['P_RETURN_MSG']; + pRETURNSTATUS = json['P_RETURN_STATUS']; + } + + Map toJson() { + Map data = new Map(); + data['P_RETURN_MSG'] = this.pRETURNMSG; + data['P_RETURN_STATUS'] = this.pRETURNSTATUS; + return data; + } +} \ No newline at end of file diff --git a/lib/models/update_user_item_type_list.dart b/lib/models/update_user_item_type_list.dart index 2253ebb..c6e938c 100644 --- a/lib/models/update_user_item_type_list.dart +++ b/lib/models/update_user_item_type_list.dart @@ -1,5 +1,3 @@ - - class UpdateUserItemTypesList { String? pRETURNMSG; String? pRETURNSTATUS; diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index d87fa88..0703caf 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -4,7 +4,9 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/leave_balance_api_client.dart'; +import 'package:mohem_flutter_app/classes/date_uitl.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; @@ -12,7 +14,9 @@ import 'package:mohem_flutter_app/models/get_eit_dff_structure_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/calculate_absence_duration_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_attendance_types_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_dff_structure_list_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/sumbit_absence_transaction_list_model.dart'; import 'package:mohem_flutter_app/models/worklist/replacement_list_model.dart'; +import 'package:mohem_flutter_app/ui/misc/request_submit_screen.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheets/search_employee_bottom_sheet.dart'; @@ -59,11 +63,11 @@ class _AddLeaveBalanceScreenState extends State { } } - void getAbsenceDffStructure(String flexCode) async { + void getAbsenceDffStructure() async { try { Utils.showLoading(context); getabsenceDffStructureList.clear(); - getabsenceDffStructureList = await LeaveBalanceApiClient().getAbsenceDffStructure(flexCode, "HR_LOA_SS", -999); + getabsenceDffStructureList = await LeaveBalanceApiClient().getAbsenceDffStructure(selectedAbsenceType!.dESCFLEXCONTEXTCODE!, "HR_LOA_SS", -999); Utils.hideLoading(context); setState(() {}); } catch (ex) { @@ -87,6 +91,50 @@ class _AddLeaveBalanceScreenState extends State { } } + void validateAbsenceTransaction() async { + try { + Utils.showLoading(context); + Map dffDataMap = {}; + for (int i = 1; i <= 20; i++) { + dffDataMap["P_ATTRIBUTE$i"] = null; + for (int dffIndex = 0; dffIndex < getabsenceDffStructureList.length; dffIndex++) { + if ("ATTRIBUTE$i" == getabsenceDffStructureList[dffIndex].aPPLICATIONCOLUMNNAME) { + if (getabsenceDffStructureList[dffIndex].fORMATTYPE == "X") { + dffDataMap["P_ATTRIBUTE$i"] = Utils.formatDate(getabsenceDffStructureList[dffIndex].eSERVICESDV!.pIDCOLUMNNAME!); + } else { + dffDataMap["P_ATTRIBUTE$i"] = getabsenceDffStructureList[dffIndex].eSERVICESDV?.pIDCOLUMNNAME; + } + break; + } + } + } + await LeaveBalanceApiClient().validateAbsenceTransaction(selectedAbsenceType!.dESCFLEXCONTEXTCODE!, "HR_LOA_SS", selectedAbsenceType!.aBSENCEATTENDANCETYPEID!, + selectedReplacementEmployee!.userName!, DateUtil.getFormattedDate(startDateTime!, "MM/dd/yyyy"), DateUtil.getFormattedDate(endDateTime!, "MM/dd/yyyy"), -999, dffDataMap, + comments: comment); + + SumbitAbsenceTransactionList submit = await LeaveBalanceApiClient().submitAbsenceTransaction( + selectedAbsenceType!.dESCFLEXCONTEXTCODE!, + "HR_LOA_SS", + selectedAbsenceType!.aBSENCEATTENDANCETYPEID!, + selectedReplacementEmployee!.userName!, + DateUtil.getFormattedDate(startDateTime!, "MM/dd/yyyy"), + DateUtil.getFormattedDate(endDateTime!, "MM/dd/yyyy"), + -999, + dffDataMap, + comments: comment); + + Utils.hideLoading(context); + + await Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, arguments: RequestSubmitScreenParams(LocaleKeys.submit.tr(), submit.pTRANSACTIONID!, "", '')); + Utils.showLoading(context); + await LeaveBalanceApiClient().cancelHrTransaction(submit.pTRANSACTIONID!); + Utils.hideLoading(context); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + @override void dispose() { super.dispose(); @@ -121,7 +169,7 @@ class _AddLeaveBalanceScreenState extends State { } selectedAbsenceType = absenceList[popupIndex]; setState(() {}); - getAbsenceDffStructure(selectedAbsenceType!.dESCFLEXCONTEXTCODE!); + getAbsenceDffStructure(); }, ), 12.height, @@ -206,13 +254,22 @@ class _AddLeaveBalanceScreenState extends State { ).expanded, DefaultButton( LocaleKeys.next.tr(), - (selectedAbsenceType == null || startDateTime == null || endDateTime == null) ? null : () {}, + validateFieldData() + ? null + : () { + validateAbsenceTransaction(); + }, ).insideContainer ], ), ); } + bool validateFieldData() { + List filteredList = getabsenceDffStructureList.where((element) => element.rEQUIREDFLAG == "Y" && (element.eSERVICESDV?.pVALUECOLUMNNAME) == null).toList(); + return (selectedAbsenceType == null || startDateTime == null || endDateTime == null || filteredList.isNotEmpty); + } + Widget parseDynamicFormatType(GetAbsenceDffStructureList model, int index) { if (model.dISPLAYFLAG != "N") { if (model.vALIDATIONTYPE == "N") { diff --git a/lib/ui/leave_balance/leave_balance_screen.dart b/lib/ui/leave_balance/leave_balance_screen.dart index 70a7f7c..52d2613 100644 --- a/lib/ui/leave_balance/leave_balance_screen.dart +++ b/lib/ui/leave_balance/leave_balance_screen.dart @@ -35,15 +35,15 @@ class _LeaveBalanceState extends State { } void getAbsenceTransactions() async { - // try { + try { Utils.showLoading(context); absenceTransList = await LeaveBalanceApiClient().getAbsenceTransactions(-999); Utils.hideLoading(context); setState(() {}); - // } catch (ex) { - // Utils.hideLoading(context); - // Utils.handleException(ex, context, null); - // } + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } } @override diff --git a/lib/ui/misc/request_submit_screen.dart b/lib/ui/misc/request_submit_screen.dart index 63874c7..dd3d68f 100644 --- a/lib/ui/misc/request_submit_screen.dart +++ b/lib/ui/misc/request_submit_screen.dart @@ -27,6 +27,7 @@ class RequestSubmitScreenParams { int transactionId; String pItemId; String approvalFlag; + RequestSubmitScreenParams(this.title, this.transactionId, this.pItemId, this.approvalFlag); } @@ -147,17 +148,16 @@ class _RequestSubmitScreenState extends State { } return Scaffold( backgroundColor: Colors.white, - appBar: AppBarWidget( - context, - title: params!.title, - ), + appBar: AppBarWidget(context, title: params!.title), body: Column( children: [ ListView( padding: const EdgeInsets.all(21).copyWith(top: 14), physics: const BouncingScrollPhysics(), children: [ - attachmentView(LocaleKeys.attachments.tr(),), + attachmentView( + LocaleKeys.attachments.tr(), + ), 14.height, InputWidget( LocaleKeys.comments.tr(), @@ -207,15 +207,15 @@ class _RequestSubmitScreenState extends State { return Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - CircularAvatar(url: approver.eMPLOYEEIMAGE, isImageBase64: true, height: 40, width: 40), + CircularAvatar(url: approver.eMPLOYEEIMAGE, isImageBase64: approver.eMPLOYEEIMAGE != null, height: 40, width: 40), 9.width, Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - approver.aPPROVER!.toText16(), - approver.pOSITIONTITLE!.toText12(color: MyColors.lightTextColor), + (approver.aPPROVER ?? "").toText16(), + (approver.pOSITIONTITLE ?? "").toText12(color: MyColors.lightTextColor), ], ), ) From ee2c74b5dada0fbc80f53a1c0a760aa14972b2d4 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 1 Sep 2022 09:31:29 +0300 Subject: [PATCH 36/40] leave balance submit request added. --- lib/api/leave_balance_api_client.dart | 16 ++++++++++++++++ lib/models/generic_response_model.dart | 9 ++++++--- .../start_absence_approval_proccess_model.dart | 18 ++++++++++++++++++ .../add_leave_balance_screen.dart | 2 +- lib/ui/misc/request_submit_screen.dart | 15 ++++++++++----- 5 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 lib/models/leave_balance/start_absence_approval_proccess_model.dart diff --git a/lib/api/leave_balance_api_client.dart b/lib/api/leave_balance_api_client.dart index e24b47d..cd577ba 100644 --- a/lib/api/leave_balance_api_client.dart +++ b/lib/api/leave_balance_api_client.dart @@ -7,6 +7,7 @@ import 'package:mohem_flutter_app/models/leave_balance/cancel_hr_transaction_lis import 'package:mohem_flutter_app/models/leave_balance/get_absence_attendance_types_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_dff_structure_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_transaction_list_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/start_absence_approval_proccess_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/sumbit_absence_transaction_list_model.dart'; class LeaveBalanceApiClient { @@ -127,4 +128,19 @@ class LeaveBalanceApiClient { return responseData.cancelHRTransactionLIst!; }, url, postParams); } + + Future startAbsenceApprovalProcess(int pTransactionID, String comments, int pSelectedResopID) async { + String url = "${ApiConsts.erpRest}START_ABSENCE_APPROVAL_PROCESS"; + Map postParams = { + "P_TRANSACTION_ID": pTransactionID, + "P_SELECTED_RESP_ID": pSelectedResopID, + "P_COMMENTS": comments, + "P_MENU_TYPE": "E", + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.startAbsenceApprovalProccess!; + }, url, postParams); + } } diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index 31e52fb..5fca9a3 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -38,6 +38,7 @@ import 'package:mohem_flutter_app/models/leave_balance/cancel_hr_transaction_lis import 'package:mohem_flutter_app/models/leave_balance/get_absence_attendance_types_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_dff_structure_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/get_absence_transaction_list_model.dart'; +import 'package:mohem_flutter_app/models/leave_balance/start_absence_approval_proccess_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/sumbit_absence_transaction_list_model.dart'; import 'package:mohem_flutter_app/models/leave_balance/validate_absence_transaction_list_model.dart'; import 'package:mohem_flutter_app/models/member_information_list_model.dart'; @@ -312,7 +313,7 @@ class GenericResponseModel { String? resubmitHrTransactionList; String? sFHGetPoNotificationBodyList; String? sFHGetPrNotificationBodyList; - String? startAbsenceApprovalProccess; + StartAbsenceApprovalProccess? startAbsenceApprovalProccess; StartAddressApprovalProcess? startAddressApprovalProcessList; String? startBasicDetApprProcessList; String? startCeiApprovalProcess; @@ -1215,7 +1216,7 @@ class GenericResponseModel { resubmitHrTransactionList = json['ResubmitHrTransactionList']; sFHGetPoNotificationBodyList = json['SFH_GetPoNotificationBodyList']; sFHGetPrNotificationBodyList = json['SFH_GetPrNotificationBodyList']; - startAbsenceApprovalProccess = json['StartAbsenceApprovalProccess']; + startAbsenceApprovalProccess = json['StartAbsenceApprovalProccess'] != null ? StartAbsenceApprovalProccess.fromJson(json['StartAbsenceApprovalProccess']) : null; startAddressApprovalProcessList = json['StartAddressApprovalProcessList'] != null ? StartAddressApprovalProcess.fromJson(json['StartAddressApprovalProcessList']) : null; startBasicDetApprProcessList = json['StartBasicDetApprProcessList']; @@ -1650,7 +1651,9 @@ class GenericResponseModel { data['ResubmitHrTransactionList'] = this.resubmitHrTransactionList; data['SFH_GetPoNotificationBodyList'] = this.sFHGetPoNotificationBodyList; data['SFH_GetPrNotificationBodyList'] = this.sFHGetPrNotificationBodyList; - data['StartAbsenceApprovalProccess'] = this.startAbsenceApprovalProccess; + if (this.startAbsenceApprovalProccess != null) { + data['StartAbsenceApprovalProccess'] = this.startAbsenceApprovalProccess!.toJson(); + } data['StartAddressApprovalProcessList'] = this.startAddressApprovalProcessList; data['StartBasicDetApprProcessList'] = this.startBasicDetApprProcessList; data['StartCeiApprovalProcess'] = this.startCeiApprovalProcess; diff --git a/lib/models/leave_balance/start_absence_approval_proccess_model.dart b/lib/models/leave_balance/start_absence_approval_proccess_model.dart new file mode 100644 index 0000000..ca27cb1 --- /dev/null +++ b/lib/models/leave_balance/start_absence_approval_proccess_model.dart @@ -0,0 +1,18 @@ +class StartAbsenceApprovalProccess { + String? pRETURNMSG; + String? pRETURNSTATUS; + + StartAbsenceApprovalProccess({this.pRETURNMSG, this.pRETURNSTATUS}); + + StartAbsenceApprovalProccess.fromJson(Map json) { + pRETURNMSG = json['P_RETURN_MSG']; + pRETURNSTATUS = json['P_RETURN_STATUS']; + } + + Map toJson() { + Map data = new Map(); + data['P_RETURN_MSG'] = this.pRETURNMSG; + data['P_RETURN_STATUS'] = this.pRETURNSTATUS; + return data; + } +} diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index 0703caf..dc44085 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -125,7 +125,7 @@ class _AddLeaveBalanceScreenState extends State { Utils.hideLoading(context); - await Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, arguments: RequestSubmitScreenParams(LocaleKeys.submit.tr(), submit.pTRANSACTIONID!, "", '')); + await Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, arguments: RequestSubmitScreenParams(LocaleKeys.submit.tr(), submit.pTRANSACTIONID!, "", "add_leave_balance")); Utils.showLoading(context); await LeaveBalanceApiClient().cancelHrTransaction(submit.pTRANSACTIONID!); Utils.hideLoading(context); diff --git a/lib/ui/misc/request_submit_screen.dart b/lib/ui/misc/request_submit_screen.dart index dd3d68f..ba69ee8 100644 --- a/lib/ui/misc/request_submit_screen.dart +++ b/lib/ui/misc/request_submit_screen.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:easy_localization/easy_localization.dart'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/api/leave_balance_api_client.dart'; import 'package:mohem_flutter_app/api/my_attendance_api_client.dart'; import 'package:mohem_flutter_app/api/profile_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; @@ -114,20 +115,24 @@ class _RequestSubmitScreenState extends State { params!.pItemId, params!.transactionId, ); - } else { + } else if (params!.approvalFlag == 'add_leave_balance') { + await LeaveBalanceApiClient().startAbsenceApprovalProcess( + params!.transactionId, + comments.text, + -999, + ); + } else if (params!.approvalFlag == 'eit') { await MyAttendanceApiClient().startEitApprovalProcess( LocaleKeys.submit.tr(), comments.text, params!.pItemId, params!.transactionId, ); - } + } else {} Utils.hideLoading(context); Utils.showToast(LocaleKeys.yourRequestHasBeenSubmittedForApprovals.tr(), longDuration: true); - Navigator.of(context).popUntil((route) { - return route.settings.name == AppRoutes.dashboard; - }); + Navigator.of(context).popUntil((route) => route.settings.name == AppRoutes.dashboard); Navigator.pushNamed(context, AppRoutes.workList); } catch (ex) { Utils.hideLoading(context); From 907b205d2108fbe8e4efdad29f6b6eb67976e30a Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Thu, 1 Sep 2022 14:16:38 +0300 Subject: [PATCH 37/40] added subordinate leave --- assets/images/user.svg | 6 ++ assets/langs/ar-SA.json | 2 + assets/langs/en-US.json | 2 + lib/generated/codegen_loader.g.dart | 4 + lib/generated/locale_keys.g.dart | 2 + lib/ui/my_team/employee_details.dart | 4 +- lib/ui/my_team/my_team.dart | 1 - lib/ui/my_team/profile_details.dart | 6 +- lib/ui/my_team/subordinate_leave.dart | 150 ++++++++++++++------------ lib/ui/my_team/team_members.dart | 25 +++-- lib/ui/my_team/view_attendance.dart | 10 +- lib/ui/profile/family_members.dart | 2 - 12 files changed, 114 insertions(+), 100 deletions(-) create mode 100644 assets/images/user.svg diff --git a/assets/images/user.svg b/assets/images/user.svg new file mode 100644 index 0000000..13d9aed --- /dev/null +++ b/assets/images/user.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 7e2048d..1ba7218 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -356,6 +356,8 @@ "hours": "ساعات", "approvalStatus": "حالة القبول", "absenceStatus": "حالة الغياب", + "subordinateLeave": "إجازة التابعيين", + "numberDays": "عدد الأيام", "profile": { "reset_password": { "label": "Reset Password", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 38765dd..47d33b9 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -356,6 +356,8 @@ "hours": "Hours", "approvalStatus": "Approval Status", "absenceStatus": "Absence Status", + "subordinateLeave": "Subordinate Leave", + "numberDays": "Number of days", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 53499b8..7452524 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -371,6 +371,8 @@ class CodegenLoader extends AssetLoader{ "hours": "ساعات", "approvalStatus": "حالة القبول", "absenceStatus": "حالة الغياب", + "subordinateLeave": "إجازة التابعيين", + "numberDays": "عدد الأيام", "profile": { "reset_password": { "label": "Reset Password", @@ -762,6 +764,8 @@ static const Map en_US = { "hours": "Hours", "approvalStatus": "Approval Status", "absenceStatus": "Absence Status", + "subordinateLeave": "Subordinate Leave", + "numberDays": "Number of days", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 43165af..12fb29a 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -356,6 +356,8 @@ abstract class LocaleKeys { static const hours = 'hours'; static const approvalStatus = 'approvalStatus'; static const absenceStatus = 'absenceStatus'; + static const subordinateLeave = 'subordinateLeave'; + static const numberDays = 'numberDays'; static const profile_reset_password_label = 'profile.reset_password.label'; static const profile_reset_password_username = 'profile.reset_password.username'; static const profile_reset_password_password = 'profile.reset_password.password'; diff --git a/lib/ui/my_team/employee_details.dart b/lib/ui/my_team/employee_details.dart index b1252aa..26c844f 100644 --- a/lib/ui/my_team/employee_details.dart +++ b/lib/ui/my_team/employee_details.dart @@ -129,7 +129,6 @@ class _EmployeeDetailsState extends State { child: Stack(children: [ Container( width: _width, - //height: 150, margin: EdgeInsets.only(top: 50), //padding: EdgeInsets.only(right: 17, left: 17), decoration: BoxDecoration( @@ -168,7 +167,6 @@ class _EmployeeDetailsState extends State { color: MyColors.green9CColor, ), ), - // Container(height: 100, alignment: Alignment.center, child: ProfileImage()), InkWell( onTap:() { launchUrl(phoneNumber); @@ -185,7 +183,7 @@ class _EmployeeDetailsState extends State { customLabel(getEmployeeSubordinates!.eMPLOYEENUMBER.toString() + ' | ' + getEmployeeSubordinates!.jOBNAME.toString(), 13, MyColors.grey80Color, true), customLabel(getEmployeeSubordinates!.eMPLOYEEEMAILADDRESS.toString(), 13, MyColors.grey3AColor, true), ], - ).paddingOnly(bottom: 10), + ).paddingOnly(bottom: 10, left: 35,right: 31), ], ), ), diff --git a/lib/ui/my_team/my_team.dart b/lib/ui/my_team/my_team.dart index 37ab561..15ce3d2 100644 --- a/lib/ui/my_team/my_team.dart +++ b/lib/ui/my_team/my_team.dart @@ -123,7 +123,6 @@ class _MyTeamState extends State { : ListView.separated( scrollDirection: Axis.vertical, shrinkWrap: true, - // padding: EdgeInsets.only(left: 21, right: 21), physics: ScrollPhysics(), separatorBuilder: (cxt, index) => 12.height, itemCount: _textEditingController!.text.isNotEmpty ? getEmployeeSListOnSearch.length : getEmployeeSubordinatesList.length, diff --git a/lib/ui/my_team/profile_details.dart b/lib/ui/my_team/profile_details.dart index 419f897..cfc1730 100644 --- a/lib/ui/my_team/profile_details.dart +++ b/lib/ui/my_team/profile_details.dart @@ -1,15 +1,12 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_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/models/my_team/get_employee_subordinates_list.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; -import 'package:mohem_flutter_app/widgets/button/default_button.dart'; + class ProfileDetails extends StatefulWidget { const ProfileDetails({Key? key}) : super(key: key); @@ -19,7 +16,6 @@ class ProfileDetails extends StatefulWidget { } class _ProfileDetailsState extends State { - GetEmployeeSubordinatesList? getEmployeeSubordinates; diff --git a/lib/ui/my_team/subordinate_leave.dart b/lib/ui/my_team/subordinate_leave.dart index c5adb17..9e69fdc 100644 --- a/lib/ui/my_team/subordinate_leave.dart +++ b/lib/ui/my_team/subordinate_leave.dart @@ -32,8 +32,7 @@ class _SubordinateLeaveState extends State { DateTime selectedDateFrom = DateTime.now(); DateTime selectedDateTo = DateTime.now(); bool showList = false; - // DateTime dateFrom = DateFormat("MMM/DD/YYYY").format(selectedDateFrom) as DateTime; - // DateTime dateTo = DateFormat("MMM/DD/YYYY").format(selectedDateTo) as DateTime; + @@ -45,9 +44,11 @@ class _SubordinateLeaveState extends State { void getSubordinatesLeaves()async { try { Utils.showLoading(context); - getSubordinatesLeavesTotalList = await MyTeamApiClient().getSubordinatesLeavesList(selectedDateFrom.toIso8601String(), selectedDateTo.toIso8601String()); + getSubordinatesLeavesTotalList = await MyTeamApiClient().getSubordinatesLeavesList(DateUtil.convertDateToStringLocation(selectedDateFrom), DateUtil.convertDateToStringLocation(selectedDateTo)); + showList= true; Utils.hideLoading(context); - } catch (ex) {da + setState(() {}); + } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); } @@ -59,83 +60,94 @@ class _SubordinateLeaveState extends State { return Scaffold( appBar: AppBarWidget( context, - title: "Subordinate Leave", + title: LocaleKeys.subordinateLeave.tr(), ), backgroundColor: MyColors.backgroundColor, body: Column( children: [ Expanded( - child: Column( - children: [ - Column( + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Column( children: [ - DynamicTextFieldWidget( - LocaleKeys.dateFrom.tr(), - selectedDateFrom.toString().split(" ")[0], - suffixIconData: Icons.calendar_today, - isEnable: false, - onTap: () async { - selectedDateFrom = await _selectDate(context, DateTime.now()); - setState(() {}); - }, - ), - 12.height, - DynamicTextFieldWidget( - LocaleKeys.dateTo.tr(), - selectedDateTo.toString().split(" ")[0], - suffixIconData: Icons.calendar_today, - isEnable: false, - onTap: () async { - selectedDateTo = await _selectDate(context, DateTime.now()); - setState(() {}); - }, - ) - ], - ).objectContainerView(), - !showList? - SingleChildScrollView( - child: ListView.separated( + Column( + children: [ + DynamicTextFieldWidget( + LocaleKeys.dateFrom.tr(), + selectedDateFrom.toString().split(" ")[0], + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + selectedDateFrom = await _selectDate(context, DateTime.now()); + setState(() {}); + }, + ), + 12.height, + DynamicTextFieldWidget( + LocaleKeys.dateTo.tr(), + selectedDateTo.toString().split(" ")[0], + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + selectedDateTo = await _selectDate(context, DateTime.now()); + setState(() {}); + }, + ) + ], + ).objectContainerView(), + Container( + margin: EdgeInsets.only(left: 21, right: 21), + width: MediaQuery.of(context).size.width, + child: SingleChildScrollView( scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: ScrollPhysics(), - separatorBuilder: (cxt, index) => 12.height, - itemCount: getSubordinatesLeavesTotalList.length, - itemBuilder: (context, index) { - var diffDays = selectedDateTo.difference(selectedDateFrom).inDays; - return Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - // CircleAvatar( - // radius: 25, - // backgroundImage: MemoryImage(Utils.getPostBytes(getSubordinatesLeavesTotalList[index].eMPLOYEEIMAGE)), - // backgroundColor: Colors.black, - // ), - SvgPicture.asset("assets/images/clock.svg"), - 10.width, - "${getSubordinatesLeavesTotalList[index].eMPLOYEENAME}".toText16(isBold: true, color: MyColors.grey3AColor), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - "From: ${getSubordinatesLeavesTotalList[index].dATESTART}".toText10(isBold: true, color: MyColors.grey57Color), - "To: ${getSubordinatesLeavesTotalList[index].dATEEND}".toText10(isBold: true, color: MyColors.grey57Color), - ], - ).expanded, - "Number of days: $diffDays".toText13(color: MyColors.grey3AColor), - ], - ).objectContainerView(); - }), - ).objectContainerView() - :Container(), - ], + child: Column( + children: [ + showList? ListView.separated( + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: ScrollPhysics(), + separatorBuilder: (BuildContext cxt,int index) => 12.height, + itemCount: getSubordinatesLeavesTotalList.length, + itemBuilder: (BuildContext context,int index) { + var diffDays = DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATEEND!).difference(DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATESTART!)).inDays; + return getSubordinatesLeavesTotalList.isEmpty + ? Utils.getNoDataWidget(context) + : Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + SvgPicture.asset("assets/images/user.svg"), + 14.width, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "${getSubordinatesLeavesTotalList[index].eMPLOYEENAME}".toText16(isBold: true, color: MyColors.grey3AColor), + 10.height, + Row( + children: [ + (LocaleKeys.from.tr() + ': ${DateUtil.getFormattedDate(DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATESTART!), "MMM dd yyyy")}').toText10(isBold: true, color: MyColors.grey57Color), + 14.width, + (LocaleKeys.to.tr() + ': ${DateUtil.getFormattedDate(DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATEEND!), "MMM dd yyyy")}').toText10(isBold: true, color: MyColors.grey57Color), + ], + ), + (LocaleKeys.numberDays.tr()+ ": $diffDays").toText10(color: MyColors.grey3AColor), + ], + ).expanded + ], + ).objectContainerView(); + } + ) + :Container(), + ], + ), + ), + ), + ], + ), ), ), DefaultButton( LocaleKeys.submit.tr(), () async { getSubordinatesLeaves(); - setState(() { - showList= true; - }); - showList= true; }).insideContainer ], ), diff --git a/lib/ui/my_team/team_members.dart b/lib/ui/my_team/team_members.dart index f36a13b..37a779d 100644 --- a/lib/ui/my_team/team_members.dart +++ b/lib/ui/my_team/team_members.dart @@ -58,15 +58,16 @@ class _TeamMembersState extends State { scrollDirection: Axis.vertical, child: Column( children: [ - getEmployeeSubordinatesList != 0 - ? ListView.separated( + getEmployeeSubordinatesList.isEmpty + ? Utils.getNoDataWidget(context): + ListView.separated( scrollDirection: Axis.vertical, shrinkWrap: true, padding: EdgeInsets.all(21), physics: ScrollPhysics(), separatorBuilder: (cxt, index) => 12.height, itemCount: getEmployeeSubordinatesList.length, - itemBuilder: (context, index) { + itemBuilder: (BuildContext context, int index) { var phoneNumber = Uri.parse('tel:${getEmployeeSubordinatesList[index].eMPLOYEEMOBILENUMBER}'); return Container( child: Row( @@ -89,18 +90,20 @@ class _TeamMembersState extends State { Column( children: [ IconButton( - onPressed: () { - launchUrl(phoneNumber); + onPressed: () { + launchUrl(phoneNumber); }, icon: Icon( Icons.whatsapp, color: Colors.green, - ),),], - ),], - ),).objectContainerView(); - }): Container( - child: LocaleKeys.noResultsFound.tr().toText16(color: MyColors.blackColor), - ).paddingOnly(top: 10), + ), + ), + ], + ), + ], + ), + ).objectContainerView(); + }), ], ) )); diff --git a/lib/ui/my_team/view_attendance.dart b/lib/ui/my_team/view_attendance.dart index 06b0bce..28ab0f6 100644 --- a/lib/ui/my_team/view_attendance.dart +++ b/lib/ui/my_team/view_attendance.dart @@ -1,21 +1,17 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:mohem_flutter_app/api/monthly_attendance_api_client.dart'; import 'package:mohem_flutter_app/api/my_team/my_team_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; -import 'package:mohem_flutter_app/config/routes.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/dashboard/get_attendance_tracking_list_model.dart'; import 'package:mohem_flutter_app/models/get_day_hours_type_details_list_model.dart'; -import 'package:mohem_flutter_app/models/get_schedule_shifts_details_list_model.dart'; import 'package:mohem_flutter_app/models/get_time_card_summary_list_model.dart'; import 'package:mohem_flutter_app/models/my_team/get_employee_subordinates_list.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; -import 'package:mohem_flutter_app/widgets/circular_step_progress_bar.dart'; import 'package:month_picker_dialog/month_picker_dialog.dart'; import 'package:pie_chart/pie_chart.dart'; import 'package:syncfusion_flutter_calendar/calendar.dart'; @@ -54,7 +50,6 @@ class _ViewAttendanceState extends State { super.initState(); formattedDate = date; callTimeCardAndHourDetails(date.day, searchMonth, searchYear); - // setState(() {}); } @@ -86,8 +81,7 @@ class _ViewAttendanceState extends State { "Present": getTimeCardSummaryList?.aTTENDEDDAYS != null ? getTimeCardSummaryList!.aTTENDEDDAYS!.toDouble() : 0, "Absent": getTimeCardSummaryList?.aBSENTDAYS != null ? getTimeCardSummaryList!.aBSENTDAYS!.toDouble() : 0, }; - //if(getTimeCardSummaryList ==null) - // callTimeCardAndHourDetails(date.day, searchMonth, searchYear); + return Scaffold( appBar: AppBarWidget( context, @@ -193,7 +187,6 @@ class _ViewAttendanceState extends State { searchMonth = getMonth(selectedDate.month); searchYear = selectedDate.year; formattedDate = selectedDate; //DateFormat('MMMM-yyyy').format(selectedDate); - // _calendarController.selectedDate = formattedDate; callTimeCardAndHourDetails(selectedDate.day, searchMonth, searchYear); } }); @@ -322,7 +315,6 @@ class _ViewAttendanceState extends State { dayFormat: 'EEE', showTrailingAndLeadingDates: false, showAgenda: false, - //navigationDirection: MonthNavigationDirection.vertical, monthCellStyle: MonthCellStyle( textStyle: TextStyle( fontStyle: FontStyle.normal, diff --git a/lib/ui/profile/family_members.dart b/lib/ui/profile/family_members.dart index c2b1e2f..f81a288 100644 --- a/lib/ui/profile/family_members.dart +++ b/lib/ui/profile/family_members.dart @@ -11,7 +11,6 @@ import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart'; import 'package:mohem_flutter_app/models/get_employee_contacts.model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; -import 'package:mohem_flutter_app/ui/profile/dynamic_screens/dynamic_input_familyMembers_screen.dart'; import 'package:mohem_flutter_app/ui/profile/profile_screen.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; @@ -76,7 +75,6 @@ class _FamilyMembersState extends State { width: double.infinity, margin: EdgeInsets.only(left: 21, right: 21, ), - // padding: EdgeInsets.only(left: 14, right: 14, top: 13, bottom: 10), decoration: BoxDecoration( boxShadow: [ BoxShadow( From 6be8510b861855c21e9c1089fe50a84743cb53c4 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 1 Sep 2022 15:30:16 +0300 Subject: [PATCH 38/40] drawer menu ui changed. --- assets/images/drawer/change_password.svg | 3 + assets/images/drawer/employee_id.svg | 7 + assets/images/drawer/logout.svg | 3 + assets/images/drawer/mowadhafi.svg | 5 + assets/images/drawer/my_profile.svg | 14 ++ assets/images/drawer/my_requests.svg | 5 + assets/images/drawer/my_team.svg | 34 +++ assets/images/drawer/pending_trasactions.svg | 6 + .../images/drawer/performance_evaluation.svg | 12 ++ assets/images/drawer/view_business_card.svg | 11 + assets/langs/ar-SA.json | 11 +- assets/langs/en-US.json | 11 +- lib/api/dashboard_api_client.dart | 5 +- lib/extensions/string_extensions.dart | 9 +- lib/generated/codegen_loader.g.dart | 12 ++ lib/generated/locale_keys.g.dart | 6 + .../dashboard/drawer_menu_item_model.dart | 7 + lib/provider/dashboard_provider_model.dart | 31 ++- lib/ui/landing/dashboard_screen.dart | 13 +- lib/ui/landing/widget/app_drawer.dart | 202 ++++++++++-------- pubspec.yaml | 1 + 21 files changed, 287 insertions(+), 121 deletions(-) create mode 100644 assets/images/drawer/change_password.svg create mode 100644 assets/images/drawer/employee_id.svg create mode 100644 assets/images/drawer/logout.svg create mode 100644 assets/images/drawer/mowadhafi.svg create mode 100644 assets/images/drawer/my_profile.svg create mode 100644 assets/images/drawer/my_requests.svg create mode 100644 assets/images/drawer/my_team.svg create mode 100644 assets/images/drawer/pending_trasactions.svg create mode 100644 assets/images/drawer/performance_evaluation.svg create mode 100644 assets/images/drawer/view_business_card.svg create mode 100644 lib/models/dashboard/drawer_menu_item_model.dart diff --git a/assets/images/drawer/change_password.svg b/assets/images/drawer/change_password.svg new file mode 100644 index 0000000..7e953d2 --- /dev/null +++ b/assets/images/drawer/change_password.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/images/drawer/employee_id.svg b/assets/images/drawer/employee_id.svg new file mode 100644 index 0000000..b40b670 --- /dev/null +++ b/assets/images/drawer/employee_id.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/images/drawer/logout.svg b/assets/images/drawer/logout.svg new file mode 100644 index 0000000..acdc741 --- /dev/null +++ b/assets/images/drawer/logout.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/images/drawer/mowadhafi.svg b/assets/images/drawer/mowadhafi.svg new file mode 100644 index 0000000..b76f9b8 --- /dev/null +++ b/assets/images/drawer/mowadhafi.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/images/drawer/my_profile.svg b/assets/images/drawer/my_profile.svg new file mode 100644 index 0000000..45b9155 --- /dev/null +++ b/assets/images/drawer/my_profile.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/assets/images/drawer/my_requests.svg b/assets/images/drawer/my_requests.svg new file mode 100644 index 0000000..223beee --- /dev/null +++ b/assets/images/drawer/my_requests.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/images/drawer/my_team.svg b/assets/images/drawer/my_team.svg new file mode 100644 index 0000000..9eae21b --- /dev/null +++ b/assets/images/drawer/my_team.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/images/drawer/pending_trasactions.svg b/assets/images/drawer/pending_trasactions.svg new file mode 100644 index 0000000..5975ca3 --- /dev/null +++ b/assets/images/drawer/pending_trasactions.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/images/drawer/performance_evaluation.svg b/assets/images/drawer/performance_evaluation.svg new file mode 100644 index 0000000..534b5a6 --- /dev/null +++ b/assets/images/drawer/performance_evaluation.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/images/drawer/view_business_card.svg b/assets/images/drawer/view_business_card.svg new file mode 100644 index 0000000..5544e05 --- /dev/null +++ b/assets/images/drawer/view_business_card.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 7e2048d..f16b125 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -97,6 +97,7 @@ "cancel": "إلغاء", "requestedItems": "العناصر المطلوبة", "request": "طلب", + "myRequest": "طلبي", "actions": "أجراءات", "delegate": "مندوب", "request_info": "اطلب معلومات", @@ -311,6 +312,9 @@ "requestType": "نوع الطلب", "employeeDigitalID": "هويةالموظف الرقمية", "businessCard": "بطاقة العمل", + "viewBusinessCard": "عرض بطاقة العمل", + "performanceEvaluation": "تقييم الأداء", + "logout": "تسجيل خروج", "checkOut": "وقت الخروج", "regular": "منتظم", "mark": "علامة", @@ -341,13 +345,12 @@ "pleaseSelectDate": "الرجاء تحديد التاريخ", "todayAttendance": "حضور اليوم", "viewAttendance": "عرض الحضور", - "teamMembers":"اعضاءالفريق", + "teamMembers": "اعضاءالفريق", "profileDetails": "الملف الشخصي", - "noResultsFound" : "لايوجد نتائج", + "noResultsFound": "لايوجد نتائج", "searchBy": "بحث بواسطة", "myTeamMembers": "اعضاء فريقي", "save": "حفظ", - "itemType": "نوع العنصر", "TurnNotificationsFor": "تفعيل الاشعارات", "worklistSettings": "اعدادات الاشعارات", "absenceType": "نوع الغياب", @@ -356,6 +359,8 @@ "hours": "ساعات", "approvalStatus": "حالة القبول", "absenceStatus": "حالة الغياب", + "poweredBy": "مشغل بواسطة", + "cloudSolutions": "حلول السحابة", "profile": { "reset_password": { "label": "Reset Password", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 38765dd..3593bf2 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -94,6 +94,7 @@ "cancel": "Cancel", "requestedItems": "Requested Items", "request": "Request", + "myRequest": "My Request", "actions": "Actions", "delegate": "Delegate", "request_info": "Request Info", @@ -311,6 +312,9 @@ "wantToReject": "Are you sure want to reject?", "employeeDigitalID": "Employee Digital ID", "businessCard": "Business Card", + "viewBusinessCard": "View Business Card", + "performanceEvaluation": "Performance Evaluation", + "logout": "Logout", "checkOut": "Check Out", "regular": "Regular", "mark": "Mark", @@ -341,13 +345,12 @@ "pleaseSelectDate": "Please select date", "todayAttendance": "Today's Attendance", "viewAttendance": "View Attendance", - "teamMembers":"Team Members", + "teamMembers": "Team Members", "profileDetails": "Profile Details", - "noResultsFound" : "No Results Found", + "noResultsFound": "No Results Found", "searchBy": "Search by", "myTeamMembers": "My Team Members", "save": "Save", - "itemType": "Item Type", "TurnNotificationsFor": "Turn on notifications for", "worklistSettings": "Worklist Settings", "absenceType": "Absence Type", @@ -356,6 +359,8 @@ "hours": "Hours", "approvalStatus": "Approval Status", "absenceStatus": "Absence Status", + "poweredBy": "Powered By", + "cloudSolutions": "Cloud Solutions", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart index 1dd58b1..5b00e7f 100644 --- a/lib/api/dashboard_api_client.dart +++ b/lib/api/dashboard_api_client.dart @@ -5,6 +5,7 @@ import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/models/dashboard/get_attendance_tracking_list_model.dart'; import 'package:mohem_flutter_app/models/dashboard/itg_forms_model.dart'; +import 'package:mohem_flutter_app/models/dashboard/list_menu.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:uuid/uuid.dart'; @@ -66,13 +67,13 @@ class DashboardApiClient { } //Menus List - Future getListMenu() async { + Future> getListMenu() async { String url = "${ApiConsts.erpRest}GET_MENU"; Map postParams = {}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); - return responseData; + return responseData.listMenu ?? []; }, url, postParams); } diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index e895ad1..b59d90d 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -49,9 +49,9 @@ extension EmailValidator on String { style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.52, decoration: isUnderLine ? TextDecoration.underline : null), ); - Widget toText14({Color? color, bool isBold = false}) => Text( + Widget toText14({Color? color, bool isBold = false, FontWeight? weight}) => Text( this, - style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 14, letterSpacing: -0.48, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), + style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 14, letterSpacing: -0.48, fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600)), ); Widget toText16({Color? color, bool isUnderLine = false, bool isBold = false, int? maxlines}) => Text( @@ -71,6 +71,11 @@ extension EmailValidator on String { style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 17, letterSpacing: -0.68, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), ); + Widget toText18({Color? color, bool isBold = false}) => Text( + this, + style: TextStyle(fontSize: 18, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -1.08), + ); + Widget toText20({Color? color, bool isBold = false}) => Text( this, style: TextStyle(fontSize: 20, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.4), diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 53499b8..fa2d61e 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -113,6 +113,7 @@ class CodegenLoader extends AssetLoader{ "cancel": "إلغاء", "requestedItems": "العناصر المطلوبة", "request": "طلب", + "myRequest": "طلبي", "actions": "أجراءات", "delegate": "مندوب", "request_info": "اطلب معلومات", @@ -327,6 +328,9 @@ class CodegenLoader extends AssetLoader{ "requestType": "نوع الطلب", "employeeDigitalID": "هويةالموظف الرقمية", "businessCard": "بطاقة العمل", + "viewBusinessCard": "عرض بطاقة العمل", + "performanceEvaluation": "تقييم الأداء", + "logout": "تسجيل خروج", "checkOut": "وقت الخروج", "regular": "منتظم", "mark": "علامة", @@ -371,6 +375,8 @@ class CodegenLoader extends AssetLoader{ "hours": "ساعات", "approvalStatus": "حالة القبول", "absenceStatus": "حالة الغياب", + "poweredBy": "مشغل بواسطة", + "cloudSolutions": "حلول السحابة", "profile": { "reset_password": { "label": "Reset Password", @@ -501,6 +507,7 @@ static const Map en_US = { "cancel": "Cancel", "requestedItems": "Requested Items", "request": "Request", + "myRequest": "My Request", "actions": "Actions", "delegate": "Delegate", "request_info": "Request Info", @@ -718,6 +725,9 @@ static const Map en_US = { "wantToReject": "Are you sure want to reject?", "employeeDigitalID": "Employee Digital ID", "businessCard": "Business Card", + "viewBusinessCard": "View Business Card", + "performanceEvaluation": "Performance Evaluation", + "logout": "Logout", "checkOut": "Check Out", "regular": "Regular", "mark": "Mark", @@ -762,6 +772,8 @@ static const Map en_US = { "hours": "Hours", "approvalStatus": "Approval Status", "absenceStatus": "Absence Status", + "poweredBy": "Powered By", + "cloudSolutions": "Cloud Solutions", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 43165af..c307d43 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -98,6 +98,7 @@ abstract class LocaleKeys { static const cancel = 'cancel'; static const requestedItems = 'requestedItems'; static const request = 'request'; + static const myRequest = 'myRequest'; static const actions = 'actions'; static const delegate = 'delegate'; static const request_info = 'request_info'; @@ -312,6 +313,9 @@ abstract class LocaleKeys { static const requestType = 'requestType'; static const employeeDigitalID = 'employeeDigitalID'; static const businessCard = 'businessCard'; + static const viewBusinessCard = 'viewBusinessCard'; + static const performanceEvaluation = 'performanceEvaluation'; + static const logout = 'logout'; static const checkOut = 'checkOut'; static const regular = 'regular'; static const mark = 'mark'; @@ -356,6 +360,8 @@ abstract class LocaleKeys { static const hours = 'hours'; static const approvalStatus = 'approvalStatus'; static const absenceStatus = 'absenceStatus'; + static const poweredBy = 'poweredBy'; + static const cloudSolutions = 'cloudSolutions'; static const profile_reset_password_label = 'profile.reset_password.label'; static const profile_reset_password_username = 'profile.reset_password.username'; static const profile_reset_password_password = 'profile.reset_password.password'; diff --git a/lib/models/dashboard/drawer_menu_item_model.dart b/lib/models/dashboard/drawer_menu_item_model.dart new file mode 100644 index 0000000..54a7bfc --- /dev/null +++ b/lib/models/dashboard/drawer_menu_item_model.dart @@ -0,0 +1,7 @@ +class DrawerMenuItem { + String icon; + String title; + String routeName; + + DrawerMenuItem(this.icon, this.title, this.routeName); +} diff --git a/lib/provider/dashboard_provider_model.dart b/lib/provider/dashboard_provider_model.dart index 511fc03..20a0634 100644 --- a/lib/provider/dashboard_provider_model.dart +++ b/lib/provider/dashboard_provider_model.dart @@ -1,15 +1,16 @@ -import 'dart:convert'; - import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/dashboard_api_client.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/main.dart'; +import 'package:mohem_flutter_app/models/dashboard/drawer_menu_item_model.dart'; import 'package:mohem_flutter_app/models/dashboard/get_attendance_tracking_list_model.dart'; import 'package:mohem_flutter_app/models/dashboard/get_open_notifications_list.dart'; import 'package:mohem_flutter_app/models/dashboard/itg_forms_model.dart'; +import 'package:mohem_flutter_app/models/dashboard/list_menu.dart'; import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart'; import 'package:mohem_flutter_app/models/dashboard/menus.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; @@ -138,20 +139,28 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } //List Menu API's & Methods + + List drawerMenuItemList = [ + DrawerMenuItem("assets/images/drawer/my_profile.svg", LocaleKeys.myProfile.tr(), AppRoutes.profile), + DrawerMenuItem("assets/images/drawer/performance_evaluation.svg", LocaleKeys.performanceEvaluation.tr(), ""), + DrawerMenuItem("assets/images/drawer/mowadhafi.svg", LocaleKeys.mowadhafhi.tr(), AppRoutes.mowadhafhi), + DrawerMenuItem("assets/images/drawer/pending_trasactions.svg", LocaleKeys.pendingTransactions.tr(), AppRoutes.pendingTransactions), + DrawerMenuItem("assets/images/drawer/change_password.svg", LocaleKeys.changePassword.tr(), ""), + ]; + void fetchListMenu() async { try { - GenericResponseModel? genericResponseModel = await DashboardApiClient().getListMenu(); - Map map = {}; - print(jsonEncode(genericResponseModel!.listMenu)); - for (int i = 0; i < genericResponseModel.listMenu!.length; i++) { - print(genericResponseModel.listMenu![i].menuName ?? ""); - map[genericResponseModel.listMenu![i].menuName ?? ""] = i.toString(); + List menuList = await DashboardApiClient().getListMenu(); + List findMyRequest = menuList.where((element) => element.menuName == "My Requests").toList(); + if (findMyRequest.isNotEmpty) { + drawerMenuItemList.insert(3, DrawerMenuItem("assets/images/drawer/my_requests.svg", LocaleKeys.myRequest.tr(), AppRoutes.myTeam)); + } + List findMyTeam = menuList.where((element) => element.menuName == "My Team").toList(); + if (findMyTeam.isNotEmpty) { + drawerMenuItemList.insert(2, DrawerMenuItem("assets/images/drawer/my_team.svg", LocaleKeys.myTeamMembers.tr(), AppRoutes.myTeam)); } - logger.i(map); - notifyListeners(); } catch (ex) { logger.wtf(ex); - notifyListeners(); Utils.handleException(ex, null, null); } } diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 4a6ad82..5c3f38f 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -41,6 +41,7 @@ class _DashboardScreenState extends State { void initState() { super.initState(); data = Provider.of(context, listen: false); + data.fetchListMenu(); data.fetchAttendanceTracking(context); data.fetchWorkListCounter(context); data.fetchMissingSwipe(context); @@ -217,9 +218,11 @@ class _DashboardScreenState extends State { ), ], ), - ).onPress(() { - Navigator.pushNamed(context, AppRoutes.todayAttendance); - })) + ).onPress( + () { + Navigator.pushNamed(context, AppRoutes.todayAttendance); + }, + )) .animatedSwither(); }, ), @@ -237,10 +240,10 @@ class _DashboardScreenState extends State { 8.height, Container( width: double.infinity, - padding: EdgeInsets.only(top: 31), + padding: const EdgeInsets.only(top: 31), decoration: BoxDecoration( color: Colors.white, - borderRadius: BorderRadius.only(topRight: Radius.circular(50), topLeft: Radius.circular(50)), + borderRadius: const BorderRadius.only(topRight: Radius.circular(50), topLeft: Radius.circular(50)), border: Border.all(color: MyColors.lightGreyEDColor, width: 1), ), child: Column( diff --git a/lib/ui/landing/widget/app_drawer.dart b/lib/ui/landing/widget/app_drawer.dart index e9a33b4..7ea9748 100644 --- a/lib/ui/landing/widget/app_drawer.dart +++ b/lib/ui/landing/widget/app_drawer.dart @@ -1,13 +1,20 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; -import 'package:mohem_flutter_app/config/routes.dart'; +import 'package:flutter_svg/flutter_svg.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/dashboard/drawer_menu_item_model.dart'; +import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; +import 'package:mohem_flutter_app/ui/dialogs/id/business_card_dialog.dart'; import 'package:mohem_flutter_app/ui/dialogs/id/employee_digital_id_dialog.dart'; -import 'package:mohem_flutter_app/ui/landing/widget/drawer_item.dart'; - import 'package:mohem_flutter_app/widgets/dialogs/dialogs.dart'; -import 'package:mohem_flutter_app/ui/dialogs/id/business_card_dialog.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; +import 'package:provider/provider.dart'; class AppDrawer extends StatefulWidget { @override @@ -15,103 +22,108 @@ class AppDrawer extends StatefulWidget { } class _AppDrawerState extends State { + List drawerMenuItemList = []; + @override Widget build(BuildContext context) { - return Container( - color: Colors.white, - child: Drawer( - child: Column( - children: [ - const SizedBox( - height: 200, - ), - Expanded( - child: ListView( - padding: const EdgeInsets.all(21), - physics: const BouncingScrollPhysics(), + if (drawerMenuItemList.isEmpty) { + drawerMenuItemList = Provider.of(context, listen: false).drawerMenuItemList; + } + + return Drawer( + width: MediaQuery.of(context).size.width * 303 / 375, + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Image.asset("assets/images/logos/main_mohemm_logo.png", width: 134, height: 24), + const Icon(Icons.clear).onPress(() => Navigator.pop(context)), + ], + ).paddingOnly(left: 4, right: 14), + Row( + children: [ + CircleAvatar( + radius: 52 / 2, + backgroundImage: MemoryImage(Utils.getPostBytes(AppState().memberInformationList!.eMPLOYEEIMAGE)), + backgroundColor: Colors.black, + ), + 12.width, + Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Divider(), - InkWell( - child: new DrawerItem( - //'My Profile', - LocaleKeys.myProfile.tr(), - icon: Icons.person, - color: Colors.grey, - ), - onTap: () { - drawerNavigator(context, AppRoutes.profile); - }), - const Divider(), - InkWell( - child: DrawerItem( - // 'Mowadhafhi', - LocaleKeys.mowadhafhi.tr(), - icon: Icons.person, - color: Colors.grey, - ), - onTap: () { - drawerNavigator(context, AppRoutes.mowadhafhi); - }, - ), - const Divider(), - InkWell( - child: DrawerItem( - LocaleKeys.pendingTransactions.tr(), - icon: Icons.person, - color: Colors.grey, - ), - onTap: () { - drawerNavigator(context, AppRoutes.pendingTransactions); - }, - ), - const Divider(), - InkWell( - child: DrawerItem( - "My Team", - icon: Icons.person, - color: Colors.grey, - ), - onTap: () { - drawerNavigator(context, AppRoutes.myTeam); - }, - ), - InkWell( - child: DrawerItem( - LocaleKeys.employeeDigitalID.tr(), - icon: Icons.insert_drive_file_outlined, - color: Colors.grey, - ), - onTap: () { - showMDialog(context, child: EmployeeDigitialIdDialog()); - }, - ), - Divider(), - InkWell( - child: DrawerItem( - LocaleKeys.businessCard.tr(), - icon: Icons.insert_drive_file_outlined, - color: Colors.grey, - ), - onTap: () { - showMDialog(context, child: BusinessCardDialog()); - }, - ), + AppState().memberInformationList!.eMPLOYEENAME!.toText18(isBold: true), + AppState().memberInformationList!.jOBNAME!.toText14(weight: FontWeight.w500), ], - ), - ) - ], - ), - ), + ).expanded + ], + ).paddingOnly(left: 14, right: 14, top: 21, bottom: 21), + const Divider( + height: 1, + thickness: 1, + color: MyColors.lightGreyEFColor, + ), + ListView( + padding: const EdgeInsets.only(top: 21, bottom: 21), + children: [ + ListView.builder( + padding: EdgeInsets.zero, + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: drawerMenuItemList.length, + itemBuilder: (cxt, index) { + return menuItem(drawerMenuItemList[index].icon, drawerMenuItemList[index].title, drawerMenuItemList[index].routeName, onPress: () { + Navigator.pushNamed(context, drawerMenuItemList[index].routeName); + }); + }), + menuItem("assets/images/drawer/employee_id.svg", LocaleKeys.employeeDigitalID.tr(), "", closeDrawer: false, onPress: () => showMDialog(context, child: EmployeeDigitialIdDialog())), + menuItem("assets/images/drawer/view_business_card.svg", LocaleKeys.viewBusinessCard.tr(), "", closeDrawer: false, onPress: () => showMDialog(context, child: BusinessCardDialog())), + menuItem("assets/images/drawer/logout.svg", LocaleKeys.logout.tr(), "", color: MyColors.redA3Color, closeDrawer: false, onPress: () {}), + ], + ).expanded, + const Divider( + height: 1, + thickness: 1, + color: MyColors.lightGreyEFColor, + ), + Row( + children: [ + RichText( + text: TextSpan(text: LocaleKeys.poweredBy.tr() + " ", style: const TextStyle(color: MyColors.grey98Color, fontSize: 14, letterSpacing: -0.56, fontWeight: FontWeight.w600), children: [ + TextSpan( + text: LocaleKeys.cloudSolutions.tr(), + style: const TextStyle(color: MyColors.grey3AColor, fontSize: 14, letterSpacing: -0.56, fontWeight: FontWeight.w600), + ), + ]), + ).expanded, + Image.asset("assets/images/logos/bn_cloud_soloution.jpg", width: 40, height: 40) + ], + ).paddingOnly(left: 21, right: 21, top: 21) + ], + ).paddingOnly(top: 21, bottom: 21), ); } + Widget menuItem(String icon, String title, String routeName, {Color? color, bool closeDrawer = true, VoidCallback? onPress}) { + return Row( + children: [ + SvgPicture.asset( + icon, + height: 20, + width: 20, + ), + 9.width, + title.toText14(color: color).expanded + ], + ).paddingOnly(left: 21, top: 10, bottom: 10).onPress(closeDrawer + ? () async { + Navigator.pop(context); + Future.delayed(const Duration(microseconds: 200), onPress); + } + : onPress!); + } + void drawerNavigator(context, routeName) { Navigator.of(context).pushNamed(routeName); } } - -String capitalizeOnlyFirstLater(String text) { - if (text.trim().isEmpty) return ""; - - return "${text[0].toUpperCase()}${text.substring(1)}"; -} diff --git a/pubspec.yaml b/pubspec.yaml index dde9d39..dd26813 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -111,6 +111,7 @@ flutter: - assets/images/ - assets/images/login/ - assets/images/logos/ + - assets/images/drawer/ - assets/icons/nfc/ic_nfc.png - assets/icons/nfc/ic_done.png From 55cafb5466022ebce6f0980e79feb51ede731b75 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 1 Sep 2022 16:39:43 +0300 Subject: [PATCH 39/40] improvement. --- lib/ui/my_team/profile_details.dart | 61 +++------ lib/ui/my_team/subordinate_leave.dart | 178 +++++++++++--------------- 2 files changed, 94 insertions(+), 145 deletions(-) diff --git a/lib/ui/my_team/profile_details.dart b/lib/ui/my_team/profile_details.dart index cfc1730..b1bf5df 100644 --- a/lib/ui/my_team/profile_details.dart +++ b/lib/ui/my_team/profile_details.dart @@ -3,11 +3,11 @@ import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/classes/colors.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/my_team/get_employee_subordinates_list.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; - class ProfileDetails extends StatefulWidget { const ProfileDetails({Key? key}) : super(key: key); @@ -18,8 +18,6 @@ class ProfileDetails extends StatefulWidget { class _ProfileDetailsState extends State { GetEmployeeSubordinatesList? getEmployeeSubordinates; - - @override void initState() { super.initState(); @@ -33,47 +31,26 @@ class _ProfileDetailsState extends State { title: LocaleKeys.profileDetails.tr(), ), backgroundColor: MyColors.backgroundColor, - body: Column( + body: ListView( + padding: EdgeInsets.all(21), children: [ - Container( - width: double.infinity, - margin: EdgeInsets.only( - top: 20, - left: 21, - right: 21, - ), - padding: EdgeInsets.only(left: 14, right: 14, top: 13, bottom: 20), - 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: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - LocaleKeys.category.tr().toText13(color: MyColors.lightGrayColor), - "${getEmployeeSubordinates?.eMPLOYMENTCATEGORYMEANING}".toText16(isBold: true, color: MyColors.darkTextColor), - 23.height, - LocaleKeys.address.tr().toText13(color: MyColors.lightGrayColor), - "${getEmployeeSubordinates?.lOCATIONNAME}".toText16(isBold: true, color: MyColors.darkTextColor), - 23.height, - LocaleKeys.phoneNumber.tr().toText13(color: MyColors.lightGrayColor), - "${getEmployeeSubordinates?.eMPLOYEEMOBILENUMBER}".toText16(isBold: true, color: MyColors.darkTextColor), - 23.height, - LocaleKeys.businessGroup.tr().toText13(color: MyColors.lightGrayColor), - "${getEmployeeSubordinates?.bUSINESSGROUPNAME}".toText16(isBold: true, color: MyColors.darkTextColor), - 23.height, - LocaleKeys.Payroll.tr().toText13(color: MyColors.lightGrayColor), - "${getEmployeeSubordinates?.pAYROLLNAME}".toText16(isBold: true, color: MyColors.darkTextColor), - ]), - ), + Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + LocaleKeys.category.tr().toText13(color: MyColors.lightGrayColor), + "${getEmployeeSubordinates?.eMPLOYMENTCATEGORYMEANING}".toText16(isBold: true, color: MyColors.darkTextColor), + 23.height, + LocaleKeys.address.tr().toText13(color: MyColors.lightGrayColor), + "${getEmployeeSubordinates?.lOCATIONNAME}".toText16(isBold: true, color: MyColors.darkTextColor), + 23.height, + LocaleKeys.phoneNumber.tr().toText13(color: MyColors.lightGrayColor), + "${getEmployeeSubordinates?.eMPLOYEEMOBILENUMBER}".toText16(isBold: true, color: MyColors.darkTextColor), + 23.height, + LocaleKeys.businessGroup.tr().toText13(color: MyColors.lightGrayColor), + "${getEmployeeSubordinates?.bUSINESSGROUPNAME}".toText16(isBold: true, color: MyColors.darkTextColor), + 23.height, + LocaleKeys.Payroll.tr().toText13(color: MyColors.lightGrayColor), + "${getEmployeeSubordinates?.pAYROLLNAME}".toText16(isBold: true, color: MyColors.darkTextColor), + ]).objectContainerView(), ], )); } - } diff --git a/lib/ui/my_team/subordinate_leave.dart b/lib/ui/my_team/subordinate_leave.dart index 9e69fdc..d9ca110 100644 --- a/lib/ui/my_team/subordinate_leave.dart +++ b/lib/ui/my_team/subordinate_leave.dart @@ -1,4 +1,3 @@ - import 'dart:io'; import 'package:easy_localization/easy_localization.dart'; @@ -9,7 +8,6 @@ import 'package:mohem_flutter_app/api/my_team/my_team_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/date_uitl.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; -import 'package:mohem_flutter_app/config/routes.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'; @@ -18,7 +16,7 @@ import 'package:mohem_flutter_app/models/my_team/get_subordinates_leaves_total_v 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'; - +import 'package:mohem_flutter_app/widgets/item_detail_view_widget.dart'; class SubordinateLeave extends StatefulWidget { const SubordinateLeave({Key? key}) : super(key: key); @@ -33,19 +31,16 @@ class _SubordinateLeaveState extends State { DateTime selectedDateTo = DateTime.now(); bool showList = false; - - - @override void initState() { super.initState(); } - void getSubordinatesLeaves()async { + void getSubordinatesLeaves() async { try { Utils.showLoading(context); getSubordinatesLeavesTotalList = await MyTeamApiClient().getSubordinatesLeavesList(DateUtil.convertDateToStringLocation(selectedDateFrom), DateUtil.convertDateToStringLocation(selectedDateTo)); - showList= true; + showList = true; Utils.hideLoading(context); setState(() {}); } catch (ex) { @@ -54,108 +49,85 @@ class _SubordinateLeaveState extends State { } } - @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBarWidget( - context, - title: LocaleKeys.subordinateLeave.tr(), - ), - backgroundColor: MyColors.backgroundColor, - body: Column( - children: [ - Expanded( - child: SingleChildScrollView( - scrollDirection: Axis.vertical, - child: Column( - children: [ - Column( - children: [ - DynamicTextFieldWidget( - LocaleKeys.dateFrom.tr(), - selectedDateFrom.toString().split(" ")[0], - suffixIconData: Icons.calendar_today, - isEnable: false, - onTap: () async { - selectedDateFrom = await _selectDate(context, DateTime.now()); - setState(() {}); - }, - ), - 12.height, - DynamicTextFieldWidget( - LocaleKeys.dateTo.tr(), - selectedDateTo.toString().split(" ")[0], - suffixIconData: Icons.calendar_today, - isEnable: false, - onTap: () async { - selectedDateTo = await _selectDate(context, DateTime.now()); - setState(() {}); - }, - ) - ], - ).objectContainerView(), - Container( - margin: EdgeInsets.only(left: 21, right: 21), - width: MediaQuery.of(context).size.width, - child: SingleChildScrollView( - scrollDirection: Axis.vertical, - child: Column( - children: [ - showList? ListView.separated( - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: ScrollPhysics(), - separatorBuilder: (BuildContext cxt,int index) => 12.height, - itemCount: getSubordinatesLeavesTotalList.length, - itemBuilder: (BuildContext context,int index) { - var diffDays = DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATEEND!).difference(DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATESTART!)).inDays; - return getSubordinatesLeavesTotalList.isEmpty - ? Utils.getNoDataWidget(context) - : Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - SvgPicture.asset("assets/images/user.svg"), - 14.width, - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - "${getSubordinatesLeavesTotalList[index].eMPLOYEENAME}".toText16(isBold: true, color: MyColors.grey3AColor), - 10.height, - Row( - children: [ - (LocaleKeys.from.tr() + ': ${DateUtil.getFormattedDate(DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATESTART!), "MMM dd yyyy")}').toText10(isBold: true, color: MyColors.grey57Color), - 14.width, - (LocaleKeys.to.tr() + ': ${DateUtil.getFormattedDate(DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATEEND!), "MMM dd yyyy")}').toText10(isBold: true, color: MyColors.grey57Color), - ], - ), - (LocaleKeys.numberDays.tr()+ ": $diffDays").toText10(color: MyColors.grey3AColor), - ], - ).expanded - ], - ).objectContainerView(); - } - ) - :Container(), - ], - ), - ), - ), - ], - ), - ), + appBar: AppBarWidget( + context, + title: LocaleKeys.subordinateLeave.tr(), + ), + backgroundColor: MyColors.backgroundColor, + body: Column( + children: [ + Expanded( + child: Column( + children: [ + Column( + children: [ + DynamicTextFieldWidget( + LocaleKeys.dateFrom.tr(), + selectedDateFrom.toString().split(" ")[0], + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + selectedDateFrom = await _selectDate(context, DateTime.now()); + setState(() {}); + }, + ), + 12.height, + DynamicTextFieldWidget( + LocaleKeys.dateTo.tr(), + selectedDateTo.toString().split(" ")[0], + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + selectedDateTo = await _selectDate(context, DateTime.now()); + setState(() {}); + }, + ) + ], + ).objectContainerView(), + if (showList) + ListView.separated( + scrollDirection: Axis.vertical, + physics: ScrollPhysics(), + padding: const EdgeInsets.all(21), + separatorBuilder: (BuildContext cxt, int index) => 12.height, + itemCount: getSubordinatesLeavesTotalList.length, + itemBuilder: (BuildContext context, int index) { + var diffDays = DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATEEND!) + .difference(DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATESTART!)) + .inDays; + return getSubordinatesLeavesTotalList.isEmpty + ? Utils.getNoDataWidget(context) + : Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SvgPicture.asset("assets/images/user.svg", width: 34, height: 34).paddingOnly(top: 4), + 9.width, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + getSubordinatesLeavesTotalList[index].eMPLOYEENAME!.toText16(), + ItemDetailView(LocaleKeys.from.tr(), DateUtil.getFormattedDate(DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATESTART!), "MMM dd yyyy")), + ItemDetailView(LocaleKeys.to.tr(), DateUtil.getFormattedDate(DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATEEND!), "MMM dd yyyy")), + ItemDetailView(LocaleKeys.numberDays.tr(), diffDays.toString()), + ], + ).expanded + ], + ).objectContainerView(); + }).expanded + ], ), - DefaultButton( - LocaleKeys.submit.tr(), () async { - getSubordinatesLeaves(); - }).insideContainer - ], ), - ); + DefaultButton(LocaleKeys.submit.tr(), () async { + getSubordinatesLeaves(); + }).insideContainer + ], + ), + ); } - - Future _selectDate(BuildContext context, DateTime selectedDate) async { DateTime time = selectedDate; if (!Platform.isIOS) { From b79edd701cfa9294e2a7317294056fbd31b21ab8 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Sun, 4 Sep 2022 12:44:38 +0300 Subject: [PATCH 40/40] code improvement & translation added. --- assets/langs/ar-SA.json | 7 + assets/langs/en-US.json | 7 + lib/classes/colors.dart | 1 + lib/extensions/int_extensions.dart | 4 + lib/extensions/string_extensions.dart | 2 +- lib/generated/codegen_loader.g.dart | 18 +- lib/generated/locale_keys.g.dart | 11 +- lib/provider/dashboard_provider_model.dart | 2 +- lib/ui/landing/dashboard_screen.dart | 10 +- lib/ui/profile/profile_screen.dart | 1 - .../fragments/items_for_sale.dart | 190 +++++++++--------- .../items_for_sale/item_for_sale_detail.dart | 7 +- .../items_for_sale/items_for_sale_home.dart | 23 +-- lib/ui/screens/my_requests/my_requests.dart | 91 ++++----- lib/ui/screens/my_requests/new_request.dart | 80 ++++---- .../offers_and_discounts_details.dart | 135 ++++++------- .../offers_and_discounts_home.dart | 39 ++-- 17 files changed, 307 insertions(+), 321 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 5353a84..082270f 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -363,6 +363,13 @@ "numberDays": "عدد الأيام", "poweredBy": "مشغل بواسطة", "cloudSolutions": "حلول السحابة", + "selectTemplate": "حدد قالب", + "myPostedAds": "إعلاناتي المنشورة", + "browseCategories": "تصفح الفئات", + "searchItems": "عناصر البحث", + "offerAndDiscounts": "العروض والخصومات", + "offerValid": "العرض صالح", + "offerExpired": "انتهى العرض", "profile": { "reset_password": { "label": "Reset Password", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 18bf326..1bf8cc7 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -363,6 +363,13 @@ "cloudSolutions": "Cloud Solutions", "subordinateLeave": "Subordinate Leave", "numberDays": "Number of days", + "selectTemplate": "Select Template", + "myPostedAds": "My posted ads", + "browseCategories": "Browse Categories", + "searchItems": "Search Items", + "offerAndDiscounts": "Offer & Discounts", + "offerValid": "Offer Valid", + "offerExpired": "Offer Expired", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/classes/colors.dart b/lib/classes/colors.dart index 3469681..e1448ef 100644 --- a/lib/classes/colors.dart +++ b/lib/classes/colors.dart @@ -18,6 +18,7 @@ class MyColors { static const Color grey98Color = Color(0xff989898); static const Color lightGreyEFColor = Color(0xffEFEFEF); static const Color lightGreyEDColor = Color(0xffEDEDED); + static const Color lightGreyE3Color = Color(0xffE3E3E3); static const Color lightGreyE6Color = Color(0xffE6E6E6); static const Color lightGreyEAColor = Color(0xffEAEAEA); static const Color darkWhiteColor = Color(0xffE0E0E0); diff --git a/lib/extensions/int_extensions.dart b/lib/extensions/int_extensions.dart index 215f8d9..f46d5bb 100644 --- a/lib/extensions/int_extensions.dart +++ b/lib/extensions/int_extensions.dart @@ -1,9 +1,13 @@ import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; extension IntExtensions on int { Widget get height => SizedBox(height: toDouble()); Widget get width => SizedBox(width: toDouble()); + Widget get divider => Divider(height: toDouble(), thickness: toDouble(), color: MyColors.lightGreyEFColor); + Widget get makeItSquare => SizedBox(width: toDouble(), height: toDouble()); } diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index 30c7e2e..5627f4c 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -15,7 +15,7 @@ extension CapExtension on String { extension EmailValidator on String { Widget get toWidget => Text(this); - Widget toText10({Color? color, bool isBold = false, int? maxLine}) => Text( + Widget toText10({Color? color, bool isBold = false, int? maxlines}) => Text( this, maxLines: maxlines, style: TextStyle(fontSize: 10, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.4), diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 255e04e..0dfa765 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -379,6 +379,13 @@ class CodegenLoader extends AssetLoader{ "numberDays": "عدد الأيام", "poweredBy": "مشغل بواسطة", "cloudSolutions": "حلول السحابة", + "selectTemplate": "حدد قالب", + "myPostedAds": "إعلاناتي المنشورة", + "browseCategories": "تصفح الفئات", + "searchItems": "عناصر البحث", + "offerAndDiscounts": "العروض والخصومات", + "offerValid": "العرض صالح", + "offerExpired": "انتهى العرض", "profile": { "reset_password": { "label": "Reset Password", @@ -774,10 +781,17 @@ static const Map en_US = { "hours": "Hours", "approvalStatus": "Approval Status", "absenceStatus": "Absence Status", - "subordinateLeave": "Subordinate Leave", - "numberDays": "Number of days", "poweredBy": "Powered By", "cloudSolutions": "Cloud Solutions", + "subordinateLeave": "Subordinate Leave", + "numberDays": "Number of days", + "selectTemplate": "Select Template", + "myPostedAds": "My posted ads", + "browseCategories": "Browse Categories", + "searchItems": "Search Items", + "offerAndDiscounts": "Offer & Discounts", + "offerValid": "Offer Valid", + "offerExpired": "Offer Expired", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 8c6247b..7214616 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -360,10 +360,17 @@ abstract class LocaleKeys { static const hours = 'hours'; static const approvalStatus = 'approvalStatus'; static const absenceStatus = 'absenceStatus'; - static const poweredBy = 'poweredBy'; - static const cloudSolutions = 'cloudSolutions'; static const subordinateLeave = 'subordinateLeave'; static const numberDays = 'numberDays'; + static const poweredBy = 'poweredBy'; + static const cloudSolutions = 'cloudSolutions'; + static const selectTemplate = 'selectTemplate'; + static const myPostedAds = 'myPostedAds'; + static const browseCategories = 'browseCategories'; + static const searchItems = 'searchItems'; + static const offerAndDiscounts = 'offerAndDiscounts'; + static const offerValid = 'offerValid'; + static const offerExpired = 'offerExpired'; static const profile_reset_password_label = 'profile.reset_password.label'; static const profile_reset_password_username = 'profile.reset_password.username'; static const profile_reset_password_password = 'profile.reset_password.password'; diff --git a/lib/provider/dashboard_provider_model.dart b/lib/provider/dashboard_provider_model.dart index 5c4b20f..dca964d 100644 --- a/lib/provider/dashboard_provider_model.dart +++ b/lib/provider/dashboard_provider_model.dart @@ -159,7 +159,7 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { List menuList = await DashboardApiClient().getListMenu(); List findMyRequest = menuList.where((element) => element.menuName == "My Requests").toList(); if (findMyRequest.isNotEmpty) { - drawerMenuItemList.insert(3, DrawerMenuItem("assets/images/drawer/my_requests.svg", LocaleKeys.myRequest.tr(), AppRoutes.myTeam)); + drawerMenuItemList.insert(3, DrawerMenuItem("assets/images/drawer/my_requests.svg", LocaleKeys.myRequest.tr(), AppRoutes.myRequests)); } List findMyTeam = menuList.where((element) => element.menuName == "My Team").toList(); if (findMyTeam.isNotEmpty) { diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index ad5ba1d..907072e 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -277,11 +277,9 @@ class _DashboardScreenState extends State { ], ), ), - InkWell( - onTap: () { - Navigator.pushNamed(context, AppRoutes.offersAndDiscounts); - }, - child: LocaleKeys.viewAllOffers.tr().toText12(isUnderLine: true)), + LocaleKeys.viewAllOffers.tr().toText12(isUnderLine: true).onPress(() { + Navigator.pushNamed(context, AppRoutes.offersAndDiscounts); + }) ], ).paddingOnly(left: 21, right: 21), Consumer( @@ -312,7 +310,7 @@ class _DashboardScreenState extends State { borderRadius: const BorderRadius.all( Radius.circular(100), ), - border: Border.all(color: MyColors.lightGreyEDColor, width: 1), + border: Border.all(color: MyColors.lightGreyE3Color, width: 1), ), child: ClipRRect( borderRadius: const BorderRadius.all( diff --git a/lib/ui/profile/profile_screen.dart b/lib/ui/profile/profile_screen.dart index 8caf637..e72d3a9 100644 --- a/lib/ui/profile/profile_screen.dart +++ b/lib/ui/profile/profile_screen.dart @@ -17,7 +17,6 @@ import 'package:mohem_flutter_app/models/member_information_list_model.dart'; import 'package:mohem_flutter_app/ui/profile/widgets/profile_panel.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; -// todo '@sultan' kindly follow structure of code written. use extension methods for widgets and dont hard code strings, use localizations class ProfileScreen extends StatefulWidget { const ProfileScreen({Key? key}) : super(key: key); diff --git a/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart b/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart index 93ea8e9..0e9f4db 100644 --- a/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart +++ b/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:mohem_flutter_app/api/items_for_sale/items_for_sale_api_client.dart'; @@ -9,9 +10,9 @@ import 'package:mohem_flutter_app/config/routes.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/items_for_sale/get_items_for_sale_list.dart'; import 'package:mohem_flutter_app/models/items_for_sale/get_sale_categories_list.dart'; -import 'package:mohem_flutter_app/ui/screens/items_for_sale/items_for_sale_home.dart'; import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; class ItemsForSaleFragment extends StatefulWidget { @@ -35,7 +36,7 @@ class _ItemsForSaleFragmentState extends State { gridScrollController.addListener(() { if (gridScrollController.position.atEdge) { bool isTop = gridScrollController.position.pixels == 0; - if (!isTop) { + if (!isTop && getItemsForSaleList.length == currentPageNo * 10) { print('At the bottom'); currentPageNo++; getItemsForSale(currentPageNo, currentCategoryID); @@ -47,103 +48,100 @@ class _ItemsForSaleFragmentState extends State { @override Widget build(BuildContext context) { - return SingleChildScrollView( + return ListView( controller: gridScrollController, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - DynamicTextFieldWidget( - "Search", - "Search Items", - isEnable: true, - suffixIconData: Icons.search, - isPopup: false, - lines: 1, - isInputTypeNum: false, - isReadOnly: false, - onChange: (String value) { - // _runFilter(value); - }, - ).paddingOnly(left: 21, right: 21, top: 21, bottom: 18), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - "Browse Categories".toText17(), - IconButton( - icon: const Icon(Icons.filter_alt_sharp, color: MyColors.darkIconColor, size: 28.0), - onPressed: () => Navigator.pop(context), - ), - ], - ).paddingOnly(left: 21, right: 21), - SizedBox( - height: 105.0, - child: getSaleCategoriesList.isNotEmpty - ? ListView.separated( - shrinkWrap: true, - physics: const BouncingScrollPhysics(), - padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), - scrollDirection: Axis.horizontal, - itemBuilder: (cxt, index) { - return AspectRatio( - aspectRatio: 1 / 1, - child: InkWell( - onTap: () { - setState(() { - currentCategoryID = getSaleCategoriesList[index].categoryID!; - getItemsForSaleList.clear(); - currentPageNo = 1; - getItemsForSale(currentPageNo, currentCategoryID); - }); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(15), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SvgPicture.string(getSaleCategoriesList[index].content!, fit: BoxFit.contain), - currentCategoryID == getSaleCategoriesList[index].categoryID ? const Icon(Icons.check_circle_rounded, color: MyColors.greenColor, size: 16.0) : Container(), - ], - ).expanded, - getSaleCategoriesList[index].title!.toText10() - ], - ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), + children: [ + DynamicTextFieldWidget( + LocaleKeys.search.tr(), + LocaleKeys.searchItems.tr(), + isEnable: true, + suffixIconData: Icons.search, + isPopup: false, + lines: 1, + isInputTypeNum: false, + isReadOnly: false, + onChange: (String value) { + // _runFilter(value); + }, + ).paddingOnly(left: 21, right: 21, top: 21), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + LocaleKeys.browseCategories.tr().toText17(), + // todo @haroon define the purpose of this icon button + IconButton( + icon: const Icon(Icons.filter_alt_sharp, color: MyColors.darkIconColor, size: 28.0), + onPressed: () => Navigator.pop(context), + ), + ], + ).paddingOnly(left: 21, right: 21), + SizedBox( + height: 105.0, + child: getSaleCategoriesList.isNotEmpty + ? ListView.separated( + shrinkWrap: true, + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), + scrollDirection: Axis.horizontal, + itemBuilder: (cxt, index) { + return AspectRatio( + aspectRatio: 1 / 1, + child: InkWell( + onTap: () { + setState(() { + currentCategoryID = getSaleCategoriesList[index].categoryID!; + getItemsForSaleList.clear(); + currentPageNo = 1; + getItemsForSale(currentPageNo, currentCategoryID); + }); + }, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(15), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SvgPicture.string(getSaleCategoriesList[index].content!, fit: BoxFit.contain), + currentCategoryID == getSaleCategoriesList[index].categoryID ? const Icon(Icons.check_circle_rounded, color: MyColors.greenColor, size: 16.0) : Container(), + ], + ).expanded, + getSaleCategoriesList[index].title!.toText10() + ], + ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), ), - ); - }, - separatorBuilder: (cxt, index) => 12.width, - itemCount: getSaleCategoriesList.length) - : Container(), - ), - getItemsForSaleList.isNotEmpty - ? GridView( - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 162 / 266, crossAxisSpacing: 12, mainAxisSpacing: 12), - padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 21), - shrinkWrap: true, - primary: false, - physics: const ScrollPhysics(), - children: getItemsForSaleWidgets(), - ) - : Utils.getNoDataWidget(context).paddingOnly(top: 50), - // 32.height, - ], - ), + ), + ); + }, + separatorBuilder: (cxt, index) => 12.width, + itemCount: getSaleCategoriesList.length) + : Container(), + ), + getItemsForSaleList.isNotEmpty + ? GridView( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 162 / 266, crossAxisSpacing: 12, mainAxisSpacing: 12), + padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 21), + shrinkWrap: true, + primary: false, + physics: const ScrollPhysics(), + children: getItemsForSaleWidgets(), + ) + : Utils.getNoDataWidget(context).paddingOnly(top: 50), + // 32.height, + ], ); } diff --git a/lib/ui/screens/items_for_sale/item_for_sale_detail.dart b/lib/ui/screens/items_for_sale/item_for_sale_detail.dart index c85f4e0..8129b8a 100644 --- a/lib/ui/screens/items_for_sale/item_for_sale_detail.dart +++ b/lib/ui/screens/items_for_sale/item_for_sale_detail.dart @@ -1,10 +1,12 @@ import 'dart:convert'; +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/date_uitl.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/items_for_sale/get_items_for_sale_list.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; @@ -26,10 +28,7 @@ class _ItemForSaleDetailPageState extends State { getItemsForSaleList = ModalRoute.of(context)?.settings.arguments as GetItemsForSaleList; return Scaffold( backgroundColor: Colors.white, - appBar: AppBarWidget(context, - // title: LocaleKeys.mowadhafhiRequest.tr(), - title: "Items for sale", - showHomeButton: true,), + appBar: AppBarWidget(context, title: LocaleKeys.itemsForSale.tr(), showHomeButton: true), body: SingleChildScrollView( child: Column( children: [ diff --git a/lib/ui/screens/items_for_sale/items_for_sale_home.dart b/lib/ui/screens/items_for_sale/items_for_sale_home.dart index 360c0ae..9f3151d 100644 --- a/lib/ui/screens/items_for_sale/items_for_sale_home.dart +++ b/lib/ui/screens/items_for_sale/items_for_sale_home.dart @@ -1,10 +1,11 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/config/routes.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/models/items_for_sale/get_sale_categories_list.dart'; +import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/items_for_sale.dart'; import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; @@ -24,10 +25,7 @@ class _ItemsForSaleState extends State { Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, - appBar: AppBarWidget(context, - // title: LocaleKeys.mowadhafhiRequest.tr(), - title: "Items for sale", - showHomeButton: true), + appBar: AppBarWidget(context, title: LocaleKeys.itemsForSale.tr(), showHomeButton: true), body: Column( children: [ Container( @@ -48,7 +46,7 @@ class _ItemsForSaleState extends State { ), ), child: Row( - children: [myTab("Items for sale", 0), myTab("My posted ads", 1)], + children: [myTab(LocaleKeys.itemsForSale.tr(), 0), myTab("My posted ads", 1)], ), ), PageView( @@ -59,10 +57,7 @@ class _ItemsForSaleState extends State { tabIndex = pageIndex; }); }, - children: [ - ItemsForSaleFragment(), - MyPostedAdsFragment() - ], + children: [ItemsForSaleFragment(), MyPostedAdsFragment()], ).expanded, ], ), @@ -77,9 +72,11 @@ class _ItemsForSaleState extends State { ]), ), child: const Icon(Icons.add, color: Colors.white, size: 30), - ).onPress(() { - Navigator.pushNamed(context, AppRoutes.addNewItemForSale); - }) + ).onPress( + () { + Navigator.pushNamed(context, AppRoutes.addNewItemForSale); + }, + ), ); } diff --git a/lib/ui/screens/my_requests/my_requests.dart b/lib/ui/screens/my_requests/my_requests.dart index ebeff43..65aa534 100644 --- a/lib/ui/screens/my_requests/my_requests.dart +++ b/lib/ui/screens/my_requests/my_requests.dart @@ -49,45 +49,36 @@ class _MyRequestsState extends State { context, title: "Concurrent Reports", ), - body: Container( - width: double.infinity, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - children: [ - 12.height, - Container( - padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 0), - margin: const EdgeInsets.only(left: 12, right: 12, top: 0, bottom: 0), - child: PopupMenuButton( - child: DynamicTextFieldWidget( - "Template Name", - selectedConcurrentProgramList?.uSERCONCURRENTPROGRAMNAME ?? "", - isEnable: false, - isPopup: true, - isInputTypeNum: true, - isReadOnly: false, - ).paddingOnly(bottom: 12), - itemBuilder: (_) => >[ - for (int i = 0; i < getConcurrentProgramsList!.length; i++) PopupMenuItem(child: Text(getConcurrentProgramsList![i].uSERCONCURRENTPROGRAMNAME!), value: i), - ], - onSelected: (int popupIndex) { - selectedConcurrentProgramList = getConcurrentProgramsList![popupIndex]; - getCCPTransactions(selectedConcurrentProgramList?.cONCURRENTPROGRAMNAME); - setState(() {}); - }), - ), - 12.height, - Expanded( + body: Column( + children: [ + ListView( + physics: const BouncingScrollPhysics(), + children: [ + Container( + padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 0), + margin: const EdgeInsets.only(left: 12, right: 12, top: 0, bottom: 0), + child: PopupMenuButton( + child: DynamicTextFieldWidget( + LocaleKeys.templateName.tr(), + selectedConcurrentProgramList?.uSERCONCURRENTPROGRAMNAME ?? LocaleKeys.selectTemplate.tr(), + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + for (int i = 0; i < getConcurrentProgramsList!.length; i++) PopupMenuItem(child: Text(getConcurrentProgramsList![i].uSERCONCURRENTPROGRAMNAME!), value: i), + ], + onSelected: (int popupIndex) { + selectedConcurrentProgramList = getConcurrentProgramsList![popupIndex]; + getCCPTransactions(selectedConcurrentProgramList?.cONCURRENTPROGRAMNAME); + setState(() {}); + }), + ), + 12.height, + Expanded( + // todo list don't have data, need to confirm later , because have issues, need fixes + child: ListView.separated( physics: const BouncingScrollPhysics(), shrinkWrap: true, @@ -149,21 +140,15 @@ class _MyRequestsState extends State { ); }, separatorBuilder: (BuildContext context, int index) => 12.height, - itemCount: getCCPTransactionsList.length ?? 0)), - 80.height, - Container( - decoration: const BoxDecoration( - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), - ], + itemCount: getCCPTransactionsList.length), ), - child: DefaultButton(LocaleKeys.createRequest.tr(), () async { - openNewRequest(); - }).insideContainer, - ) - ], - ), + ], + ).expanded, + 1.divider, + DefaultButton(LocaleKeys.createRequest.tr(), () async { + openNewRequest(); + }).insideContainer, + ], ), ); } diff --git a/lib/ui/screens/my_requests/new_request.dart b/lib/ui/screens/my_requests/new_request.dart index 4cc2b20..b476ecc 100644 --- a/lib/ui/screens/my_requests/new_request.dart +++ b/lib/ui/screens/my_requests/new_request.dart @@ -4,7 +4,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/my_requests_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'; @@ -27,7 +26,7 @@ class _NewRequestState extends State { List getConcurrentProgramsList = []; GetConcurrentProgramsModel? selectedConcurrentProgramList; - List getCCPDFFStructureModelList = []; + List? getCCPDFFStructureModelList; DateTime selectedDate = DateTime.now(); @@ -45,17 +44,16 @@ class _NewRequestState extends State { context, title: "Concurrent Reports", ), - body: Container( - child: Column( - children: [ - 12.height, - Container( - padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 0), - margin: const EdgeInsets.only(left: 12, right: 12, top: 0, bottom: 0), - child: PopupMenuButton( + body: Column( + children: [ + ListView( + padding: const EdgeInsets.all(21), + physics: const BouncingScrollPhysics(), + children: [ + PopupMenuButton( child: DynamicTextFieldWidget( - "Template Name", - selectedConcurrentProgramList?.uSERCONCURRENTPROGRAMNAME ?? "", + LocaleKeys.templateName.tr(), + selectedConcurrentProgramList?.uSERCONCURRENTPROGRAMNAME ?? LocaleKeys.selectTemplate.tr(), isEnable: false, isPopup: true, isInputTypeNum: true, @@ -69,32 +67,28 @@ class _NewRequestState extends State { getCCPDFFStructure(selectedConcurrentProgramList?.cONCURRENTPROGRAMNAME); setState(() {}); }), - ), - (getCCPDFFStructureModelList.isEmpty - ? LocaleKeys.noDataAvailable.tr().toText16().center - : ListView.separated( - physics: const BouncingScrollPhysics(), - padding: const EdgeInsets.all(21), - itemBuilder: (cxt, int parentIndex) => parseDynamicFormatType(getCCPDFFStructureModelList[parentIndex], parentIndex), - separatorBuilder: (cxt, index) => 0.height, - itemCount: getCCPDFFStructureModelList.length)) - .expanded, - Container( - decoration: const BoxDecoration( - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), - ], - ), - child: DefaultButton(LocaleKeys.submit.tr(), () async { - // openNewRequest(); - }) - .insideContainer, - ) - ], - ), + getCCPDFFStructureModelList == null + ? const SizedBox() + : (getCCPDFFStructureModelList!.isEmpty + ? LocaleKeys.noDataAvailable.tr().toText16().center + : ListView.separated( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: const EdgeInsets.all(0), + itemBuilder: (cxt, int parentIndex) => parseDynamicFormatType(getCCPDFFStructureModelList![parentIndex], parentIndex), + separatorBuilder: (cxt, index) => 0.height, + itemCount: getCCPDFFStructureModelList!.length, + )), + ], + ).expanded, + 1.divider, + DefaultButton(LocaleKeys.submit.tr(), () { + // todo need to add submit method + // openNewRequest(); + }) + .insideContainer, + ], ), - // bottomSheet: ); } @@ -132,9 +126,7 @@ class _NewRequestState extends State { isReadOnly: model.rEADONLY == "Y", onChange: (text) { model.fieldAnswer = text; - if (model.eSERVICESDV == null) { - model.eSERVICESDV = ESERVICESDV(); - } + model.eSERVICESDV ??= ESERVICESDV(); model.eSERVICESDV!.pIDCOLUMNNAME = text; }, ).paddingOnly(bottom: 12); @@ -146,9 +138,7 @@ class _NewRequestState extends State { isInputTypeNum: true, onChange: (text) { model.fieldAnswer = text; - if (model.eSERVICESDV == null) { - model.eSERVICESDV = ESERVICESDV(); - } + model.eSERVICESDV ??= ESERVICESDV(); model.eSERVICESDV!.pIDCOLUMNNAME = text; }, ).paddingOnly(bottom: 12); @@ -164,7 +154,7 @@ class _NewRequestState extends State { } return DynamicTextFieldWidget( (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - displayText, + displayText.isEmpty ? LocaleKeys.pleaseSelectDate.tr() : displayText, suffixIconData: Icons.calendar_today, isEnable: false, onTap: () async { @@ -331,7 +321,7 @@ class _NewRequestState extends State { } return DynamicTextFieldWidget( (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - displayText, + displayText.isEmpty ? LocaleKeys.pleaseSelectDate.tr() : displayText, suffixIconData: Icons.calendar_today, isEnable: false, onTap: () async { diff --git a/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart b/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart index e1e216d..9a308ba 100644 --- a/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart +++ b/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart @@ -50,86 +50,69 @@ class _OffersAndDiscountsDetailsState extends State { title: "Offers & Discounts", showHomeButton: true, ), - body: SingleChildScrollView( + body: ListView( controller: _scrollController, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Hero( + tag: "ItemImage" + getOffersList[0].rowID!, + // transitionOnUserGestures: true, + child: RepaintBoundary( + key: _globalKey, + child: ClipRRect( + borderRadius: BorderRadius.circular(6), + child: Image.network( + getOffersList[0].bannerImage!, + fit: BoxFit.contain, + ), + ).paddingAll(12), + ), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + 8.height, + AppState().isArabic(context) + ? getOffersList[0].titleAR!.toText22(isBold: true, color: const Color(0xff2B353E)).center + : getOffersList[0].title!.toText22(isBold: true, color: const Color(0xff2B353E)).center, + Html( + data: AppState().isArabic(context) ? getOffersList[0].descriptionAR! : getOffersList[0].description ?? "", + onLinkTap: (String? url, RenderContext context, Map attributes, _) { + launchUrl(Uri.parse(url!)); + }, + ), + checkDate(getOffersList[0].endDate!).paddingOnly(left: 8), + 10.height, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Hero( - tag: "ItemImage" + getOffersList[0].rowID!, - // transitionOnUserGestures: true, - child: RepaintBoundary( - key: _globalKey, - child: ClipRRect( - borderRadius: BorderRadius.circular(6), - child: Image.network( - getOffersList[0].bannerImage!, - fit: BoxFit.contain, - ), - ).paddingAll(12), - ), - ), - 8.height, - AppState().isArabic(context) - ? getOffersList[0].titleAR!.toText22(isBold: true, color: const Color(0xff2B353E)).center - : getOffersList[0].title!.toText22(isBold: true, color: const Color(0xff2B353E)).center, - Html( - data: AppState().isArabic(context) ? getOffersList[0].descriptionAR! : getOffersList[0].description ?? "", - onLinkTap: (String? url, RenderContext context, Map attributes, _) { - launchUrl(Uri.parse(url!)); - }, - ), - checkDate(getOffersList[0].endDate!).paddingOnly(left: 8), - 10.height, - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - getOffersList[0].discount!.toText16(isBold: true), - InkWell( - onTap: () { - _shareOfferAsImage(); - }, - child: const Icon(Icons.share, color: MyColors.darkIconColor).paddingOnly(bottom: 4)) - ], - ).paddingOnly(left: 8, right: 8), - getOffersList[0].isHasLocation == "true" - ? InkWell( - onTap: () {}, - child: Row( - children: [const Icon(Icons.map_sharp, color: MyColors.darkIconColor).paddingOnly(bottom: 4), "Offer Location".toText16(isUnderLine: true).paddingOnly(left: 8)], - ).paddingOnly(left: 8, right: 8, top: 8), - ) - : 12.height, + getOffersList[0].discount!.toText16(isBold: true), + InkWell( + onTap: () { + _shareOfferAsImage(); + }, + child: const Icon(Icons.share, color: MyColors.darkIconColor).paddingOnly(bottom: 4)) ], - ), - ).paddingOnly(left: 21, right: 21, top: 21), - "Related Offers".toText22(isBold: true, color: const Color(0xff2B353E)).paddingAll(21.0), - GridView( - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 162 / 266, crossAxisSpacing: 12, mainAxisSpacing: 12), - padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 21), - shrinkWrap: true, - primary: false, - physics: const ScrollPhysics(), - children: getItemsForSaleWidgets(), - ), - 50.height, - ], - ), + ).paddingOnly(left: 8, right: 8), + getOffersList[0].isHasLocation == "true" + ? InkWell( + onTap: () {}, + child: Row( + children: [const Icon(Icons.map_sharp, color: MyColors.darkIconColor).paddingOnly(bottom: 4), "Offer Location".toText16(isUnderLine: true).paddingOnly(left: 8)], + ).paddingOnly(left: 8, right: 8, top: 8), + ) + : 12.height, + ], + ).objectContainerView().paddingOnly(left: 21, right: 21, top: 21), + "Related Offers".toText22(isBold: true, color: const Color(0xff2B353E)).paddingOnly(left: 21, right: 21, top: 21), + GridView( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 162 / 266, crossAxisSpacing: 12, mainAxisSpacing: 12), + padding: const EdgeInsets.all(21), + shrinkWrap: true, + primary: false, + physics: const ScrollPhysics(), + children: getItemsForSaleWidgets(), + ), + ], ), ); } diff --git a/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart b/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart index bdf6ed5..fed4583 100644 --- a/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart +++ b/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart @@ -9,6 +9,7 @@ import 'package:mohem_flutter_app/config/routes.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/offers_and_discounts/get_categories_list.dart'; import 'package:mohem_flutter_app/models/offers_and_discounts/get_offers_list.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; @@ -37,20 +38,15 @@ class _OffersAndDiscountsHomeState extends State { Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, - appBar: AppBarWidget( - context, - // title: LocaleKeys.mowadhafhiRequest.tr(), - title: "Offers & Discounts", - showHomeButton: true, - ), + appBar: AppBarWidget(context, title: LocaleKeys.offerAndDiscounts.tr(), showHomeButton: true), body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ DynamicTextFieldWidget( - "Search", - "Search Items", + LocaleKeys.search.tr(), + LocaleKeys.searchItems.tr(), isEnable: true, suffixIconData: Icons.search, isPopup: false, @@ -60,17 +56,16 @@ class _OffersAndDiscountsHomeState extends State { onChange: (String value) { // _runFilter(value); }, - ).paddingOnly(left: 21, right: 21, top: 21, bottom: 18), + ).paddingOnly(left: 21, right: 21, top: 21), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - "Browse Categories".toText17(), - IconButton( - icon: const Icon(Icons.filter_alt_sharp, color: MyColors.darkIconColor, size: 28.0), - onPressed: () => Navigator.pop(context), - ), + LocaleKeys.browseCategories.tr().toText17(), + const Icon(Icons.filter_alt_sharp, color: MyColors.darkIconColor, size: 28.0).onPress(() { + Navigator.pop(context); + }), ], - ).paddingOnly(left: 21, right: 21), + ).paddingOnly(left: 21, right: 21, top: 21), SizedBox( height: 110.0, child: getCategoriesList.isNotEmpty @@ -120,7 +115,7 @@ class _OffersAndDiscountsHomeState extends State { currentCategoryID == getCategoriesList[index].id ? const Icon(Icons.check_circle_rounded, color: MyColors.greenColor, size: 16.0) : Container(), ], ).expanded, - AppState().isArabic(context) ? getCategoriesList[index].categoryNameAr!.toText10(maxLine: 1) : getCategoriesList[index].categoryNameEn!.toText10(maxLine: 1) + AppState().isArabic(context) ? getCategoriesList[index].categoryNameAr!.toText10(maxlines: 1) : getCategoriesList[index].categoryNameEn!.toText10(maxlines: 1) ], ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), ), @@ -195,7 +190,9 @@ class _OffersAndDiscountsHomeState extends State { ), ), 10.height, - AppState().isArabic(context) ? getOffersList.titleAR!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1) : getOffersList.title!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), + AppState().isArabic(context) + ? getOffersList.titleAR!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1) + : getOffersList.title!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), // Html( // data: AppState().isArabic(context) ? getOffersList.descriptionAR! : getOffersList.description ?? "", // // onLinkTap: (String? url, RenderContext context, Map attributes, _) { @@ -224,8 +221,8 @@ class _OffersAndDiscountsHomeState extends State { getOffersDetailList.add(offersListModelObj); getOffersList.forEach((element) { - if(counter <= 4) { - if(element.rowID != offersListModelObj.rowID) { + if (counter <= 4) { + if (element.rowID != offersListModelObj.rowID) { getOffersDetailList.add(element); counter++; } @@ -238,9 +235,9 @@ class _OffersAndDiscountsHomeState extends State { Widget checkDate(String endDate) { DateTime endDateObj = DateFormat("yyyy-MM-dd").parse(endDate); if (endDateObj.isAfter(DateTime.now())) { - return "Offer Valid".toText14(isBold: true, color: MyColors.greenColor); + return LocaleKeys.offerValid.tr().toText14(isBold: true, color: MyColors.greenColor); } else { - return "Offer Expired".toText14(isBold: true, color: MyColors.redColor); + return LocaleKeys.offerExpired.tr().toText14(isBold: true, color: MyColors.redColor); } }