From da7929bf3ebc6843b9e98b732e71a2cdf1d91629 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 18 Oct 2022 16:51:39 +0300 Subject: [PATCH 1/7] 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 2/7] 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 3/7] 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 4/7] 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 5/7] 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 6/7] 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 7/7] 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(),