diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 8a09315..8a41c93 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", @@ -454,6 +456,17 @@ "reset_locale": "إعادة ضبط اللغة", "chat": "دردشة", "mychats": "دردشاتي", + "advancedSearch": "بحث متقدم", + "openNot": "التبليغات المفتوحة", + "fyi": "تبليغات للعلم", + "toDo": "تبليغات الأعمال", + "all": "كل التبليغات", + "meNot": "تبليغات صادرة مني", + "view": "عرض", + "fromUserName": "من", + "sentDate": "تاريخ الإرسال", + "itemTypeDisplayName": "اسم العرض", + "none": "بدون", "createNewChat": "إنشاء محادثة جديدة", "brainMarathon": "ماراثون الدماغ", "contestTopicAbout": "سيكون موضوع المسابقة حول:", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 847d01b..4717c8b 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", @@ -470,5 +472,16 @@ "sponsoredBy": "Sponsored By:", "question": "Question", "marathoners": "Marathoners", - "prize": "Prize:" + "prize": "Prize:", + "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/chat/chat_provider_model.dart b/lib/api/chat/chat_provider_model.dart index d5b6fb3..ea6ea13 100644 --- a/lib/api/chat/chat_provider_model.dart +++ b/lib/api/chat/chat_provider_model.dart @@ -2,15 +2,20 @@ import 'dart:convert'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:http/http.dart'; -import 'package:logger/logger.dart' as L; 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; class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { List userChatHistory = []; @@ -19,21 +24,35 @@ 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; - void getChatMemberFromSearch(String sName, int cUserId) async { - isLoading = true; - notifyListeners(); - Response response = await ApiClient().getJsonForResponse("${ApiConsts.chatSearchMember}$sName/$cUserId", token: token); + 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(); + } + + Future?> getChatMemberFromSearch(String sName, int cUserId) async { + Response response = await ApiClient().getJsonForResponse( + "${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}", token: token); + Response response = await ApiClient().getJsonForResponse( + "${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatRecentUrl}", + token: AppState().chatDetails!.response!.token, + ); ChatUserModel recentChat = userToList(response.body); pChatHistory = recentChat.response; searchedChats = pChatHistory; @@ -45,24 +64,31 @@ 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, ); - userChatHistory = getSingleUserChatintoModel(response.body); + logger.d(response.statusCode); + print(response.body); + if (response.statusCode == 204) { + userChatHistory = []; + } else { + userChatHistory = getSingleUserChatModel(response.body); + } isLoading = false; - logger.d(jsonEncode(userChatHistory)); 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)); - 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")) + .configureLogging( + Logger("Logs Enabled"), + ) .build(); hubConnection.onclose( ({Exception? error}) { @@ -84,21 +110,65 @@ 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(); - for (var user in searchedChats!) { + logger.d(items); + for (ChatUser user in searchedChats!) { if (user.id == items.first["id"]) { user.userStatus = items.first["userStatus"]; } @@ -111,7 +181,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); } @@ -124,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); @@ -155,7 +225,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( @@ -165,8 +235,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, ), @@ -182,9 +252,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/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..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'; @@ -28,7 +29,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 +38,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) { @@ -231,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 = { @@ -481,12 +501,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 +513,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/app_state/app_state.dart b/lib/app_state/app_state.dart index d7f6a9d..44de36f 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'; @@ -72,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 @@ -116,4 +119,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/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index 45e3293..9ee4546 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -99,19 +99,10 @@ extension EmailValidator on String { 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( diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index e7c6880..16d2aff 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -486,7 +486,18 @@ class CodegenLoader extends AssetLoader{ "sponsoredBy": "برعاية:", "question": "سؤال", "marathoners": "الماراثون", - "prize": "جائزة:" + "prize": "جائزة:", + "advancedSearch": "بحث متقدم", + "openNot": "التبليغات المفتوحة", + "fyi": "تبليغات للعلم", + "toDo": "تبليغات الأعمال", + "all": "كل التبليغات", + "meNot": "تبليغات صادرة مني", + "view": "عرض", + "fromUserName": "من", + "sentDate": "تاريخ الإرسال", + "itemTypeDisplayName": "اسم العرض", + "none": "بدون" }; static const Map en_US = { "mohemm": "Mohemm", @@ -961,6 +972,18 @@ static const Map en_US = { "question": "Question", "marathoners": "Marathoners", "prize": "Prize:" + "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 4d1ffb4..95dd6d3 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'; @@ -457,5 +459,16 @@ abstract class LocaleKeys { static const question = 'question'; static const marathoners = 'marathoners'; static const prize = 'prize'; + 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/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/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/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/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_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..ef984a3 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]}, ); }, ); @@ -161,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/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/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 7c78bc9..c85b383 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -82,7 +82,7 @@ class _DashboardScreenState extends State { mainAxisSize: MainAxisSize.min, children: [ Image.memory( - Utils.getPostBytes( + Utils.dataFromBase64String( AppState().memberInformationList!.eMPLOYEEIMAGE ?? "", ), errorBuilder: (BuildContext context, Object error, @@ -186,58 +186,25 @@ class _DashboardScreenState extends State { children: [ Expanded( child: Column( - mainAxisSize: - MainAxisSize - .min, - crossAxisAlignment: - CrossAxisAlignment - .start, + mainAxisSize: MainAxisSize.min, + 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) + LocaleKeys.markAttendance.tr().toText14(color: Colors.white, isBold: true), + if (model.isTimeRemainingInSeconds == 0) DateTime.now().toString().split(" ")[0].toText12(color: Colors.white), + if (model.isTimeRemainingInSeconds != 0) Column( - mainAxisSize: - MainAxisSize - .min, - crossAxisAlignment: - CrossAxisAlignment - .start, + mainAxisSize: MainAxisSize.min, + 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 @@ -282,61 +249,29 @@ class _DashboardScreenState extends State { CrossAxisAlignment .start, children: [ - LocaleKeys - .checkIn - .tr() - .toText12( - color: - Colors.white), - (model.attendanceTracking!.pSwipeIn == - null - ? "--:--" - : model - .attendanceTracking! - .pSwipeIn) + LocaleKeys.checkIn.tr().toText12(color: Colors.white), + (model.attendanceTracking!.pSwipeIn == null ? "--:--" : model.attendanceTracking!.pSwipeIn) .toString() - .toText14( - color: Colors - .white, - isBold: - true), + .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( - color: Color( - 0xff259EA4), - borderRadius: - BorderRadius - .only( - bottomRight: Radius - .circular( - 15), + padding: const EdgeInsets.only(left: 14, right: 14), + decoration: BoxDecoration( + color: Color(0xff259EA4), + borderRadius: BorderRadius.only( + 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"), + child: SvgPicture.asset(model.isTimeRemainingInSeconds == 0 ? "assets/images/play.svg" : "assets/images/stop.svg"), ).onPress(() { - showMyBottomSheet( - context, - child: - MarkAttendanceWidget( - model)); + showMyBottomSheet(context, child: MarkAttendanceWidget(model)); }), ], ), @@ -346,10 +281,7 @@ class _DashboardScreenState extends State { ), ).onPress( () { - Navigator.pushNamed( - context, - AppRoutes - .todayAttendance); + Navigator.pushNamed(context, AppRoutes.todayAttendance); }, )) .animatedSwither(); @@ -364,28 +296,19 @@ class _DashboardScreenState extends State { ], ), ], - ).paddingOnly(left: 20, right: 20, top: 7), - MarathonBanner().paddingOnly( - left: 20, - right: 20, - top: 11, - bottom: 11, - ), + ).paddingOnly(left: 21, right: 21, top: 7), ServicesWidget(), + // 8.height, Container( width: double.infinity, padding: const EdgeInsets.only(top: 31), decoration: BoxDecoration( color: Colors.white, - borderRadius: const BorderRadius.only( - topRight: Radius.circular(50), - topLeft: Radius.circular(50), - ), - border: Border.all( - color: MyColors.lightGreyEDColor, width: 1), + borderRadius: const BorderRadius.only(topRight: Radius.circular(50), topLeft: Radius.circular(50)), + border: Border.all(color: MyColors.lightGreyEDColor, width: 1), ), child: Column( - mainAxisSize: MainAxisSize.min, + mainAxisSize: MainAxisSize.min,crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, @@ -398,45 +321,33 @@ class _DashboardScreenState extends State { LocaleKeys.offers.tr().toText12(), Row( children: [ - LocaleKeys.discounts - .tr() - .toText24(isBold: true), + LocaleKeys.discounts.tr().toText24(isBold: true), 6.width, Container( - padding: const EdgeInsets.only( - left: 8, right: 8), + padding: const EdgeInsets.only(left: 8, right: 8), decoration: BoxDecoration( color: MyColors.yellowColor, - borderRadius: - BorderRadius.circular(10), + borderRadius: BorderRadius.circular(10), ), - child: LocaleKeys.newString - .tr() - .toText10(isBold: true)), + child: LocaleKeys.newString.tr().toText10(isBold: true)), ], ), ], ), ), - LocaleKeys.viewAllOffers - .tr() - .toText12(isUnderLine: true) - .onPress(() { - Navigator.pushNamed( - context, AppRoutes.offersAndDiscounts); + LocaleKeys.viewAllOffers.tr().toText12(isUnderLine: true).onPress(() { + Navigator.pushNamed(context, AppRoutes.offersAndDiscounts); }) ], ).paddingOnly(left: 21, right: 21), Consumer( - builder: (BuildContext context, - DashboardProviderModel model, Widget? child) { + builder: (context, model, child) { return SizedBox( height: 103 + 33, child: ListView.separated( shrinkWrap: true, physics: const BouncingScrollPhysics(), - padding: const EdgeInsets.only( - left: 21, right: 21, top: 13), + padding: const EdgeInsets.only(left: 21, right: 21, top: 13), scrollDirection: Axis.horizontal, itemBuilder: (BuildContext cxt, int index) { return model.isOffersLoading @@ -461,30 +372,17 @@ class _DashboardScreenState extends State { .all( Radius.circular(100), ), - border: Border.all( - color: MyColors - .lightGreyE3Color, - width: 1), + border: Border.all(color: MyColors.lightGreyE3Color, width: 1), ), child: ClipRRect( - borderRadius: - const BorderRadius - .all( + borderRadius: const BorderRadius.all( Radius.circular(50), ), child: Hero( - tag: "ItemImage" + - data - .getOffersList[ - index] - .rowID!, - transitionOnUserGestures: - true, + tag: "ItemImage" + data.getOffersList[index].rowID!, + transitionOnUserGestures: true, child: Image.network( - data - .getOffersList[ - index] - .bannerImage!, + data.getOffersList[index].bannerImage!, fit: BoxFit.contain, ), ), @@ -492,24 +390,9 @@ class _DashboardScreenState extends State { ), 4.height, Expanded( - child: AppState() - .isArabic(context) - ? data - .getOffersList[ - index] - .titleAR! - .toText12( - isCenter: - true, - maxLine: 1) - : data - .getOffersList[ - index] - .title! - .toText12( - isCenter: - true, - maxLine: 1), + child: AppState().isArabic(context) + ? data.getOffersList[index].titleAR!.toText12(isCenter: true, maxLine: 1) + : data.getOffersList[index].title!.toText12(isCenter: true, maxLine: 1), ), ], ), @@ -534,7 +417,7 @@ class _DashboardScreenState extends State { ], ), drawer: SafeArea( - child: AppDrawer(), + child: AppDrawer(onLanguageChange: _onRefresh), ), bottomNavigationBar: SizedBox( height: Platform.isAndroid ? 70 : 100, @@ -601,7 +484,7 @@ class _DashboardScreenState extends State { ? MyColors.grey3AColor : MyColors.grey98Color, ).paddingAll(4), - label: LocaleKeys.chat.tr(), + label: LocaleKeys.itemsForSale.tr(), ), BottomNavigationBarItem( icon: SvgPicture.asset( diff --git a/lib/ui/landing/widget/app_drawer.dart b/lib/ui/landing/widget/app_drawer.dart index ea6343b..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(); } @@ -52,7 +56,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, @@ -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/landing/widget/services_widget.dart b/lib/ui/landing/widget/services_widget.dart index 854fa43..d822920 100644 --- a/lib/ui/landing/widget/services_widget.dart +++ b/lib/ui/landing/widget/services_widget.dart @@ -76,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)), ], ) ], @@ -118,9 +114,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")).toList() ?? []; menuEntry.icon = ""; - print(menuEntry.toJson()); if (menuList.isEmpty) { if (menuEntry.requestType == "EIT") { Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(menuEntry.prompt!, menuEntry.functionName!)); @@ -128,7 +123,9 @@ 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() ?? []; + Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, _menuList.isEmpty ? menuList : _menuList)); } return; } diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index 5fce5ec..e1c58c2 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); @@ -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) { @@ -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/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index d9f73a1..8cd93e4 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 @@ -138,11 +139,12 @@ class _LoginScreenState extends State { @override Widget build(BuildContext context) { if (isAppOpenBySystem == null) { - isAppOpenBySystem = - (ModalRoute.of(context)!.settings.arguments ?? true) as bool; - - username.text = "15153"; - password.text = "Abcd@12345"; + isAppOpenBySystem = (ModalRoute.of(context)!.settings.arguments ?? true) as bool; + if (kDebugMode) { + // username.text = "15444"; // Maha User + username.text = "15153"; // Tamer User + password.text = "Abcd@12345"; + } if (isAppOpenBySystem!) checkFirebaseToken(); } 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/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), ), 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, ); } 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/itg_detail_screen.dart b/lib/ui/work_list/itg_detail_screen.dart index b1deae8..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; @@ -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 @@ -355,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); @@ -368,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/sheets/delegate_sheet.dart b/lib/ui/work_list/sheets/delegate_sheet.dart index 1dbc30c..75b33c9 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(); @@ -204,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/work_list_screen.dart b/lib/ui/work_list/work_list_screen.dart index 1eaac3e..369bf0c 100644 --- a/lib/ui/work_list/work_list_screen.dart +++ b/lib/ui/work_list/work_list_screen.dart @@ -1,4 +1,5 @@ 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 +19,8 @@ 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/bottom_sheets/worklist_advance_search_bottom_sheet.dart'; import 'package:provider/provider.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; @@ -87,6 +90,10 @@ class _WorkListScreenState extends State { final RefreshController _refreshController = RefreshController(initialRefresh: false); + final ScrollController _controller = ScrollController(); + + int pNotificationType = 1; + @override void initState() { super.initState(); @@ -132,7 +139,7 @@ class _WorkListScreenState extends State { } } else { itgRequestTypeIndex = null; - workList = await WorkListApiClient().getWorkList(pageNumber, workListItemTypes[workListItemIndex].key); + workList = await WorkListApiClient().getWorkList(pageNumber, workListItemTypes[workListItemIndex].key, pNotificationType.toString()); AppState().setWorkList = workList; } if (showLoading) Utils.hideLoading(context); @@ -152,6 +159,7 @@ class _WorkListScreenState extends State { getWorkList(showLoading: false), ]); calculateCounter(); + Utils.hideLoading(context); setState(() {}); } catch (ex) { Utils.hideLoading(context); @@ -183,6 +191,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), @@ -191,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) { @@ -213,7 +225,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, color: MyColors.textMixColor).onPress(() { + openBottomSheet(context); + }).paddingOnly(left: 21, right: 21) + ], + ), SmartRefresher( enablePullDown: true, enablePullUp: false, @@ -364,6 +384,38 @@ class _WorkListScreenState extends State { ); } + void openBottomSheet(BuildContext context) { + showMyBottomSheet( + context, + 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(() {}); + }), + ); + } + Widget rowItem(WorkListItemTypeModelData data, WorkListResponseModel workData, int index) { return InkWell( onTap: () async { @@ -390,6 +442,8 @@ class _WorkListScreenState extends State { calculateCounter(); if (mounted) setState(() {}); } + } else { + if (mounted) setState(() {}); } }, child: Container( @@ -442,4 +496,12 @@ class _WorkListScreenState extends State { ), ); } + + void _animateToIndex(int index, double width) { + _controller.animateTo( + index * width, + duration: const Duration(seconds: 1), + curve: Curves.fastOutSlowIn, + ); + } } diff --git a/lib/ui/work_list/worklist_detail_screen.dart b/lib/ui/work_list/worklist_detail_screen.dart index 94c7208..7aea35e 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; @@ -93,91 +93,77 @@ 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(); + } + if (workListData!.iTEMTYPE == "REQAPPRV") { + getPRNotification(); + } - 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]; + notificationGetRespondAttributes(); - // 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); - } + // 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) { @@ -243,6 +229,7 @@ class _WorkListDetailScreenState extends State { getBasicDetNtfBodyList: getBasicDetNtfBodyList, getAbsenceCollectionNotificationBodyList: getAbsenceCollectionNotificationBodyList, getContactNotificationBodyList: getContactNotificationBodyList, + getPrNotificationBodyList: getPrNotificationBody, ), (workListData!.iTEMTYPE == "HRSSA" || workListData!.iTEMTYPE == "STAMP") ? DetailFragment(workListData, memberInformationListModel) @@ -250,6 +237,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), @@ -319,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; @@ -376,33 +364,34 @@ 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; } @@ -482,7 +471,7 @@ class _WorkListDetailScreenState extends State { child: isIconAsset ? SvgPicture.asset(icon) : Image.memory( - base64Decode(icon), + Utils.dataFromBase64String(icon), fit: BoxFit.cover, ), ) @@ -491,16 +480,19 @@ class _WorkListDetailScreenState extends State { } void performAction(String actionMode) { + TextEditingController textEditingController = TextEditingController(); + print("actionMode:$actionMode"); 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_COMMENTS": note, "P_FORWARD_TO_USER_NAME": "", "P_NOTIFICATION_ID": workListData!.nOTIFICATIONID, "RespondAttributeList": [ @@ -511,7 +503,13 @@ class _WorkListDetailScreenState extends State { } ], }; - performNotificationAction(payload); + if (actionMode == "APPROVED" || actionMode == "APPROVE") { + performNotificationAction(payload); + } else if (note.isNotEmpty && (actionMode != "APPROVED" || actionMode != "APPROVE")) { + performNotificationAction(payload); + } else { + Utils.showToast(LocaleKeys.pleaseEnterComments.tr()); + } }, ), ); @@ -523,10 +521,287 @@ 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); + } + } + + 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 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); + 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); + } + } } 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 27b1c29..b900578 100644 --- a/lib/ui/work_list/worklist_fragments/request_fragment.dart +++ b/lib/ui/work_list/worklist_fragments/request_fragment.dart @@ -1,12 +1,16 @@ 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'; 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'; 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'; @@ -15,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 @@ -33,72 +39,114 @@ class RequestFragment extends StatelessWidget { if (moNotificationBodyList.isNotEmpty) moNotificationDataView(), if (poLinesList.isNotEmpty) poLinesDataView(), if (itemCreationLines.isNotEmpty) itemCreationLinesView(), + if (prLinesList.isNotEmpty) prLinesDataView(), ], ), ); } 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 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() { 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/bottom_sheets/search_employee_bottom_sheet.dart b/lib/widgets/bottom_sheets/search_employee_bottom_sheet.dart index e807a7b..face11b 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,24 @@ 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())); Utils.hideLoading(context); setState(() {}); } catch (e) { @@ -114,9 +138,8 @@ 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)) ], @@ -134,8 +157,7 @@ class _SearchEmployeeBottomSheetState extends State { ListView.separated( physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, - itemBuilder: (cxt, index) => - employeeItemView(favouriteUserList![index]), + itemBuilder: (cxt, index) => employeeItemView(favouriteUserList![index]), separatorBuilder: (cxt, index) => Container( height: 1, color: MyColors.borderE3Color, @@ -149,8 +171,7 @@ class _SearchEmployeeBottomSheetState extends State { ListView.separated( physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, - itemBuilder: (cxt, index) => employeeItemView( - nonFavouriteUserList![index]), + itemBuilder: (cxt, index) => employeeItemView(nonFavouriteUserList![index]), separatorBuilder: (cxt, index) => Container( height: 1, color: MyColors.borderE3Color, @@ -158,13 +179,68 @@ class _SearchEmployeeBottomSheetState extends State { itemCount: nonFavouriteUserList?.length ?? 0), ] ], - ).expanded + ).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), + ), + ), + ), + ) + ], + ), + 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 +277,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 +300,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)), ), ), 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; + } +} 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 = ""; 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); 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), ], ), diff --git a/pubspec.yaml b/pubspec.yaml index 3f0333c..e621c50 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -83,6 +83,7 @@ dependencies: steps_indicator: ^1.3.0 # Marathon Card Swipe appinio_swiper: ^1.1.1 + expandable: ^5.0.1 #Chat signalr_netcore: ^1.3.3