diff --git a/lib/api/chat/chat_api_client.dart b/lib/api/chat/chat_api_client.dart index e9a5afa..318a383 100644 --- a/lib/api/chat/chat_api_client.dart +++ b/lib/api/chat/chat_api_client.dart @@ -1,9 +1,7 @@ import 'dart:convert'; import 'dart:io'; -import 'dart:typed_data'; import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; import 'package:http/http.dart'; import 'package:mohem_flutter_app/api/api_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; @@ -310,4 +308,59 @@ class ChatApiClient { throw e; } } + + // CallUser Login Token + + Future getUserCallToken({required String userid}) async { + user.UserAutoLoginModel userLoginResponse = user.UserAutoLoginModel(); + Response response = await ApiClient().postJsonForResponse( + "${ApiConsts.chatLoginTokenUrl}externaluserlogin", + { + "employeeNumber": userid, + "password": "FxIu26rWIKoF8n6mpbOmAjDLphzFGmpG", + }, + ); + + if (!kReleaseMode) { + logger.i("login-res: " + response.body); + } + if (response.statusCode == 200) { + userLoginResponse = user.userAutoLoginModelFromJson(response.body); + } else if (response.statusCode == 501 || response.statusCode == 502 || response.statusCode == 503 || response.statusCode == 504) { + getUserCallToken(userid: userid); + } else { + userLoginResponse = user.userAutoLoginModelFromJson(response.body); + Utils.showToast(userLoginResponse.errorResponses!.first.message!); + } + return userLoginResponse; + } + + // Call Decline On App Terminated State + Future callDecline({required int cUserID, required int tUserID, required String targetUsertoken}) async { + Response response = await ApiClient().postJsonForResponse( + "${ApiConsts.chatLoginTokenUrl}calldecline", + {"currentUserId": cUserID, "targetUserId": tUserID, "secretKey": "derichatmobileuser", "targetUserToken": targetUsertoken}, + ); + print("res: " + response.body); + if (!kReleaseMode) { + logger.i({"currentUserId": cUserID, "targetUserId": tUserID, "secretKey": "derichatmobileuser", "targetUserToken": targetUsertoken}); + print("res: " + response.body); + } + return response; + } + + Future oneSignalVoip(String value) async { + String id = ""; + Response response = await ApiClient().postJsonForResponse( + "${ApiConsts.oneSignalCall}players", + {"app_id": ApiConsts.oneSignalAppID, "identifier": value, "device_type": 0, "test_type": !kReleaseMode ? 1 : 0}, + ); + + Map values = jsonDecode(response.body) as Map; + id = values["id"]; + if (!kReleaseMode) { + print("res: " + response.body); + } + return id; + } } diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index d4276f4..55f9448 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -194,7 +194,6 @@ class AppState { bool cancelRequestTrancsection = true; - String _iosVoipPlayerID = ""; String get iosVoipPlayerID => _iosVoipPlayerID; diff --git a/lib/classes/chat_call_kit.dart b/lib/classes/chat_call_kit.dart index 644c552..35838a5 100644 --- a/lib/classes/chat_call_kit.dart +++ b/lib/classes/chat_call_kit.dart @@ -1,11 +1,9 @@ import 'dart:convert'; -import 'dart:io'; + import 'package:firebase_messaging/firebase_messaging.dart'; -import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_callkit_incoming/entities/entities.dart'; import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart'; -import 'package:logger/logger.dart'; import 'package:mohem_flutter_app/api/chat/chat_api_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/consts.dart'; @@ -17,9 +15,6 @@ import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart' a import 'package:mohem_flutter_app/models/chat/incoming_call_model.dart'; import 'package:mohem_flutter_app/provider/chat_call_provider.dart'; import 'package:mohem_flutter_app/provider/chat_provider_model.dart'; -import 'package:mohem_flutter_app/ui/landing/dashboard_screen.dart'; -import 'package:path_provider/path_provider.dart'; -import 'package:signalr_netcore/hub_connection.dart'; import 'package:signalr_netcore/signalr_client.dart'; class ChatVoipCall { @@ -106,7 +101,7 @@ class ChatVoipCall { } } - Future declineCall({ payload}) async { + Future declineCall({payload}) async { IncomingCallModel data = IncomingCallModel.fromJson(jsonDecode(payload)); if (isUserOnline) { @@ -120,44 +115,45 @@ class ChatVoipCall { chatHubConnection = _hc; } } - } - //else { - // Future.delayed(const Duration(seconds: 3), () { - // ChatApiClient().callDecline(cUserID: data.extra!.callerDetails!.targetUserId!, tUserID: data.extra!.callerDetails!.currentUserId!, targetUsertoken: data.extra!.loginDetails!.token!); - // }); - // HubConnection _hc = await makeHub(sessionData: data); - // await _hc.start(); - // if (_hc.state == HubConnectionState.Connected) { - // logger.log(Level.info, "HUB-EVENT"); - // await _hc.invoke("HangUpAsync", args: [ - // data.extra!.callerDetails!.currentUserId!, - // data.extra!.callerDetails!.targetUserId!, - // ]); - // FlutterCallkitIncoming.endAllCalls(); - // await _hc.stop(); - // } - // } + } + //else { + // Future.delayed(const Duration(seconds: 3), () { + // ChatApiClient().callDecline(cUserID: data.extra!.callerDetails!.targetUserId!, tUserID: data.extra!.callerDetails!.currentUserId!, targetUsertoken: data.extra!.loginDetails!.token!); + // }); + // HubConnection _hc = await makeHub(sessionData: data); + // await _hc.start(); + // if (_hc.state == HubConnectionState.Connected) { + // logger.log(Level.info, "HUB-EVENT"); + // await _hc.invoke("HangUpAsync", args: [ + // data.extra!.callerDetails!.currentUserId!, + // data.extra!.callerDetails!.targetUserId!, + // ]); + // FlutterCallkitIncoming.endAllCalls(); + // await _hc.stop(); + // } + // } - // - // try { - // var response = await platform.invokeMethod( - // 'executeHttpPostRequest', {"currentUserID": data.extra!.callerDetails!.targetUserId, "targetUserID": data.extra!.callerDetails!.currentUserId, "token": data.extra!.loginDetails!.token}); - // print('HTTP POST response: $response'); - // Future.delayed(Duration(seconds: 3), () { - // ChatApiClient().callDecline(cUserID: data.extra!.callerDetails!.targetUserId!, tUserID: data.extra!.callerDetails!.currentUserId!, targetUsertoken: data.extra!.loginDetails!.token!); - // }); - // } on PlatformException catch (e) { - // print('Error invoking method: ${e.message}'); - // } + // + // try { + // var response = await platform.invokeMethod( + // 'executeHttpPostRequest', {"currentUserID": data.extra!.callerDetails!.targetUserId, "targetUserID": data.extra!.callerDetails!.currentUserId, "token": data.extra!.loginDetails!.token}); + // print('HTTP POST response: $response'); + // Future.delayed(Duration(seconds: 3), () { + // ChatApiClient().callDecline(cUserID: data.extra!.callerDetails!.targetUserId!, tUserID: data.extra!.callerDetails!.currentUserId!, targetUsertoken: data.extra!.loginDetails!.token!); + // }); + // } on PlatformException catch (e) { + // print('Error invoking method: ${e.message}'); + // } - //await ChatApiClient().callDecline(cUserID: data.extra!.callerDetails!.targetUserId!, tUserID: data.extra!.callerDetails!.currentUserId!, targetUsertoken: data.extra!.loginDetails!.token!); - // logger.log(Level.error, "API-EVENT-END"); + //await ChatApiClient().callDecline(cUserID: data.extra!.callerDetails!.targetUserId!, tUserID: data.extra!.callerDetails!.currentUserId!, targetUsertoken: data.extra!.loginDetails!.token!); + // logger.log(Level.error, "API-EVENT-END"); } - - Future voipDeclineCall(IosCallPayload? _iosCallPayload ) async { + + Future voipDeclineCall(IosCallPayload? _iosCallPayload) async { try { ALM.UserAutoLoginModel model = await ChatApiClient().getUserCallToken(userid: _iosCallPayload!.incomingCallReciverId.toString()); - dynamic Res = await ChatApiClient().callDecline(cUserID: int.parse(_iosCallPayload!.incomingCallerId!), tUserID: int.parse(_iosCallPayload!.incomingCallReciverId.toString()), targetUsertoken: model.response!.token!); + dynamic Res = await ChatApiClient() + .callDecline(cUserID: int.parse(_iosCallPayload!.incomingCallerId!), tUserID: int.parse(_iosCallPayload!.incomingCallReciverId.toString()), targetUsertoken: model.response!.token!); } catch (err) { print(err); } @@ -177,4 +173,3 @@ class ChatVoipCall { } } } - diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 6c5d40e..8052afb 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -4,7 +4,7 @@ class ApiConsts { //static String baseUrl = "http://10.200.204.20:2801/"; // Local server // static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server - static String baseUrl = "https://hmgwebservices.com"; // Live server + static String baseUrl = "https://hmgwebservices.com"; // Live server static String baseUrlServices = baseUrl + "/Services/"; // server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/"; @@ -37,7 +37,6 @@ class ApiConsts { static String oneSignalCall = "https://onesignal.com/api/v1/"; static String oneSignalAppID = "472e4582-5c44-47ab-a5f5-9369b8967107"; - //Brain Marathon Constants static String marathonBaseUrl = "https://marathoon.com/service/api/"; static String marathonBaseUrlServices = "https://marathoon.com/service/"; diff --git a/lib/generated_plugin_registrant.dart b/lib/generated_plugin_registrant.dart index 9189ef6..4af7a8d 100644 --- a/lib/generated_plugin_registrant.dart +++ b/lib/generated_plugin_registrant.dart @@ -10,6 +10,7 @@ import 'package:audio_session/audio_session_web.dart'; import 'package:file_picker/_internal/file_picker_web.dart'; import 'package:firebase_core_web/firebase_core_web.dart'; import 'package:firebase_messaging_web/firebase_messaging_web.dart'; +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import 'package:fluttertoast/fluttertoast_web.dart'; import 'package:geolocator_web/geolocator_web.dart'; import 'package:image_picker_for_web/image_picker_for_web.dart'; @@ -19,8 +20,6 @@ import 'package:shared_preferences_web/shared_preferences_web.dart'; import 'package:url_launcher_web/url_launcher_web.dart'; import 'package:video_player_web/video_player_web.dart'; -import 'package:flutter_web_plugins/flutter_web_plugins.dart'; - // ignore: public_member_api_docs void registerPlugins(Registrar registrar) { AudioSessionWeb.registerWith(registrar); diff --git a/lib/main.dart b/lib/main.dart index c066703..eb6497c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -20,7 +20,6 @@ import 'package:provider/single_child_widget.dart'; import 'package:signalr_netcore/hub_connection.dart'; import 'package:sizer/sizer.dart'; - // test uat account // username 199067 // pass h123456 diff --git a/lib/provider/chat_provider_model.dart b/lib/provider/chat_provider_model.dart index 908e8dd..a43a55c 100644 --- a/lib/provider/chat_provider_model.dart +++ b/lib/provider/chat_provider_model.dart @@ -1,11 +1,12 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'dart:typed_data'; + import 'package:audio_waveforms/audio_waveforms.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart' as Material; import 'package:flutter/services.dart'; import 'package:http/http.dart'; import 'package:just_audio/just_audio.dart' as JustAudio; @@ -19,33 +20,24 @@ import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/main.dart'; import 'package:mohem_flutter_app/models/chat/chat_user_image_model.dart'; -import 'package:mohem_flutter_app/models/chat/create_group_request.dart' - as createGroup; -import 'package:mohem_flutter_app/models/chat/get_group_chat_history.dart' - as groupchathistory; +import 'package:mohem_flutter_app/models/chat/create_group_request.dart' as createGroup; +import 'package:mohem_flutter_app/models/chat/get_group_chat_history.dart' as groupchathistory; 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_groups_by_id.dart' - as groups; +import 'package:mohem_flutter_app/models/chat/get_user_groups_by_id.dart' as groups; import 'package:mohem_flutter_app/models/chat/get_user_groups_by_id.dart'; -import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart' - as userLoginToken; -import 'package:mohem_flutter_app/models/chat/make_user_favotire_unfavorite_chat_model.dart' - as fav; +import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart' as userLoginToken; +import 'package:mohem_flutter_app/models/chat/make_user_favotire_unfavorite_chat_model.dart' as fav; import 'package:mohem_flutter_app/models/chat/target_users.dart'; import 'package:mohem_flutter_app/models/my_team/get_employee_subordinates_list.dart'; import 'package:mohem_flutter_app/provider/chat_call_provider.dart'; import 'package:mohem_flutter_app/ui/chat/chat_detailed_screen.dart'; -import 'package:mohem_flutter_app/ui/landing/dashboard_screen.dart'; import 'package:mohem_flutter_app/widgets/image_picker.dart'; import 'package:open_file/open_file.dart'; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; -import 'package:provider/provider.dart'; -import 'package:signalr_netcore/hub_connection.dart'; import 'package:signalr_netcore/signalr_client.dart'; import 'package:uuid/uuid.dart'; -import 'package:flutter/material.dart' as Material; class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { ScrollController scrollController = ScrollController(); @@ -66,10 +58,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { List favUsersList = []; int paginationVal = 0; int? cTypingUserId = 0; - bool isTextMsg = false, - isReplyMsg = false, - isAttachmentMsg = false, - isVoiceMsg = false; + bool isTextMsg = false, isReplyMsg = false, isAttachmentMsg = false, isVoiceMsg = false; // Audio Recoding Work Timer? _timer; @@ -113,7 +102,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { AppState().setchatUserDetails = userLoginResponse; Utils.saveStringFromPrefs("userLoginChatDetails", jsonEncode(userLoginResponse.response)); isUserOnline = true; - if(Platform.isIOS){ + if (Platform.isIOS) { AppState().setisUserOnline = true; } } else { @@ -124,7 +113,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { ); disableChatForThisUser = true; isUserOnline = false; - if(Platform.isIOS){ + if (Platform.isIOS) { AppState().setisUserOnline = false; } notifyListeners(); @@ -132,7 +121,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } catch (e) { disableChatForThisUser = true; isUserOnline = false; - if(Platform.isIOS){ + if (Platform.isIOS) { AppState().setisUserOnline = false; } notifyListeners(); @@ -160,15 +149,10 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { Future getHubConnection() async { HubConnection hub; - HttpConnectionOptions httpOp = - HttpConnectionOptions(skipNegotiation: false, logMessageContent: true); + HttpConnectionOptions httpOp = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true); hub = HubConnectionBuilder() - .withUrl( - ApiConsts.chatHubConnectionUrl + - "?UserId=${AppState().chatDetails!.response!.id}&source=Desktop&access_token=${AppState().chatDetails!.response!.token}", - options: httpOp) - .withAutomaticReconnect( - retryDelays: [2000, 5000, 10000, 20000]).build(); + .withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${AppState().chatDetails!.response!.id}&source=Desktop&access_token=${AppState().chatDetails!.response!.token}", options: httpOp) + .withAutomaticReconnect(retryDelays: [2000, 5000, 10000, 20000]).build(); return hub; } @@ -180,12 +164,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { chatHubConnection.on("OnUserTypingAsync", onUserTyping); chatHubConnection.on("OnUserCountAsync", userCountAsync); // chatHubConnection.on("OnUpdateUserChatHistoryWindowsAsync", updateChatHistoryWindow); - chatHubConnection.on( - "OnGetUserChatHistoryNotDeliveredAsync", chatNotDelivered); - chatHubConnection.on( - "OnUpdateUserChatHistoryStatusAsync", updateUserChatStatus); - chatHubConnection.on( - "OnGetGroupUserStatusAsync", getGroupUserStatus); + chatHubConnection.on("OnGetUserChatHistoryNotDeliveredAsync", chatNotDelivered); + chatHubConnection.on("OnUpdateUserChatHistoryStatusAsync", updateUserChatStatus); + chatHubConnection.on("OnGetGroupUserStatusAsync", getGroupUserStatus); // // {"type":1,"target":"","arguments":[[{"id":217869,"userName":"Sultan.Khan","email":"Sultan.Khan@cloudsolutions.com.sa","phone":null,"title":"Sultan.Khan","userStatus":1,"image":null,"unreadMessageCount":0,"userAction":3,"isPin":false,"isFav":false,"isAdmin":false,"rKey":null,"totalCount":0,"isHuaweiDevice":false,"deviceToken":null},{"id":15153,"userName":"Tamer.Fanasheh","email":"Tamer.F@cloudsolutions.com.sa","phone":null,"title":"Tamer Fanasheh","userStatus":2,"image":null,"unreadMessageCount":0,"userAction":3,"isPin":false,"isFav":false,"isAdmin":true,"rKey":null,"totalCount":0,"isHuaweiDevice":false,"deviceToken":null}]]} @@ -201,8 +182,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { // userGroups = await ChatApiClient().getGroupsByUserId(); if (favUList.response != null && recentChat.response != null) { favUsersList = favUList.response!; - favUsersList.sort((ChatUser a, ChatUser b) => - a.userName!.toLowerCase().compareTo(b.userName!.toLowerCase())); + favUsersList.sort((ChatUser a, ChatUser b) => a.userName!.toLowerCase().compareTo(b.userName!.toLowerCase())); for (dynamic user in recentChat.response!) { for (dynamic favUser in favUList.response!) { if (user.id == favUser.id) { @@ -213,12 +193,10 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } pChatHistory = recentChat.response ?? []; uGroups = userGroups.groupresponse ?? []; - pChatHistory!.sort((ChatUser a, ChatUser b) => - a.userName!.toLowerCase().compareTo(b.userName!.toLowerCase())); + pChatHistory!.sort((ChatUser a, ChatUser b) => a.userName!.toLowerCase().compareTo(b.userName!.toLowerCase())); searchedChats = pChatHistory; isLoading = false; - await invokeUserChatHistoryNotDeliveredAsync( - userId: int.parse(AppState().chatDetails!.response!.id.toString())); + await invokeUserChatHistoryNotDeliveredAsync(userId: int.parse(AppState().chatDetails!.response!.id.toString())); sort(); notifyListeners(); if (searchedChats!.isNotEmpty || favUsersList.isNotEmpty) { @@ -227,38 +205,27 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } Future invokeUserChatHistoryNotDeliveredAsync({required int userId}) async { - await chatHubConnection - .invoke("GetUserChatHistoryNotDeliveredAsync", args: [userId]); + await chatHubConnection.invoke("GetUserChatHistoryNotDeliveredAsync", args: [userId]); return ""; } - void getSingleUserChatHistory( - {required int senderUID, - required int receiverUID, - required bool loadMore, - bool isNewChat = false}) async { + void getSingleUserChatHistory({required int senderUID, required int receiverUID, required bool loadMore, bool isNewChat = false}) async { isLoading = true; if (isNewChat) userChatHistory = []; if (!loadMore) paginationVal = 0; isChatScreenActive = true; receiverID = receiverUID; - Response response = await ChatApiClient().getSingleUserChatHistory( - senderUID: senderUID, - receiverUID: receiverUID, - loadMore: loadMore, - paginationVal: paginationVal); + Response response = await ChatApiClient().getSingleUserChatHistory(senderUID: senderUID, receiverUID: receiverUID, loadMore: loadMore, paginationVal: paginationVal); if (response.statusCode == 204) { if (isNewChat) { userChatHistory = []; } else if (loadMore) {} } else { if (loadMore) { - List temp = - getSingleUserChatModel(response.body).reversed.toList(); + List temp = getSingleUserChatModel(response.body).reversed.toList(); userChatHistory.addAll(temp); } else { - userChatHistory = - getSingleUserChatModel(response.body).reversed.toList(); + userChatHistory = getSingleUserChatModel(response.body).reversed.toList(); } } isLoading = false; @@ -285,9 +252,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { dynamic data = [ { "userChatHistoryId": element.userChatHistoryId, - "TargetUserId": element.currentUserId == receiverID - ? element.currentUserId - : element.targetUserId, + "TargetUserId": element.currentUserId == receiverID ? element.currentUserId : element.targetUserId, "isDelivered": true, "isSeen": true, } @@ -309,8 +274,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { void updateUserChatHistoryStatusAsync(List data) { try { - chatHubConnection - .invoke("UpdateUserChatHistoryStatusAsync", args: [data]); + chatHubConnection.invoke("UpdateUserChatHistoryStatusAsync", args: [data]); } catch (e) { throw e; } @@ -318,21 +282,16 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { void updateUserChatHistoryOnMsg(List data) { try { - chatHubConnection - .invoke("UpdateUserChatHistoryStatusAsync", args: [data]); + chatHubConnection.invoke("UpdateUserChatHistoryStatusAsync", args: [data]); } catch (e) { throw e; } } - List getSingleUserChatModel(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))); List getGroupChatHistoryAsync(String str) => - List.from( - json.decode(str).map((x) => groupchathistory.GetGroupChatHistoryAsync.fromJson(x))); - + List.from(json.decode(str).map((x) => groupchathistory.GetGroupChatHistoryAsync.fromJson(x))); Future uploadAttachments(String userId, File file) async { dynamic result; @@ -362,9 +321,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { notifyListeners(); } - void getGroupUserStatus(List? args){ - //note: need to implement this function... - print(args); + void getGroupUserStatus(List? args) { + //note: need to implement this function... + print(args); } void onChatSeen(List? args) { @@ -393,8 +352,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { void updateChatHistoryWindow(List? args) { dynamic items = args!.toList(); if (kDebugMode) { - logger.i( - "---------------------------------Update Chat History Windows Async -------------------------------------"); + logger.i("---------------------------------Update Chat History Windows Async -------------------------------------"); } logger.d(items); // for (var user in searchedChats!) { @@ -464,26 +422,14 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { data.first.currentUserName = temp.first.targetUserName; data.first.currentUserEmail = temp.first.targetUserEmail; - if (data.first.fileTypeId == 12 || - data.first.fileTypeId == 4 || - data.first.fileTypeId == 3) { - data.first.image = await ChatApiClient().downloadURL( - fileName: data.first.contant!, - fileTypeDescription: - data.first.fileTypeResponse!.fileTypeDescription ?? - "image/jpg"); + if (data.first.fileTypeId == 12 || data.first.fileTypeId == 4 || data.first.fileTypeId == 3) { + data.first.image = await ChatApiClient().downloadURL(fileName: data.first.contant!, fileTypeDescription: data.first.fileTypeResponse!.fileTypeDescription ?? "image/jpg"); } if (data.first.userChatReplyResponse != null) { if (data.first.fileTypeResponse != null) { - if (data.first.userChatReplyResponse!.fileTypeId == 12 || - data.first.userChatReplyResponse!.fileTypeId == 4 || - data.first.userChatReplyResponse!.fileTypeId == 3) { - data.first.userChatReplyResponse!.image = await ChatApiClient() - .downloadURL( - fileName: data.first.userChatReplyResponse!.contant!, - fileTypeDescription: - data.first.fileTypeResponse!.fileTypeDescription ?? - "image/jpg"); + if (data.first.userChatReplyResponse!.fileTypeId == 12 || data.first.userChatReplyResponse!.fileTypeId == 4 || data.first.userChatReplyResponse!.fileTypeId == 3) { + data.first.userChatReplyResponse!.image = + await ChatApiClient().downloadURL(fileName: data.first.userChatReplyResponse!.contant!, fileTypeDescription: data.first.fileTypeResponse!.fileTypeDescription ?? "image/jpg"); data.first.userChatReplyResponse!.isImageLoaded = true; } } @@ -491,14 +437,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } if (searchedChats != null) { - dynamic contain = searchedChats! - .where((ChatUser element) => element.id == data.first.currentUserId); + dynamic contain = searchedChats!.where((ChatUser element) => element.id == data.first.currentUserId); if (contain.isEmpty) { List emails = []; - emails.add(await EmailImageEncryption() - .encrypt(val: data.first.currentUserEmail!)); - List chatImages = - await ChatApiClient().getUsersImages(encryptedEmails: emails); + emails.add(await EmailImageEncryption().encrypt(val: data.first.currentUserEmail!)); + List chatImages = await ChatApiClient().getUsersImages(encryptedEmails: emails); searchedChats!.add( ChatUser( id: data.first.currentUserId, @@ -510,9 +453,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { isImageLoaded: true, userStatus: 1, isTyping: false, - userLocalDownlaodedImage: await downloadImageLocal( - chatImages.first.profilePicture, - data.first.currentUserId.toString()), + userLocalDownlaodedImage: await downloadImageLocal(chatImages.first.profilePicture, data.first.currentUserId.toString()), ), ); } @@ -539,9 +480,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { "userChatHistoryId": data.first.userChatHistoryId, "TargetUserId": temp.first.targetUserId, "isDelivered": true, - "isSeen": isChatScreenActive && data.first.currentUserId == receiverID - ? true - : false + "isSeen": isChatScreenActive && data.first.currentUserId == receiverID ? true : false } ]; updateUserChatHistoryOnMsg(list); @@ -552,38 +491,24 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { Future onGroupMsgReceived(List? parameters) async { List data = [], temp = []; - for (dynamic msg in parameters!) { - // groupChatHistory.add(groupchathistory.GetGroupChatHistoryAsync.fromJson(msg)); + // groupChatHistory.add(groupchathistory.GetGroupChatHistoryAsync.fromJson(msg)); data.add(groupchathistory.GetGroupChatHistoryAsync.fromJson(msg)); - temp =data; + temp = data; // data.first.currentUserId = temp.first.currentUserId; // data.first.currentUserName = temp.first.currentUserName; // // data.first.currentUserId = temp.first.currentUserId; // data.first.currentUserName = temp.first.currentUserName; - - if (data.first.fileTypeId == 12 || - data.first.fileTypeId == 4 || - data.first.fileTypeId == 3) { - data.first.image = await ChatApiClient().downloadURL( - fileName: data.first.contant!, - fileTypeDescription: - data.first.fileTypeResponse!.fileTypeDescription ?? - "image/jpg"); + if (data.first.fileTypeId == 12 || data.first.fileTypeId == 4 || data.first.fileTypeId == 3) { + data.first.image = await ChatApiClient().downloadURL(fileName: data.first.contant!, fileTypeDescription: data.first.fileTypeResponse!.fileTypeDescription ?? "image/jpg"); } if (data.first.groupChatReplyResponse != null) { if (data.first.fileTypeResponse != null) { - if (data.first.groupChatReplyResponse!.fileTypeId == 12 || - data.first.groupChatReplyResponse!.fileTypeId == 4 || - data.first.groupChatReplyResponse!.fileTypeId == 3) { - data.first.groupChatReplyResponse!.image = await ChatApiClient() - .downloadURL( - fileName: data.first.groupChatReplyResponse!.contant!, - fileTypeDescription: - data.first.fileTypeResponse!.fileTypeDescription ?? - "image/jpg"); + if (data.first.groupChatReplyResponse!.fileTypeId == 12 || data.first.groupChatReplyResponse!.fileTypeId == 4 || data.first.groupChatReplyResponse!.fileTypeId == 3) { + data.first.groupChatReplyResponse!.image = + await ChatApiClient().downloadURL(fileName: data.first.groupChatReplyResponse!.contant!, fileTypeDescription: data.first.fileTypeResponse!.fileTypeDescription ?? "image/jpg"); data.first.groupChatReplyResponse!.isImageLoaded = true; } } @@ -616,10 +541,10 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { // ), // ); // } - // } + // } groupChatHistory.insert(0, data.first); setMsgTune(); - // if (isChatScreenActive && data.first.currentUserId == receiverID) { + // if (isChatScreenActive && data.first.currentUserId == receiverID) { // } else { // if (searchedChats != null) { @@ -629,8 +554,8 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { // user.unreadMessageCount = tempCount + 1; // } // } - sort(); - //} + sort(); + //} //} // // List list = [ @@ -643,13 +568,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { // : false // } // ]; - // updateUserChatHistoryOnMsg(list); - // invokeChatCounter(userId: AppState().chatDetails!.response!.id!); + // updateUserChatHistoryOnMsg(list); + // invokeChatCounter(userId: AppState().chatDetails!.response!.id!); notifyListeners(); } - - void OnSubmitChatAsync(List? parameters) { List data = [], temp = []; for (dynamic msg in parameters!) { @@ -674,8 +597,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { void sort() { searchedChats!.sort( - (ChatUser a, ChatUser b) => - b.unreadMessageCount!.compareTo(a.unreadMessageCount!), + (ChatUser a, ChatUser b) => b.unreadMessageCount!.compareTo(a.unreadMessageCount!), ); } @@ -805,22 +727,14 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { targetUserName: targetUserName, isReplied: false, fileTypeId: fileTypeId, - userChatReplyResponse: isReply - ? UserChatReplyResponse.fromJson(repliedMsg.first.toJson()) - : null, + userChatReplyResponse: isReply ? UserChatReplyResponse.fromJson(repliedMsg.first.toJson()) : null, fileTypeResponse: isAttachment ? FileTypeResponse( fileTypeId: fileTypeId, - fileTypeName: isVoiceMsg - ? getFileExtension(voiceFile!.path).toString() - : getFileExtension(selectedFile.path).toString(), + fileTypeName: isVoiceMsg ? getFileExtension(voiceFile!.path).toString() : getFileExtension(selectedFile.path).toString(), fileKind: "file", fileName: isVoiceMsg ? msg : selectedFile.path.split("/").last, - fileTypeDescription: isVoiceMsg - ? getFileTypeDescription( - getFileExtension(voiceFile!.path).toString()) - : getFileTypeDescription( - getFileExtension(selectedFile.path).toString()), + fileTypeDescription: isVoiceMsg ? getFileTypeDescription(getFileExtension(voiceFile!.path).toString()) : getFileTypeDescription(getFileExtension(selectedFile.path).toString()), ) : null, image: image, @@ -842,8 +756,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { String chatData = '{"contant":"$msg","contantNo":"$contentNo","chatEventId":$chatEventId,"fileTypeId": $fileTypeId,"currentUserId":${AppState().chatDetails!.response!.id},"chatSource":1,"userChatHistoryLineRequestList":[{"isSeen":false,"isDelivered":false,"targetUserId":$targetUserId,"targetUserStatus":1}],"chatReplyId":$chatReplyId,"conversationId":"$chatCID"}'; - await chatHubConnection - .invoke("AddChatUserAsync", args: [json.decode(chatData)]); + await chatHubConnection.invoke("AddChatUserAsync", args: [json.decode(chatData)]); } //groupChatMessage @@ -862,8 +775,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { int? userStatus, File? voiceFile, required bool isVoiceAttached, - required List userList - }) async { + required List userList}) async { Uuid uuid = const Uuid(); String contentNo = uuid.v4(); String msg; @@ -873,36 +785,36 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { msg = message.text; logger.w(msg); } - groupchathistory.GetGroupChatHistoryAsync data = - groupchathistory.GetGroupChatHistoryAsync( - //userChatHistoryId: 0, - chatEventId: chatEventId, - chatSource: 1, - contant: msg, - contantNo: contentNo, - conversationId: chatCID, - createdDate: DateTime.now().toString(), - currentUserId: AppState().chatDetails!.response!.id, - currentUserName: AppState().chatDetails!.response!.userName, - groupId: targetGroupId, - groupName: targetUserName, - isReplied: false, - fileTypeId: fileTypeId, - fileTypeResponse: isAttachment - ? groupchathistory.FileTypeResponse( - fileTypeId: fileTypeId, - fileTypeName: isVoiceMsg ? getFileExtension(voiceFile!.path).toString() : getFileExtension(selectedFile.path).toString(), - fileKind: "file", - fileName: isVoiceMsg ? msg : selectedFile.path.split("/").last, - fileTypeDescription: isVoiceMsg ? getFileTypeDescription(getFileExtension(voiceFile!.path).toString()) : getFileTypeDescription(getFileExtension(selectedFile.path).toString())) : null, - image: image, - isImageLoaded: isImageLoaded, - voice: isVoiceMsg ? voiceFile! : null, - voiceController: isVoiceMsg ? AudioPlayer() : null); + groupchathistory.GetGroupChatHistoryAsync data = groupchathistory.GetGroupChatHistoryAsync( + //userChatHistoryId: 0, + chatEventId: chatEventId, + chatSource: 1, + contant: msg, + contantNo: contentNo, + conversationId: chatCID, + createdDate: DateTime.now().toString(), + currentUserId: AppState().chatDetails!.response!.id, + currentUserName: AppState().chatDetails!.response!.userName, + groupId: targetGroupId, + groupName: targetUserName, + isReplied: false, + fileTypeId: fileTypeId, + fileTypeResponse: isAttachment + ? groupchathistory.FileTypeResponse( + fileTypeId: fileTypeId, + fileTypeName: isVoiceMsg ? getFileExtension(voiceFile!.path).toString() : getFileExtension(selectedFile.path).toString(), + fileKind: "file", + fileName: isVoiceMsg ? msg : selectedFile.path.split("/").last, + fileTypeDescription: isVoiceMsg ? getFileTypeDescription(getFileExtension(voiceFile!.path).toString()) : getFileTypeDescription(getFileExtension(selectedFile.path).toString())) + : null, + image: image, + isImageLoaded: isImageLoaded, + voice: isVoiceMsg ? voiceFile! : null, + voiceController: isVoiceMsg ? AudioPlayer() : null); if (kDebugMode) { logger.i("model data: " + jsonEncode(data)); } - groupChatHistory.insert(0, data); + groupChatHistory.insert(0, data); isTextMsg = false; isReplyMsg = false; isAttachmentMsg = false; @@ -911,27 +823,26 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { message.clear(); notifyListeners(); - List targetUsers =[]; + List targetUsers = []; for (GroupUserList element in userList) { - targetUsers.add(TargetUsers(isDelivered: false,isSeen: false, targetUserId: element.id, userAction: element.userAction, userStatus: element.userStatus)); - + targetUsers.add(TargetUsers(isDelivered: false, isSeen: false, targetUserId: element.id, userAction: element.userAction, userStatus: element.userStatus)); } String chatData = '{"contant":"$msg","contantNo":"$contentNo","chatEventId":$chatEventId,"fileTypeId":$fileTypeId,"currentUserId":${AppState().chatDetails!.response!.id},"chatSource":1,"groupId":$targetGroupId,"groupChatHistoryLineRequestList":${json.encode(targetUsers)},"chatReplyId": $chatReplyId,"conversationId":"${uuid.v4()}"}'; - await chatHubConnection.invoke("AddGroupChatHistoryAsync", - args: [json.decode(chatData)]); + await chatHubConnection.invoke("AddGroupChatHistoryAsync", args: [json.decode(chatData)]); } - void sendGroupChatMessage(BuildContext context, - {required int targetUserId, - required int userStatus, - required String userEmail, - required String targetUserName, - required List userList, - }) async { + void sendGroupChatMessage( + BuildContext context, { + required int targetUserId, + required int userStatus, + required String userEmail, + required String targetUserName, + required List userList, + }) async { if (isTextMsg && !isAttachmentMsg && !isVoiceMsg && !isReplyMsg) { logger.d("// Normal Text Message"); if (message.text.isEmpty) { @@ -950,8 +861,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { isVoiceAttached: false, userEmail: userEmail, userStatus: userStatus, - userList:userList - ); + userList: userList); } else if (isTextMsg && !isAttachmentMsg && !isVoiceMsg && isReplyMsg) { logger.d("// Text Message as Reply"); if (message.text.isEmpty) { @@ -971,15 +881,13 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { voiceFile: null, userEmail: userEmail, userStatus: userStatus, - userList:userList - ); + userList: userList); } // Attachment else if (!isTextMsg && isAttachmentMsg && !isVoiceMsg && !isReplyMsg) { logger.d("// Normal Image Message"); Utils.showLoading(context); - dynamic value = await uploadAttachments( - AppState().chatDetails!.response!.id.toString(), selectedFile); + dynamic value = await uploadAttachments(AppState().chatDetails!.response!.id.toString(), selectedFile); String? ext = getFileExtension(selectedFile.path); Utils.hideLoading(context); sendGroupChatToServer( @@ -995,19 +903,16 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { isVoiceAttached: false, userEmail: userEmail, userStatus: userStatus, - userList:userList - ); + userList: userList); } else if (!isTextMsg && isAttachmentMsg && !isVoiceMsg && isReplyMsg) { logger.d("// Image as Reply Msg"); Utils.showLoading(context); - dynamic value = await uploadAttachments( - AppState().chatDetails!.response!.id.toString(), selectedFile); + dynamic value = await uploadAttachments(AppState().chatDetails!.response!.id.toString(), selectedFile); String? ext = getFileExtension(selectedFile.path); Utils.hideLoading(context); sendGroupChatToServer( chatEventId: 2, fileTypeId: getFileType(ext.toString()), - targetGroupId: targetUserId, targetUserName: targetUserName, isAttachment: true, @@ -1018,8 +923,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { isVoiceAttached: false, userEmail: userEmail, userStatus: userStatus, - userList:userList - ); + userList: userList); } //Voice @@ -1039,9 +943,8 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { isPlaying = false; isRecoding = false; Utils.showLoading(context); - dynamic value = await uploadAttachments( - AppState().chatDetails!.response!.id.toString(), voiceFile); - String? ext = getFileExtension(voiceFile.path); + dynamic value = await uploadAttachments(AppState().chatDetails!.response!.id.toString(), voiceFile); + String? ext = getFileExtension(voiceFile.path); Utils.hideLoading(context); sendGroupChatToServer( chatEventId: 2, @@ -1057,8 +960,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { isVoiceAttached: true, userEmail: userEmail, userStatus: userStatus, - userList:userList - ); + userList: userList); notifyListeners(); } else if (!isTextMsg && !isAttachmentMsg && isVoiceMsg && isReplyMsg) { logger.d("// Voice as Reply Msg"); @@ -1077,9 +979,8 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { isRecoding = false; Utils.showLoading(context); - dynamic value = await uploadAttachments( - AppState().chatDetails!.response!.id.toString(), voiceFile); - String? ext = getFileExtension(voiceFile.path); + dynamic value = await uploadAttachments(AppState().chatDetails!.response!.id.toString(), voiceFile); + String? ext = getFileExtension(voiceFile.path); Utils.hideLoading(context); sendGroupChatToServer( chatEventId: 2, @@ -1094,18 +995,15 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { isVoiceAttached: true, userEmail: userEmail, userStatus: userStatus, - userList:userList - ); + userList: userList); notifyListeners(); } if (searchedChats != null) { - dynamic contain = searchedChats! - .where((ChatUser element) => element.id == targetUserId); + dynamic contain = searchedChats!.where((ChatUser element) => element.id == targetUserId); if (contain.isEmpty) { List emails = []; emails.add(await EmailImageEncryption().encrypt(val: userEmail)); - List chatImages = - await ChatApiClient().getUsersImages(encryptedEmails: emails); + List chatImages = await ChatApiClient().getUsersImages(encryptedEmails: emails); searchedChats!.add( ChatUser( id: targetUserId, @@ -1126,13 +1024,13 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } } - void sendChatMessage(BuildContext context, - {required int targetUserId, - required int userStatus, - required String userEmail, - required String targetUserName, - - }) async { + void sendChatMessage( + BuildContext context, { + required int targetUserId, + required int userStatus, + required String userEmail, + required String targetUserName, + }) async { if (kDebugMode) { print("====================== Values ============================"); print("Is Text " + isTextMsg.toString()); @@ -1183,8 +1081,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { else if (!isTextMsg && isAttachmentMsg && !isVoiceMsg && !isReplyMsg) { logger.d("// Normal Image Message"); Utils.showLoading(context); - dynamic value = await uploadAttachments( - AppState().chatDetails!.response!.id.toString(), selectedFile); + dynamic value = await uploadAttachments(AppState().chatDetails!.response!.id.toString(), selectedFile); String? ext = getFileExtension(selectedFile.path); Utils.hideLoading(context); sendChatToServer( @@ -1203,8 +1100,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } else if (!isTextMsg && isAttachmentMsg && !isVoiceMsg && isReplyMsg) { logger.d("// Image as Reply Msg"); Utils.showLoading(context); - dynamic value = await uploadAttachments( - AppState().chatDetails!.response!.id.toString(), selectedFile); + dynamic value = await uploadAttachments(AppState().chatDetails!.response!.id.toString(), selectedFile); String? ext = getFileExtension(selectedFile.path); Utils.hideLoading(context); sendChatToServer( @@ -1239,8 +1135,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { isPlaying = false; isRecoding = false; Utils.showLoading(context); - dynamic value = await uploadAttachments( - AppState().chatDetails!.response!.id.toString(), voiceFile); + dynamic value = await uploadAttachments(AppState().chatDetails!.response!.id.toString(), voiceFile); String? ext = getFileExtension(voiceFile.path); Utils.hideLoading(context); sendChatToServer( @@ -1274,8 +1169,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { isRecoding = false; Utils.showLoading(context); - dynamic value = await uploadAttachments( - AppState().chatDetails!.response!.id.toString(), voiceFile); + dynamic value = await uploadAttachments(AppState().chatDetails!.response!.id.toString(), voiceFile); String? ext = getFileExtension(voiceFile.path); Utils.hideLoading(context); sendChatToServer( @@ -1294,13 +1188,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { notifyListeners(); } if (searchedChats != null) { - dynamic contain = searchedChats! - .where((ChatUser element) => element.id == targetUserId); + dynamic contain = searchedChats!.where((ChatUser element) => element.id == targetUserId); if (contain.isEmpty) { List emails = []; emails.add(await EmailImageEncryption().encrypt(val: userEmail)); - List chatImages = - await ChatApiClient().getUsersImages(encryptedEmails: emails); + List chatImages = await ChatApiClient().getUsersImages(encryptedEmails: emails); searchedChats!.add( ChatUser( id: targetUserId, @@ -1313,8 +1205,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { isTyping: false, isFav: false, userStatus: userStatus, - userLocalDownlaodedImage: await downloadImageLocal( - chatImages.first.profilePicture, targetUserId.toString()), + userLocalDownlaodedImage: await downloadImageLocal(chatImages.first.profilePicture, targetUserId.toString()), ), ); notifyListeners(); @@ -1344,8 +1235,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } void selectImageToUpload(BuildContext context) { - ImageOptions.showImageOptionsNew(context, true, - (String image, File file) async { + ImageOptions.showImageOptionsNew(context, true, (String image, File file) async { if (checkFileSize(file.path)) { selectedFile = file; isAttachmentMsg = true; @@ -1434,6 +1324,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { repliedMsg.add(data); notifyListeners(); } + void groupChatReply(groupchathistory.GetGroupChatHistoryAsync data) { groupChatReplyData = []; data.isReplied = true; @@ -1441,6 +1332,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { groupChatReplyData.add(data); notifyListeners(); } + void closeMe() { repliedMsg = []; isReplyMsg = false; @@ -1453,18 +1345,13 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { return f.format(data); } - Future favoriteUser( - {required int userID, - required int targetUserID, - required bool fromSearch}) async { - fav.FavoriteChatUser favoriteChatUser = await ChatApiClient() - .favUser(userID: userID, targetUserID: targetUserID); + Future favoriteUser({required int userID, required int targetUserID, required bool fromSearch}) async { + fav.FavoriteChatUser favoriteChatUser = await ChatApiClient().favUser(userID: userID, targetUserID: targetUserID); if (favoriteChatUser.response != null) { for (ChatUser user in searchedChats!) { if (user.id == favoriteChatUser.response!.targetUserId!) { user.isFav = favoriteChatUser.response!.isFav; - dynamic contain = favUsersList!.where((ChatUser element) => - element.id == favoriteChatUser.response!.targetUserId!); + dynamic contain = favUsersList!.where((ChatUser element) => element.id == favoriteChatUser.response!.targetUserId!); if (contain.isEmpty) { favUsersList.add(user); } @@ -1474,8 +1361,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { for (ChatUser user in chatUsersList!) { if (user.id == favoriteChatUser.response!.targetUserId!) { user.isFav = favoriteChatUser.response!.isFav; - dynamic contain = favUsersList!.where((ChatUser element) => - element.id == favoriteChatUser.response!.targetUserId!); + dynamic contain = favUsersList!.where((ChatUser element) => element.id == favoriteChatUser.response!.targetUserId!); if (contain.isEmpty) { favUsersList.add(user); } @@ -1494,10 +1380,8 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { notifyListeners(); } - Future unFavoriteUser( - {required int userID, required int targetUserID}) async { - fav.FavoriteChatUser favoriteChatUser = await ChatApiClient() - .unFavUser(userID: userID, targetUserID: targetUserID); + Future unFavoriteUser({required int userID, required int targetUserID}) async { + fav.FavoriteChatUser favoriteChatUser = await ChatApiClient().unFavUser(userID: userID, targetUserID: targetUserID); if (favoriteChatUser.response != null) { for (ChatUser user in searchedChats!) { @@ -1602,14 +1486,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { emails.add(await EmailImageEncryption().encrypt(val: element.email!)); } - List chatImages = - await ChatApiClient().getUsersImages(encryptedEmails: emails); + List chatImages = await ChatApiClient().getUsersImages(encryptedEmails: emails); for (ChatUser user in searchedChats!) { for (ChatUserImageModel uImage in chatImages) { if (user.email == uImage.email) { user.image = uImage.profilePicture ?? ""; - user.userLocalDownlaodedImage = await downloadImageLocal( - uImage.profilePicture, user.id.toString()); + user.userLocalDownlaodedImage = await downloadImageLocal(uImage.profilePicture, user.id.toString()); user.isImageLoading = false; user.isImageLoaded = true; } @@ -1619,8 +1501,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { for (ChatUserImageModel uImage in chatImages) { if (favUser.email == uImage.email) { favUser.image = uImage.profilePicture ?? ""; - favUser.userLocalDownlaodedImage = await downloadImageLocal( - uImage.profilePicture, favUser.id.toString()); + favUser.userLocalDownlaodedImage = await downloadImageLocal(uImage.profilePicture, favUser.id.toString()); favUser.isImageLoading = false; favUser.isImageLoaded = true; } @@ -1637,8 +1518,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } else { await deleteFile(userID); Uint8List decodedBytes = base64Decode(encodedBytes); - Directory appDocumentsDirectory = - await getApplicationDocumentsDirectory(); + Directory appDocumentsDirectory = await getApplicationDocumentsDirectory(); String dirPath = '${appDocumentsDirectory.path}/chat_images'; if (!await Directory(dirPath).exists()) { await Directory(dirPath).create(); @@ -1661,8 +1541,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { Future downChatMedia(Uint8List bytes, String ext) async { String dir = (await getApplicationDocumentsDirectory()).path; - File file = File( - "$dir/" + DateTime.now().millisecondsSinceEpoch.toString() + "." + ext); + File file = File("$dir/" + DateTime.now().millisecondsSinceEpoch.toString() + "." + ext); await file.writeAsBytes(bytes); return file.path; } @@ -1685,20 +1564,10 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } } - Future getChatMedia(BuildContext context, - {required String fileName, - required String fileTypeName, - required int fileTypeID}) async { + Future getChatMedia(BuildContext context, {required String fileName, required String fileTypeName, required int fileTypeID}) async { Utils.showLoading(context); - if (fileTypeID == 1 || - fileTypeID == 5 || - fileTypeID == 7 || - fileTypeID == 6 || - fileTypeID == 8 || - fileTypeID == 2) { - Uint8List encodedString = await ChatApiClient().downloadURL( - fileName: fileName, - fileTypeDescription: getFileTypeDescription(fileTypeName)); + if (fileTypeID == 1 || fileTypeID == 5 || fileTypeID == 7 || fileTypeID == 6 || fileTypeID == 8 || fileTypeID == 2) { + Uint8List encodedString = await ChatApiClient().downloadURL(fileName: fileName, fileTypeDescription: getFileTypeDescription(fileTypeName)); try { String path = await downChatMedia(encodedString, fileTypeName ?? ""); Utils.hideLoading(context); @@ -1720,19 +1589,15 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { return ""; } - void userTypingInvoke( - {required int currentUser, required int reciptUser}) async { - await chatHubConnection - .invoke("UserTypingAsync", args: [reciptUser, currentUser]); + void userTypingInvoke({required int currentUser, required int reciptUser}) async { + await chatHubConnection.invoke("UserTypingAsync", args: [reciptUser, currentUser]); } - void groupTypingInvoke( - {required GroupResponse groupDetails, required int groupId}) async { + + void groupTypingInvoke({required GroupResponse groupDetails, required int groupId}) async { var data = json.decode(json.encode(groupDetails.groupUserList)); - await chatHubConnection - .invoke("GroupTypingAsync", args: ["${groupDetails.adminUser!.userName}",data, groupId ]); + await chatHubConnection.invoke("GroupTypingAsync", args: ["${groupDetails.adminUser!.userName}", data, groupId]); } - //////// Audio Recoding Work //////////////////// Future initAudio({required int receiverId}) async { @@ -1746,8 +1611,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { await Directory(dirPath).create(); await File('$dirPath/.nomedia').create(); } - path = - "$dirPath/${AppState().chatDetails!.response!.id}-$receiverID-${DateTime.now().microsecondsSinceEpoch}.aac"; + path = "$dirPath/${AppState().chatDetails!.response!.id}-$receiverID-${DateTime.now().microsecondsSinceEpoch}.aac"; recorderController = RecorderController() ..androidEncoder = AndroidEncoder.aac ..androidOutputFormat = AndroidOutputFormat.mpeg4 @@ -1877,19 +1741,15 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { return numberStr; } - Future downChatVoice( - Uint8List bytes, String ext, SingleUserChatModel data) async { + Future downChatVoice(Uint8List bytes, String ext, SingleUserChatModel data) async { File file; try { - String dirPath = - '${(await getApplicationDocumentsDirectory()).path}/chat_audios'; + String dirPath = '${(await getApplicationDocumentsDirectory()).path}/chat_audios'; if (!await Directory(dirPath).exists()) { await Directory(dirPath).create(); await File('$dirPath/.nomedia').create(); } - file = File( - "$dirPath/${data.currentUserId}-${data.targetUserId}-${DateTime.now().microsecondsSinceEpoch}" + - ext); + file = File("$dirPath/${data.currentUserId}-${data.targetUserId}-${DateTime.now().microsecondsSinceEpoch}" + ext); await file.writeAsBytes(bytes); } catch (e) { if (kDebugMode) { @@ -1901,14 +1761,10 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } void scrollToMsg(SingleUserChatModel data) { - if (data.userChatReplyResponse != null && - data.userChatReplyResponse!.userChatHistoryId != null) { - int index = userChatHistory.indexWhere((SingleUserChatModel element) => - element.userChatHistoryId == - data.userChatReplyResponse!.userChatHistoryId); + if (data.userChatReplyResponse != null && data.userChatReplyResponse!.userChatHistoryId != null) { + int index = userChatHistory.indexWhere((SingleUserChatModel element) => element.userChatHistoryId == data.userChatReplyResponse!.userChatHistoryId); if (index >= 1) { - double contentSize = scrollController.position.viewportDimension + - scrollController.position.maxScrollExtent; + double contentSize = scrollController.position.viewportDimension + scrollController.position.maxScrollExtent; double target = contentSize * index / userChatHistory.length; scrollController.position.animateTo( target, @@ -1940,18 +1796,14 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { isImageLoading: false, image: element.eMPLOYEEIMAGE ?? "", isImageLoaded: element.eMPLOYEEIMAGE == null ? false : true, - userLocalDownlaodedImage: element.eMPLOYEEIMAGE == null - ? null - : await downloadImageLocal( - element.eMPLOYEEIMAGE ?? "", element.eMPLOYEENUMBER!), + userLocalDownlaodedImage: element.eMPLOYEEIMAGE == null ? null : await downloadImageLocal(element.eMPLOYEEIMAGE ?? "", element.eMPLOYEENUMBER!), ), ); } } } } else { - getEmployeeSubordinatesList = - await MyTeamApiClient().getEmployeeSubordinates("", "", ""); + getEmployeeSubordinatesList = await MyTeamApiClient().getEmployeeSubordinates("", "", ""); AppState().setemployeeSubordinatesList = getEmployeeSubordinatesList; for (GetEmployeeSubordinatesList element in getEmployeeSubordinatesList) { if (element.eMPLOYEEEMAILADDRESS != null) { @@ -1969,10 +1821,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { isImageLoading: false, image: element.eMPLOYEEIMAGE ?? "", isImageLoaded: element.eMPLOYEEIMAGE == null ? false : true, - userLocalDownlaodedImage: element.eMPLOYEEIMAGE == null - ? null - : await downloadImageLocal( - element.eMPLOYEEIMAGE ?? "", element.eMPLOYEENUMBER!), + userLocalDownlaodedImage: element.eMPLOYEEIMAGE == null ? null : await downloadImageLocal(element.eMPLOYEEIMAGE ?? "", element.eMPLOYEENUMBER!), ), ); } @@ -2041,14 +1890,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { SingleUserChatModel nUser = SingleUserChatModel(); Utils.saveStringFromPrefs("isAppOpendByChat", "false"); if (await Utils.getStringFromPrefs("notificationData") != "null") { - nUser = SingleUserChatModel.fromJson( - jsonDecode(await Utils.getStringFromPrefs("notificationData"))); + nUser = SingleUserChatModel.fromJson(jsonDecode(await Utils.getStringFromPrefs("notificationData"))); Utils.saveStringFromPrefs("notificationData", "null"); Future.delayed(const Duration(seconds: 2)); for (ChatUser user in searchedChats!) { if (user.id == nUser.targetUserId) { - Navigator.pushNamed(context, AppRoutes.chatDetailed, - arguments: ChatDetailedScreenParams(user, false)); + Navigator.pushNamed(context, AppRoutes.chatDetailed, arguments: ChatDetailedScreenParams(user, false)); return; } } @@ -2085,9 +1932,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { Future getGroupChatHistory(groups.GroupResponse groupDetails) async { isLoading = true; - groupChatHistory = await ChatApiClient().getGroupChatHistory( - groupDetails.groupId, - groupDetails.groupUserList as List); + groupChatHistory = await ChatApiClient().getGroupChatHistory(groupDetails.groupId, groupDetails.groupUserList as List); isLoading = false; @@ -2104,12 +1949,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { Future addGroupAndUsers(createGroup.CreateGroupRequest request) async { isLoading = true; var groups = await ChatApiClient().addGroupAndUsers(request); - userGroups.groupresponse! - .add(GroupResponse.fromJson(json.decode(groups)['response'])); + userGroups.groupresponse!.add(GroupResponse.fromJson(json.decode(groups)['response'])); isLoading = false; notifyListeners(); } + Future updateGroupAndUsers(createGroup.CreateGroupRequest request) async { isLoading = true; await ChatApiClient().updateGroupAndUsers(request); diff --git a/lib/ui/chat/group_chat_detaied_screen.dart b/lib/ui/chat/group_chat_detaied_screen.dart index 84ae3bd..3a828f9 100644 --- a/lib/ui/chat/group_chat_detaied_screen.dart +++ b/lib/ui/chat/group_chat_detaied_screen.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'dart:convert'; + import 'package:audio_waveforms/audio_waveforms.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; @@ -11,24 +12,17 @@ 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/main.dart'; -import 'package:mohem_flutter_app/models/chat/call.dart'; import 'package:mohem_flutter_app/models/chat/get_group_chat_history.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_groups_by_id.dart'; -import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart'; import 'package:mohem_flutter_app/provider/chat_call_provider.dart'; import 'package:mohem_flutter_app/provider/chat_provider_model.dart'; -import 'package:mohem_flutter_app/ui/chat/custom_auto_direction.dart'; -import 'package:mohem_flutter_app/ui/chat/call/chat_outgoing_call_screen.dart'; -import 'package:mohem_flutter_app/ui/chat/chat_bubble.dart'; import 'package:mohem_flutter_app/ui/chat/common.dart'; +import 'package:mohem_flutter_app/ui/chat/custom_auto_direction.dart'; import 'package:mohem_flutter_app/ui/chat/group_chat_bubble.dart'; import 'package:mohem_flutter_app/widgets/chat_app_bar_widge.dart'; import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart'; import 'package:provider/provider.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; -import 'package:signalr_netcore/signalr_client.dart'; import 'package:swipe_to/swipe_to.dart'; class GroupChatDetailedScreenParams { @@ -58,11 +52,11 @@ class _GroupChatDetailScreenState extends State { data.paginationVal = data.paginationVal + 10; if (params != null) { data.getGroupChatHistory(params!.groupChatDetails! - // senderUID: AppState().chatDetails!.response!.id!.toInt(), - // receiverUID: params!.groupChatDetails!.groupId!, - // loadMore: true, - // isNewChat: false, - ); + // senderUID: AppState().chatDetails!.response!.id!.toInt(), + // receiverUID: params!.groupChatDetails!.groupId!, + // loadMore: true, + // isNewChat: false, + ); } } await Future.delayed( @@ -83,13 +77,12 @@ class _GroupChatDetailScreenState extends State { data = Provider.of(context, listen: false); // callPro = Provider.of(context, listen: false); if (params != null) { - data.getGroupChatHistory( - params!.groupChatDetails! - // senderUID: AppState().chatDetails!.response!.id!.toInt(), - // receiverUID: params!.groupChatHistory!.groupId!, - // loadMore: false, - // isNewChat: params!.isNewChat!, - ); + data.getGroupChatHistory(params!.groupChatDetails! + // senderUID: AppState().chatDetails!.response!.id!.toInt(), + // receiverUID: params!.groupChatHistory!.groupId!, + // loadMore: false, + // isNewChat: params!.isNewChat!, + ); data.initAudio(receiverId: params!.groupChatDetails!.groupId!); } @@ -99,8 +92,8 @@ class _GroupChatDetailScreenState extends State { context, title: params!.groupChatDetails!.groupName.toString().replaceAll(".", " ").capitalizeFirstofEach, showHomeButton: false, - // showTyping: true, - // chatUser: params!.groupChatHistory!.groupChatHistoryTargetUserList as ChatUser, + // showTyping: true, + // chatUser: params!.groupChatHistory!.groupChatHistoryTargetUserList as ChatUser, actions: [ // SvgPicture.asset("assets/icons/chat/call.svg", width: 21, height: 23).onPress(() { // makeCall(callType: "AUDIO"); @@ -117,224 +110,220 @@ class _GroupChatDetailScreenState extends State { builder: (BuildContext context, ChatProviderModel m, Widget? child) { return (m.isLoading ? ChatHomeShimmer( - isDetailedScreen: true, - ) + isDetailedScreen: true, + ) : Column( - children: [ - SmartRefresher( - enablePullDown: false, - enablePullUp: true, - onLoading: () { - getMoreChat(); - }, - header: const MaterialClassicHeader( - color: MyColors.gradiantEndColor, - ), - controller: _rc, - reverse: true, - child: ListView.separated( - controller: m.scrollController, - shrinkWrap: true, - physics: const BouncingScrollPhysics(), - reverse: true, - itemCount: m.groupChatHistory.length, - padding: const EdgeInsets.all(21), - separatorBuilder: (BuildContext cxt, int index) => 8.height, - itemBuilder: (BuildContext context, int i) { - return SwipeTo( - iconColor: MyColors.lightGreenColor, - child: GroupChatBubble( - dateTime: m.groupChatHistory[i].createdDate!, - cItem: m.groupChatHistory[i], - ), - onRightSwipe: (val) { - m.groupChatReply( - m.groupChatHistory[i], - ); + children: [ + SmartRefresher( + enablePullDown: false, + enablePullUp: true, + onLoading: () { + getMoreChat(); }, - ).onPress(() async { - logger.w(m.userChatHistory[i].toJson()); - if (m.userChatHistory[i].fileTypeResponse != null && m.userChatHistory[i].fileTypeId != null) { - if (m.userChatHistory[i].fileTypeId! == 1 || - m.userChatHistory[i].fileTypeId! == 5 || - m.userChatHistory[i].fileTypeId! == 7 || - m.userChatHistory[i].fileTypeId! == 6 || - m.userChatHistory[i].fileTypeId! == 8 - // || m.userChatHistory[i].fileTypeId! == 2 - ) { - m.getChatMedia(context, - fileTypeName: m.userChatHistory[i].fileTypeResponse!.fileTypeName ?? "", fileTypeID: m.userChatHistory[i].fileTypeId!, fileName: m.userChatHistory[i].contant!); - } - } - }); - }, - ), - ).expanded, - if (m.isReplyMsg) - SizedBox( - height: 82, - child: Row( - children: [ - Container(height: 82, color: MyColors.textMixColor, width: 6), - Container( - color: MyColors.darkTextColor.withOpacity(0.10), - padding: const EdgeInsets.only(top: 11, left: 14, bottom: 14, right: 21), + header: const MaterialClassicHeader( + color: MyColors.gradiantEndColor, + ), + controller: _rc, + reverse: true, + child: ListView.separated( + controller: m.scrollController, + shrinkWrap: true, + physics: const BouncingScrollPhysics(), + reverse: true, + itemCount: m.groupChatHistory.length, + padding: const EdgeInsets.all(21), + separatorBuilder: (BuildContext cxt, int index) => 8.height, + itemBuilder: (BuildContext context, int i) { + return SwipeTo( + iconColor: MyColors.lightGreenColor, + child: GroupChatBubble( + dateTime: m.groupChatHistory[i].createdDate!, + cItem: m.groupChatHistory[i], + ), + onRightSwipe: (val) { + m.groupChatReply( + m.groupChatHistory[i], + ); + }, + ).onPress(() async { + logger.w(m.userChatHistory[i].toJson()); + if (m.userChatHistory[i].fileTypeResponse != null && m.userChatHistory[i].fileTypeId != null) { + if (m.userChatHistory[i].fileTypeId! == 1 || + m.userChatHistory[i].fileTypeId! == 5 || + m.userChatHistory[i].fileTypeId! == 7 || + m.userChatHistory[i].fileTypeId! == 6 || + m.userChatHistory[i].fileTypeId! == 8 + // || m.userChatHistory[i].fileTypeId! == 2 + ) { + m.getChatMedia(context, + fileTypeName: m.userChatHistory[i].fileTypeResponse!.fileTypeName ?? "", fileTypeID: m.userChatHistory[i].fileTypeId!, fileName: m.userChatHistory[i].contant!); + } + } + }); + }, + ), + ).expanded, + if (m.isReplyMsg) + SizedBox( + height: 82, child: Row( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - (AppState().chatDetails!.response!.userName == m.groupChatReplyData.first.currentUserName.toString() - ? "You" - : m.groupChatReplyData.first.currentUserName.toString().replaceAll(".", " ")) - .toText14(color: MyColors.lightGreenColor), - (m.groupChatReplyData.isNotEmpty ? m.groupChatReplyData.first.contant! : "").toText12(color: MyColors.grey71Color, maxLine: 2) - ], + children: [ + Container(height: 82, color: MyColors.textMixColor, width: 6), + Container( + color: MyColors.darkTextColor.withOpacity(0.10), + padding: const EdgeInsets.only(top: 11, left: 14, bottom: 14, right: 21), + child: Row( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + (AppState().chatDetails!.response!.userName == m.groupChatReplyData.first.currentUserName.toString() + ? "You" + : m.groupChatReplyData.first.currentUserName.toString().replaceAll(".", " ")) + .toText14(color: MyColors.lightGreenColor), + (m.groupChatReplyData.isNotEmpty ? m.groupChatReplyData.first.contant! : "").toText12(color: MyColors.grey71Color, maxLine: 2) + ], + ).expanded, + 12.width, + if (m.isReplyMsg && m.groupChatReplyData.isNotEmpty) showReplyImage(m.groupChatReplyData, m), + 12.width, + const Icon(Icons.cancel, size: 23, color: MyColors.grey7BColor).onPress(m.closeMe), + ], + ), ).expanded, - 12.width, - if (m.isReplyMsg && m.groupChatReplyData.isNotEmpty) showReplyImage(m.groupChatReplyData, m), - 12.width, - const Icon(Icons.cancel, size: 23, color: MyColors.grey7BColor).onPress(m.closeMe), ], ), - ).expanded, - ], - ), - ), - if (m.isAttachmentMsg && m.sFileType == ".png" || m.sFileType == ".jpeg" || m.sFileType == ".jpg") - SizedBox(height: 200, width: double.infinity, child: Image.file(m.selectedFile, fit: BoxFit.cover)).paddingOnly(left: 21, right: 21, top: 21), - const Divider(height: 1, color: MyColors.lightGreyEFColor), - if (m.isRecoding) - Column( - children: [ - Row( - children: [ - Text(m.buildTimer()).paddingAll(10), - if (m.isRecoding && m.isPlaying) - WaveBubble( - playerController: m.playerController, - isPlaying: m.playerController.playerState == PlayerState.playing, - onTap: () {}, - ).expanded - else - AudioWaveforms( - waveStyle: const WaveStyle( - waveColor: MyColors.lightGreenColor, - middleLineColor: Colors.transparent, - extendWaveform: true, - showBottom: true, - showTop: true, - waveThickness: 2, - showMiddleLine: false, - middleLineThickness: 0, - ), - padding: const EdgeInsets.all(5), - shouldCalculateScrolledPosition: false, - margin: EdgeInsets.zero, - size: const Size(double.infinity, 30.0), - recorderController: m.recorderController, - backgroundColor: Colors.white, - ).expanded, - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - const Icon( - Icons.delete_outlined, - size: 26, - color: MyColors.lightGreenColor, - ).paddingAll(10).onPress(() { - m.deleteRecoding(); - }), - SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26) - .onPress( - () => m.sendGroupChatMessage(context, - targetUserId: params!.groupChatDetails!.groupId!, - userStatus: 0, - userEmail: "", - targetUserName: params!.groupChatDetails!.groupName!, - userList: params!.groupChatDetails!.groupUserList! - ), - ) - .paddingOnly(right: 21), - ], - ), - ], - ).objectContainerView(disablePadding: true, radius: 0), - if (!m.isRecoding) - Row( - children: [ - CustomAutoDirection( - onDirectionChange: (bool isRTL) => m.onDirectionChange(isRTL), - text: m.msgText, - child: TextField( - // textDirection: m.textDirection, - controller: m.message, - decoration: InputDecoration( - hintTextDirection: m.textDirection, - hintText: m.isAttachmentMsg ? m.selectedFile.path.split("/").last : LocaleKeys.typeheretoreply.tr(), - hintStyle: TextStyle(color: m.isAttachmentMsg ? MyColors.darkTextColor : MyColors.grey98Color, fontSize: 14), - border: InputBorder.none, - focusedBorder: InputBorder.none, - enabledBorder: InputBorder.none, - errorBorder: InputBorder.none, - disabledBorder: InputBorder.none, - filled: true, - fillColor: MyColors.white, - contentPadding: const EdgeInsets.only( - left: 21, - top: 20, - bottom: 20, - ), - prefixIconConstraints: const BoxConstraints(), - prefixIcon: m.sFileType.isNotEmpty - ? SvgPicture.asset(m.getType(m.sFileType), height: 30, width: 22, alignment: Alignment.center, fit: BoxFit.cover).paddingOnly(left: 21, right: 15) - : null, - ), - onChanged: (String val) { - m.inputBoxDirection(val); - m.groupTypingInvoke(groupDetails: params!.groupChatDetails!, groupId: params!.groupChatDetails!.groupId!); - }, - ).expanded, - ), - if (m.sFileType.isNotEmpty) - Row( + ), + if (m.isAttachmentMsg && m.sFileType == ".png" || m.sFileType == ".jpeg" || m.sFileType == ".jpg") + SizedBox(height: 200, width: double.infinity, child: Image.file(m.selectedFile, fit: BoxFit.cover)).paddingOnly(left: 21, right: 21, top: 21), + const Divider(height: 1, color: MyColors.lightGreyEFColor), + if (m.isRecoding) + Column( children: [ - const Icon(Icons.cancel, size: 15, color: MyColors.redA3Color).paddingOnly(right: 5), - ("Clear").toText11(color: MyColors.redA3Color, isUnderLine: true).paddingOnly(left: 0), + Row( + children: [ + Text(m.buildTimer()).paddingAll(10), + if (m.isRecoding && m.isPlaying) + WaveBubble( + playerController: m.playerController, + isPlaying: m.playerController.playerState == PlayerState.playing, + onTap: () {}, + ).expanded + else + AudioWaveforms( + waveStyle: const WaveStyle( + waveColor: MyColors.lightGreenColor, + middleLineColor: Colors.transparent, + extendWaveform: true, + showBottom: true, + showTop: true, + waveThickness: 2, + showMiddleLine: false, + middleLineThickness: 0, + ), + padding: const EdgeInsets.all(5), + shouldCalculateScrolledPosition: false, + margin: EdgeInsets.zero, + size: const Size(double.infinity, 30.0), + recorderController: m.recorderController, + backgroundColor: Colors.white, + ).expanded, + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Icon( + Icons.delete_outlined, + size: 26, + color: MyColors.lightGreenColor, + ).paddingAll(10).onPress(() { + m.deleteRecoding(); + }), + SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26) + .onPress( + () => m.sendGroupChatMessage(context, + targetUserId: params!.groupChatDetails!.groupId!, + userStatus: 0, + userEmail: "", + targetUserName: params!.groupChatDetails!.groupName!, + userList: params!.groupChatDetails!.groupUserList!), + ) + .paddingOnly(right: 21), + ], + ), ], - ).onPress(() => m.removeAttachment()).paddingOnly(right: 15), - if (m.sFileType.isEmpty) - RotationTransition( - turns: const AlwaysStoppedAnimation(45 / 360), - child: const Icon(Icons.attach_file_rounded, size: 26, color: MyColors.grey3AColor).onPress( - () => { - m.selectImageToUpload(context) + ).objectContainerView(disablePadding: true, radius: 0), + if (!m.isRecoding) + Row( + children: [ + CustomAutoDirection( + onDirectionChange: (bool isRTL) => m.onDirectionChange(isRTL), + text: m.msgText, + child: TextField( + // textDirection: m.textDirection, + controller: m.message, + decoration: InputDecoration( + hintTextDirection: m.textDirection, + hintText: m.isAttachmentMsg ? m.selectedFile.path.split("/").last : LocaleKeys.typeheretoreply.tr(), + hintStyle: TextStyle(color: m.isAttachmentMsg ? MyColors.darkTextColor : MyColors.grey98Color, fontSize: 14), + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + errorBorder: InputBorder.none, + disabledBorder: InputBorder.none, + filled: true, + fillColor: MyColors.white, + contentPadding: const EdgeInsets.only( + left: 21, + top: 20, + bottom: 20, + ), + prefixIconConstraints: const BoxConstraints(), + prefixIcon: m.sFileType.isNotEmpty + ? SvgPicture.asset(m.getType(m.sFileType), height: 30, width: 22, alignment: Alignment.center, fit: BoxFit.cover).paddingOnly(left: 21, right: 15) + : null, + ), + onChanged: (String val) { + m.inputBoxDirection(val); + m.groupTypingInvoke(groupDetails: params!.groupChatDetails!, groupId: params!.groupChatDetails!.groupId!); }, - ), - ).paddingOnly(right: 15), - const Icon( - Icons.mic, - color: MyColors.lightGreenColor, - ).paddingOnly(right: 15).onPress(() { - m.startRecoding(context); - }), - SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26) - .onPress( - () =>m.sendGroupChatMessage(context, - targetUserId: params!.groupChatDetails!.groupId!, - userStatus: 0, - userEmail: "", - targetUserName: params!.groupChatDetails!.groupName!, - userList: params!.groupChatDetails!.groupUserList! + ).expanded, ), - ) - .paddingOnly(right: 21), + if (m.sFileType.isNotEmpty) + Row( + children: [ + const Icon(Icons.cancel, size: 15, color: MyColors.redA3Color).paddingOnly(right: 5), + ("Clear").toText11(color: MyColors.redA3Color, isUnderLine: true).paddingOnly(left: 0), + ], + ).onPress(() => m.removeAttachment()).paddingOnly(right: 15), + if (m.sFileType.isEmpty) + RotationTransition( + turns: const AlwaysStoppedAnimation(45 / 360), + child: const Icon(Icons.attach_file_rounded, size: 26, color: MyColors.grey3AColor).onPress( + () => {m.selectImageToUpload(context)}, + ), + ).paddingOnly(right: 15), + const Icon( + Icons.mic, + color: MyColors.lightGreenColor, + ).paddingOnly(right: 15).onPress(() { + m.startRecoding(context); + }), + SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26) + .onPress( + () => m.sendGroupChatMessage(context, + targetUserId: params!.groupChatDetails!.groupId!, + userStatus: 0, + userEmail: "", + targetUserName: params!.groupChatDetails!.groupName!, + userList: params!.groupChatDetails!.groupUserList!), + ) + .paddingOnly(right: 21), + ], + ).objectContainerView(disablePadding: true, radius: 0), ], - ).objectContainerView(disablePadding: true, radius: 0), - ], - )); + )); }, ), ), @@ -352,17 +341,17 @@ class _GroupChatDetailScreenState extends State { } else { return data.first.fileTypeResponse != null && data.first.fileTypeResponse!.fileTypeName != null ? Container( - width: 43, - height: 43, - constraints: const BoxConstraints(), - decoration: BoxDecoration(border: Border.all(color: MyColors.darkGrey3BColor, width: 1), borderRadius: BorderRadius.circular(10.0), color: Colors.white), - child: SvgPicture.asset(m.getType(data.first.fileTypeResponse!.fileTypeName ?? ""), alignment: Alignment.center, fit: BoxFit.cover).paddingOnly(left: 5, right: 5, top: 5, bottom: 5)) + width: 43, + height: 43, + constraints: const BoxConstraints(), + decoration: BoxDecoration(border: Border.all(color: MyColors.darkGrey3BColor, width: 1), borderRadius: BorderRadius.circular(10.0), color: Colors.white), + child: SvgPicture.asset(m.getType(data.first.fileTypeResponse!.fileTypeName ?? ""), alignment: Alignment.center, fit: BoxFit.cover).paddingOnly(left: 5, right: 5, top: 5, bottom: 5)) : const SizedBox(); } } void makeCall({required String callType}) async { - callPro.initCallListeners(); + // callPro.initCallListeners(); print("================== Make call Triggered ============================"); // Map json = { // "callerID": AppState().chatDetails!.response!.id!.toString(), @@ -373,22 +362,22 @@ class _GroupChatDetailScreenState extends State { // "calltype": callType == "VIDEO" ? "Video" : "Audio", // }; logger.w(json); - // CallDataModel callData = CallDataModel.fromJson(json); - // await Navigator.push( - // context, - // MaterialPageRoute( - // builder: (BuildContext context) => OutGoingCall( - // isVideoCall: callType == "VIDEO" ? true : false, - // outGoingCallData: callData, - // ), - // ), - // ).then((value) { - // print("then"); - // callPro.stopListeners(); - // }); + // CallDataModel callData = CallDataModel.fromJson(json); + // await Navigator.push( + // context, + // MaterialPageRoute( + // builder: (BuildContext context) => OutGoingCall( + // isVideoCall: callType == "VIDEO" ? true : false, + // outGoingCallData: callData, + // ), + // ), + // ).then((value) { + // print("then"); + // callPro.stopListeners(); + // }); } + GroupUserList getCurrentUser(int id, GroupResponse groupChatDetails) { - return groupChatDetails.groupUserList!.firstWhere((GroupUserList item) => item.id ==id); + return groupChatDetails.groupUserList!.firstWhere((GroupUserList item) => item.id == id); } - } diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 87262e2..84e6d0f 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -1,10 +1,8 @@ import 'dart:async'; -import 'dart:convert'; import 'dart:io'; import 'dart:ui' as ui; import 'package:easy_localization/easy_localization.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_callkit_incoming/entities/call_event.dart'; import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart'; @@ -12,7 +10,6 @@ import 'package:flutter_countdown_timer/flutter_countdown_timer.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:mohem_flutter_app/api/dashboard_api_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; -import 'package:mohem_flutter_app/classes/chat_call_kit.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'; @@ -21,9 +18,6 @@ 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/main.dart'; -import 'package:mohem_flutter_app/models/chat/incoming_call_model.dart'; -import 'package:mohem_flutter_app/models/itg/itg_main_response.dart'; -import 'package:mohem_flutter_app/models/itg/itg_response_model.dart'; import 'package:mohem_flutter_app/models/offers_and_discounts/get_offers_list.dart'; import 'package:mohem_flutter_app/models/privilege_list_model.dart'; import 'package:mohem_flutter_app/provider/chat_call_provider.dart'; @@ -42,7 +36,6 @@ import 'package:mohem_flutter_app/widgets/shimmer/offers_shimmer_widget.dart'; import 'package:provider/provider.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:signalr_netcore/signalr_client.dart'; -import 'package:http/http.dart' as http; class DashboardScreen extends StatefulWidget { DashboardScreen({Key? key}) : super(key: key); @@ -329,106 +322,106 @@ class _DashboardScreenState extends State with WidgetsBindingOb child: Consumer( builder: (BuildContext context, DashboardProviderModel model, Widget? child) { return (model.isAttendanceTrackingLoading - ? GetAttendanceTrackingShimmer() - : Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15), - gradient: const LinearGradient(transform: GradientRotation(.46), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [ - MyColors.gradiantEndColor, - MyColors.gradiantStartColor, - ]), - ), - child: Stack( - alignment: Alignment.center, - children: [ - if (model.isTimeRemainingInSeconds == 0) SvgPicture.asset("assets/images/thumb.svg"), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, + ? GetAttendanceTrackingShimmer() + : Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + gradient: const LinearGradient(transform: GradientRotation(.46), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ]), + ), + child: Stack( + alignment: Alignment.center, children: [ - 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, - children: [ - 9.height, - Directionality( - textDirection: ui.TextDirection.ltr, - child: CountdownTimer( - endTime: model.endTime, - onEnd: null, - endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), - textStyle: const TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold), - ), - ), - LocaleKeys.timeLeftToday.tr().toText12(color: Colors.white), - 9.height, - ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(20)), - child: LinearProgressIndicator( - value: model.progress, - minHeight: 8, - valueColor: const AlwaysStoppedAnimation(Colors.white), - backgroundColor: const Color(0xff196D73), - ), - ), - ], - ), - ], - ).paddingOnly(top: 12, right: 15, left: 12), - ), - Row( - children: [ - Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, + if (model.isTimeRemainingInSeconds == 0) SvgPicture.asset("assets/images/thumb.svg"), + Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - LocaleKeys.checkIn.tr().toText12(color: Colors.white), - (model.attendanceTracking!.pSwipeIn == null ? "--:--" : model.attendanceTracking!.pSwipeIn) - .toString() - .toText14(color: Colors.white, isBold: true), - 4.height, + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 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, + children: [ + 9.height, + Directionality( + textDirection: ui.TextDirection.ltr, + child: CountdownTimer( + endTime: model.endTime, + onEnd: null, + endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), + textStyle: const TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold), + ), + ), + LocaleKeys.timeLeftToday.tr().toText12(color: Colors.white), + 9.height, + ClipRRect( + borderRadius: const BorderRadius.all(Radius.circular(20)), + child: LinearProgressIndicator( + value: model.progress, + minHeight: 8, + valueColor: const AlwaysStoppedAnimation(Colors.white), + backgroundColor: const Color(0xff196D73), + ), + ), + ], + ), + ], + ).paddingOnly(top: 12, right: 15, left: 12), + ), + Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.checkIn.tr().toText12(color: Colors.white), + (model.attendanceTracking!.pSwipeIn == null ? "--:--" : model.attendanceTracking!.pSwipeIn) + .toString() + .toText14(color: Colors.white, isBold: true), + 4.height, + ], + ).paddingOnly(left: 12, right: 12), + ), + Container( + margin: EdgeInsets.only(top: AppState().isArabic(context) ? 6 : 0), + width: 45, + height: 45, + padding: const EdgeInsets.only(left: 10, right: 10), + 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/biometrics.svg" : "assets/images/biometrics.svg"), + ).onPress(() { + showMyBottomSheet( + context, + callBackFunc: () {}, + child: MarkAttendanceWidget(model, isFromDashboard: true), + ); + }), + ], + ), ], - ).paddingOnly(left: 12, right: 12), - ), - Container( - margin: EdgeInsets.only(top: AppState().isArabic(context) ? 6 : 0), - width: 45, - height: 45, - padding: const EdgeInsets.only(left: 10, right: 10), - 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/biometrics.svg" : "assets/images/biometrics.svg"), - ).onPress(() { - showMyBottomSheet( - context, - callBackFunc: () {}, - child: MarkAttendanceWidget(model, isFromDashboard: true), - ); - }), - ], - ), - ], - ), - ], - ), - ).onPress( - () { - Navigator.pushNamed(context, AppRoutes.todayAttendance); - }, - )) + ], + ), + ).onPress( + () { + Navigator.pushNamed(context, AppRoutes.todayAttendance); + }, + )) .animatedSwither(); }, ), @@ -489,48 +482,48 @@ class _DashboardScreenState extends State with WidgetsBindingOb return model.isOffersLoading ? const OffersShimmerWidget() : InkWell( - onTap: () { - navigateToDetails(data.getOffersList[index]); - }, - child: SizedBox( - width: 73, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( + onTap: () { + navigateToDetails(data.getOffersList[index]); + }, + child: SizedBox( width: 73, - height: 73, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all( - Radius.circular(100), - ), - border: Border.all(color: MyColors.lightGreyE3Color, width: 1), - ), - child: ClipRRect( - borderRadius: const BorderRadius.all( - Radius.circular(50), - ), - child: Hero( - tag: "ItemImage" + data.getOffersList[index].offersDiscountId.toString()!, - transitionOnUserGestures: true, - child: Image.network( - data.getOffersList[index].logo ?? "", - fit: BoxFit.contain, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: 73, + height: 73, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all( + Radius.circular(100), + ), + border: Border.all(color: MyColors.lightGreyE3Color, width: 1), + ), + child: ClipRRect( + borderRadius: const BorderRadius.all( + Radius.circular(50), + ), + child: Hero( + tag: "ItemImage" + data.getOffersList[index].offersDiscountId.toString()!, + transitionOnUserGestures: true, + child: Image.network( + data.getOffersList[index].logo ?? "", + fit: BoxFit.contain, + ), + ), + ), ), - ), + 4.height, + Expanded( + child: AppState().isArabic(context) + ? data.getOffersList[index].titleAr!.toText12(isCenter: true, maxLine: 1) + : data.getOffersList[index].titleEn!.toText12(isCenter: true, maxLine: 1), + ), + ], ), ), - 4.height, - Expanded( - child: AppState().isArabic(context) - ? data.getOffersList[index].titleAr!.toText12(isCenter: true, maxLine: 1) - : data.getOffersList[index].titleEn!.toText12(isCenter: true, maxLine: 1), - ), - ], - ), - ), - ); + ); }, separatorBuilder: (BuildContext cxt, int index) => 8.width, itemCount: 9), @@ -625,27 +618,27 @@ class _DashboardScreenState extends State with WidgetsBindingOb children: [ SvgPicture.asset("assets/icons/chat/chat.svg", color: !checkIfPrivilegedForChat() ? MyColors.lightGreyE3Color : MyColors.grey98Color - // currentIndex == 4 - // ? MyColors.grey3AColor - // : cProvider.disableChatForThisUser - // ? MyColors.lightGreyE3Color - // : MyColors.grey98Color, - ) + // currentIndex == 4 + // ? MyColors.grey3AColor + // : cProvider.disableChatForThisUser + // ? MyColors.lightGreyE3Color + // : MyColors.grey98Color, + ) .paddingAll(4), Consumer( builder: (BuildContext cxt, ChatProviderModel data, Widget? child) { return !checkIfPrivilegedForChat() ? const SizedBox() : Positioned( - right: 0, - top: 0, - child: Container( - padding: const EdgeInsets.only(left: 4, right: 4), - alignment: Alignment.center, - decoration: BoxDecoration(color: data.disableChatForThisUser ? MyColors.pinkDarkColor : MyColors.redColor, borderRadius: BorderRadius.circular(17)), - child: data.chatUConvCounter.toString().toText10(color: Colors.white), - ), - ); + right: 0, + top: 0, + child: Container( + padding: const EdgeInsets.only(left: 4, right: 4), + alignment: Alignment.center, + decoration: BoxDecoration(color: data.disableChatForThisUser ? MyColors.pinkDarkColor : MyColors.redColor, borderRadius: BorderRadius.circular(17)), + child: data.chatUConvCounter.toString().toText10(color: Colors.white), + ), + ); }, ), ], diff --git a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart index 20da2c8..2d755dc 100644 --- a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart +++ b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart @@ -96,7 +96,8 @@ class _DynamicInputScreenState extends State { SubmitEITTransactionList submitEITTransactionList = await MyAttendanceApiClient().submitEitTransaction(dESCFLEXCONTEXTCODE, dynamicParams!.dynamicId, values, empID: dynamicParams!.selectedEmp); Utils.hideLoading(context); await Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, - arguments: RequestSubmitScreenParams(LocaleKeys.submit.tr(), submitEITTransactionList.pTRANSACTIONID!, submitEITTransactionList.pITEMKEY!, 'eit',isAttachmentMandatory: dynamicParams!.isAttachmentMandatory)); + arguments: RequestSubmitScreenParams(LocaleKeys.submit.tr(), submitEITTransactionList.pTRANSACTIONID!, submitEITTransactionList.pITEMKEY!, 'eit', + isAttachmentMandatory: dynamicParams!.isAttachmentMandatory)); if (!AppState().cancelRequestTrancsection) { return; }