From 34cb722b96dfc4599ffdd7404c38d43c487ff1e4 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 17 Oct 2022 11:06:51 +0300 Subject: [PATCH 01/21] updates --- lib/ui/login/login_screen.dart | 5 ++--- lib/ui/work_list/worklist_detail_screen.dart | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index 3518b18..6322ccc 100644 --- a/lib/ui/login/login_screen.dart +++ b/lib/ui/login/login_screen.dart @@ -129,9 +129,8 @@ class _LoginScreenState extends State { Widget build(BuildContext context) { if (isAppOpenBySystem == null) { isAppOpenBySystem = (ModalRoute.of(context)!.settings.arguments ?? true) as bool; - print('isAppOpenBySystem:$isAppOpenBySystem'); - username.text = "15153"; - password.text = "Abcd@12345"; + // username.text = "15153"; + // password.text = "Abcd@12345"; if (isAppOpenBySystem!) checkFirebaseToken(); } diff --git a/lib/ui/work_list/worklist_detail_screen.dart b/lib/ui/work_list/worklist_detail_screen.dart index 9a32d30..3521979 100644 --- a/lib/ui/work_list/worklist_detail_screen.dart +++ b/lib/ui/work_list/worklist_detail_screen.dart @@ -149,6 +149,9 @@ class _WorkListDetailScreenState extends State { } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); + setState(() { + + }); } } From 7aa2e0f0001706531e312b03b6dd97a11c236489 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 17 Oct 2022 15:54:17 +0300 Subject: [PATCH 02/21] code of conduct, workmen regulations added. & improvement. --- lib/ui/landing/widget/services_widget.dart | 4 +- lib/ui/login/login_screen.dart | 13 +- .../services_menu_list_screen.dart | 15 ++- lib/ui/work_list/worklist_detail_screen.dart | 1 + .../worklist_fragments/request_fragment.dart | 124 ++++++++++-------- pubspec.yaml | 1 + 6 files changed, 86 insertions(+), 72 deletions(-) diff --git a/lib/ui/landing/widget/services_widget.dart b/lib/ui/landing/widget/services_widget.dart index 7a6e976..ecb0641 100644 --- a/lib/ui/landing/widget/services_widget.dart +++ b/lib/ui/landing/widget/services_widget.dart @@ -49,6 +49,7 @@ class ServicesWidget extends StatelessWidget { padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), scrollDirection: Axis.horizontal, itemBuilder: (cxt, index) { + return AspectRatio( aspectRatio: 105 / 105, child: data.isServicesMenusLoading @@ -118,9 +119,8 @@ class ServicesWidget extends StatelessWidget { Navigator.of(context).pushNamed(AppRoutes.profile); return; } - List menuList = pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && element.menuEntryType == "FUNCTION").toList() ?? []; + List menuList = pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION" || element.menuEntryType == "MENU")).toList() ?? []; menuEntry.icon = ""; - print(menuEntry.toJson()); if (menuList.isEmpty) { if (menuEntry.requestType == "EIT") { Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(menuEntry.prompt!, menuEntry.functionName!)); diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index b4b406b..de25f7a 100644 --- a/lib/ui/login/login_screen.dart +++ b/lib/ui/login/login_screen.dart @@ -5,6 +5,7 @@ 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/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:mohem_flutter_app/api/login_api_client.dart'; @@ -50,7 +51,7 @@ class _LoginScreenState extends State { @override void initState() { super.initState(); - // checkFirebaseToken(); + // checkFirebaseToken(); } @override @@ -129,14 +130,14 @@ class _LoginScreenState extends State { Widget build(BuildContext context) { if (isAppOpenBySystem == null) { isAppOpenBySystem = (ModalRoute.of(context)!.settings.arguments ?? true) as bool; - - // username.text = "15153"; - // password.text = "Abcd@12345"; + if (kDebugMode) { + // username.text = "15444"; // Maha User + username.text = "15153"; // Tamer User + password.text = "Abcd@12345"; + } if (isAppOpenBySystem!) checkFirebaseToken(); } - // username.text = "15444"; - return Scaffold( body: Column( children: [ diff --git a/lib/ui/my_attendance/services_menu_list_screen.dart b/lib/ui/my_attendance/services_menu_list_screen.dart index 4e0c584..c05e035 100644 --- a/lib/ui/my_attendance/services_menu_list_screen.dart +++ b/lib/ui/my_attendance/services_menu_list_screen.dart @@ -8,8 +8,10 @@ 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/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/widgets/app_bar_widget.dart'; +import 'package:provider/provider.dart'; class ServicesMenuListScreenParams { final String title; @@ -29,10 +31,7 @@ class ServicesMenuListScreen extends StatelessWidget { return Scaffold( backgroundColor: Colors.white, - appBar: AppBarWidget( - context, - title: servicesMenuData.title, - ), + appBar: AppBarWidget(context, title: servicesMenuData.title), body: SizedBox( width: double.infinity, height: double.infinity, @@ -60,8 +59,12 @@ class ServicesMenuListScreen extends StatelessWidget { Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(servicesMenuData.list[index].prompt!, servicesMenuData.list[index].functionName!)); } else { if (servicesMenuData.list[index].requestType == "TERMINATION") { - Navigator.pushNamed(context, AppRoutes.endEmploymentScreen, arguments: DynamicListViewParams(servicesMenuData.list[index].prompt!, servicesMenuData.list[index].functionName!)); - + Navigator.pushNamed(context, AppRoutes.endEmploymentScreen, + arguments: DynamicListViewParams(servicesMenuData.list[index].prompt!, servicesMenuData.list[index].functionName!)); + } else { + var provider = Provider.of(context, listen: false); + List menuList = provider.getMenuEntriesList?.where((element) => element.parentMenuName == servicesMenuData.list[index].menuName).toList() ?? []; + Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(servicesMenuData.list[index].prompt!, menuList)); } } }), diff --git a/lib/ui/work_list/worklist_detail_screen.dart b/lib/ui/work_list/worklist_detail_screen.dart index 94c7208..0da21a6 100644 --- a/lib/ui/work_list/worklist_detail_screen.dart +++ b/lib/ui/work_list/worklist_detail_screen.dart @@ -168,6 +168,7 @@ class _WorkListDetailScreenState extends State { } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); + setState(() {}); } } diff --git a/lib/ui/work_list/worklist_fragments/request_fragment.dart b/lib/ui/work_list/worklist_fragments/request_fragment.dart index 27b1c29..38e0218 100644 --- a/lib/ui/work_list/worklist_fragments/request_fragment.dart +++ b/lib/ui/work_list/worklist_fragments/request_fragment.dart @@ -1,7 +1,9 @@ import 'package:easy_localization/src/public_ext.dart'; +import 'package:expandable/expandable.dart'; import 'package:flutter/material.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_item_creation_ntf_body_list_model.dart'; @@ -39,66 +41,72 @@ class RequestFragment extends StatelessWidget { } Widget poLinesDataView() { - return ListView.separated( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemBuilder: (cxt, index) => Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - ItemDetailGrid( - ItemDetailViewCol(LocaleKeys.code.tr(), poLinesList[index].iTEMCODE ?? ""), - ItemDetailViewCol(LocaleKeys.mfg.tr(), poLinesList[index].uOM ?? ""), - ), - ItemDetailGrid( - ItemDetailViewCol(LocaleKeys.lineType.tr(), poLinesList[index].qUANTITY?.toString() ?? ""), - ItemDetailViewCol(LocaleKeys.unit.tr(), poLinesList[index].uOM ?? ""), - ), - ItemDetailGrid( - ItemDetailViewCol(LocaleKeys.price.tr(), poLinesList[index].uNITPRICE?.toString() ?? ""), - ItemDetailViewCol(LocaleKeys.lineAmount.tr(), poLinesList[index].lINEAMOUNT?.toString() ?? ""), - ), - ItemDetailGrid( - ItemDetailViewCol(LocaleKeys.quantity.tr(), poLinesList[index].qUANTITY?.toString() ?? ""), - ItemDetailViewCol(LocaleKeys.lineDiscount.tr(), poLinesList[index].lINEDISCPERCENTAGE?.toString() ?? ""), - ), - ItemDetailGrid( - ItemDetailViewCol(LocaleKeys.needByDate.tr(), poLinesList[index].nEEDBYDATE ?? ""), - ItemDetailViewCol(LocaleKeys.promisedDate.tr(), poLinesList[index].pROMISEDDATE ?? ""), - ), - ItemDetailGrid( - ItemDetailViewCol(LocaleKeys.deliverToLocation.tr(), poLinesList[index].dELIVERTOLOCATION ?? ""), - ItemDetailViewCol(LocaleKeys.requisitionNumber.tr(), poLinesList[index].rEQUESTOR ?? ""), - ), - ItemDetailGrid( - ItemDetailViewCol(LocaleKeys.requester.tr(), poLinesList[index].pRNUM ?? ""), - Container(), - ), - 12.height, - Row( + return ExpandableNotifier( + child: ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (cxt, index) => ExpandablePanel( + header: poLinesList[index].iTEMDESCRIPTION!.toText14(), + collapsed: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, children: [ - DefaultButton(LocaleKeys.itemHistory.tr(), () { - Navigator.pushNamed( - cxt, - AppRoutes.itemHistory, - arguments: ItemHistoryScreenParams(title: LocaleKeys.itemHistory.tr(), isMO: false, pItemId: poLinesList[index].iTEMID), - ); - }).expanded, - 12.width, - DefaultButton(LocaleKeys.quotationAnalysis.tr(), () { - Navigator.pushNamed( - cxt, - AppRoutes.itemHistory, - arguments: ItemHistoryScreenParams( - isItemHistory: false, isMO: false, title: LocaleKeys.quotationAnalysis.tr(), pItemId: poLinesList[index].iTEMID, pPoHeaderId: poLinesList[index].pOHEADERID), - ); - }).expanded, + ItemDetailGrid( + ItemDetailViewCol(LocaleKeys.code.tr(), poLinesList[index].iTEMCODE ?? ""), + ItemDetailViewCol(LocaleKeys.mfg.tr(), poLinesList[index].uOM ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol(LocaleKeys.lineType.tr(), poLinesList[index].qUANTITY?.toString() ?? ""), + ItemDetailViewCol(LocaleKeys.unit.tr(), poLinesList[index].uOM ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol(LocaleKeys.price.tr(), poLinesList[index].uNITPRICE?.toString() ?? ""), + ItemDetailViewCol(LocaleKeys.lineAmount.tr(), poLinesList[index].lINEAMOUNT?.toString() ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol(LocaleKeys.quantity.tr(), poLinesList[index].qUANTITY?.toString() ?? ""), + ItemDetailViewCol(LocaleKeys.lineDiscount.tr(), poLinesList[index].lINEDISCPERCENTAGE?.toString() ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol(LocaleKeys.needByDate.tr(), poLinesList[index].nEEDBYDATE ?? ""), + ItemDetailViewCol(LocaleKeys.promisedDate.tr(), poLinesList[index].pROMISEDDATE ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol(LocaleKeys.deliverToLocation.tr(), poLinesList[index].dELIVERTOLOCATION ?? ""), + ItemDetailViewCol(LocaleKeys.requisitionNumber.tr(), poLinesList[index].rEQUESTOR ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol(LocaleKeys.requester.tr(), poLinesList[index].pRNUM ?? ""), + Container(), + ), + 12.height, + Row( + children: [ + DefaultButton(LocaleKeys.itemHistory.tr(), () { + Navigator.pushNamed( + cxt, + AppRoutes.itemHistory, + arguments: ItemHistoryScreenParams(title: LocaleKeys.itemHistory.tr(), isMO: false, pItemId: poLinesList[index].iTEMID), + ); + }).expanded, + 12.width, + DefaultButton(LocaleKeys.quotationAnalysis.tr(), () { + Navigator.pushNamed( + cxt, + AppRoutes.itemHistory, + arguments: ItemHistoryScreenParams( + isItemHistory: false, isMO: false, title: LocaleKeys.quotationAnalysis.tr(), pItemId: poLinesList[index].iTEMID, pPoHeaderId: poLinesList[index].pOHEADERID), + ); + }).expanded, + ], + ) ], - ) - ], - ).objectContainerView(title: poLinesList[index].iTEMDESCRIPTION!), - separatorBuilder: (cxt, index) => 12.height, - itemCount: poLinesList.length); + ), + expanded: const SizedBox(), + ).objectContainerView(), + separatorBuilder: (cxt, index) => 12.height, + itemCount: poLinesList.length), + ); } Widget moNotificationDataView() { diff --git a/pubspec.yaml b/pubspec.yaml index 8fd19ab..28497ea 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -77,6 +77,7 @@ dependencies: flutter_rating_bar: ^4.0.1 auto_size_text: ^3.0.0 pull_to_refresh: ^2.0.0 + expandable: ^5.0.1 #Chat signalr_netcore: ^1.3.3 From 5b5cc16b90d6aa7696f79e7d55efedd68470d2a5 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 18 Oct 2022 13:41:31 +0300 Subject: [PATCH 03/21] Advanced Search implemented --- assets/langs/ar-SA.json | 13 +- assets/langs/en-US.json | 13 +- lib/api/offers_and_discounts_api_client.dart | 4 +- lib/api/worklist/worklist_api_client.dart | 23 +- lib/extensions/string_extensions.dart | 4 +- lib/generated/codegen_loader.g.dart | 26 +- lib/generated/locale_keys.g.dart | 11 + lib/ui/landing/dashboard_screen.dart | 2 +- lib/ui/work_list/work_list_screen.dart | 321 ++++++++++++++++++- 9 files changed, 394 insertions(+), 23 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index a21411d..161bde6 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -454,5 +454,16 @@ "reset_locale": "Reset Language", "chat": "دردشة", "mychats": "دردشاتي", - "createNewChat": "Create New Chat" + "createNewChat": "Create New Chat", + "advancedSearch": "بحث متقدم", + "openNot": "التبليغات المفتوحة", + "fyi": "تبليغات للعلم", + "toDo": "تبليغات الأعمال", + "all": "كل التبليغات", + "meNot": "تبليغات صادرة مني", + "view": "عرض", + "fromUserName": "من", + "sentDate": "تاريخ الإرسال", + "itemTypeDisplayName": "اسم العرض", + "none": "بدون" } \ No newline at end of file diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index b5a607c..b88b14c 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -454,5 +454,16 @@ "reset_locale": "Reset Language", "chat": "Chat", "mychats": "My Chats", - "createNewChat": "Create New Chat" + "createNewChat": "Create New Chat", + "advancedSearch": "Advanced Search", + "openNot": "Open Notifications", + "fyi": "FYI Notifications", + "toDo": "To Do Notifications", + "all": "All Notifications", + "meNot": "Notifications from Me", + "view": "View", + "fromUserName": "From User Name", + "sentDate": "Sent Date", + "itemTypeDisplayName": "Item Type Display Name", + "none": "None" } \ No newline at end of file diff --git a/lib/api/offers_and_discounts_api_client.dart b/lib/api/offers_and_discounts_api_client.dart index b5aa9e6..6189612 100644 --- a/lib/api/offers_and_discounts_api_client.dart +++ b/lib/api/offers_and_discounts_api_client.dart @@ -57,9 +57,11 @@ class OffersAndDiscountsApiClient { var bodyData = json.decode(body['result']['data']); - bodyData.forEach((v) { + if(bodyData != null) { + bodyData.forEach((v) { getSaleCategoriesList.add(OffersListModel.fromJson(v)); }); + } return getSaleCategoriesList; }, url, diff --git a/lib/api/worklist/worklist_api_client.dart b/lib/api/worklist/worklist_api_client.dart index 91c0db0..8c5aed2 100644 --- a/lib/api/worklist/worklist_api_client.dart +++ b/lib/api/worklist/worklist_api_client.dart @@ -28,7 +28,6 @@ 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 { @@ -38,13 +37,18 @@ class WorkListApiClient { factory WorkListApiClient() => _instance; - Future?> getWorkList(int pPageNum, String pItemType) async { + Future?> getWorkList(int pPageNum, String pItemType, String pNotificationType, + {String pSearchUser = "", String pSearchItemType = "", String pSentDate = "", String pSearchSubject = ""}) async { String url = "${ApiConsts.erpRest}GET_WORKLIST"; Map postParams = { - "P_NOTIFICATION_TYPE": "1", + "P_NOTIFICATION_TYPE": pNotificationType, "P_PAGE_NUM": pPageNum, - "P_PAGE_LIMIT": 50, + "P_PAGE_LIMIT": 25, "P_ITEM_TYPE": pItemType, + "P_SEARCH_FROM_USER": pSearchUser, + "P_SEARCH_ITEM_TYPE_DSP_NAME": pSearchItemType, + "P_SEARCH_SENT_DATE": pSentDate, + "P_SEARCH_SUBJECT": pSearchSubject }; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { @@ -481,12 +485,9 @@ class WorkListApiClient { }, url, postParams); } - Future> getUserItemTypes() async { String url = "${ApiConsts.erpRest}GET_USER_ITEM_TYPES"; - Map postParams = { - - }; + Map postParams = {}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); @@ -496,15 +497,11 @@ class WorkListApiClient { Future updateUserItemTypes(List> itemList) async { String url = "${ApiConsts.erpRest}UPDATE_USER_ITEM_TYPES"; - Map postParams = { - "UpdateItemTypeList": itemList - }; + Map postParams = {"UpdateItemTypeList": itemList}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); return responseData.updateUserItemTypesList; }, url, postParams); } - - } diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index a9075c7..2462f57 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -65,10 +65,10 @@ 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, FontWeight? weight, int? maxlines}) => Text( + Widget toText14({Color? color, bool isUnderLine = false, bool isBold = false, FontWeight? weight, int? maxlines}) => Text( this, maxLines: maxlines, - style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 14, letterSpacing: -0.48, fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600)), + style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 14, letterSpacing: -0.48, fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600), decoration: isUnderLine ? TextDecoration.underline : null), ); Widget toText16({Color? color, bool isUnderLine = false, bool isBold = false, int? maxlines}) => Text( diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 37e5d4e..42dc55e 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -470,7 +470,18 @@ class CodegenLoader extends AssetLoader{ "reset_locale": "Reset Language", "chat": "دردشة", "mychats": "دردشاتي", - "createNewChat": "Create New Chat" + "createNewChat": "Create New Chat", + "advancedSearch": "بحث متقدم", + "openNot": "التبليغات المفتوحة", + "fyi": "تبليغات للعلم", + "toDo": "تبليغات الأعمال", + "all": "كل التبليغات", + "meNot": "تبليغات صادرة مني", + "view": "عرض", + "fromUserName": "من", + "sentDate": "تاريخ الإرسال", + "itemTypeDisplayName": "اسم العرض", + "none": "بدون" }; static const Map en_US = { "mohemm": "Mohemm", @@ -928,7 +939,18 @@ static const Map en_US = { "reset_locale": "Reset Language", "chat": "Chat", "mychats": "My Chats", - "createNewChat": "Create New Chat" + "createNewChat": "Create New Chat", + "advancedSearch": "Advanced Search", + "openNot": "Open Notifications", + "fyi": "FYI Notifications", + "toDo": "To Do Notifications", + "all": "All Notifications", + "meNot": "Notifications from Me", + "view": "View", + "fromUserName": "From User Name", + "sentDate": "Sent Date", + "itemTypeDisplayName": "Item Type Display Name", + "none": "None" }; static const Map> mapLocales = {"ar_SA": ar_SA, "en_US": en_US}; } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 85b677d..b17f5ba 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -441,5 +441,16 @@ abstract class LocaleKeys { static const chat = 'chat'; static const mychats = 'mychats'; static const createNewChat = 'createNewChat'; + static const advancedSearch = 'advancedSearch'; + static const openNot = 'openNot'; + static const fyi = 'fyi'; + static const toDo = 'toDo'; + static const all = 'all'; + static const meNot = 'meNot'; + static const view = 'view'; + static const fromUserName = 'fromUserName'; + static const sentDate = 'sentDate'; + static const itemTypeDisplayName = 'itemTypeDisplayName'; + static const none = 'none'; } diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 026d17e..0e21937 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -414,7 +414,7 @@ class _DashboardScreenState extends State { "assets/icons/item_for_sale.svg", color: currentIndex == 3 ? MyColors.grey3AColor : MyColors.grey98Color, ).paddingAll(4), - label: LocaleKeys.chat.tr(), + label: LocaleKeys.itemsForSale.tr(), ), BottomNavigationBarItem( icon: SvgPicture.asset( diff --git a/lib/ui/work_list/work_list_screen.dart b/lib/ui/work_list/work_list_screen.dart index 1eaac3e..de0815c 100644 --- a/lib/ui/work_list/work_list_screen.dart +++ b/lib/ui/work_list/work_list_screen.dart @@ -1,4 +1,7 @@ +import 'dart:io'; + 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'; @@ -18,6 +21,9 @@ import 'package:mohem_flutter_app/models/worklist_item_type_model.dart'; import 'package:mohem_flutter_app/models/worklist_response_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_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/button/default_button.dart'; +import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; import 'package:provider/provider.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; @@ -87,12 +93,36 @@ class _WorkListScreenState extends State { final RefreshController _refreshController = RefreshController(initialRefresh: false); + final Map advancedSearchViews = {}; + final Map advancedSearchSearchBy = {}; + final Map advancedSearchItemType = {}; + + int selectedViewID = 1; + String? selectedViewName; + + int selectedSearchByID = 0; + String? selectedSearchByName; + + String selectedItemTypeID = ""; + String? selectedItemTypeName; + + String searchByInput = ""; + String searchByDate = ""; + + DateTime selectedDate = DateTime.now(); + final ScrollController _controller = ScrollController(); + @override void initState() { super.initState(); providerData = Provider.of(context, listen: false); calculateCounter(); getWorkList(); + setupAdvancedSearchParams(); + } + + void setupAdvancedSearchParams() { + advancedSearchViews.addAll({1: LocaleKeys.openNot.tr(), 2: LocaleKeys.fyi.tr(), 3: LocaleKeys.toDo.tr(), 4: LocaleKeys.all.tr(), 5: LocaleKeys.meNot.tr()}); } void calculateCounter() { @@ -132,7 +162,7 @@ class _WorkListScreenState extends State { } } else { itgRequestTypeIndex = null; - workList = await WorkListApiClient().getWorkList(pageNumber, workListItemTypes[workListItemIndex].key); + workList = await WorkListApiClient().getWorkList(pageNumber, workListItemTypes[workListItemIndex].key, selectedViewID.toString()); AppState().setWorkList = workList; } if (showLoading) Utils.hideLoading(context); @@ -183,6 +213,7 @@ class _WorkListScreenState extends State { SizedBox( height: 40, child: ListView.separated( + controller: _controller, itemBuilder: (context, index) { return Container( padding: const EdgeInsets.only(left: 21, right: 21, top: 8, bottom: 8), @@ -213,7 +244,15 @@ class _WorkListScreenState extends State { padding: const EdgeInsets.only(left: 21, right: 21), ), ).paddingOnly(top: 21, bottom: 21), - workListItemTypes[workListItemIndex].fullName.toSectionHeading().paddingOnly(left: 21, right: 21), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + workListItemTypes[workListItemIndex].fullName.toSectionHeading().paddingOnly(left: 21, right: 21), + LocaleKeys.advancedSearch.tr().toText14(isUnderLine: true).onPress(() { + openBottomSheet(context); + }).paddingOnly(left: 21, right: 21) + ], + ), SmartRefresher( enablePullDown: true, enablePullUp: false, @@ -364,6 +403,147 @@ class _WorkListScreenState extends State { ); } + void openBottomSheet(BuildContext context) { + showMyBottomSheet( + context, + child: Padding( + padding: const EdgeInsets.all(21.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + LocaleKeys.advancedSearch.tr().toText18(), + IconButton( + icon: const Icon(Icons.close, color: MyColors.darkIconColor), + onPressed: () => Navigator.pop(context), + ), + ], + ), + 12.height, + PopupMenuButton( + child: DynamicTextFieldWidget( + LocaleKeys.view.tr(), + selectedViewName != null ? selectedViewName! : LocaleKeys.view.tr(), + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, + ), + itemBuilder: (_) => >[ + PopupMenuItem(value: 1, child: Text(LocaleKeys.openNot.tr())), + PopupMenuItem(value: 2, child: Text(LocaleKeys.fyi.tr())), + PopupMenuItem(value: 3, child: Text(LocaleKeys.toDo.tr())), + PopupMenuItem(value: 4, child: Text(LocaleKeys.all.tr())), + PopupMenuItem(value: 5, child: Text(LocaleKeys.meNot.tr())), + ], + onSelected: (int popupIndex) { + selectedViewID = popupIndex; + selectedViewName = getSelectedViewName(popupIndex); + setState(() {}); + }, + ), + 12.height, + PopupMenuButton( + child: DynamicTextFieldWidget( + LocaleKeys.searchBy.tr(), + selectedSearchByName != null ? selectedSearchByName! : LocaleKeys.searchBy.tr(), + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, + ), + itemBuilder: (_) => >[ + PopupMenuItem(value: 1, child: Text(LocaleKeys.fromUserName.tr())), + PopupMenuItem(value: 2, child: Text(LocaleKeys.subject.tr())), + PopupMenuItem(value: 3, child: Text(LocaleKeys.sentDate.tr())), + PopupMenuItem(value: 4, child: Text(LocaleKeys.itemTypeDisplayName.tr())), + PopupMenuItem(value: 5, child: Text(LocaleKeys.none.tr())), + ], + onSelected: (int popupIndex) { + selectedSearchByID = popupIndex; + selectedSearchByName = getSelectedSearchByName(popupIndex); + setState(() {}); + }, + ), + 12.height, + if (selectedSearchByID == 1 || selectedSearchByID == 2 || selectedSearchByID == 4) + DynamicTextFieldWidget( + LocaleKeys.searchBy.tr(), + LocaleKeys.searchBy.tr(), + isEnable: true, + isPopup: false, + lines: 1, + isInputTypeNum: false, + isReadOnly: false, + onChange: (String value) { + debugPrint(value); + searchByInput = value; + }, + ), + if (selectedSearchByID == 3) + DynamicTextFieldWidget( + LocaleKeys.searchBy.tr(), + LocaleKeys.sentDate.tr(), + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + selectedDate = await _selectDate(context, DateTime.now()); + searchByDate = selectedDate.day.toString() + "-" + getMonth(selectedDate.month) + "-" + selectedDate.year.toString(); + setState(() {}); + }, + ), + 12.height, + PopupMenuButton( + child: DynamicTextFieldWidget( + LocaleKeys.itemType.tr(), + selectedItemTypeName != null ? selectedItemTypeName! : LocaleKeys.itemType.tr(), + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, + ), + itemBuilder: (_) => >[ + const PopupMenuItem(value: "HRSSA", child: Text("HR")), + const PopupMenuItem(value: "POAPPRV", child: Text("PO")), + const PopupMenuItem(value: "REQAPPRV", child: Text("PR")), + const PopupMenuItem(value: "INVMOA", child: Text("MR")), + const PopupMenuItem(value: "INVITEM", child: Text("IC")), + const PopupMenuItem(value: "STAMP", child: Text("STAMP")), + ], + onSelected: (String popupIndex) { + selectedItemTypeID = popupIndex; + selectedItemTypeName = getSelectedItemType(popupIndex); + setState(() {}); + }, + ), + 20.height, + DefaultButton(LocaleKeys.search.tr(), () async { + Navigator.pop(context); + itgRequestTypeIndex = null; + int index = -1; + for (int i = 0; i < workListItemTypes.length; i++) { + if (workListItemTypes[i].key == selectedItemTypeID) { + index = i; + break; + } + } + Utils.showLoading(context); + workList = await WorkListApiClient().getWorkList(pageNumber, selectedItemTypeID, selectedViewID.toString(), + pSearchUser: searchByInput, pSearchSubject: searchByInput, pSentDate: searchByDate, pSearchItemType: searchByInput); + workListItemIndex = index; + AppState().setWorkList = workList; + _animateToIndex(index, 50.0); + Utils.hideLoading(context); + setState(() {}); + }) + ], + ), + ), + ); + } + Widget rowItem(WorkListItemTypeModelData data, WorkListResponseModel workData, int index) { return InkWell( onTap: () async { @@ -442,4 +622,141 @@ class _WorkListScreenState extends State { ), ); } + + void _animateToIndex(int index, double width) { + _controller.animateTo( + index * width, + duration: const Duration(seconds: 1), + curve: Curves.fastOutSlowIn, + ); + } + + String getSelectedViewName(int index) { + String returnVal = ""; + switch (index) { + case 1: + returnVal = LocaleKeys.openNot.tr(); + break; + case 2: + returnVal = LocaleKeys.fyi.tr(); + break; + case 3: + returnVal = LocaleKeys.toDo.tr(); + break; + case 4: + returnVal = LocaleKeys.all.tr(); + break; + case 5: + returnVal = LocaleKeys.meNot.tr(); + break; + } + return returnVal; + } + + String getSelectedSearchByName(int index) { + String returnVal = ""; + switch (index) { + case 1: + returnVal = LocaleKeys.fromUserName.tr(); + break; + case 2: + returnVal = LocaleKeys.subject.tr(); + break; + case 3: + returnVal = LocaleKeys.sentDate.tr(); + break; + case 4: + returnVal = LocaleKeys.itemType.tr(); + break; + case 5: + returnVal = LocaleKeys.none.tr(); + break; + } + return returnVal; + } + + String getSelectedItemType(String index) { + String returnVal = ""; + switch (index) { + case "HRSSA": + returnVal = "HR"; + break; + case "POAPPRV": + returnVal = "PO"; + break; + case "REQAPPRV": + returnVal = "PR"; + break; + case "INVMOA": + returnVal = "MR"; + break; + case "INVITEM": + returnVal = "IC"; + break; + case "STAMP": + returnVal = "STAMP"; + break; + } + return returnVal; + } + + 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; + } + + String getMonth(int month) { + switch (month) { + case 1: + return "Jan"; + case 2: + return "Feb"; + case 3: + return "Mar"; + case 4: + return "Apr"; + case 5: + return "May"; + case 6: + return "June"; + case 7: + return "July"; + case 8: + return "Aug"; + case 9: + return "Sep"; + case 10: + return "Oct"; + case 11: + return "Nov"; + case 12: + return "Dec"; + default: + return ""; + } + } } From 847b9df6fc4bc299254d69e4cade8fbe6af95428 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 18 Oct 2022 13:47:00 +0300 Subject: [PATCH 04/21] date fix in dashboard --- lib/ui/landing/dashboard_screen.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 0e21937..4ecb644 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -162,7 +162,7 @@ class _DashboardScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ LocaleKeys.markAttendance.tr().toText14(color: Colors.white, isBold: true), - if (model.isTimeRemainingInSeconds == 0) "01-02-2022".toText12(color: Colors.white), + if (model.isTimeRemainingInSeconds == 0) DateTime.now().toString().split(" ")[0].toText12(color: Colors.white), if (model.isTimeRemainingInSeconds != 0) Column( mainAxisSize: MainAxisSize.min, @@ -173,7 +173,7 @@ class _DashboardScreenState extends State { endTime: model.endTime, onEnd: null, endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), - textStyle: TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold), + textStyle: const TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold), ), LocaleKeys.timeLeftToday.tr().toText12(color: Colors.white), 9.height, From f07167e734a352bf2920a3fd96d00a29aeab83c8 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 18 Oct 2022 14:06:28 +0300 Subject: [PATCH 05/21] Leave balance fix, Items for sale fix --- lib/ui/leave_balance/add_leave_balance_screen.dart | 8 ++++---- .../fragments/add_details_fragment.dart | 12 ++++++------ lib/ui/work_list/work_list_screen.dart | 1 + lib/widgets/bottom_sheets/attachment_options.dart | 5 +++-- lib/widgets/image_picker.dart | 3 ++- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index 5fce5ec..eb8e493 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -109,14 +109,14 @@ class _AddLeaveBalanceScreenState extends State { } } 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, + selectedReplacementEmployee != null ? 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!, + selectedReplacementEmployee != null ? selectedReplacementEmployee!.userName! : "", DateUtil.getFormattedDate(startDateTime!, "MM/dd/yyyy"), DateUtil.getFormattedDate(endDateTime!, "MM/dd/yyyy"), -999, @@ -126,9 +126,9 @@ class _AddLeaveBalanceScreenState extends State { Utils.hideLoading(context); await Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, arguments: RequestSubmitScreenParams(LocaleKeys.submit.tr(), submit.pTRANSACTIONID!, "", "add_leave_balance")); - Utils.showLoading(context); + // Utils.showLoading(context); await LeaveBalanceApiClient().cancelHrTransaction(submit.pTRANSACTIONID!); - Utils.hideLoading(context); + // Utils.hideLoading(context); } 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 index 8b2f24e..b2791ec 100644 --- a/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart +++ b/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart @@ -189,7 +189,7 @@ class _AddItemDetailsFragmentState extends State { title.toText16().expanded, 6.width, SimpleButton(LocaleKeys.add.tr(), () { - ImageOptions.showImageOptionsNew(context, (String image, File file) { + ImageOptions.showImageOptionsNew(context, false, (String image, File file) { setState(() { images.add(image); Navigator.of(context).pop(); @@ -272,15 +272,15 @@ class _AddItemDetailsFragmentState extends State { } void getRegions() async { - // try { + try { Utils.showLoading(context); getRegionsList = await ItemsForSaleApiClient().getRegions(); await getAdDetails(); Utils.hideLoading(context); setState(() {}); - // } catch (ex) { - // Utils.hideLoading(context); - // Utils.handleException(ex, context, null); - // } + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } } } diff --git a/lib/ui/work_list/work_list_screen.dart b/lib/ui/work_list/work_list_screen.dart index de0815c..a19d6a5 100644 --- a/lib/ui/work_list/work_list_screen.dart +++ b/lib/ui/work_list/work_list_screen.dart @@ -182,6 +182,7 @@ class _WorkListScreenState extends State { getWorkList(showLoading: false), ]); calculateCounter(); + Utils.hideLoading(context); setState(() {}); } catch (ex) { Utils.hideLoading(context); diff --git a/lib/widgets/bottom_sheets/attachment_options.dart b/lib/widgets/bottom_sheets/attachment_options.dart index 83b6d3d..30189a0 100644 --- a/lib/widgets/bottom_sheets/attachment_options.dart +++ b/lib/widgets/bottom_sheets/attachment_options.dart @@ -8,8 +8,9 @@ class AttachmentOptions extends StatelessWidget { VoidCallback onCameraTap; VoidCallback onGalleryTap; VoidCallback onFilesTap; + bool showFilesOption; - AttachmentOptions({Key? key, required this.onCameraTap, required this.onGalleryTap, required this.onFilesTap}) : super(key: key); + AttachmentOptions({Key? key, required this.onCameraTap, required this.onGalleryTap, required this.onFilesTap, this.showFilesOption = true}) : super(key: key); @override Widget build(BuildContext context) { @@ -28,7 +29,7 @@ class AttachmentOptions extends StatelessWidget { children: [ itemView("open_camera.svg", "Open\nCamera", onCameraTap), itemView("gallery.svg", "Upload from\nGallery", onGalleryTap), - itemView("files.svg", "Upload from\nFiles", onFilesTap), + if (showFilesOption) itemView("files.svg", "Upload from\nFiles", onFilesTap), ], ) ], diff --git a/lib/widgets/image_picker.dart b/lib/widgets/image_picker.dart index 4c17250..4a99577 100644 --- a/lib/widgets/image_picker.dart +++ b/lib/widgets/image_picker.dart @@ -10,10 +10,11 @@ import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheets/attachment_options.dart'; class ImageOptions { - static void showImageOptionsNew(BuildContext context, Function(String, File) image) { + static void showImageOptionsNew(BuildContext context, bool showFilesOption, Function(String, File) image) { showMyBottomSheet( context, child: AttachmentOptions( + showFilesOption: showFilesOption, onCameraTap: () async { if (Platform.isAndroid) { cameraImageAndroid(image); From 02aff92726b6957a4874aed869ad9701f4ad47d8 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 18 Oct 2022 16:26:01 +0300 Subject: [PATCH 06/21] advance search improvement, approve delegate added. --- lib/ui/work_list/work_list_screen.dart | 326 ++---------------- lib/ui/work_list/worklist_detail_screen.dart | 13 +- .../worklist_advance_search_bottom_sheet.dart | 242 +++++++++++++ 3 files changed, 282 insertions(+), 299 deletions(-) create mode 100644 lib/widgets/bottom_sheets/worklist_advance_search_bottom_sheet.dart diff --git a/lib/ui/work_list/work_list_screen.dart b/lib/ui/work_list/work_list_screen.dart index a19d6a5..35c3c17 100644 --- a/lib/ui/work_list/work_list_screen.dart +++ b/lib/ui/work_list/work_list_screen.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -22,8 +20,7 @@ import 'package:mohem_flutter_app/models/worklist_response_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_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/button/default_button.dart'; -import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; +import 'package:mohem_flutter_app/widgets/bottom_sheets/worklist_advance_search_bottom_sheet.dart'; import 'package:provider/provider.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; @@ -93,36 +90,16 @@ class _WorkListScreenState extends State { final RefreshController _refreshController = RefreshController(initialRefresh: false); - final Map advancedSearchViews = {}; - final Map advancedSearchSearchBy = {}; - final Map advancedSearchItemType = {}; - - int selectedViewID = 1; - String? selectedViewName; - - int selectedSearchByID = 0; - String? selectedSearchByName; - - String selectedItemTypeID = ""; - String? selectedItemTypeName; - - String searchByInput = ""; - String searchByDate = ""; - - DateTime selectedDate = DateTime.now(); final ScrollController _controller = ScrollController(); + int pNotificationType = 1; + @override void initState() { super.initState(); providerData = Provider.of(context, listen: false); calculateCounter(); getWorkList(); - setupAdvancedSearchParams(); - } - - void setupAdvancedSearchParams() { - advancedSearchViews.addAll({1: LocaleKeys.openNot.tr(), 2: LocaleKeys.fyi.tr(), 3: LocaleKeys.toDo.tr(), 4: LocaleKeys.all.tr(), 5: LocaleKeys.meNot.tr()}); } void calculateCounter() { @@ -162,7 +139,7 @@ class _WorkListScreenState extends State { } } else { itgRequestTypeIndex = null; - workList = await WorkListApiClient().getWorkList(pageNumber, workListItemTypes[workListItemIndex].key, selectedViewID.toString()); + workList = await WorkListApiClient().getWorkList(pageNumber, workListItemTypes[workListItemIndex].key, pNotificationType.toString()); AppState().setWorkList = workList; } if (showLoading) Utils.hideLoading(context); @@ -223,6 +200,9 @@ class _WorkListScreenState extends State { child: ("${workListItemTypes[index].name} ${workListItemTypes[index].value > 0 ? "(${workListItemTypes[index].value})" : ""}") .toText12(color: workListItemIndex == index ? MyColors.white : MyColors.black), ).onPress(() { + if (pNotificationType != 1) { + pNotificationType = 1; + } if (workListItemIndex != index && !workListItemTypes[index].disable) { workListItemIndex = index; if (workListItemTypes[index].value == 0) { @@ -249,7 +229,7 @@ class _WorkListScreenState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ workListItemTypes[workListItemIndex].fullName.toSectionHeading().paddingOnly(left: 21, right: 21), - LocaleKeys.advancedSearch.tr().toText14(isUnderLine: true).onPress(() { + LocaleKeys.advancedSearch.tr().toText14(isUnderLine: true, color: MyColors.textMixColor).onPress(() { openBottomSheet(context); }).paddingOnly(left: 21, right: 21) ], @@ -407,141 +387,32 @@ class _WorkListScreenState extends State { void openBottomSheet(BuildContext context) { showMyBottomSheet( context, - child: Padding( - padding: const EdgeInsets.all(21.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - LocaleKeys.advancedSearch.tr().toText18(), - IconButton( - icon: const Icon(Icons.close, color: MyColors.darkIconColor), - onPressed: () => Navigator.pop(context), - ), - ], - ), - 12.height, - PopupMenuButton( - child: DynamicTextFieldWidget( - LocaleKeys.view.tr(), - selectedViewName != null ? selectedViewName! : LocaleKeys.view.tr(), - isEnable: false, - isPopup: true, - isInputTypeNum: true, - isReadOnly: false, - ), - itemBuilder: (_) => >[ - PopupMenuItem(value: 1, child: Text(LocaleKeys.openNot.tr())), - PopupMenuItem(value: 2, child: Text(LocaleKeys.fyi.tr())), - PopupMenuItem(value: 3, child: Text(LocaleKeys.toDo.tr())), - PopupMenuItem(value: 4, child: Text(LocaleKeys.all.tr())), - PopupMenuItem(value: 5, child: Text(LocaleKeys.meNot.tr())), - ], - onSelected: (int popupIndex) { - selectedViewID = popupIndex; - selectedViewName = getSelectedViewName(popupIndex); - setState(() {}); - }, - ), - 12.height, - PopupMenuButton( - child: DynamicTextFieldWidget( - LocaleKeys.searchBy.tr(), - selectedSearchByName != null ? selectedSearchByName! : LocaleKeys.searchBy.tr(), - isEnable: false, - isPopup: true, - isInputTypeNum: true, - isReadOnly: false, - ), - itemBuilder: (_) => >[ - PopupMenuItem(value: 1, child: Text(LocaleKeys.fromUserName.tr())), - PopupMenuItem(value: 2, child: Text(LocaleKeys.subject.tr())), - PopupMenuItem(value: 3, child: Text(LocaleKeys.sentDate.tr())), - PopupMenuItem(value: 4, child: Text(LocaleKeys.itemTypeDisplayName.tr())), - PopupMenuItem(value: 5, child: Text(LocaleKeys.none.tr())), - ], - onSelected: (int popupIndex) { - selectedSearchByID = popupIndex; - selectedSearchByName = getSelectedSearchByName(popupIndex); - setState(() {}); - }, - ), - 12.height, - if (selectedSearchByID == 1 || selectedSearchByID == 2 || selectedSearchByID == 4) - DynamicTextFieldWidget( - LocaleKeys.searchBy.tr(), - LocaleKeys.searchBy.tr(), - isEnable: true, - isPopup: false, - lines: 1, - isInputTypeNum: false, - isReadOnly: false, - onChange: (String value) { - debugPrint(value); - searchByInput = value; - }, - ), - if (selectedSearchByID == 3) - DynamicTextFieldWidget( - LocaleKeys.searchBy.tr(), - LocaleKeys.sentDate.tr(), - suffixIconData: Icons.calendar_today, - isEnable: false, - onTap: () async { - selectedDate = await _selectDate(context, DateTime.now()); - searchByDate = selectedDate.day.toString() + "-" + getMonth(selectedDate.month) + "-" + selectedDate.year.toString(); - setState(() {}); - }, - ), - 12.height, - PopupMenuButton( - child: DynamicTextFieldWidget( - LocaleKeys.itemType.tr(), - selectedItemTypeName != null ? selectedItemTypeName! : LocaleKeys.itemType.tr(), - isEnable: false, - isPopup: true, - isInputTypeNum: true, - isReadOnly: false, - ), - itemBuilder: (_) => >[ - const PopupMenuItem(value: "HRSSA", child: Text("HR")), - const PopupMenuItem(value: "POAPPRV", child: Text("PO")), - const PopupMenuItem(value: "REQAPPRV", child: Text("PR")), - const PopupMenuItem(value: "INVMOA", child: Text("MR")), - const PopupMenuItem(value: "INVITEM", child: Text("IC")), - const PopupMenuItem(value: "STAMP", child: Text("STAMP")), - ], - onSelected: (String popupIndex) { - selectedItemTypeID = popupIndex; - selectedItemTypeName = getSelectedItemType(popupIndex); - setState(() {}); - }, - ), - 20.height, - DefaultButton(LocaleKeys.search.tr(), () async { - Navigator.pop(context); - itgRequestTypeIndex = null; - int index = -1; - for (int i = 0; i < workListItemTypes.length; i++) { - if (workListItemTypes[i].key == selectedItemTypeID) { - index = i; - break; - } - } - Utils.showLoading(context); - workList = await WorkListApiClient().getWorkList(pageNumber, selectedItemTypeID, selectedViewID.toString(), - pSearchUser: searchByInput, pSearchSubject: searchByInput, pSentDate: searchByDate, pSearchItemType: searchByInput); - workListItemIndex = index; - AppState().setWorkList = workList; - _animateToIndex(index, 50.0); - Utils.hideLoading(context); - setState(() {}); - }) - ], - ), - ), + child: WorkListAdvanceSearch((selectedViewID, selectedItemTypeID, searchByInput, searchByDate) async { + itgRequestTypeIndex = null; + pNotificationType = selectedViewID; + int index = -1; + for (int i = 0; i < workListItemTypes.length; i++) { + if (workListItemTypes[i].key == selectedItemTypeID) { + index = i; + break; + } + } + Utils.showLoading(context); + workList = await WorkListApiClient().getWorkList( + pageNumber, + selectedItemTypeID, + selectedViewID.toString(), + pSearchUser: searchByInput, + pSearchSubject: searchByInput, + pSentDate: searchByDate, + pSearchItemType: searchByInput, + ); + workListItemIndex = index; + AppState().setWorkList = workList; + Utils.hideLoading(context); + _animateToIndex(index, 50.0); + setState(() {}); + }), ); } @@ -631,133 +502,4 @@ class _WorkListScreenState extends State { curve: Curves.fastOutSlowIn, ); } - - String getSelectedViewName(int index) { - String returnVal = ""; - switch (index) { - case 1: - returnVal = LocaleKeys.openNot.tr(); - break; - case 2: - returnVal = LocaleKeys.fyi.tr(); - break; - case 3: - returnVal = LocaleKeys.toDo.tr(); - break; - case 4: - returnVal = LocaleKeys.all.tr(); - break; - case 5: - returnVal = LocaleKeys.meNot.tr(); - break; - } - return returnVal; - } - - String getSelectedSearchByName(int index) { - String returnVal = ""; - switch (index) { - case 1: - returnVal = LocaleKeys.fromUserName.tr(); - break; - case 2: - returnVal = LocaleKeys.subject.tr(); - break; - case 3: - returnVal = LocaleKeys.sentDate.tr(); - break; - case 4: - returnVal = LocaleKeys.itemType.tr(); - break; - case 5: - returnVal = LocaleKeys.none.tr(); - break; - } - return returnVal; - } - - String getSelectedItemType(String index) { - String returnVal = ""; - switch (index) { - case "HRSSA": - returnVal = "HR"; - break; - case "POAPPRV": - returnVal = "PO"; - break; - case "REQAPPRV": - returnVal = "PR"; - break; - case "INVMOA": - returnVal = "MR"; - break; - case "INVITEM": - returnVal = "IC"; - break; - case "STAMP": - returnVal = "STAMP"; - break; - } - return returnVal; - } - - 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; - } - - String getMonth(int month) { - switch (month) { - case 1: - return "Jan"; - case 2: - return "Feb"; - case 3: - return "Mar"; - case 4: - return "Apr"; - case 5: - return "May"; - case 6: - return "June"; - case 7: - return "July"; - case 8: - return "Aug"; - case 9: - return "Sep"; - case 10: - return "Oct"; - case 11: - return "Nov"; - case 12: - return "Dec"; - default: - return ""; - } - } } diff --git a/lib/ui/work_list/worklist_detail_screen.dart b/lib/ui/work_list/worklist_detail_screen.dart index 0da21a6..c5d2914 100644 --- a/lib/ui/work_list/worklist_detail_screen.dart +++ b/lib/ui/work_list/worklist_detail_screen.dart @@ -377,33 +377,32 @@ class _WorkListDetailScreenState extends State { void handleFabAction(GetNotificationButtonsList notificationButton) { switch (notificationButton.bUTTONACTION) { case "DELEGATE": - // do something - showMyBottomSheet(context, child: DelegateSheet(title: "Delegate", apiMode: "DELEGATE", notificationID: workListData!.nOTIFICATIONID, actionHistoryList: actionHistoryList)); + showMyBottomSheet(context, child: DelegateSheet(title: LocaleKeys.delegate.tr(), apiMode: notificationButton.bUTTONACTION!, notificationID: workListData!.nOTIFICATIONID, actionHistoryList: actionHistoryList)); + break; case "REQUEST_INFO": // do something else - showMyBottomSheet(context, child: DelegateSheet(title: "Request Info", apiMode: "REQUEST_INFO", notificationID: workListData!.nOTIFICATIONID, actionHistoryList: actionHistoryList)); + showMyBottomSheet(context, child: DelegateSheet(title: LocaleKeys.request_info.tr(), apiMode: "REQUEST_INFO", notificationID: workListData!.nOTIFICATIONID, actionHistoryList: actionHistoryList)); break; case "RFC": // do something else break; + case "APPROVE": + performAction(notificationButton.bUTTONACTION!); + break; case "UPDATE_ACTION": // do something else case "APPROVE_AND_FORWARD": - // do something else showMyBottomSheet(context, child: DelegateSheet(title: "Approve and Forward", apiMode: "APPROVE_AND_FORWARD", notificationID: workListData!.nOTIFICATIONID, actionHistoryList: actionHistoryList)); break; case "FORWARD": - // do something else showMyBottomSheet(context, child: DelegateSheet(title: "Forward", apiMode: "FORWARD", notificationID: workListData!.nOTIFICATIONID, actionHistoryList: actionHistoryList)); break; case "REJECT": - // do something else performNetworkCall(context, email: "", userId: ""); break; case "RETURNED": - // do something else Navigator.pop(context); break; } diff --git a/lib/widgets/bottom_sheets/worklist_advance_search_bottom_sheet.dart b/lib/widgets/bottom_sheets/worklist_advance_search_bottom_sheet.dart new file mode 100644 index 0000000..b669218 --- /dev/null +++ b/lib/widgets/bottom_sheets/worklist_advance_search_bottom_sheet.dart @@ -0,0 +1,242 @@ +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/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/widgets/button/default_button.dart'; +import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; + +class WorkListAdvanceSearch extends StatefulWidget { + Function(int, String, String, String) onSearch; + + WorkListAdvanceSearch(this.onSearch, {Key? key}) : super(key: key); + + @override + _WorkListAdvanceSearchState createState() { + return _WorkListAdvanceSearchState(); + } +} + +class _WorkListAdvanceSearchState extends State { + final Map advancedSearchViews = {}; + final Map advancedSearchSearchBy = {}; + final Map advancedSearchItemType = {}; + + int selectedViewID = 1; + String? selectedViewName; + + int selectedSearchByID = 0; + String? selectedSearchByName; + + String selectedItemTypeID = ""; + String? selectedItemTypeName; + + String searchByInput = ""; + String searchByDate = ""; + + DateTime selectedDate = DateTime.now(); + + @override + void initState() { + super.initState(); + advancedSearchViews.addAll({1: LocaleKeys.openNot.tr(), 2: LocaleKeys.fyi.tr(), 3: LocaleKeys.toDo.tr(), 4: LocaleKeys.all.tr(), 5: LocaleKeys.meNot.tr()}); + } + + @override + void dispose() { + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + LocaleKeys.advancedSearch.tr().toText18(), + IconButton( + icon: const Icon(Icons.close, color: MyColors.darkIconColor), + onPressed: () => Navigator.pop(context), + ), + ], + ), + 12.height, + PopupMenuButton( + child: DynamicTextFieldWidget( + LocaleKeys.view.tr(), + selectedViewName != null ? selectedViewName! : LocaleKeys.selectTypeT.tr(), + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, + ), + itemBuilder: (_) => >[ + PopupMenuItem(value: 1, child: Text(LocaleKeys.openNot.tr())), + PopupMenuItem(value: 2, child: Text(LocaleKeys.fyi.tr())), + PopupMenuItem(value: 3, child: Text(LocaleKeys.toDo.tr())), + PopupMenuItem(value: 4, child: Text(LocaleKeys.all.tr())), + PopupMenuItem(value: 5, child: Text(LocaleKeys.meNot.tr())), + ], + onSelected: (int popupIndex) { + selectedViewID = popupIndex; + selectedViewName = getSelectedViewName(popupIndex); + setState(() {}); + }, + ), + 12.height, + PopupMenuButton( + child: DynamicTextFieldWidget( + LocaleKeys.searchBy.tr(), + selectedSearchByName != null ? selectedSearchByName! : LocaleKeys.selectTypeT.tr(), + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, + ), + itemBuilder: (_) => >[ + PopupMenuItem(value: 1, child: Text(LocaleKeys.fromUserName.tr())), + PopupMenuItem(value: 2, child: Text(LocaleKeys.subject.tr())), + PopupMenuItem(value: 3, child: Text(LocaleKeys.sentDate.tr())), + PopupMenuItem(value: 4, child: Text(LocaleKeys.itemTypeDisplayName.tr())), + PopupMenuItem(value: 5, child: Text(LocaleKeys.none.tr())), + ], + onSelected: (int popupIndex) { + selectedSearchByID = popupIndex; + selectedSearchByName = getSelectedSearchByName(popupIndex); + setState(() {}); + }, + ), + 12.height, + if (selectedSearchByID == 1 || selectedSearchByID == 2 || selectedSearchByID == 4) + DynamicTextFieldWidget( + LocaleKeys.searchBy.tr(), + LocaleKeys.searchBy.tr(), + isEnable: true, + isPopup: false, + lines: 1, + isInputTypeNum: false, + isReadOnly: false, + onChange: (String value) { + searchByInput = value; + }, + ), + if (selectedSearchByID == 3) + DynamicTextFieldWidget( + LocaleKeys.searchBy.tr(), + searchByDate.isEmpty ? LocaleKeys.sentDate.tr() : searchByDate, + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + selectedDate = await Utils.selectDate(context, DateTime.now()); + searchByDate = selectedDate.day.toString() + "-" + DateUtil.getMonth(selectedDate.month) + "-" + selectedDate.year.toString(); + setState(() {}); + }, + ), + 12.height, + PopupMenuButton( + child: DynamicTextFieldWidget( + LocaleKeys.itemType.tr(), + selectedItemTypeName != null ? selectedItemTypeName! : LocaleKeys.selectTypeT.tr(), + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, + ), + itemBuilder: (_) => >[ + const PopupMenuItem(value: "HRSSA", child: Text("HR")), + const PopupMenuItem(value: "POAPPRV", child: Text("PO")), + const PopupMenuItem(value: "REQAPPRV", child: Text("PR")), + const PopupMenuItem(value: "INVMOA", child: Text("MR")), + const PopupMenuItem(value: "INVITEM", child: Text("IC")), + const PopupMenuItem(value: "STAMP", child: Text("STAMP")), + ], + onSelected: (String popupIndex) { + selectedItemTypeID = popupIndex; + selectedItemTypeName = getSelectedItemType(popupIndex); + setState(() {}); + }, + ), + 20.height, + DefaultButton(LocaleKeys.search.tr(), () async { + Navigator.pop(context); + widget.onSearch(selectedViewID, selectedItemTypeID, searchByInput, searchByDate); + }) + ], + ).paddingOnly(left: 21, right: 21, bottom: 21); + } + + String getSelectedViewName(int index) { + String returnVal = ""; + switch (index) { + case 1: + returnVal = LocaleKeys.openNot.tr(); + break; + case 2: + returnVal = LocaleKeys.fyi.tr(); + break; + case 3: + returnVal = LocaleKeys.toDo.tr(); + break; + case 4: + returnVal = LocaleKeys.all.tr(); + break; + case 5: + returnVal = LocaleKeys.meNot.tr(); + break; + } + return returnVal; + } + + String getSelectedSearchByName(int index) { + String returnVal = ""; + switch (index) { + case 1: + returnVal = LocaleKeys.fromUserName.tr(); + break; + case 2: + returnVal = LocaleKeys.subject.tr(); + break; + case 3: + returnVal = LocaleKeys.sentDate.tr(); + break; + case 4: + returnVal = LocaleKeys.itemType.tr(); + break; + case 5: + returnVal = LocaleKeys.none.tr(); + break; + } + return returnVal; + } + + String getSelectedItemType(String index) { + String returnVal = ""; + switch (index) { + case "HRSSA": + returnVal = "HR"; + break; + case "POAPPRV": + returnVal = "PO"; + break; + case "REQAPPRV": + returnVal = "PR"; + break; + case "INVMOA": + returnVal = "MR"; + break; + case "INVITEM": + returnVal = "IC"; + break; + case "STAMP": + returnVal = "STAMP"; + break; + } + return returnVal; + } +} From d24103b872c0f14cd97f2101c6cb3408f07a3efc Mon Sep 17 00:00:00 2001 From: "Aamir.Muhammad" Date: Tue, 18 Oct 2022 16:45:18 +0300 Subject: [PATCH 07/21] Chat Login Api Implementation --- lib/api/chat/chat_provider_model.dart | 88 +++++++++++++++---- lib/app_state/app_state.dart | 7 ++ .../chat/get_user_login_token_model.dart | 78 ++++++++++++++++ lib/ui/chat/chat_detailed_screen.dart | 6 +- lib/ui/chat/chat_home.dart | 8 +- 5 files changed, 163 insertions(+), 24 deletions(-) create mode 100644 lib/models/chat/get_user_login_token_model.dart diff --git a/lib/api/chat/chat_provider_model.dart b/lib/api/chat/chat_provider_model.dart index d4b49f8..465c5af 100644 --- a/lib/api/chat/chat_provider_model.dart +++ b/lib/api/chat/chat_provider_model.dart @@ -6,10 +6,13 @@ import 'package:fluttertoast/fluttertoast.dart'; import 'package:http/http.dart'; import 'package:logging/logging.dart'; 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/classes/utils.dart'; import 'package:mohem_flutter_app/models/chat/get_search_user_chat_model.dart'; import 'package:mohem_flutter_app/models/chat/get_single_user_chat_list_Model.dart'; +import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart' as login; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:signalr_netcore/hub_connection.dart'; import 'package:signalr_netcore/signalr_client.dart'; import 'package:logger/logger.dart' as L; @@ -21,17 +24,23 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { L.Logger logger = L.Logger(); TextEditingController message = TextEditingController(); ScrollController scrollController = ScrollController(); - static String token = - "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiI0MjA2MiIsImVtYWlsIjoiYWFtaXIubXVoYW1tYWRAY2xvdWRzb2x1dGlvbnMuY29tLnNhIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy91c2VyZGF0YSI6ImFhbWlyLm11aGFtbWFkIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvbW9iaWxlcGhvbmUiOiI5NjY1MzA4OTYwMTgiLCJuYmYiOjE2NjU5MjA2NDEsImV4cCI6MTY2NjAwNzA0MSwiaWF0IjoxNjY1OTIwNjQxfQ.70tXWdpXtQ20PNBO3WF9ScWNWSyECpFfrW7_iuOmNfWmA63PCZzlTO0E6I3q3K9Kg2CWvOT9-dSDLjlRuXuC2w"; - bool isLoading = true; + Future getUserAutoLoginToken() async { + String userName = AppState().memberInformationList!.eMPLOYEEEMAILADDRESS!.split("@").first.toString(); + Response response = + await ApiClient().postJsonForResponse("${ApiConsts.chatServerBaseApiUrl}user/desktopuserlogin", {"userName": userName, "password": "FxIu26rWIKoF8n6mpbOmAjDLphzFGmpG", "loginType": 2}); + login.UserAutoLoginModel userLoginResponse = login.userAutoLoginModelFromJson(response.body); + AppState().setchatUserDetails = userLoginResponse; + await buildHubConnection(); + } + void getChatMemberFromSearch(String sName, int cUserId) async { isLoading = true; notifyListeners(); Response response = await ApiClient().getJsonForResponse( "${ApiConsts.chatSearchMember}$sName/$cUserId", - token: token, + token: AppState().chatDetails!.response!.token, ); isLoading = false; notifyListeners(); @@ -40,7 +49,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { void getUserRecentChats() async { Response response = await ApiClient().getJsonForResponse( "${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatRecentUrl}", - token: token, + token: AppState().chatDetails!.response!.token, ); ChatUserModel recentChat = userToList(response.body); pChatHistory = recentChat.response; @@ -53,11 +62,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { isLoading = true; Response response = await ApiClient().getJsonForResponse( "${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSingleUserHistoryUrl}/$senderUID/$receiverUID/$pagination", - token: token, + token: AppState().chatDetails!.response!.token, ); + logger.d(response.body); userChatHistory = getSingleUserChatintoModel(response.body); isLoading = false; - logger.d(jsonEncode(userChatHistory)); notifyListeners(); } @@ -65,10 +74,10 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { ChatUserModel userToList(String str) => ChatUserModel.fromJson(json.decode(str)); - void buildHubConnection() async { + Future buildHubConnection() async { HttpConnectionOptions httpOp = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true); hubConnection = await HubConnectionBuilder() - .withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=42062&source=Web&access_token=$token", options: httpOp) + .withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${AppState().chatDetails!.response!.id}&source=Web&access_token=${AppState().chatDetails!.response!.token}", options: httpOp) .withAutomaticReconnect(retryDelays: [2000, 5000, 10000, 20000]) .configureLogging(Logger("Logs Enabled")) .build(); @@ -92,20 +101,64 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { await hubConnection.start(); hubConnection.on("OnUpdateUserStatusAsync", changeStatus); hubConnection.on("OnDeliveredChatUserAsync", onMsgReceived); - // hubConnection.on("OnUserTypingAsync", onUserTyping); - //hubConnection.on("OnUserTypingAsync", changeTypingStatus); + + // hubConnection.on("OnUserTypingAsync", onUserTyping); + // hubConnection.on("OnUserCountAsync", userCountAsync); + // hubConnection.on("OnUpdateUserChatHistoryWindowsAsync", updateChatHistoryWindow); + // hubConnection.on("OnGetUserChatHistoryNotDeliveredAsync", chatNotDelivered); } else { hubConnection.on("OnUpdateUserStatusAsync", changeStatus); hubConnection.on("OnDeliveredChatUserAsync", onMsgReceived); - // hubConnection.on("OnUserTypingAsync", onUserTyping); - //hubConnection.on("OnUserTypingAsync", changeTypingStatus); + + // hubConnection.on("OnUserTypingAsync", onUserTyping); + // hubConnection.on("OnUserCountAsync", userCountAsync); + // hubConnection.on("OnUpdateUserChatHistoryWindowsAsync", updateChatHistoryWindow); + // hubConnection.on("OnGetUserChatHistoryNotDeliveredAsync", chatNotDelivered); } isLoading = false; notifyListeners(); } + void userCountAsync(List? args) { + List items = args!.toList(); + print("---------------------------------User Count Async -------------------------------------"); + logger.d(items); + // for (var user in searchedChats!) { + // if (user.id == items.first["id"]) { + // user.userStatus = items.first["userStatus"]; + // } + // } + // notifyListeners(); + } + + void updateChatHistoryWindow(List? args) { + List items = args!.toList(); + print("---------------------------------Update Chat History Windows Async -------------------------------------"); + logger.d(items); + // for (var user in searchedChats!) { + // if (user.id == items.first["id"]) { + // user.userStatus = items.first["userStatus"]; + // } + // } + // notifyListeners(); + } + + void chatNotDelivered(List? args) { + List items = args!.toList(); + print("--------------------------------- Chat Not Delivered Windows Async -------------------------------------"); + logger.d(items); + // for (var user in searchedChats!) { + // if (user.id == items.first["id"]) { + // user.userStatus = items.first["userStatus"]; + // } + // } + // notifyListeners(); + } + void changeStatus(List? args) { + // print("================= Status Online // Offline ===================="); List items = args!.toList(); + logger.d(items); for (var user in searchedChats!) { if (user.id == items.first["id"]) { user.userStatus = items.first["userStatus"]; @@ -163,7 +216,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { return; } String chatData = - '{"contant":"$chatMessage","contantNo":"8a129295-36d7-7185-5d34-cc4eec7bcba4","chatEventId":1,"fileTypeId":null,"currentUserId":42062,"chatSource":1,"userChatHistoryLineRequestList":[{"isSeen":false,"isDelivered":false,"targetUserId":$targetUserId,"targetUserStatus":1}],"conversationId":"715f8b13-96ee-cd36-cb07-5a982a219982"}'; + '{"contant":"$chatMessage","contantNo":"8a129295-36d7-7185-5d34-cc4eec7bcba4","chatEventId":1,"fileTypeId":null,"currentUserId":${AppState().chatDetails!.response!.id},"chatSource":1,"userChatHistoryLineRequestList":[{"isSeen":false,"isDelivered":false,"targetUserId":$targetUserId,"targetUserStatus":1}],"conversationId":"715f8b13-96ee-cd36-cb07-5a982a219982"}'; await hubConnection.invoke("AddChatUserAsync", args: [json.decode(chatData)]); userChatHistory.add( SingleUserChatModel( @@ -173,8 +226,8 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { contantNo: "8a129295-36d7-7185-5d34-cc4eec7bcba4", conversationId: "715f8b13-96ee-cd36-cb07-5a982a219982", createdDate: DateTime.now(), - currentUserId: 42062, - currentUserName: "aamir.muhammad", + currentUserId: AppState().chatDetails!.response!.id, + currentUserName: AppState().chatDetails!.response!.userName, targetUserId: targetUserId, targetUserName: targetUserName, ), @@ -190,9 +243,6 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { curve: Curves.easeOut, duration: const Duration(milliseconds: 300), ); - - // scrollController.animateTo(double.parse(userChatHistory.length.toString()), duration: Duration(milliseconds: 500), curve: Curves.fastOutSlowIn); - notifyListeners(); } diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index d7f6a9d..ceb4881 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:easy_localization/easy_localization.dart'; +import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart'; import 'package:mohem_flutter_app/models/itg_forms_models/request_detail_model.dart'; import 'package:mohem_flutter_app/models/member_information_list_model.dart'; import 'package:mohem_flutter_app/models/member_login_list_model.dart'; @@ -116,4 +117,10 @@ class AppState { int? itgWorkListIndex; set setItgWorkListIndex(int? _itgWorkListIndex) => itgWorkListIndex = _itgWorkListIndex; + + UserAutoLoginModel? chatDetails; + + set setchatUserDetails(UserAutoLoginModel details) => chatDetails = details; + + UserAutoLoginModel? get getchatUserDetails => chatDetails; } diff --git a/lib/models/chat/get_user_login_token_model.dart b/lib/models/chat/get_user_login_token_model.dart new file mode 100644 index 0000000..8afd3a9 --- /dev/null +++ b/lib/models/chat/get_user_login_token_model.dart @@ -0,0 +1,78 @@ + +import 'dart:convert'; + +UserAutoLoginModel userAutoLoginModelFromJson(String str) => UserAutoLoginModel.fromJson(json.decode(str)); + +String userAutoLoginModelToJson(UserAutoLoginModel data) => json.encode(data.toJson()); + +class UserAutoLoginModel { + UserAutoLoginModel({ + this.response, + this.errorResponses, + }); + + Response? response; + dynamic? errorResponses; + + factory UserAutoLoginModel.fromJson(Map json) => UserAutoLoginModel( + response: json["response"] == null ? null : Response.fromJson(json["response"]), + errorResponses: json["errorResponses"], + ); + + Map toJson() => { + "response": response == null ? null : response!.toJson(), + "errorResponses": errorResponses, + }; +} + +class Response { + Response({ + this.id, + this.userName, + this.email, + this.phone, + this.title, + this.token, + this.isDomainUser, + this.isActiveCode, + this.encryptedUserId, + this.encryptedUserName, + }); + + int? id; + String? userName; + String? email; + String? phone; + String? title; + String? token; + bool? isDomainUser; + bool? isActiveCode; + String? encryptedUserId; + String? encryptedUserName; + + factory Response.fromJson(Map json) => Response( + id: json["id"] == null ? null : json["id"], + userName: json["userName"] == null ? null : json["userName"], + email: json["email"] == null ? null : json["email"], + phone: json["phone"] == null ? null : json["phone"], + title: json["title"] == null ? null : json["title"], + token: json["token"] == null ? null : json["token"], + isDomainUser: json["isDomainUser"] == null ? null : json["isDomainUser"], + isActiveCode: json["isActiveCode"] == null ? null : json["isActiveCode"], + encryptedUserId: json["encryptedUserId"] == null ? null : json["encryptedUserId"], + encryptedUserName: json["encryptedUserName"] == null ? null : json["encryptedUserName"], + ); + + Map toJson() => { + "id": id == null ? null : id, + "userName": userName == null ? null : userName, + "email": email == null ? null : email, + "phone": phone == null ? null : phone, + "title": title == null ? null : title, + "token": token == null ? null : token, + "isDomainUser": isDomainUser == null ? null : isDomainUser, + "isActiveCode": isActiveCode == null ? null : isActiveCode, + "encryptedUserId": encryptedUserId == null ? null : encryptedUserId, + "encryptedUserName": encryptedUserName == null ? null : encryptedUserName, + }; +} diff --git a/lib/ui/chat/chat_detailed_screen.dart b/lib/ui/chat/chat_detailed_screen.dart index 17ba325..b647a38 100644 --- a/lib/ui/chat/chat_detailed_screen.dart +++ b/lib/ui/chat/chat_detailed_screen.dart @@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:mohem_flutter_app/api/chat/chat_provider_model.dart'; +import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/ui/chat/chat_bubble.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; @@ -20,7 +21,7 @@ class ChatDetailScreen extends StatelessWidget { Widget build(BuildContext context) { userDetails = ModalRoute.of(context)!.settings.arguments; data = Provider.of(context, listen: false); - data.getSingleUserChatHistory(senderUID: "42062", receiverUID: userDetails["targetUser"].id, pagination: "0"); + data.getSingleUserChatHistory(senderUID: AppState().chatDetails!.response!.id.toString(), receiverUID: userDetails["targetUser"].id, pagination: "0"); Timer(const Duration(seconds: 1), () => data.scrollDown()); return Scaffold( backgroundColor: const Color(0xFFF8F8F8), @@ -70,7 +71,8 @@ class ChatDetailScreen extends StatelessWidget { width: 35, ), onPressed: () { - m.sendChatMessage(m.message.text, userDetails["targetUser"].id, userDetails["targetUser"].userName); + // m.logger.d(userDetails); + m.sendChatMessage(m.message.text, userDetails["targetUser"].id, userDetails["targetUser"].userName); }, ), ), diff --git a/lib/ui/chat/chat_home.dart b/lib/ui/chat/chat_home.dart index 236a73f..18c11bf 100644 --- a/lib/ui/chat/chat_home.dart +++ b/lib/ui/chat/chat_home.dart @@ -5,6 +5,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:mohem_flutter_app/api/chat/chat_provider_model.dart'; +import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; @@ -30,8 +31,9 @@ class _ChatHomeScreenState extends State { void initState() { super.initState(); data = Provider.of(context, listen: false); - data.buildHubConnection(); - data.getUserRecentChats(); + data.getUserAutoLoginToken().whenComplete(() { + data.getUserRecentChats(); + }); } @override @@ -115,7 +117,7 @@ class _ChatHomeScreenState extends State { Navigator.pushNamed( context, AppRoutes.chatDetailed, - arguments: {"currentUser": "42062", "targetUser": m.searchedChats![index]}, + arguments: {"targetUser": m.searchedChats![index]}, ); }, ); From b5442734163dd74579efaba2d0383f848d7d5828 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 18 Oct 2022 16:47:08 +0300 Subject: [PATCH 08/21] improvements --- lib/ui/work_list/itg_detail_screen.dart | 3 ++- lib/ui/work_list/sheets/delegate_sheet.dart | 4 +++- lib/ui/work_list/worklist_detail_screen.dart | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/ui/work_list/itg_detail_screen.dart b/lib/ui/work_list/itg_detail_screen.dart index b1deae8..491672f 100644 --- a/lib/ui/work_list/itg_detail_screen.dart +++ b/lib/ui/work_list/itg_detail_screen.dart @@ -259,7 +259,8 @@ class _ItgDetailScreenState extends State { void handleFabAction(AllowedActions action) { switch (action.action) { case "DELEGATE": - // do something + // showMyBottomSheet(context, child: DelegateSheet(title: LocaleKeys.delegate.tr(), apiMode: action.action!, notificationID: workListData!.nOTIFICATIONID, actionHistoryList: actionHistoryList)); + break; case "REQUEST_INFO": // do something else diff --git a/lib/ui/work_list/sheets/delegate_sheet.dart b/lib/ui/work_list/sheets/delegate_sheet.dart index 1dbc30c..ec7d80a 100644 --- a/lib/ui/work_list/sheets/delegate_sheet.dart +++ b/lib/ui/work_list/sheets/delegate_sheet.dart @@ -12,6 +12,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/generic_response_model.dart'; import 'package:mohem_flutter_app/models/get_action_history_list_model.dart'; +import 'package:mohem_flutter_app/models/itg_forms_models/wf_history_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/ui/work_list/sheets/search_options_sheet.dart'; @@ -25,8 +26,9 @@ class DelegateSheet extends StatefulWidget { int? notificationID; String title, apiMode; List? actionHistoryList; + List? wFHistory; - DelegateSheet({required this.title, required this.apiMode, this.notificationID, this.actionHistoryList}); + DelegateSheet({required this.title, required this.apiMode, this.notificationID, this.actionHistoryList,this.wFHistory}); @override State createState() => _DelegateSheetState(); diff --git a/lib/ui/work_list/worklist_detail_screen.dart b/lib/ui/work_list/worklist_detail_screen.dart index c5d2914..241b2e8 100644 --- a/lib/ui/work_list/worklist_detail_screen.dart +++ b/lib/ui/work_list/worklist_detail_screen.dart @@ -377,12 +377,14 @@ class _WorkListDetailScreenState extends State { void handleFabAction(GetNotificationButtonsList notificationButton) { switch (notificationButton.bUTTONACTION) { case "DELEGATE": - showMyBottomSheet(context, child: DelegateSheet(title: LocaleKeys.delegate.tr(), apiMode: notificationButton.bUTTONACTION!, notificationID: workListData!.nOTIFICATIONID, actionHistoryList: actionHistoryList)); + showMyBottomSheet(context, + child: DelegateSheet(title: LocaleKeys.delegate.tr(), apiMode: notificationButton.bUTTONACTION!, notificationID: workListData!.nOTIFICATIONID, actionHistoryList: actionHistoryList)); break; case "REQUEST_INFO": // do something else - showMyBottomSheet(context, child: DelegateSheet(title: LocaleKeys.request_info.tr(), apiMode: "REQUEST_INFO", notificationID: workListData!.nOTIFICATIONID, actionHistoryList: actionHistoryList)); + showMyBottomSheet(context, + child: DelegateSheet(title: LocaleKeys.request_info.tr(), apiMode: "REQUEST_INFO", notificationID: workListData!.nOTIFICATIONID, actionHistoryList: actionHistoryList)); break; case "RFC": // do something else From da7929bf3ebc6843b9e98b732e71a2cdf1d91629 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 18 Oct 2022 16:51:39 +0300 Subject: [PATCH 09/21] updates --- lib/ui/landing/dashboard_screen.dart | 8 +++----- lib/ui/landing/widget/app_drawer.dart | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 4ecb644..7141ecb 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -80,7 +80,7 @@ class _DashboardScreenState extends State { mainAxisSize: MainAxisSize.min, children: [ Image.memory( - Utils.getPostBytes( + Utils.dataFromBase64String( AppState().memberInformationList!.eMPLOYEEIMAGE ?? "", ), errorBuilder: (BuildContext context, error, stackTrace) { @@ -419,9 +419,7 @@ class _DashboardScreenState extends State { BottomNavigationBarItem( icon: SvgPicture.asset( "assets/icons/chat/chat.svg", - color: currentIndex == 4 - ? MyColors.grey3AColor - : MyColors.grey98Color, + color: currentIndex == 4 ? MyColors.grey3AColor : MyColors.grey98Color, ).paddingAll(4), label: LocaleKeys.chat.tr(), ), @@ -441,7 +439,7 @@ class _DashboardScreenState extends State { Navigator.pushNamed(context, AppRoutes.workList); } else if (index == 3) { Navigator.pushNamed(context, AppRoutes.itemsForSale); - }else if (index == 4) { + } else if (index == 4) { Navigator.pushNamed(context, AppRoutes.chat); } }, diff --git a/lib/ui/landing/widget/app_drawer.dart b/lib/ui/landing/widget/app_drawer.dart index ea6343b..d828270 100644 --- a/lib/ui/landing/widget/app_drawer.dart +++ b/lib/ui/landing/widget/app_drawer.dart @@ -52,7 +52,7 @@ class _AppDrawerState extends State { ) : CircleAvatar( radius: 52 / 2, - backgroundImage: MemoryImage(Utils.getPostBytes(AppState().memberInformationList!.eMPLOYEEIMAGE)), + backgroundImage: MemoryImage(Utils.dataFromBase64String(AppState().memberInformationList!.eMPLOYEEIMAGE!)), backgroundColor: Colors.black, ), 12.width, From c8d25c997b5f84aeb42a1c053b20a33432e3659d Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 18 Oct 2022 16:52:03 +0300 Subject: [PATCH 10/21] Revert "updates" This reverts commit 981fc9f8d207334488189c9051042d3792452592. --- lib/ui/landing/dashboard_screen.dart | 8 +++++--- lib/ui/landing/widget/app_drawer.dart | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 7141ecb..4ecb644 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -80,7 +80,7 @@ class _DashboardScreenState extends State { mainAxisSize: MainAxisSize.min, children: [ Image.memory( - Utils.dataFromBase64String( + Utils.getPostBytes( AppState().memberInformationList!.eMPLOYEEIMAGE ?? "", ), errorBuilder: (BuildContext context, error, stackTrace) { @@ -419,7 +419,9 @@ class _DashboardScreenState extends State { BottomNavigationBarItem( icon: SvgPicture.asset( "assets/icons/chat/chat.svg", - color: currentIndex == 4 ? MyColors.grey3AColor : MyColors.grey98Color, + color: currentIndex == 4 + ? MyColors.grey3AColor + : MyColors.grey98Color, ).paddingAll(4), label: LocaleKeys.chat.tr(), ), @@ -439,7 +441,7 @@ class _DashboardScreenState extends State { Navigator.pushNamed(context, AppRoutes.workList); } else if (index == 3) { Navigator.pushNamed(context, AppRoutes.itemsForSale); - } else if (index == 4) { + }else if (index == 4) { Navigator.pushNamed(context, AppRoutes.chat); } }, diff --git a/lib/ui/landing/widget/app_drawer.dart b/lib/ui/landing/widget/app_drawer.dart index d828270..ea6343b 100644 --- a/lib/ui/landing/widget/app_drawer.dart +++ b/lib/ui/landing/widget/app_drawer.dart @@ -52,7 +52,7 @@ class _AppDrawerState extends State { ) : CircleAvatar( radius: 52 / 2, - backgroundImage: MemoryImage(Utils.dataFromBase64String(AppState().memberInformationList!.eMPLOYEEIMAGE!)), + backgroundImage: MemoryImage(Utils.getPostBytes(AppState().memberInformationList!.eMPLOYEEIMAGE)), backgroundColor: Colors.black, ), 12.width, From 8f9fb5eb1d0193fdfbbb41d95a2ff07d48722ca3 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 18 Oct 2022 16:53:48 +0300 Subject: [PATCH 11/21] image fixes --- lib/ui/landing/dashboard_screen.dart | 2 +- lib/ui/landing/widget/app_drawer.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 4ecb644..cf14b3a 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -80,7 +80,7 @@ class _DashboardScreenState extends State { mainAxisSize: MainAxisSize.min, children: [ Image.memory( - Utils.getPostBytes( + Utils.dataFromBase64String( AppState().memberInformationList!.eMPLOYEEIMAGE ?? "", ), errorBuilder: (BuildContext context, error, stackTrace) { diff --git a/lib/ui/landing/widget/app_drawer.dart b/lib/ui/landing/widget/app_drawer.dart index ea6343b..d828270 100644 --- a/lib/ui/landing/widget/app_drawer.dart +++ b/lib/ui/landing/widget/app_drawer.dart @@ -52,7 +52,7 @@ class _AppDrawerState extends State { ) : CircleAvatar( radius: 52 / 2, - backgroundImage: MemoryImage(Utils.getPostBytes(AppState().memberInformationList!.eMPLOYEEIMAGE)), + backgroundImage: MemoryImage(Utils.dataFromBase64String(AppState().memberInformationList!.eMPLOYEEIMAGE!)), backgroundColor: Colors.black, ), 12.width, From d4b31d4338c520cf89807592ac72a0aa59f7e89f Mon Sep 17 00:00:00 2001 From: "Aamir.Muhammad" Date: Wed, 19 Oct 2022 09:54:44 +0300 Subject: [PATCH 12/21] Chat Login Api Implementation --- lib/api/chat/chat_provider_model.dart | 28 ++- .../attendance/add_vacation_rule_screen.dart | 1 + lib/ui/chat/chat_home.dart | 1 + .../add_leave_balance_screen.dart | 1 + .../search_employee_bottom_sheet.dart | 206 ++++++++++++------ 5 files changed, 165 insertions(+), 72 deletions(-) diff --git a/lib/api/chat/chat_provider_model.dart b/lib/api/chat/chat_provider_model.dart index 465c5af..fe95696 100644 --- a/lib/api/chat/chat_provider_model.dart +++ b/lib/api/chat/chat_provider_model.dart @@ -35,17 +35,19 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { await buildHubConnection(); } - void getChatMemberFromSearch(String sName, int cUserId) async { - isLoading = true; - notifyListeners(); + Future?> getChatMemberFromSearch(String sName, int cUserId) async { Response response = await ApiClient().getJsonForResponse( - "${ApiConsts.chatSearchMember}$sName/$cUserId", + "${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSearchMember}$sName/$cUserId", token: AppState().chatDetails!.response!.token, ); + return searchUserJsonModel(response.body); + logger.d(response.body); isLoading = false; notifyListeners(); } + List searchUserJsonModel(String str) => List.from(json.decode(str).map((x) => ChatUser.fromJson(x))); + void getUserRecentChats() async { Response response = await ApiClient().getJsonForResponse( "${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatRecentUrl}", @@ -64,8 +66,14 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { "${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSingleUserHistoryUrl}/$senderUID/$receiverUID/$pagination", token: AppState().chatDetails!.response!.token, ); - logger.d(response.body); - userChatHistory = getSingleUserChatintoModel(response.body); + logger.d(response.statusCode); + print(response.body); + if (response.statusCode == 204) { + print(null); + userChatHistory = []; + } else { + userChatHistory = getSingleUserChatintoModel(response.body); + } isLoading = false; notifyListeners(); } @@ -79,7 +87,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { hubConnection = await HubConnectionBuilder() .withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${AppState().chatDetails!.response!.id}&source=Web&access_token=${AppState().chatDetails!.response!.token}", options: httpOp) .withAutomaticReconnect(retryDelays: [2000, 5000, 10000, 20000]) - .configureLogging(Logger("Logs Enabled")) + .configureLogging( + Logger("Logs Enabled"), + ) .build(); hubConnection.onclose( ({Exception? error}) { @@ -159,7 +169,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { // print("================= Status Online // Offline ===================="); List items = args!.toList(); logger.d(items); - for (var user in searchedChats!) { + for (ChatUser user in searchedChats!) { if (user.id == items.first["id"]) { user.userStatus = items.first["userStatus"]; } @@ -172,7 +182,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { if (value.isEmpty || value == "") { tmp = pChatHistory; } else { - for (var element in pChatHistory!) { + for (ChatUser element in pChatHistory!) { if (element.userName!.toLowerCase().contains(value.toLowerCase())) { tmp.add(element); } diff --git a/lib/ui/attendance/add_vacation_rule_screen.dart b/lib/ui/attendance/add_vacation_rule_screen.dart index 4846053..aa48696 100644 --- a/lib/ui/attendance/add_vacation_rule_screen.dart +++ b/lib/ui/attendance/add_vacation_rule_screen.dart @@ -433,6 +433,7 @@ class _AddVacationRuleScreenState extends State { child: SearchEmployeeBottomSheet( title: LocaleKeys.searchForEmployee.tr(), apiMode: LocaleKeys.delegate.tr(), + fromChat: false, onSelectEmployee: (_selectedEmployee) { // Navigator.pop(context); selectedReplacementEmployee = _selectedEmployee; diff --git a/lib/ui/chat/chat_home.dart b/lib/ui/chat/chat_home.dart index 18c11bf..ef984a3 100644 --- a/lib/ui/chat/chat_home.dart +++ b/lib/ui/chat/chat_home.dart @@ -163,6 +163,7 @@ class _ChatHomeScreenState extends State { child: SearchEmployeeBottomSheet( title: LocaleKeys.searchForEmployee.tr(), apiMode: LocaleKeys.delegate.tr(), + fromChat: true, onSelectEmployee: (_selectedEmployee) { // Navigator.pop(context); // selectedReplacementEmployee = _selectedEmployee; diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index eb8e493..81cfe0f 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -224,6 +224,7 @@ class _AddLeaveBalanceScreenState extends State { child: SearchEmployeeBottomSheet( title: LocaleKeys.searchForEmployee.tr(), apiMode: LocaleKeys.delegate.tr(), + fromChat: false, onSelectEmployee: (_selectedEmployee) { // Navigator.pop(context); selectedReplacementEmployee = _selectedEmployee; diff --git a/lib/widgets/bottom_sheets/search_employee_bottom_sheet.dart b/lib/widgets/bottom_sheets/search_employee_bottom_sheet.dart index e807a7b..14da765 100644 --- a/lib/widgets/bottom_sheets/search_employee_bottom_sheet.dart +++ b/lib/widgets/bottom_sheets/search_employee_bottom_sheet.dart @@ -1,14 +1,21 @@ +import 'dart:convert'; + import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:mohem_flutter_app/api/chat/chat_provider_model.dart'; import 'package:mohem_flutter_app/api/worklist/worklist_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/generated/locale_keys.g.dart'; +import 'package:mohem_flutter_app/models/chat/get_search_user_chat_model.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'; @@ -21,17 +28,19 @@ class SearchEmployeeBottomSheet extends StatefulWidget { String title, apiMode; List? actionHistoryList; Function(ReplacementList) onSelectEmployee; + bool fromChat; - SearchEmployeeBottomSheet( - {required this.title, - required this.apiMode, - this.notificationID, - this.actionHistoryList, - required this.onSelectEmployee}); + SearchEmployeeBottomSheet({ + required this.title, + required this.apiMode, + this.notificationID, + this.actionHistoryList, + required this.onSelectEmployee, + required this.fromChat, + }); @override - State createState() => - _SearchEmployeeBottomSheetState(); + State createState() => _SearchEmployeeBottomSheetState(); } class _SearchEmployeeBottomSheetState extends State { @@ -49,6 +58,9 @@ class _SearchEmployeeBottomSheetState extends State { List? favouriteUserList; List? nonFavouriteUserList; + // Chat Items + List? chatUsersList = []; + int _selectedSearchIndex = 0; void fetchUserByInput({bool isNeedLoading = true}) async { @@ -59,12 +71,30 @@ class _SearchEmployeeBottomSheetState extends State { userId: _selectedSearchIndex == 1 ? searchText : "", email: _selectedSearchIndex == 2 ? searchText : "", ); - favouriteUserList = replacementList - ?.where((element) => element.isFavorite ?? false) - .toList(); - nonFavouriteUserList = replacementList - ?.where((element) => !(element.isFavorite ?? false)) - .toList(); + 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; + } + + void fetchChatUser({bool isNeedLoading = true}) async { + try { + Utils.showLoading(context); + + chatUsersList = await ChatProviderModel().getChatMemberFromSearch(searchText, int.parse(AppState().chatDetails!.response!.id.toString())); + print("================================"); + print(jsonEncode(chatUsersList)); + // + // favouriteUserList = replacementList?.where((element) => element.isFavorite ?? false).toList(); + // nonFavouriteUserList = replacementList?.where((element) => !(element.isFavorite ?? false)).toList(); Utils.hideLoading(context); setState(() {}); } catch (e) { @@ -114,57 +144,113 @@ class _SearchEmployeeBottomSheetState extends State { IconButton( constraints: const BoxConstraints(), onPressed: () async { - await SystemChannels.textInput - .invokeMethod('TextInput.hide'); - fetchUserByInput(); + await SystemChannels.textInput.invokeMethod('TextInput.hide'); + widget.fromChat ? fetchChatUser() : 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, + : 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, + + if(widget.fromChat) + if (chatUsersList != null && widget.fromChat) + chatUsersList!.isEmpty + ? Utils.getNoDataWidget(context) + : ListView( + physics: const BouncingScrollPhysics(), + padding: EdgeInsets.only(top: 0, bottom: 8), + children: [ + ListView.separated( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + + itemBuilder: (cxt, index) { + return ListTile( + leading: Stack( + children: [ + SvgPicture.asset( + "assets/images/user.svg", + height: 48, + width: 48, + ), + Positioned( + right: 5, + bottom: 1, + child: Container( + width: 10, + height: 10, + decoration: BoxDecoration( + color: chatUsersList![index].userStatus == 1 ? MyColors.green2DColor : Colors.red, + borderRadius: const BorderRadius.all( + Radius.circular(10), + ), + ), ), - itemCount: nonFavouriteUserList?.length ?? 0), - ] - ], - ).expanded + ) + ], + ), + title: (chatUsersList![index].userName ?? "").toText14(color: MyColors.darkTextColor), + subtitle: (chatUsersList![index].isTyping == true ? "Something is Typing" : "Last message text").toText11(color: MyColors.normalTextColor), + trailing: ("Today").toText10(color: MyColors.lightTextColor), + minVerticalPadding: 0, + onTap: () { + Navigator.pop(context); + Navigator.pushNamed( + context, + AppRoutes.chatDetailed, + arguments: {"targetUser": chatUsersList![index]}, + ); + }, + ); + }, + separatorBuilder: (cxt, index) => Container( + height: 1, + color: MyColors.borderE3Color, + ), + itemCount: chatUsersList?.length ?? 0), + 12.height, + ], + ).expanded, ], ).paddingOnly(left: 21, right: 21, bottom: 0, top: 21).expanded, - Container( - width: double.infinity, - height: 1, - color: MyColors.lightGreyEFColor), + + Container(width: double.infinity, height: 1, color: MyColors.lightGreyEFColor), DefaultButton( LocaleKeys.cancel.tr(), () { @@ -201,11 +287,7 @@ class _SearchEmployeeBottomSheetState extends State { Expanded( child: (replacement.employeeDisplayName ?? "").toText12(), ), - Icon(Icons.star, - size: 16, - color: replacement.isFavorite! - ? MyColors.yellowFavColor - : MyColors.borderCEColor), + Icon(Icons.star, size: 16, color: replacement.isFavorite! ? MyColors.yellowFavColor : MyColors.borderCEColor), ], ), ), @@ -228,9 +310,7 @@ class _SearchEmployeeBottomSheetState extends State { width: double.infinity, height: double.infinity, decoration: BoxDecoration( - color: value == groupValue - ? MyColors.grey3AColor - : Colors.transparent, + color: value == groupValue ? MyColors.grey3AColor : Colors.transparent, borderRadius: BorderRadius.all(const Radius.circular(100)), ), ), From 05c6cc7f140a270b0b22c7ec848afa8a0370959b Mon Sep 17 00:00:00 2001 From: "Aamir.Muhammad" Date: Wed, 19 Oct 2022 09:56:03 +0300 Subject: [PATCH 13/21] Chat Search User Api Implementation --- lib/api/chat/chat_provider_model.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/api/chat/chat_provider_model.dart b/lib/api/chat/chat_provider_model.dart index fe95696..ea6ea13 100644 --- a/lib/api/chat/chat_provider_model.dart +++ b/lib/api/chat/chat_provider_model.dart @@ -69,16 +69,15 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { logger.d(response.statusCode); print(response.body); if (response.statusCode == 204) { - print(null); userChatHistory = []; } else { - userChatHistory = getSingleUserChatintoModel(response.body); + userChatHistory = getSingleUserChatModel(response.body); } isLoading = false; notifyListeners(); } - List getSingleUserChatintoModel(String str) => List.from(json.decode(str).map((x) => SingleUserChatModel.fromJson(x))); + List getSingleUserChatModel(String str) => List.from(json.decode(str).map((x) => SingleUserChatModel.fromJson(x))); ChatUserModel userToList(String str) => ChatUserModel.fromJson(json.decode(str)); @@ -195,7 +194,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { Future onMsgReceived(List? parameters) async { List data = []; for (dynamic msg in parameters!) { - data = getSingleUserChatintoModel(jsonEncode(msg)); + data = getSingleUserChatModel(jsonEncode(msg)); logger.d(msg); } userChatHistory.add(data.first); From 109c0ca0a25d1a518c72d0bf25781bafd0b9fd9e Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 19 Oct 2022 12:47:08 +0300 Subject: [PATCH 14/21] PR PO fixes, Worklist fixes --- lib/api/worklist/worklist_api_client.dart | 16 +++ lib/models/generic_response_model.dart | 10 +- .../get_po_notification_body_list_model.dart | 4 +- .../get_pr_notification_body_list_model.dart | 130 ++++++++++++++++++ .../id/employee_digital_id_dialog.dart | 6 +- lib/ui/work_list/sheets/delegate_sheet.dart | 2 +- .../work_list/sheets/selected_item_sheet.dart | 28 ++-- lib/ui/work_list/worklist_detail_screen.dart | 49 ++++--- .../worklist_fragments/actions_fragment.dart | 8 +- .../worklist_fragments/info_fragments.dart | 74 +++++++--- .../worklist_fragments/request_fragment.dart | 40 ++++++ .../dialogs/accept_reject_input_dialog.dart | 3 +- 12 files changed, 309 insertions(+), 61 deletions(-) create mode 100644 lib/models/get_pr_notification_body_list_model.dart diff --git a/lib/api/worklist/worklist_api_client.dart b/lib/api/worklist/worklist_api_client.dart index 8c5aed2..1bd8ec9 100644 --- a/lib/api/worklist/worklist_api_client.dart +++ b/lib/api/worklist/worklist_api_client.dart @@ -14,6 +14,7 @@ import 'package:mohem_flutter_app/models/get_mo_notification_body_list_model.dar import 'package:mohem_flutter_app/models/get_notification_buttons_list_model.dart'; import 'package:mohem_flutter_app/models/get_po_Item_history_list_model.dart'; import 'package:mohem_flutter_app/models/get_po_notification_body_list_model.dart'; +import 'package:mohem_flutter_app/models/get_pr_notification_body_list_model.dart'; 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'; @@ -235,6 +236,21 @@ class WorkListApiClient { }, url, postParams); } + Future getPRNotificationBody(int pNotificationID, int pTransactionID) async { + String url = "${ApiConsts.erpRest}GET_PR_NOTIFICATION_BODY"; + Map postParams = { + "P_NOTIFICATION_ID": pNotificationID, + "P_TRANSACTION_ID": pTransactionID, + "P_PAGE_LIMIT": 100, + "P_PAGE_NUM": 1, + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + return responseData.getPrNotificationBodyList; + }, url, postParams); + } + Future> getMoItemHistory(int pItemID, int pOrgID) async { String url = "${ApiConsts.erpRest}GET_MO_ITEM_HISTORY"; Map postParams = { diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index b96098e..b812411 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -28,6 +28,7 @@ import 'package:mohem_flutter_app/models/get_mobile_login_info_list_model.dart'; import 'package:mohem_flutter_app/models/get_notification_buttons_list_model.dart'; import 'package:mohem_flutter_app/models/get_po_Item_history_list_model.dart'; import 'package:mohem_flutter_app/models/get_po_notification_body_list_model.dart'; +import 'package:mohem_flutter_app/models/get_pr_notification_body_list_model.dart'; import 'package:mohem_flutter_app/models/get_quotation_analysis_list_model.dart'; import 'package:mohem_flutter_app/models/get_schedule_shifts_details_list_model.dart'; import 'package:mohem_flutter_app/models/get_stamp_ms_notification_body_list_model.dart'; @@ -220,7 +221,7 @@ class GenericResponseModel { List? getPhonesNotificationBodyList; List? getPoItemHistoryList; GetPoNotificationBodyList? getPoNotificationBodyList; - List? getPrNotificationBodyList; + GetPrNotificationBodyList? getPrNotificationBodyList; List? getQuotationAnalysisList; List? getRFCEmployeeListList; List? getRespondAttributeValueList; @@ -985,7 +986,7 @@ class GenericResponseModel { }); } getPoNotificationBodyList = json['GetPoNotificationBodyList'] != null ? GetPoNotificationBodyList.fromJson(json['GetPoNotificationBodyList']) : null; - getPrNotificationBodyList = json['GetPrNotificationBodyList']; + getPrNotificationBodyList = json['GetPrNotificationBodyList'] != null ? GetPrNotificationBodyList.fromJson(json['GetPrNotificationBodyList']) : null; if (json['GetQuotationAnalysisList'] != null) { getQuotationAnalysisList = []; json['GetQuotationAnalysisList'].forEach((v) { @@ -1594,7 +1595,10 @@ class GenericResponseModel { if (this.getPoNotificationBodyList != null) { data['GetPoNotificationBodyList'] = this.getPoNotificationBodyList!.toJson(); } - data['GetPrNotificationBodyList'] = this.getPrNotificationBodyList; + if (this.getPrNotificationBodyList != null) { + data['GetPrNotificationBodyList'] = this.getPrNotificationBodyList!.toJson(); + } + if (this.getQuotationAnalysisList != null) { data['GetQuotationAnalysisList'] = this.getQuotationAnalysisList!.map((v) => v.toJson()).toList(); } diff --git a/lib/models/get_po_notification_body_list_model.dart b/lib/models/get_po_notification_body_list_model.dart index ff18949..3bc92a0 100644 --- a/lib/models/get_po_notification_body_list_model.dart +++ b/lib/models/get_po_notification_body_list_model.dart @@ -150,8 +150,8 @@ class POLines { String? iTEMCODE; String? iTEMDESCRIPTION; int? iTEMID; - int? lINEAMOUNT; - int? lINEDISCPERCENTAGE; + num? lINEAMOUNT; + num? lINEDISCPERCENTAGE; int? lINENUM; String? lINETYPE; String? mFG; diff --git a/lib/models/get_pr_notification_body_list_model.dart b/lib/models/get_pr_notification_body_list_model.dart new file mode 100644 index 0000000..dfc8b39 --- /dev/null +++ b/lib/models/get_pr_notification_body_list_model.dart @@ -0,0 +1,130 @@ +class GetPrNotificationBodyList { + List? pRHeader; + List? pRLines; + String? pCURRENCYCODE; + String? pINFORMATION; + String? pQUESTION; + + GetPrNotificationBodyList( + {this.pRHeader, + this.pRLines, + this.pCURRENCYCODE, + this.pINFORMATION, + this.pQUESTION}); + + GetPrNotificationBodyList.fromJson(Map json) { + if (json['PRHeader'] != null) { + pRHeader = []; + json['PRHeader'].forEach((v) { + pRHeader!.add(new PRHeader.fromJson(v)); + }); + } + if (json['PRLines'] != null) { + pRLines = []; + json['PRLines'].forEach((v) { + pRLines!.add(new PRLines.fromJson(v)); + }); + } + pCURRENCYCODE = json['P_CURRENCY_CODE']; + pINFORMATION = json['P_INFORMATION']; + pQUESTION = json['P_QUESTION']; + } + + Map toJson() { + Map data = new Map(); + if (this.pRHeader != null) { + data['PRHeader'] = this.pRHeader!.map((v) => v.toJson()).toList(); + } + if (this.pRLines != null) { + data['PRLines'] = this.pRLines!.map((v) => v.toJson()).toList(); + } + data['P_CURRENCY_CODE'] = this.pCURRENCYCODE; + data['P_INFORMATION'] = this.pINFORMATION; + data['P_QUESTION'] = this.pQUESTION; + return data; + } +} + +class PRHeader { + String? hDRATTRIBUTENAME; + String? hDRATTRIBUTEVALUE; + + PRHeader({this.hDRATTRIBUTENAME, this.hDRATTRIBUTEVALUE}); + + PRHeader.fromJson(Map json) { + hDRATTRIBUTENAME = json['HDR_ATTRIBUTE_NAME']; + hDRATTRIBUTEVALUE = json['HDR_ATTRIBUTE_VALUE']; + } + + Map toJson() { + Map data = new Map(); + data['HDR_ATTRIBUTE_NAME'] = this.hDRATTRIBUTENAME; + data['HDR_ATTRIBUTE_VALUE'] = this.hDRATTRIBUTEVALUE; + return data; + } +} + +class PRLines { + String? cOSTCENTER; + String? dESCRIPTION; + int? fROMROWNUM; + int? iTEMAMU; + String? iTEMCODE; + num? lINEAMOUNT; + int? lINENUM; + int? nOOFROWS; + int? qUANTITY; + int? rOWNUM; + int? tOROWNUM; + num? uNITPRICE; + String? uOM; + + PRLines( + {this.cOSTCENTER, + this.dESCRIPTION, + this.fROMROWNUM, + this.iTEMAMU, + this.iTEMCODE, + this.lINEAMOUNT, + this.lINENUM, + this.nOOFROWS, + this.qUANTITY, + this.rOWNUM, + this.tOROWNUM, + this.uNITPRICE, + this.uOM}); + + PRLines.fromJson(Map json) { + cOSTCENTER = json['COST_CENTER']; + dESCRIPTION = json['DESCRIPTION']; + fROMROWNUM = json['FROM_ROW_NUM']; + iTEMAMU = json['ITEM_AMU']; + iTEMCODE = json['ITEM_CODE']; + lINEAMOUNT = json['LINE_AMOUNT']; + lINENUM = json['LINE_NUM']; + nOOFROWS = json['NO_OF_ROWS']; + qUANTITY = json['QUANTITY']; + rOWNUM = json['ROW_NUM']; + tOROWNUM = json['TO_ROW_NUM']; + uNITPRICE = json['UNIT_PRICE']; + uOM = json['UOM']; + } + + Map toJson() { + Map data = new Map(); + data['COST_CENTER'] = this.cOSTCENTER; + data['DESCRIPTION'] = this.dESCRIPTION; + data['FROM_ROW_NUM'] = this.fROMROWNUM; + data['ITEM_AMU'] = this.iTEMAMU; + data['ITEM_CODE'] = this.iTEMCODE; + data['LINE_AMOUNT'] = this.lINEAMOUNT; + data['LINE_NUM'] = this.lINENUM; + data['NO_OF_ROWS'] = this.nOOFROWS; + data['QUANTITY'] = this.qUANTITY; + data['ROW_NUM'] = this.rOWNUM; + data['TO_ROW_NUM'] = this.tOROWNUM; + data['UNIT_PRICE'] = this.uNITPRICE; + data['UOM'] = this.uOM; + return data; + } +} diff --git a/lib/ui/dialogs/id/employee_digital_id_dialog.dart b/lib/ui/dialogs/id/employee_digital_id_dialog.dart index 034a133..0e672f8 100644 --- a/lib/ui/dialogs/id/employee_digital_id_dialog.dart +++ b/lib/ui/dialogs/id/employee_digital_id_dialog.dart @@ -32,9 +32,9 @@ class EmployeeDigitialIdDialog extends StatelessWidget { Container( width: 80, height: 80, - decoration: BoxDecoration( + decoration: const BoxDecoration( color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), + borderRadius: BorderRadius.all(Radius.circular(12)), boxShadow: [BoxShadow(color: Colors.white60, blurRadius: 10, spreadRadius: 10)], ), clipBehavior: Clip.antiAlias, @@ -44,7 +44,7 @@ class EmployeeDigitialIdDialog extends StatelessWidget { child: SvgPicture.asset("assets/images/user.svg"), ) : Image.memory( - Utils.getPostBytes( + Utils.dataFromBase64String( AppState().memberInformationList!.eMPLOYEEIMAGE ?? "", ), fit: BoxFit.cover, diff --git a/lib/ui/work_list/sheets/delegate_sheet.dart b/lib/ui/work_list/sheets/delegate_sheet.dart index ec7d80a..75b33c9 100644 --- a/lib/ui/work_list/sheets/delegate_sheet.dart +++ b/lib/ui/work_list/sheets/delegate_sheet.dart @@ -206,7 +206,7 @@ class _DelegateSheetState extends State { onPressed: () { fetchUserByInput(); }, - child: Text( + child: const Text( "Search", style: TextStyle( color: Colors.blue, diff --git a/lib/ui/work_list/sheets/selected_item_sheet.dart b/lib/ui/work_list/sheets/selected_item_sheet.dart index fa43181..d406ef3 100644 --- a/lib/ui/work_list/sheets/selected_item_sheet.dart +++ b/lib/ui/work_list/sheets/selected_item_sheet.dart @@ -83,22 +83,26 @@ class SelectedItemSheet extends StatelessWidget { 16.width, Expanded( child: DefaultButton( - LocaleKeys.submit.tr(), + LocaleKeys.submit.tr(), () { - String? email = "", userId = ""; - if (actionHistoryList != null) { - email = actionHistoryList!.eMAILADDRESS; - userId = actionHistoryList!.uSERNAME; - } else if (favoriteReplacements != null) { - email = favoriteReplacements!.emailAddress; - userId = favoriteReplacements!.userName; + if (comment.trim() != "") { + String? email = "", userId = ""; + if (actionHistoryList != null) { + email = actionHistoryList!.eMAILADDRESS; + userId = actionHistoryList!.uSERNAME; + } else if (favoriteReplacements != null) { + email = favoriteReplacements!.emailAddress; + userId = favoriteReplacements!.userName; + } else { + email = replacementList!.emailAddress; + userId = replacementList!.userName; + } + performNetworkCall(context, email: email ?? "", userId: userId ?? ""); } else { - email = replacementList!.emailAddress; - userId = replacementList!.userName; + Utils.showToast("Please enter comments"); } - performNetworkCall(context, email: email ?? "", userId: userId ?? ""); }, - colors: [ + colors: const [ Color(0xff32D892), Color(0xff1AB170), ], diff --git a/lib/ui/work_list/worklist_detail_screen.dart b/lib/ui/work_list/worklist_detail_screen.dart index 241b2e8..508ce04 100644 --- a/lib/ui/work_list/worklist_detail_screen.dart +++ b/lib/ui/work_list/worklist_detail_screen.dart @@ -1,5 +1,3 @@ -import 'dart:convert'; - import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; @@ -19,6 +17,7 @@ import 'package:mohem_flutter_app/models/get_item_creation_ntf_body_list_model.d import 'package:mohem_flutter_app/models/get_mo_notification_body_list_model.dart'; import 'package:mohem_flutter_app/models/get_notification_buttons_list_model.dart'; import 'package:mohem_flutter_app/models/get_po_notification_body_list_model.dart'; +import 'package:mohem_flutter_app/models/get_pr_notification_body_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/member_information_list_model.dart'; @@ -76,6 +75,7 @@ class _WorkListDetailScreenState extends State { GenericResponseModel? getICBody; GenericResponseModel? subordinatesLeavesModel; GetPoNotificationBodyList? getPoNotificationBody; + GetPrNotificationBodyList? getPrNotificationBody; GetItemCreationNtfBodyList? getItemCreationNtfBody; bool isCloseAvailable = false; @@ -131,6 +131,9 @@ class _WorkListDetailScreenState extends State { if (workListData!.iTEMTYPE == "POAPPRV") { getPoNotificationBody = await WorkListApiClient().getPoNotificationBody(workListData!.nOTIFICATIONID!, -999); } + if (workListData!.iTEMTYPE == "REQAPPRV") { + getPrNotificationBody = await WorkListApiClient().getPRNotificationBody(workListData!.nOTIFICATIONID!, -999); + } getNotificationRespondAttributes = await WorkListApiClient().notificationGetRespondAttributes(workListData!.nOTIFICATIONID!); if (getNotificationRespondAttributes.isNotEmpty) { notificationNoteInput = getNotificationRespondAttributes.first; @@ -244,6 +247,7 @@ class _WorkListDetailScreenState extends State { getBasicDetNtfBodyList: getBasicDetNtfBodyList, getAbsenceCollectionNotificationBodyList: getAbsenceCollectionNotificationBodyList, getContactNotificationBodyList: getContactNotificationBodyList, + getPrNotificationBodyList: getPrNotificationBody, ), (workListData!.iTEMTYPE == "HRSSA" || workListData!.iTEMTYPE == "STAMP") ? DetailFragment(workListData, memberInformationListModel) @@ -251,6 +255,7 @@ class _WorkListDetailScreenState extends State { moNotificationBodyList: getMoNotificationBodyList, poLinesList: getPoNotificationBody?.pOLines ?? [], itemCreationLines: getItemCreationNtfBody?.itemCreationLines ?? [], + prLinesList: getPrNotificationBody?.pRLines ?? [], ), actionHistoryList.isEmpty ? Utils.getNoDataWidget(context) : ActionsFragment(workListData!.nOTIFICATIONID, actionHistoryList), getAttachmentList.isEmpty ? Utils.getNoDataWidget(context) : AttachmentsFragment(getAttachmentList), @@ -484,7 +489,9 @@ class _WorkListDetailScreenState extends State { child: isIconAsset ? SvgPicture.asset(icon) : Image.memory( - base64Decode(icon), + Utils.dataFromBase64String( + icon, + ), fit: BoxFit.cover, ), ) @@ -493,27 +500,33 @@ class _WorkListDetailScreenState extends State { } void performAction(String actionMode) { + TextEditingController textEditingController = TextEditingController(); showDialog( context: context, builder: (cxt) => AcceptRejectInputDialog( message: LocaleKeys.requestedItems.tr(), notificationGetRespond: notificationNoteInput, + textEditingController: textEditingController, onTap: (note) { - Map payload = { - "P_ACTION_MODE": actionMode, - "P_APPROVER_INDEX": null, - "P_COMMENTS": "", - "P_FORWARD_TO_USER_NAME": "", - "P_NOTIFICATION_ID": workListData!.nOTIFICATIONID, - "RespondAttributeList": [ - if (notificationNoteInput != null) - { - "ATTRIBUTE_NAME": notificationNoteInput!.attributeName, - if (notificationNoteInput!.attributeType == "number") "ATTRIBUTE_NUMBER_VALUE": note else if (notificationNoteInput!.attributeType == "VARCHAR2") "ATTRIBUTE_TEXT_VALUE": note - } - ], - }; - performNotificationAction(payload); + if(note.isNotEmpty && (actionMode == "APPROVED" || actionMode == "APPROVE")) { + Map payload = { + "P_ACTION_MODE": actionMode, + "P_APPROVER_INDEX": null, + "P_COMMENTS": note, + "P_FORWARD_TO_USER_NAME": "", + "P_NOTIFICATION_ID": workListData!.nOTIFICATIONID, + "RespondAttributeList": [ + if (notificationNoteInput != null) + { + "ATTRIBUTE_NAME": notificationNoteInput!.attributeName, + if (notificationNoteInput!.attributeType == "number") "ATTRIBUTE_NUMBER_VALUE": note else if (notificationNoteInput!.attributeType == "VARCHAR2") "ATTRIBUTE_TEXT_VALUE": note + } + ], + }; + performNotificationAction(payload); + } else { + Utils.showToast("Please enter comments"); + } }, ), ); diff --git a/lib/ui/work_list/worklist_fragments/actions_fragment.dart b/lib/ui/work_list/worklist_fragments/actions_fragment.dart index 3663cc5..1df9bd3 100644 --- a/lib/ui/work_list/worklist_fragments/actions_fragment.dart +++ b/lib/ui/work_list/worklist_fragments/actions_fragment.dart @@ -71,7 +71,9 @@ class ActionsFragment extends StatelessWidget { Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - CircularAvatar(url: actionHistory.eMPLOYEEIMAGE ?? "", isImageBase64: true, height: 34, width: 34), + actionHistory.eMPLOYEEIMAGE != null + ? CircularAvatar(url: actionHistory.eMPLOYEEIMAGE ?? "", isImageBase64: true, height: 34, width: 34) + : CircularAvatar(url: "https://cdn4.iconfinder.com/data/icons/professions-2-2/151/89-512.png", isImageBase64: false, height: 34, width: 34), 9.width, Expanded( child: Column( @@ -129,10 +131,10 @@ class ActionsFragment extends StatelessWidget { return MyColors.redColor; } else if (code == "PENDING") { return MyColors.orange; - } else if (code == "APPROVED") { + } else if (code == "APPROVED" || code == "APPROVE") { return const Color(0xff1FA269); } else if (code != "SUBMIT" && code != "REJECT" && code != "PENDING") { - return const Color(0xff1FA269); + return MyColors.orange; } else if (code == "REQUEST_INFO") { return const Color(0xff2E303A); } else { diff --git a/lib/ui/work_list/worklist_fragments/info_fragments.dart b/lib/ui/work_list/worklist_fragments/info_fragments.dart index 18d5f68..16a60e0 100644 --- a/lib/ui/work_list/worklist_fragments/info_fragments.dart +++ b/lib/ui/work_list/worklist_fragments/info_fragments.dart @@ -1,5 +1,6 @@ import 'package:easy_localization/src/public_ext.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/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; @@ -8,6 +9,7 @@ import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/get_absence_collection_notification_body_list_model.dart'; import 'package:mohem_flutter_app/models/get_item_creation_ntf_body_list_model.dart'; import 'package:mohem_flutter_app/models/get_po_notification_body_list_model.dart'; +import 'package:mohem_flutter_app/models/get_pr_notification_body_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/worklist/hr/eit_otification_body_model.dart'; @@ -28,19 +30,20 @@ class InfoFragment extends StatelessWidget { List? getBasicDetNtfBodyList; List? getAbsenceCollectionNotificationBodyList; GetContactNotificationBodyList? getContactNotificationBodyList; + GetPrNotificationBodyList? getPrNotificationBodyList; - InfoFragment({ - this.workListData, - this.poHeaderList = const [], - this.itemCreationHeader = const [], - this.getStampMsNotifications, - this.getStampNsNotifications, - this.getEitCollectionNotificationBodyList, - this.getPhonesNotificationBodyList, - this.getBasicDetNtfBodyList, - this.getAbsenceCollectionNotificationBodyList, - this.getContactNotificationBodyList, - }); + InfoFragment( + {this.workListData, + this.poHeaderList = const [], + this.itemCreationHeader = const [], + this.getStampMsNotifications, + this.getStampNsNotifications, + this.getEitCollectionNotificationBodyList, + this.getPhonesNotificationBodyList, + this.getBasicDetNtfBodyList, + this.getAbsenceCollectionNotificationBodyList, + this.getContactNotificationBodyList, + this.getPrNotificationBodyList}); double itemHeight = 0; double itemWidth = 0; @@ -76,8 +79,9 @@ class InfoFragment extends StatelessWidget { ), ], ).objectContainerView(), - if (getStampMsNotifications?.isNotEmpty ?? false) getStampMsNotificationsListView(getStampMsNotifications ?? []).objectContainerView(title: "Stamp Notifications"), - if (getStampNsNotifications?.isNotEmpty ?? false) getStampNsNotificationsListView(getStampNsNotifications ?? []).objectContainerView(title: "Stamp Notifications"), + if (getPrNotificationBodyList != null) getPRNotificationBodyListWidget(getPrNotificationBodyList!), + if (getStampMsNotifications?.isNotEmpty ?? false) getStampMsNotificationsListView(getStampMsNotifications ?? []), + if (getStampNsNotifications?.isNotEmpty ?? false) getStampNsNotificationsListView(getStampNsNotifications ?? []), if (poHeaderList.isNotEmpty) getPoNotificationsListView(), if (itemCreationHeader.isNotEmpty) getItemCreationHeaderView(), if (getEitCollectionNotificationBodyList?.isNotEmpty ?? false) getEitNotificationsListView(getEitCollectionNotificationBodyList ?? []), @@ -218,8 +222,8 @@ class InfoFragment extends StatelessWidget { isItLast: true, ), ], - ), - separatorBuilder: (cxt, index) => 1.divider.paddingOnly(top: 8, bottom: 8), + ).objectContainerView(), + separatorBuilder: (cxt, index) => 1.height.paddingOnly(top: 8, bottom: 8), itemCount: list.length); } @@ -240,8 +244,8 @@ class InfoFragment extends StatelessWidget { isItLast: true, ), ], - ), - separatorBuilder: (cxt, index) => 1.divider.paddingOnly(top: 8, bottom: 8), + ).objectContainerView(), + separatorBuilder: (cxt, index) => 1.height.paddingOnly(top: 8, bottom: 8), itemCount: list.length); } @@ -433,6 +437,40 @@ class InfoFragment extends StatelessWidget { ); } + Widget getPRNotificationBodyListWidget(GetPrNotificationBodyList getPrNotificationBodyList) { + return Column( + children: [ + getPrNotificationBodyList.pINFORMATION.toString().toText14(color: MyColors.textMixColor).objectContainerView(), + 12.height, + Column( + children: [ + ItemDetailGrid( + ItemDetailViewCol(LocaleKeys.from.tr(), workListData!.fROMUSER ?? ""), + ItemDetailViewCol(LocaleKeys.to.tr(), workListData!.tOUSER ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol(LocaleKeys.sent.tr(), workListData!.bEGINDATE ?? ""), + ItemDetailViewCol(LocaleKeys.closed.tr(), workListData!.eNDDATE ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol(LocaleKeys.id.tr(), workListData!.nOTIFICATIONID?.toString() ?? ""), + ItemDetailViewCol(LocaleKeys.responder.tr(), workListData!.rESPONDER ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol(getPrNotificationBodyList.pRHeader![2].hDRATTRIBUTENAME!, getPrNotificationBodyList.pRHeader![2].hDRATTRIBUTEVALUE ?? ""), + ItemDetailViewCol(getPrNotificationBodyList.pRHeader![0].hDRATTRIBUTENAME!, getPrNotificationBodyList.pRHeader![0].hDRATTRIBUTEVALUE ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol(getPrNotificationBodyList.pRHeader![1].hDRATTRIBUTENAME!, getPrNotificationBodyList.pRHeader![1].hDRATTRIBUTEVALUE ?? ""), + Container(), + isItLast: true, + ), + ], + ).objectContainerView(), + ], + ); + } + Widget getContactNotificationBodyListWidget(GetContactNotificationBodyList data) { bool isOdd = false; try { diff --git a/lib/ui/work_list/worklist_fragments/request_fragment.dart b/lib/ui/work_list/worklist_fragments/request_fragment.dart index 38e0218..b900578 100644 --- a/lib/ui/work_list/worklist_fragments/request_fragment.dart +++ b/lib/ui/work_list/worklist_fragments/request_fragment.dart @@ -1,6 +1,7 @@ import 'package:easy_localization/src/public_ext.dart'; import 'package:expandable/expandable.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'; @@ -9,6 +10,7 @@ import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/get_item_creation_ntf_body_list_model.dart'; import 'package:mohem_flutter_app/models/get_mo_notification_body_list_model.dart'; import 'package:mohem_flutter_app/models/get_po_notification_body_list_model.dart'; +import 'package:mohem_flutter_app/models/get_pr_notification_body_list_model.dart'; import 'package:mohem_flutter_app/ui/work_list/item_history_screen.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:mohem_flutter_app/widgets/item_detail_view_widget.dart'; @@ -17,12 +19,14 @@ class RequestFragment extends StatelessWidget { final List moNotificationBodyList; final List itemCreationLines; final List poLinesList; + final List prLinesList; RequestFragment({ Key? key, this.moNotificationBodyList = const [], this.itemCreationLines = const [], this.poLinesList = const [], + this.prLinesList = const [], }) : super(key: key); @override @@ -35,6 +39,7 @@ class RequestFragment extends StatelessWidget { if (moNotificationBodyList.isNotEmpty) moNotificationDataView(), if (poLinesList.isNotEmpty) poLinesDataView(), if (itemCreationLines.isNotEmpty) itemCreationLinesView(), + if (prLinesList.isNotEmpty) prLinesDataView(), ], ), ); @@ -109,6 +114,41 @@ class RequestFragment extends StatelessWidget { ); } + Widget prLinesDataView() { + return Column( + children: [ + prLinesList[0].dESCRIPTION.toString().toText14(color: MyColors.textMixColor).objectContainerView(), + 12.height, + Column( + children: [ + ItemDetailGrid( + ItemDetailViewCol("Cost Center", prLinesList[0].cOSTCENTER ?? ""), + ItemDetailViewCol("Code", prLinesList[0].iTEMCODE ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol("Unit", prLinesList[0].uOM ?? ""), + ItemDetailViewCol("Price (SAR)", prLinesList[0].uNITPRICE.toString() ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol("Amount (SAR)", prLinesList[0].lINEAMOUNT.toString() ?? ""), + ItemDetailViewCol("Quantity", prLinesList[0].qUANTITY.toString() ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol("AMU (Last 3 months)", prLinesList[0].iTEMAMU.toString() ?? ""), + Container(), + isItLast: true, + ), + // ItemDetailGrid( + // ItemDetailViewCol(getPrNotificationBodyList.pRHeader![1].hDRATTRIBUTENAME!, getPrNotificationBodyList.pRHeader![1].hDRATTRIBUTEVALUE ?? ""), + // Container(), + // isItLast: true, + // ), + ], + ).objectContainerView(), + ], + ); + } + Widget moNotificationDataView() { return ListView.separated( shrinkWrap: true, diff --git a/lib/widgets/dialogs/accept_reject_input_dialog.dart b/lib/widgets/dialogs/accept_reject_input_dialog.dart index 3b644b9..ea84484 100644 --- a/lib/widgets/dialogs/accept_reject_input_dialog.dart +++ b/lib/widgets/dialogs/accept_reject_input_dialog.dart @@ -15,8 +15,9 @@ class AcceptRejectInputDialog extends StatelessWidget { final String? okTitle; final NotificationGetRespondAttributesList? notificationGetRespond; final Function(String) onTap; + final TextEditingController textEditingController; - AcceptRejectInputDialog({Key? key, this.title, @required this.message, this.okTitle, required this.onTap, this.notificationGetRespond}) : super(key: key); + AcceptRejectInputDialog({Key? key, this.title, @required this.message, this.okTitle, required this.onTap, this.notificationGetRespond, required this.textEditingController}) : super(key: key); String note = ""; From 90b60ce55a53f9f8b428c491bf682f4a268fa529 Mon Sep 17 00:00:00 2001 From: "Aamir.Muhammad" Date: Wed, 19 Oct 2022 14:02:36 +0300 Subject: [PATCH 15/21] Chat Search User Api Implementation --- .../search_employee_bottom_sheet.dart | 180 +++++++++--------- 1 file changed, 85 insertions(+), 95 deletions(-) diff --git a/lib/widgets/bottom_sheets/search_employee_bottom_sheet.dart b/lib/widgets/bottom_sheets/search_employee_bottom_sheet.dart index 14da765..face11b 100644 --- a/lib/widgets/bottom_sheets/search_employee_bottom_sheet.dart +++ b/lib/widgets/bottom_sheets/search_employee_bottom_sheet.dart @@ -88,13 +88,7 @@ class _SearchEmployeeBottomSheetState extends State { void fetchChatUser({bool isNeedLoading = true}) async { try { Utils.showLoading(context); - chatUsersList = await ChatProviderModel().getChatMemberFromSearch(searchText, int.parse(AppState().chatDetails!.response!.id.toString())); - print("================================"); - print(jsonEncode(chatUsersList)); - // - // favouriteUserList = replacementList?.where((element) => element.isFavorite ?? false).toList(); - // nonFavouriteUserList = replacementList?.where((element) => !(element.isFavorite ?? false)).toList(); Utils.hideLoading(context); setState(() {}); } catch (e) { @@ -150,106 +144,102 @@ class _SearchEmployeeBottomSheetState extends State { 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, - - if(widget.fromChat) + : 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, + if (widget.fromChat) if (chatUsersList != null && widget.fromChat) chatUsersList!.isEmpty ? Utils.getNoDataWidget(context) : ListView( - physics: const BouncingScrollPhysics(), - padding: EdgeInsets.only(top: 0, bottom: 8), - children: [ - ListView.separated( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - - itemBuilder: (cxt, index) { - return ListTile( - leading: Stack( - children: [ - SvgPicture.asset( - "assets/images/user.svg", - height: 48, - width: 48, - ), - Positioned( - right: 5, - bottom: 1, - child: Container( - width: 10, - height: 10, - decoration: BoxDecoration( - color: chatUsersList![index].userStatus == 1 ? MyColors.green2DColor : Colors.red, - borderRadius: const BorderRadius.all( - Radius.circular(10), + physics: const BouncingScrollPhysics(), + padding: EdgeInsets.only(top: 0, bottom: 8), + children: [ + ListView.separated( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (cxt, index) { + return ListTile( + leading: Stack( + children: [ + SvgPicture.asset( + "assets/images/user.svg", + height: 48, + width: 48, ), - ), + Positioned( + right: 5, + bottom: 1, + child: Container( + width: 10, + height: 10, + decoration: BoxDecoration( + color: chatUsersList![index].userStatus == 1 ? MyColors.green2DColor : Colors.red, + borderRadius: const BorderRadius.all( + Radius.circular(10), + ), + ), + ), + ) + ], ), - ) - ], - ), - title: (chatUsersList![index].userName ?? "").toText14(color: MyColors.darkTextColor), - subtitle: (chatUsersList![index].isTyping == true ? "Something is Typing" : "Last message text").toText11(color: MyColors.normalTextColor), - trailing: ("Today").toText10(color: MyColors.lightTextColor), - minVerticalPadding: 0, - onTap: () { - Navigator.pop(context); - Navigator.pushNamed( - context, - AppRoutes.chatDetailed, - arguments: {"targetUser": chatUsersList![index]}, - ); - }, - ); - }, - separatorBuilder: (cxt, index) => Container( - height: 1, - color: MyColors.borderE3Color, - ), - itemCount: chatUsersList?.length ?? 0), - 12.height, - ], - ).expanded, + title: (chatUsersList![index].userName ?? "").toText14(color: MyColors.darkTextColor), + subtitle: (chatUsersList![index].isTyping == true ? "Something is Typing" : "Last message text").toText11(color: MyColors.normalTextColor), + trailing: ("Today").toText10(color: MyColors.lightTextColor), + minVerticalPadding: 0, + onTap: () { + Navigator.pop(context); + Navigator.pushNamed( + context, + AppRoutes.chatDetailed, + arguments: {"targetUser": chatUsersList![index]}, + ); + }, + ); + }, + separatorBuilder: (cxt, index) => Container( + height: 1, + color: MyColors.borderE3Color, + ), + itemCount: chatUsersList?.length ?? 0), + 12.height, + ], + ).expanded, ], ).paddingOnly(left: 21, right: 21, bottom: 0, top: 21).expanded, - Container(width: double.infinity, height: 1, color: MyColors.lightGreyEFColor), DefaultButton( LocaleKeys.cancel.tr(), From c29d003401450b6d677fa59c47112328fdfd31bd Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 19 Oct 2022 14:11:36 +0300 Subject: [PATCH 16/21] services dynamic list issue fixed on payslip --- lib/ui/landing/widget/services_widget.dart | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/ui/landing/widget/services_widget.dart b/lib/ui/landing/widget/services_widget.dart index ecb0641..a6f4151 100644 --- a/lib/ui/landing/widget/services_widget.dart +++ b/lib/ui/landing/widget/services_widget.dart @@ -49,7 +49,6 @@ class ServicesWidget extends StatelessWidget { padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), scrollDirection: Axis.horizontal, itemBuilder: (cxt, index) { - return AspectRatio( aspectRatio: 105 / 105, child: data.isServicesMenusLoading @@ -77,11 +76,7 @@ class ServicesWidget extends StatelessWidget { Expanded( child: data.homeMenus![parentIndex].menuEntiesList[index].prompt!.toText10(isBold: true), ), - RotatedBox( - quarterTurns: AppState().isArabic(context) ? 2:4, - child: SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4) - ), - + RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)), ], ) ], @@ -119,7 +114,7 @@ class ServicesWidget extends StatelessWidget { Navigator.of(context).pushNamed(AppRoutes.profile); return; } - List menuList = pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION" || element.menuEntryType == "MENU")).toList() ?? []; + List menuList = pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION")).toList() ?? []; menuEntry.icon = ""; if (menuList.isEmpty) { if (menuEntry.requestType == "EIT") { @@ -128,7 +123,12 @@ class ServicesWidget extends StatelessWidget { Navigator.pushNamed(context, AppRoutes.monthlyPaySlip); } } else { - Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, menuList)); + List _menuList = pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION" || element.menuEntryType == "MENU")).toList() ?? []; + if (_menuList.isEmpty) { + Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, menuList)); + } else { + Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, _menuList)); + } } return; } From 0213a7a4ef1a7bbdc14836a2b3443a6376535ad5 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 19 Oct 2022 16:34:08 +0300 Subject: [PATCH 17/21] worklist api calling delay fixed. --- lib/ui/landing/widget/services_widget.dart | 9 +- lib/ui/work_list/worklist_detail_screen.dart | 385 +++++++++++++++---- 2 files changed, 311 insertions(+), 83 deletions(-) diff --git a/lib/ui/landing/widget/services_widget.dart b/lib/ui/landing/widget/services_widget.dart index a6f4151..80328a1 100644 --- a/lib/ui/landing/widget/services_widget.dart +++ b/lib/ui/landing/widget/services_widget.dart @@ -123,12 +123,9 @@ class ServicesWidget extends StatelessWidget { Navigator.pushNamed(context, AppRoutes.monthlyPaySlip); } } else { - List _menuList = pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION" || element.menuEntryType == "MENU")).toList() ?? []; - if (_menuList.isEmpty) { - Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, menuList)); - } else { - Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, _menuList)); - } + List _menuList = + pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION" || element.menuEntryType == "MENU")).toList() ?? []; + Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, _menuList.isEmpty ? menuList : _menuList)); } return; } diff --git a/lib/ui/work_list/worklist_detail_screen.dart b/lib/ui/work_list/worklist_detail_screen.dart index 241b2e8..c20ceba 100644 --- a/lib/ui/work_list/worklist_detail_screen.dart +++ b/lib/ui/work_list/worklist_detail_screen.dart @@ -93,92 +93,73 @@ class _WorkListDetailScreenState extends State { } void getData() async { - try { - Utils.showLoading(context); - if (workListData!.iTEMTYPE == "HRSSA" || workListData!.iTEMTYPE == "STAMP") { - memberInformationListModel = await WorkListApiClient().getUserInformation(-999, workListData!.sELECTEDEMPLOYEENUMBER!); - } - if (workListData!.iTEMTYPE == "HRSSA") { - if (workListData!.rEQUESTTYPE == "EIT") { - getEitCollectionNotificationBodyList = await WorkListApiClient().GetEitNotificationBody(workListData!.nOTIFICATIONID); - } else if (workListData!.rEQUESTTYPE == "PHONE_NUMBERS") { - getPhonesNotificationBodyList = await WorkListApiClient().getPhonesNotificationBodyList(workListData!.nOTIFICATIONID); - } else if (workListData!.rEQUESTTYPE == "BASIC_DETAILS") { - getBasicDetNtfBodyList = await WorkListApiClient().getBasicDetNtfBodyList(workListData!.nOTIFICATIONID); - } else if (workListData!.rEQUESTTYPE == "ABSENCE") { - getAbsenceCollectionNotificationBodyList = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID); - } else if (workListData!.rEQUESTTYPE == "CONTACT") { - getContactNotificationBodyList = await WorkListApiClient().getContactNotificationBodyList(workListData!.nOTIFICATIONID); - } - - // getBasicNTFBody = await WorkListApiClient().getBasicDetNTFBody(workListData!.nOTIFICATIONID!, -999); - // getAbsenceCollectionNotifications = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID!, -999); - // subordinatesLeavesModel = await WorkListApiClient().getSubordinatesLeaves("", ""); - } - if (workListData!.iTEMTYPE == "STAMP") { - if (workListData!.rEQUESTTYPE == "STAMP_MS") { - getStampMsNotifications = await WorkListApiClient().getStampMsNotificationBody(workListData!.nOTIFICATIONID!, -999); - } else { - getStampNsNotifications = await WorkListApiClient().getStampNsNotificationBody(workListData!.nOTIFICATIONID!, -999); - } - } - if (workListData!.iTEMTYPE == "INVMOA") { - getMoNotificationBodyList = await WorkListApiClient().getMoNotificationBody(workListData!.nOTIFICATIONID!, -999); - } - if (workListData!.iTEMTYPE == "INVITEM") { - getItemCreationNtfBody = await WorkListApiClient().getItemCreationNtfBody(workListData!.nOTIFICATIONID!, -999); - } - if (workListData!.iTEMTYPE == "POAPPRV") { - getPoNotificationBody = await WorkListApiClient().getPoNotificationBody(workListData!.nOTIFICATIONID!, -999); - } - getNotificationRespondAttributes = await WorkListApiClient().notificationGetRespondAttributes(workListData!.nOTIFICATIONID!); - if (getNotificationRespondAttributes.isNotEmpty) { - notificationNoteInput = getNotificationRespondAttributes.first; + // try { + // Utils.showLoading(context); + if (workListData!.iTEMTYPE == "HRSSA" || workListData!.iTEMTYPE == "STAMP") { + getUserInformation(); + } + if (workListData!.iTEMTYPE == "HRSSA") { + if (workListData!.rEQUESTTYPE == "EIT") { + getEitNotificationBody(); + } else if (workListData!.rEQUESTTYPE == "PHONE_NUMBERS") { + getPhonesNotificationBody(); + } else if (workListData!.rEQUESTTYPE == "BASIC_DETAILS") { + getBasicDetNtfBody(); + } else if (workListData!.rEQUESTTYPE == "ABSENCE") { + getAbsenceNotificationBody(); + } else if (workListData!.rEQUESTTYPE == "CONTACT") { + getContactNotificationBody(); } + // getBasicNTFBody = await WorkListApiClient().getBasicDetNTFBody(workListData!.nOTIFICATIONID!, -999); + // getAbsenceCollectionNotifications = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID!, -999); + // subordinatesLeavesModel = await WorkListApiClient().getSubordinatesLeaves("", ""); + } + if (workListData!.iTEMTYPE == "STAMP") { + getStampNotificationBody(); + } + if (workListData!.iTEMTYPE == "INVMOA") { + getMoNotificationBody(); + } + if (workListData!.iTEMTYPE == "INVITEM") { + getItemCreationNtf(); + } + if (workListData!.iTEMTYPE == "POAPPRV") { + getPoNotification(); + } + notificationGetRespondAttributes(); - List dataToFetch = await Future.wait([ - WorkListApiClient().getNotificationButtons(workListData!.nOTIFICATIONID!), - WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!), - WorkListApiClient().getAttachments(workListData!.nOTIFICATIONID!), - ]); - - notificationButtonsList = dataToFetch[0]; - actionHistoryList = dataToFetch[1]; - getAttachmentList = dataToFetch[2]; - - // List futureRequest = []; - // List futureObject = []; - // - // addRequestInFuture(notificationButtonsList, WorkListApiClient().getNotificationButtons(workListData!.nOTIFICATIONID!)); - // addRequestInFuture(actionHistoryList, WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!)); - // addRequestInFuture(getAttachmentList, WorkListApiClient().getAttachments(workListData!.nOTIFICATIONID!)); + // List dataToFetch = await Future.wait([ + // + // WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!), + // WorkListApiClient().getAttachments(workListData!.nOTIFICATIONID!), + // ]); + // + // notificationButtonsList = dataToFetch[0]; + // actionHistoryList = dataToFetch[1]; + // getAttachmentList = dataToFetch[2]; - // List dataToFetch = await Future.wait(futureRequest); - // for(int i=0;i element.bUTTONACTION == "CLOSE"); - isApproveAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "APPROVED"); - isRejectAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "REJECTED"); - } - Utils.hideLoading(context); - setState(() {}); - } catch (ex) { - Utils.hideLoading(context); - Utils.handleException(ex, context, null); - setState(() {}); - } + // if (notificationButtonsList.isNotEmpty) { + // isCloseAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "CLOSE"); + // isApproveAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "APPROVED"); + // isRejectAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "REJECTED"); + // } + // Utils.hideLoading(context); + // setState(() {}); + // } catch (ex) { + // Utils.hideLoading(context); + // Utils.handleException(ex, context, null); + // setState(() {}); + // } } List futureRequest = []; List futureObject = []; - void addRequestInFuture(data, request) { - futureObject.add(data); - futureRequest.add(request); - } + int apiCallCount = 0; void getDataFromState() { if (workListData == null) { @@ -531,4 +512,254 @@ class _WorkListDetailScreenState extends State { Utils.handleException(ex, context, null); } } + + void getEitNotificationBody() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getEitCollectionNotificationBodyList = await WorkListApiClient().GetEitNotificationBody(workListData!.nOTIFICATIONID); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getUserInformation() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + memberInformationListModel = await WorkListApiClient().getUserInformation(-999, workListData!.sELECTEDEMPLOYEENUMBER!); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getPhonesNotificationBody() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getPhonesNotificationBodyList = await WorkListApiClient().getPhonesNotificationBodyList(workListData!.nOTIFICATIONID); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getBasicDetNtfBody() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getBasicDetNtfBodyList = await WorkListApiClient().getBasicDetNtfBodyList(workListData!.nOTIFICATIONID); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getAbsenceNotificationBody() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getAbsenceCollectionNotificationBodyList = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getContactNotificationBody() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getContactNotificationBodyList = await WorkListApiClient().getContactNotificationBodyList(workListData!.nOTIFICATIONID); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getStampNotificationBody() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + if (workListData!.rEQUESTTYPE == "STAMP_MS") { + getStampMsNotifications = await WorkListApiClient().getStampMsNotificationBody(workListData!.nOTIFICATIONID!, -999); + } else { + getStampNsNotifications = await WorkListApiClient().getStampNsNotificationBody(workListData!.nOTIFICATIONID!, -999); + } + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getMoNotificationBody() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getMoNotificationBodyList = await WorkListApiClient().getMoNotificationBody(workListData!.nOTIFICATIONID!, -999); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getItemCreationNtf() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getItemCreationNtfBody = await WorkListApiClient().getItemCreationNtfBody(workListData!.nOTIFICATIONID!, -999); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getPoNotification() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getPoNotificationBody = await WorkListApiClient().getPoNotificationBody(workListData!.nOTIFICATIONID!, -999); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void notificationGetRespondAttributes() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getNotificationRespondAttributes = await WorkListApiClient().notificationGetRespondAttributes(workListData!.nOTIFICATIONID!); + if (getNotificationRespondAttributes.isNotEmpty) { + notificationNoteInput = getNotificationRespondAttributes.first; + } + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getNotificationButtons() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + notificationButtonsList = await WorkListApiClient().getNotificationButtons(workListData!.nOTIFICATIONID!); + if (notificationButtonsList.isNotEmpty) { + isCloseAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "CLOSE"); + isApproveAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "APPROVED"); + isRejectAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "REJECTED"); + } + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getActionHistory() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + actionHistoryList = await WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getAttachments() async { + try { + // if (apiCallCount == 0) Utils.showLoading(context); + // apiCallCount++; + getAttachmentList = await WorkListApiClient().getAttachments(workListData!.nOTIFICATIONID!); + // apiCallCount--; + // if (apiCallCount == 0) { + // Utils.hideLoading(context); + setState(() {}); + // } + } catch (ex) { + // apiCallCount--; + // Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } } From e7d2299b43fd9787f206fd37420066e4b059ff09 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 19 Oct 2022 16:38:46 +0300 Subject: [PATCH 18/21] improvement. --- lib/ui/work_list/worklist_detail_screen.dart | 25 ++++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/ui/work_list/worklist_detail_screen.dart b/lib/ui/work_list/worklist_detail_screen.dart index 1fbab01..4494eb6 100644 --- a/lib/ui/work_list/worklist_detail_screen.dart +++ b/lib/ui/work_list/worklist_detail_screen.dart @@ -127,7 +127,7 @@ class _WorkListDetailScreenState extends State { getPoNotification(); } if (workListData!.iTEMTYPE == "REQAPPRV") { - getPrNotificationBody = await WorkListApiClient().getPRNotificationBody(workListData!.nOTIFICATIONID!, -999); + getPRNotification(); } notificationGetRespondAttributes(); @@ -471,9 +471,7 @@ class _WorkListDetailScreenState extends State { child: isIconAsset ? SvgPicture.asset(icon) : Image.memory( - Utils.dataFromBase64String( - icon - ), + Utils.dataFromBase64String(icon), fit: BoxFit.cover, ), ) @@ -490,7 +488,7 @@ class _WorkListDetailScreenState extends State { notificationGetRespond: notificationNoteInput, textEditingController: textEditingController, onTap: (note) { - if(note.isNotEmpty && (actionMode == "APPROVED" || actionMode == "APPROVE")) { + if (note.isNotEmpty && (actionMode == "APPROVED" || actionMode == "APPROVE")) { Map payload = { "P_ACTION_MODE": actionMode, "P_APPROVER_INDEX": null, @@ -701,6 +699,23 @@ class _WorkListDetailScreenState extends State { } } + void getPRNotification() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getPrNotificationBody = await WorkListApiClient().getPRNotificationBody(workListData!.nOTIFICATIONID!, -999); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + void notificationGetRespondAttributes() async { try { if (apiCallCount == 0) Utils.showLoading(context); From 4024e5fd3fbc7d8872ffbdff972b41956ab8c3f1 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 19 Oct 2022 17:05:12 +0300 Subject: [PATCH 19/21] updates & fixes --- lib/ui/landing/dashboard_screen.dart | 21 ++++++++++++------- .../add_leave_balance_screen.dart | 6 +++--- lib/ui/my_team/employee_details.dart | 2 +- lib/ui/my_team/my_team.dart | 2 +- lib/ui/my_team/team_members.dart | 2 +- lib/ui/profile/profile_screen.dart | 2 +- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index cf14b3a..70893ec 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -169,11 +169,14 @@ class _DashboardScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ 9.height, - CountdownTimer( - endTime: model.endTime, - onEnd: null, - endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), - textStyle: const TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold), + Directionality( + textDirection: TextDirection.ltr, + child: CountdownTimer( + endTime: model.endTime, + onEnd: null, + endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), + textStyle: const TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold), + ), ), LocaleKeys.timeLeftToday.tr().toText12(color: Colors.white), 9.height, @@ -206,16 +209,18 @@ class _DashboardScreenState extends State { .toText14(color: Colors.white, isBold: true), 4.height, ], - ).paddingOnly(left: 12), + ).paddingOnly(left: 12, right: 12), ), Container( + margin: EdgeInsets.only(top: AppState().isArabic(context) ? 6 : 0), width: 45, height: 45, padding: const EdgeInsets.only(left: 14, right: 14), - decoration: const BoxDecoration( + decoration: BoxDecoration( color: Color(0xff259EA4), borderRadius: BorderRadius.only( - bottomRight: Radius.circular(15), + bottomRight: AppState().isArabic(context) ? Radius.circular(0) : Radius.circular(15), + bottomLeft: AppState().isArabic(context) ? Radius.circular(15) : Radius.circular(0), ), ), child: SvgPicture.asset(model.isTimeRemainingInSeconds == 0 ? "assets/images/play.svg" : "assets/images/stop.svg"), diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index eb8e493..9cfbac9 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -175,7 +175,7 @@ class _AddLeaveBalanceScreenState extends State { 12.height, DynamicTextFieldWidget( LocaleKeys.startDateT.tr() + "*", - startDateTime == null ? "Select date" : startDateTime.toString().split(' ')[0], + startDateTime == null ? LocaleKeys.pleaseSelectDate.tr() : startDateTime.toString().split(' ')[0], suffixIconData: Icons.calendar_today, isEnable: false, onTap: () async { @@ -189,7 +189,7 @@ class _AddLeaveBalanceScreenState extends State { 12.height, DynamicTextFieldWidget( LocaleKeys.endDateT.tr() + "*", - endDateTime == null ? "Select date" : endDateTime.toString().split(' ')[0], + endDateTime == null ? LocaleKeys.pleaseSelectDate.tr() : endDateTime.toString().split(' ')[0], suffixIconData: Icons.calendar_today, isEnable: false, isReadOnly: selectedAbsenceType == null || startDateTime == null, @@ -206,7 +206,7 @@ class _AddLeaveBalanceScreenState extends State { 12.height, DynamicTextFieldWidget( LocaleKeys.totalDays.tr(), - totalDays?.toString() ?? "Calculated days", + totalDays?.toString() ?? LocaleKeys.calculatedDays.tr(), isInputTypeNum: true, isEnable: false, onChange: (input) { diff --git a/lib/ui/my_team/employee_details.dart b/lib/ui/my_team/employee_details.dart index 3b65954..e33dad8 100644 --- a/lib/ui/my_team/employee_details.dart +++ b/lib/ui/my_team/employee_details.dart @@ -73,7 +73,7 @@ class _EmployeeDetailsState extends State { Container( height: 200, margin: EdgeInsets.only(top: 30), - decoration: BoxDecoration(image: DecorationImage(image: MemoryImage(Utils.getPostBytes(getEmployeeSubordinates!.eMPLOYEEIMAGE)), fit: BoxFit.cover)), + decoration: BoxDecoration(image: DecorationImage(image: MemoryImage(Utils.dataFromBase64String(getEmployeeSubordinates!.eMPLOYEEIMAGE!)), fit: BoxFit.cover)), child: new BackdropFilter( filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), child: new Container( diff --git a/lib/ui/my_team/my_team.dart b/lib/ui/my_team/my_team.dart index bbdce84..6e83972 100644 --- a/lib/ui/my_team/my_team.dart +++ b/lib/ui/my_team/my_team.dart @@ -141,7 +141,7 @@ class _MyTeamState extends State { width: 34, child: CircleAvatar( radius: 25, - backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSListOnSearch[index].eMPLOYEEIMAGE)), + backgroundImage: MemoryImage(Utils.dataFromBase64String(getEmployeeSListOnSearch[index].eMPLOYEEIMAGE!)), backgroundColor: Colors.black, ).paddingOnly(top: 4), ), diff --git a/lib/ui/my_team/team_members.dart b/lib/ui/my_team/team_members.dart index 7ba015f..50bf7e7 100644 --- a/lib/ui/my_team/team_members.dart +++ b/lib/ui/my_team/team_members.dart @@ -85,7 +85,7 @@ class _TeamMembersState extends State { width: 34, child: CircleAvatar( radius: 25, - backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSubordinatesList[index].eMPLOYEEIMAGE)), + backgroundImage: MemoryImage(Utils.dataFromBase64String(getEmployeeSubordinatesList[index].eMPLOYEEIMAGE!)), backgroundColor: Colors.black, ).paddingOnly(top: 4), ), diff --git a/lib/ui/profile/profile_screen.dart b/lib/ui/profile/profile_screen.dart index e72d3a9..690633b 100644 --- a/lib/ui/profile/profile_screen.dart +++ b/lib/ui/profile/profile_screen.dart @@ -50,7 +50,7 @@ class _ProfileScreenState extends State { decoration: BoxDecoration( image: DecorationImage( image: MemoryImage( - Utils.getPostBytes(memberInformationList.eMPLOYEEIMAGE), + Utils.dataFromBase64String(memberInformationList.eMPLOYEEIMAGE!), ), fit: BoxFit.cover), ), From aabc86290a3a795ca8fb481e5e87b290075cfd34 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 19 Oct 2022 17:50:29 +0300 Subject: [PATCH 20/21] Language change option added in app drawer --- lib/app_state/app_state.dart | 2 ++ lib/models/post_params_model.dart | 2 ++ lib/ui/landing/dashboard_screen.dart | 2 +- lib/ui/landing/widget/app_drawer.dart | 34 +++++++++++++++++++++++ lib/ui/profile/widgets/profile_panel.dart | 2 +- 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index ceb4881..44de36f 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -73,6 +73,8 @@ class AppState { bool isArabic(context) => EasyLocalization.of(context)?.locale.languageCode == "ar"; + int getLanguageID(context) => EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2; + String? _username; // todo ''sikander' added password for now, later will remove & improve diff --git a/lib/models/post_params_model.dart b/lib/models/post_params_model.dart index b44bec9..05356c2 100644 --- a/lib/models/post_params_model.dart +++ b/lib/models/post_params_model.dart @@ -1,3 +1,5 @@ +import 'package:mohem_flutter_app/app_state/app_state.dart'; + class PostParamsModel { double? versionID; int? channel; diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 70893ec..476abd1 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -365,7 +365,7 @@ class _DashboardScreenState extends State { ], ), drawer: SafeArea( - child: AppDrawer(), + child: AppDrawer(onLanguageChange: _onRefresh), ), bottomNavigationBar: SizedBox( height: Platform.isAndroid ? 70 : 100, diff --git a/lib/ui/landing/widget/app_drawer.dart b/lib/ui/landing/widget/app_drawer.dart index d828270..67adfcb 100644 --- a/lib/ui/landing/widget/app_drawer.dart +++ b/lib/ui/landing/widget/app_drawer.dart @@ -18,6 +18,10 @@ import 'package:mohem_flutter_app/widgets/dialogs/dialogs.dart'; import 'package:provider/provider.dart'; class AppDrawer extends StatefulWidget { + final Function onLanguageChange; + + AppDrawer({required this.onLanguageChange}); + @override _AppDrawerState createState() => _AppDrawerState(); } @@ -65,6 +69,28 @@ class _AppDrawerState extends State { ).expanded ], ).paddingOnly(left: 14, right: 14, top: 21, bottom: 21), + Row( + children: [ + Row( + children: [ + LocaleKeys.english.tr().toText14(color: AppState().isArabic(context) ? null : MyColors.textMixColor).onPress(() { + context.setLocale(const Locale("en", "US")); + postLanguageChange(context); + }), + Container( + width: 1, + color: MyColors.darkWhiteColor, + height: 16, + margin: const EdgeInsets.only(left: 10, right: 10), + ), + LocaleKeys.arabic.tr().toText14(color: !AppState().isArabic(context) ? null : MyColors.textMixColor).onPress(() { + context.setLocale(const Locale("ar", "SA")); + postLanguageChange(context); + }), + ], + ), + ], + ).paddingOnly(left: 14, right: 14, bottom: 14), const Divider( height: 1, thickness: 1, @@ -132,6 +158,14 @@ class _AppDrawerState extends State { : onPress!); } + void postLanguageChange(BuildContext context) { + var obj = AppState().postParamsObject; + obj?.languageID = EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2; + AppState().setPostParamsModel(obj!); + Navigator.pop(context); + widget.onLanguageChange(); + } + void performLogout() async { AppState().isAuthenticated = false; AppState().isLogged = false; diff --git a/lib/ui/profile/widgets/profile_panel.dart b/lib/ui/profile/widgets/profile_panel.dart index 2678599..5018171 100644 --- a/lib/ui/profile/widgets/profile_panel.dart +++ b/lib/ui/profile/widgets/profile_panel.dart @@ -49,7 +49,7 @@ class ProfilePanel extends StatelessWidget { width: 68,) : CircleAvatar( radius: 68, - backgroundImage: MemoryImage(Utils.getPostBytes(memberInformationList.eMPLOYEEIMAGE)), + backgroundImage: MemoryImage(Utils.dataFromBase64String(memberInformationList.eMPLOYEEIMAGE!)), backgroundColor: Colors.black, ); } From defa8a8adb4015dae2572b263d21bba9cf609def Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 20 Oct 2022 16:35:07 +0300 Subject: [PATCH 21/21] redirection added on worklist detail when approve or reject. --- assets/langs/ar-SA.json | 2 + assets/langs/en-US.json | 2 + lib/generated/locale_keys.g.dart | 2 + lib/ui/landing/dashboard_screen.dart | 2 +- lib/ui/work_list/itg_detail_screen.dart | 28 +++++++++-- lib/ui/work_list/work_list_screen.dart | 2 + lib/ui/work_list/worklist_detail_screen.dart | 49 +++++++++++++------- lib/widgets/mark_attendance_widget.dart | 5 +- 8 files changed, 68 insertions(+), 24 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 161bde6..f5d9495 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -419,6 +419,8 @@ "adult": "بالغ", "updateMember": "هل انت متأكد تريد تحديث بيانات هذا العضو؟", "fieldIsEmpty": "'{data}' الحقل فارغ. الرجاء التحديد", + "pleaseEnterComments": "الرجاء إدخال التعليقات", + "skip": "يتخطى", "profile": { "reset_password": { "label": "Reset Password", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index b88b14c..640afdb 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -419,6 +419,8 @@ "adult": "Adult", "updateMember": "Are You Sure You Want to Update this Member?", "fieldIsEmpty": "'{data}' Field is empty. Please select", + "pleaseEnterComments": "Please enter comments", + "skip": "skip", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index b17f5ba..d2fae58 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -420,6 +420,8 @@ abstract class LocaleKeys { static const adult = 'adult'; static const updateMember = 'updateMember'; static const fieldIsEmpty = 'fieldIsEmpty'; + static const pleaseEnterComments = 'pleaseEnterComments'; + static const skip = 'skip'; 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/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index cf14b3a..c80c1a9 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -257,7 +257,7 @@ class _DashboardScreenState extends State { border: Border.all(color: MyColors.lightGreyEDColor, width: 1), ), child: Column( - mainAxisSize: MainAxisSize.min, + mainAxisSize: MainAxisSize.min,crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, diff --git a/lib/ui/work_list/itg_detail_screen.dart b/lib/ui/work_list/itg_detail_screen.dart index 491672f..c9329a1 100644 --- a/lib/ui/work_list/itg_detail_screen.dart +++ b/lib/ui/work_list/itg_detail_screen.dart @@ -203,7 +203,7 @@ class _ItgDetailScreenState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.end, children: [ - myFab("Skip", "assets/images/skip.svg").onPress(() { + myFab(LocaleKeys.pleaseEnterComments.tr(), "assets/images/skip.svg").onPress(() { if (AppState().requestAllList!.length - 1 > AppState().itgWorkListIndex!) { AppState().itgWorkListIndex = AppState().itgWorkListIndex! + 1; requestDetails = null; @@ -356,7 +356,18 @@ class _ItgDetailScreenState extends State { ITGRequest? itgRequest = await WorkListApiClient().rejectITGRequest(requestType, taskId, itemId, employeeNumber, comments); Utils.hideLoading(context); Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr()); - Navigator.pop(context, "delegate_reload"); + // Navigator.pop(context, "delegate_reload"); + AppState().workList!.removeAt(AppState().workListIndex!); + if (AppState().workList!.isEmpty) { + Navigator.pop(context, "delegate_reload"); + } else { + if (AppState().workList!.length <= AppState().workListIndex!) { + Navigator.pop(context, "delegate_reload"); + } else { + requestDetails = null; + getDataFromState(); + } + } } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); @@ -369,7 +380,18 @@ class _ItgDetailScreenState extends State { ITGRequest? itgRequest = await WorkListApiClient().approveITGRequest(requestType, taskId, itemId, employeeNumber, comments); Utils.hideLoading(context); Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr()); - Navigator.pop(context, "delegate_reload"); + // Navigator.pop(context, "delegate_reload"); + AppState().workList!.removeAt(AppState().workListIndex!); + if (AppState().workList!.isEmpty) { + Navigator.pop(context, "delegate_reload"); + } else { + if (AppState().workList!.length <= AppState().workListIndex!) { + Navigator.pop(context, "delegate_reload"); + } else { + requestDetails = null; + getDataFromState(); + } + } } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); diff --git a/lib/ui/work_list/work_list_screen.dart b/lib/ui/work_list/work_list_screen.dart index 35c3c17..369bf0c 100644 --- a/lib/ui/work_list/work_list_screen.dart +++ b/lib/ui/work_list/work_list_screen.dart @@ -442,6 +442,8 @@ class _WorkListScreenState extends State { calculateCounter(); if (mounted) setState(() {}); } + } else { + if (mounted) setState(() {}); } }, child: Container( diff --git a/lib/ui/work_list/worklist_detail_screen.dart b/lib/ui/work_list/worklist_detail_screen.dart index 4494eb6..7aea35e 100644 --- a/lib/ui/work_list/worklist_detail_screen.dart +++ b/lib/ui/work_list/worklist_detail_screen.dart @@ -307,7 +307,7 @@ class _WorkListDetailScreenState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.end, children: [ - myFab("Skip", "assets/images/skip.svg").onPress(() { + myFab(LocaleKeys.pleaseEnterComments.tr(), "assets/images/skip.svg").onPress(() { if (AppState().workList!.length - 1 > AppState().workListIndex!) { AppState().setWorkListIndex = AppState().workListIndex! + 1; workListData = null; @@ -481,6 +481,7 @@ class _WorkListDetailScreenState extends State { void performAction(String actionMode) { TextEditingController textEditingController = TextEditingController(); + print("actionMode:$actionMode"); showDialog( context: context, builder: (cxt) => AcceptRejectInputDialog( @@ -488,24 +489,26 @@ class _WorkListDetailScreenState extends State { notificationGetRespond: notificationNoteInput, textEditingController: textEditingController, onTap: (note) { - if (note.isNotEmpty && (actionMode == "APPROVED" || actionMode == "APPROVE")) { - Map payload = { - "P_ACTION_MODE": actionMode, - "P_APPROVER_INDEX": null, - "P_COMMENTS": note, - "P_FORWARD_TO_USER_NAME": "", - "P_NOTIFICATION_ID": workListData!.nOTIFICATIONID, - "RespondAttributeList": [ - if (notificationNoteInput != null) - { - "ATTRIBUTE_NAME": notificationNoteInput!.attributeName, - if (notificationNoteInput!.attributeType == "number") "ATTRIBUTE_NUMBER_VALUE": note else if (notificationNoteInput!.attributeType == "VARCHAR2") "ATTRIBUTE_TEXT_VALUE": note - } - ], - }; + Map payload = { + "P_ACTION_MODE": actionMode, + "P_APPROVER_INDEX": null, + "P_COMMENTS": note, + "P_FORWARD_TO_USER_NAME": "", + "P_NOTIFICATION_ID": workListData!.nOTIFICATIONID, + "RespondAttributeList": [ + if (notificationNoteInput != null) + { + "ATTRIBUTE_NAME": notificationNoteInput!.attributeName, + if (notificationNoteInput!.attributeType == "number") "ATTRIBUTE_NUMBER_VALUE": note else if (notificationNoteInput!.attributeType == "VARCHAR2") "ATTRIBUTE_TEXT_VALUE": note + } + ], + }; + if (actionMode == "APPROVED" || actionMode == "APPROVE") { + performNotificationAction(payload); + } else if (note.isNotEmpty && (actionMode != "APPROVED" || actionMode != "APPROVE")) { performNotificationAction(payload); } else { - Utils.showToast("Please enter comments"); + Utils.showToast(LocaleKeys.pleaseEnterComments.tr()); } }, ), @@ -518,7 +521,17 @@ class _WorkListDetailScreenState extends State { GenericResponseModel model = await WorkListApiClient().postNotificationActions(payload); Utils.hideLoading(context); Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr()); - Navigator.pop(context, true); + AppState().workList!.removeAt(AppState().workListIndex!); + if (AppState().workList!.isEmpty) { + Navigator.pop(context, "delegate_reload"); + } else { + if (AppState().workList!.length <= AppState().workListIndex!) { + Navigator.pop(context, "delegate_reload"); + } else { + workListData = null; + getDataFromState(); + } + } } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); diff --git a/lib/widgets/mark_attendance_widget.dart b/lib/widgets/mark_attendance_widget.dart index 2ccd98b..90c57e3 100644 --- a/lib/widgets/mark_attendance_widget.dart +++ b/lib/widgets/mark_attendance_widget.dart @@ -85,7 +85,8 @@ class _MarkAttendanceWidgetState extends State { 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), + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: (MediaQuery.of(context).size.width < 400) ? 3 : 5, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8), children: [ // if (isNfcEnabled) attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () { @@ -238,7 +239,7 @@ class _MarkAttendanceWidgetState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - SvgPicture.asset(image, color: Colors.white).expanded, + SvgPicture.asset(image, color: Colors.white, alignment: Alignment.topLeft).expanded, title.toText17(isBold: true, color: Colors.white), ], ),