chat changes

pull/9/head
Sultan khan 2 years ago
parent fd6058e87d
commit 790103bdc9

@ -535,5 +535,17 @@
"areYouSureWantTodelete": "هل أنت متأكد من أنك تريد الحذف؟", "areYouSureWantTodelete": "هل أنت متأكد من أنك تريد الحذف؟",
"groupMembers": "أعضاء المجموعة", "groupMembers": "أعضاء المجموعة",
"manageGroup": "إدارة المجموعة", "manageGroup": "إدارة المجموعة",
"admin": "مسؤل" "admin": "مسؤل",
"addUsers": "أضف المستخدمين إلى المجموعة",
"editGroups": "تحرير المجموعة",
"groupNameshouldbe": "يجب ألا يقل اسم المجموعة عن 10 أحرف",
"groupName": "أسم المجموعة",
"enterGroupNamePlease": "الرجاء إدخال اسم المجموعة",
"audioCall": "مكالمة صوتية",
"videoCall": "مكالمة فيديو",
"shareScreen": "شاشة المشاركة",
"searchByUserName": "البحث باسم المستخدم",
"userSearch": "بحث المستخدم",
"userName":"اسم المستخدم",
"userId":"معرف المستخدم"
} }

@ -534,5 +534,18 @@
"areYouSureWantTodelete": "Are you sure want to delete?", "areYouSureWantTodelete": "Are you sure want to delete?",
"groupMembers": "Group Members", "groupMembers": "Group Members",
"manageGroup": "Manage Group", "manageGroup": "Manage Group",
"admin": "Admin" "admin": "Admin",
} "addUsers": "Add users to the group",
"editGroups":"Edit Group",
"groupNameshouldbe": "Group name should be minimum 10 character long",
"enterGroupName": "Please enter valid group Name",
"groupName": "Group Name",
"enterGroupNamePlease": "Please enter group name",
"audioCall": "Audio Call",
"videoCall": "Video Call",
"shareScreen": "Share Screen",
"searchByUserName": "Search By Username",
"userSearch": "User Search",
"userName": "User Name",
"userId": "UserID"
}

@ -166,7 +166,7 @@ class ProfileApiClient {
], ],
"P_CONTACT_RELATIONSHIP_ID": contactRelationId, "P_CONTACT_RELATIONSHIP_ID": contactRelationId,
"P_ACTION": actionType, "P_ACTION": actionType,
"PayrollCodeStr": "CS", "PayrollCodeStr": "HMG",
"LegislationCodeStr": "SA", "LegislationCodeStr": "SA",
}; };
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);

@ -90,7 +90,7 @@ class AppState {
String get getHuaweiPushToken => _huaweiPushToken; String get getHuaweiPushToken => _huaweiPushToken;
final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 31, versionID: 4.6, mobileType: Platform.isAndroid ? "android" : "ios"); final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 33, versionID: 4.6, mobileType: Platform.isAndroid ? "android" : "ios");
void setPostParamsInitConfig() { void setPostParamsInitConfig() {
isAuthenticated = false; isAuthenticated = false;

@ -3,8 +3,8 @@ import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart';
class ApiConsts { class ApiConsts {
//static String baseUrl = "http://10.200.204.20:2801/"; // Local server //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://erptstapp.srca.org.sa"; // SRCA server
static String baseUrl = "https://uat.hmgwebservices.com"; // UAT 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 = baseUrl + "/Services/"; // server
// static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server
static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/"; static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/";

@ -545,7 +545,25 @@ class CodegenLoader extends AssetLoader{
"group": "مجموعة", "group": "مجموعة",
"searchGroup": "مجموعة البحث", "searchGroup": "مجموعة البحث",
"connectHmgWifi": "قم بتوصيل HMG WIFI", "connectHmgWifi": "قم بتوصيل HMG WIFI",
"connectedHmgWifi": "اتصال HMG WIFI" "connectedHmgWifi": "اتصال HMG WIFI",
"manage": "يدير",
"members": "أعضاء",
"areYouSureWantTodelete": "هل أنت متأكد من أنك تريد الحذف؟",
"groupMembers": "أعضاء المجموعة",
"manageGroup": "إدارة المجموعة",
"admin": "مسؤل",
"addUsers": "أضف المستخدمين إلى المجموعة",
"editGroups": "تحرير المجموعة",
"groupNameshouldbe": "يجب ألا يقل اسم المجموعة عن 10 أحرف",
"groupName": "أسم المجموعة",
"enterGroupNamePlease": "الرجاء إدخال اسم المجموعة",
"audioCall": "مكالمة صوتية",
"videoCall": "مكالمة فيديو",
"shareScreen": "شاشة المشاركة",
"searchByUserName": "البحث باسم المستخدم",
"userSearch": "بحث المستخدم",
"userName": "اسم المستخدم",
"userId": "معرف المستخدم"
}; };
static const Map<String,dynamic> en_US = { static const Map<String,dynamic> en_US = {
"mohemm": "Mohemm", "mohemm": "Mohemm",
@ -1077,7 +1095,26 @@ static const Map<String,dynamic> en_US = {
"youCanPlayDemo": "But you can play demo", "youCanPlayDemo": "But you can play demo",
"group": "Groups", "group": "Groups",
"searchGroup": "Search Group", "searchGroup": "Search Group",
"connectHmgWifi": "Connect HMG WIFI" "connectHmgWifi": "Connect HMG WIFI",
"manage": "Manage",
"members": "Members",
"areYouSureWantTodelete": "Are you sure want to delete?",
"groupMembers": "Group Members",
"manageGroup": "Manage Group",
"admin": "Admin",
"addUsers": "Add users to the group",
"editGroups": "Edit Group",
"groupNameshouldbe": "Group name should be minimum 10 character long",
"enterGroupName": "Please enter valid group Name",
"groupName": "Group Name",
"enterGroupNamePlease": "Please enter group name",
"audioCall": "Audio Call",
"videoCall": "Video Call",
"shareScreen": "Share Screen",
"searchByUserName": "Search By Username",
"userSearch": "User Search",
"userName": "User Name",
"userId": "UserID"
}; };
static const Map<String, Map<String,dynamic>> mapLocales = {"ar_SA": ar_SA, "en_US": en_US}; static const Map<String, Map<String,dynamic>> mapLocales = {"ar_SA": ar_SA, "en_US": en_US};
} }

@ -522,4 +522,17 @@ abstract class LocaleKeys {
static const groupMembers = "groupMembers"; static const groupMembers = "groupMembers";
static const manageGroup = "manageGroup"; static const manageGroup = "manageGroup";
static const admin = "admin"; static const admin = "admin";
static const addUsers ="addUsers";
static const editGroups ="editGroups";
static const groupNameshouldbe ="groupNameshouldbe";
static const enterGroupName ="enterGroupName";
static const groupName ="groupName";
static const enterGroupNamePlease ="enterGroupNamePlease";
static const audioCall = 'audioCall';
static const videoCall ='videoCall';
static const shareScreen ='shareScreen';
static const searchByUserName ='searchByUserName';
static const userSearch ='userSearch';
static const userName ='userName';
static const userId ='userId';
} }

@ -86,10 +86,10 @@ class GetGroupChatHistoryAsync {
fileTypeResponse = json['fileTypeResponse'] != null fileTypeResponse = json['fileTypeResponse'] != null
? new FileTypeResponse.fromJson(json['fileTypeResponse']) ? new FileTypeResponse.fromJson(json['fileTypeResponse'])
: null; : null;
groupChatReplyResponse = json["userChatReplyResponse"] == null ? null : GroupChatReplyResponse.fromJson(json["userChatReplyResponse"]); groupChatReplyResponse = json["groupChatReplyResponse"] == null ? null : GroupChatReplyResponse.fromJson(json["groupChatReplyResponse"]);
isReplied= json['isReplied']; isReplied= json['isReplied'];
isImageLoaded= json['isImageLoaded']; isImageLoaded= json['isImageLoaded'] ??false;
image= json['image']; image= json['image'];
voice= json['voice']; voice= json['voice'];
voiceController = json["fileTypeId"] == 13 ? AudioPlayer() : null; voiceController = json["fileTypeId"] == 13 ? AudioPlayer() : null;
@ -126,7 +126,7 @@ class GetGroupChatHistoryAsync {
} }
data['isReplied'] =isReplied; data['isReplied'] =isReplied;
data['isImageLoaded'] = isImageLoaded; data['isImageLoaded'] = isImageLoaded ?? false;
data['image'] = image; data['image'] = image;
data['voice'] = voice; data['voice'] = voice;
data["fileTypeId"] == 13 ? AudioPlayer() : null; data["fileTypeId"] == 13 ? AudioPlayer() : null;
@ -140,7 +140,7 @@ class GroupChatHistoryTargetUserList {
bool? isDelivered; bool? isDelivered;
int? targetUserId; int? targetUserId;
String? targetUserName; String? targetUserName;
Null? userAction; dynamic? userAction;
GroupChatHistoryTargetUserList( GroupChatHistoryTargetUserList(
{this.groupChatHistoryLineId, {this.groupChatHistoryLineId,

@ -0,0 +1,32 @@
class TargetUsers {
bool? isSeen;
bool? isDelivered;
int? targetUserId;
int? userAction;
int? userStatus;
TargetUsers(
{this.isSeen,
this.isDelivered,
this.targetUserId,
this.userAction,
this.userStatus});
TargetUsers.fromJson(Map<String, dynamic> json) {
isSeen = json['isSeen'];
isDelivered = json['isDelivered'];
targetUserId = json['targetUserId'];
userAction = json['userAction'];
userStatus = json['userStatus'];
}
Map<String, dynamic> toJson() {
Map<String, dynamic> data = new Map<String, dynamic>();
data['isSeen'] = this.isSeen;
data['isDelivered'] = this.isDelivered;
data['targetUserId'] = this.targetUserId;
data['userAction'] = this.userAction;
data['userStatus'] = this.userStatus;
return data;
}
}

@ -32,6 +32,7 @@ import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart'
as userLoginToken; as userLoginToken;
import 'package:mohem_flutter_app/models/chat/make_user_favotire_unfavorite_chat_model.dart' import 'package:mohem_flutter_app/models/chat/make_user_favotire_unfavorite_chat_model.dart'
as fav; 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/models/my_team/get_employee_subordinates_list.dart';
import 'package:mohem_flutter_app/ui/chat/chat_detailed_screen.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/ui/landing/dashboard_screen.dart';
@ -89,7 +90,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
//Chat Home Page Counter //Chat Home Page Counter
int chatUConvCounter = 0; int chatUConvCounter = 0;
late List<groupchathistory.GetGroupChatHistoryAsync> groupChatHistory; late List<groupchathistory.GetGroupChatHistoryAsync> groupChatHistory, groupChatReplyData;
/// Search Provider /// Search Provider
List<ChatUser>? chatUsersList = []; List<ChatUser>? chatUsersList = [];
@ -121,6 +122,10 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
} }
chatHubConnection.on("OnDeliveredChatUserAsync", onMsgReceived); chatHubConnection.on("OnDeliveredChatUserAsync", onMsgReceived);
chatHubConnection.on("OnGetChatConversationCount", onNewChatConversion); chatHubConnection.on("OnGetChatConversationCount", onNewChatConversion);
//group On message
chatHubConnection.on("OnDeliveredGroupChatHistoryAsync", onGroupMsgReceived);
} }
Future<HubConnection> getHubConnection() async { Future<HubConnection> getHubConnection() async {
@ -140,6 +145,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
void registerEvents() { void registerEvents() {
chatHubConnection.on("OnUpdateUserStatusAsync", changeStatus); chatHubConnection.on("OnUpdateUserStatusAsync", changeStatus);
// chatHubConnection.on("OnDeliveredChatUserAsync", onMsgReceived); // chatHubConnection.on("OnDeliveredChatUserAsync", onMsgReceived);
chatHubConnection.on("OnSubmitChatAsync", OnSubmitChatAsync); chatHubConnection.on("OnSubmitChatAsync", OnSubmitChatAsync);
chatHubConnection.on("OnUserTypingAsync", onUserTyping); chatHubConnection.on("OnUserTypingAsync", onUserTyping);
chatHubConnection.on("OnUserCountAsync", userCountAsync); chatHubConnection.on("OnUserCountAsync", userCountAsync);
@ -148,6 +154,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
"OnGetUserChatHistoryNotDeliveredAsync", chatNotDelivered); "OnGetUserChatHistoryNotDeliveredAsync", chatNotDelivered);
chatHubConnection.on( chatHubConnection.on(
"OnUpdateUserChatHistoryStatusAsync", updateUserChatStatus); "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}]]}
if (kDebugMode) { if (kDebugMode) {
logger.i("All listeners registered"); logger.i("All listeners registered");
@ -288,6 +299,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
List<SingleUserChatModel>.from( List<SingleUserChatModel>.from(
json.decode(str).map((x) => SingleUserChatModel.fromJson(x))); json.decode(str).map((x) => SingleUserChatModel.fromJson(x)));
List<groupchathistory.GetGroupChatHistoryAsync> getGroupChatHistoryAsync(String str) =>
List<groupchathistory.GetGroupChatHistoryAsync>.from(
json.decode(str).map((x) => groupchathistory.GetGroupChatHistoryAsync.fromJson(x)));
Future<dynamic> uploadAttachments(String userId, File file) async { Future<dynamic> uploadAttachments(String userId, File file) async {
dynamic result; dynamic result;
try { try {
@ -316,6 +332,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
notifyListeners(); notifyListeners();
} }
void getGroupUserStatus(List<Object?>? args){
//note: need to implement this function...
print(args);
}
void onChatSeen(List<Object?>? args) { void onChatSeen(List<Object?>? args) {
dynamic items = args!.toList(); dynamic items = args!.toList();
// for (var user in searchedChats!) { // for (var user in searchedChats!) {
@ -495,6 +516,107 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
notifyListeners(); notifyListeners();
} }
Future<void> onGroupMsgReceived(List<Object?>? parameters) async {
List<groupchathistory.GetGroupChatHistoryAsync> data = [], temp = [];
for (dynamic msg in parameters!) {
// groupChatHistory.add(groupchathistory.GetGroupChatHistoryAsync.fromJson(msg));
data.add(groupchathistory.GetGroupChatHistoryAsync.fromJson(msg));
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.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");
data.first.groupChatReplyResponse!.isImageLoaded = true;
}
}
}
}
// if (searchedChats != null) {
// dynamic contain = searchedChats!
// .where((ChatUser element) => element.id == data.first.currentUserId);
// if (contain.isEmpty) {
// List<String> emails = [];
// emails.add(await EmailImageEncryption()
// .encrypt(val: data.first.currentUserEmail!));
// List<ChatUserImageModel> chatImages =
// await ChatApiClient().getUsersImages(encryptedEmails: emails);
// searchedChats!.add(
// ChatUser(
// id: data.first.currentUserId,
// userName: data.first.currentUserName,
// email: data.first.currentUserEmail,
// unreadMessageCount: 0,
// isImageLoading: false,
// image: chatImages!.first.profilePicture ?? "",
// isImageLoaded: true,
// userStatus: 1,
// isTyping: false,
// userLocalDownlaodedImage: await downloadImageLocal(
// chatImages.first.profilePicture,
// data.first.currentUserId.toString()),
// ),
// );
// }
// }
groupChatHistory.insert(0, data.first);
setMsgTune();
// if (isChatScreenActive && data.first.currentUserId == receiverID) {
// } else {
// if (searchedChats != null) {
// for (ChatUser user in searchedChats!) {
// if (user.id == data.first.currentUserId) {
// int tempCount = user.unreadMessageCount ?? 0;
// user.unreadMessageCount = tempCount + 1;
// }
// }
sort();
//}
//}
//
// List<Object> list = [
// {
// "userChatHistoryId": data.first.groupId,
// "TargetUserId": temp.first.currentUserId,
// "isDelivered": true,
// "isSeen": isChatScreenActive && data.first.currentUserId == receiverID
// ? true
// : false
// }
// ];
// updateUserChatHistoryOnMsg(list);
// invokeChatCounter(userId: AppState().chatDetails!.response!.id!);
notifyListeners();
}
void OnSubmitChatAsync(List<Object?>? parameters) { void OnSubmitChatAsync(List<Object?>? parameters) {
print(isChatScreenActive); print(isChatScreenActive);
print(receiverID); print(receiverID);
@ -711,7 +833,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
String? userEmail, String? userEmail,
int? userStatus, int? userStatus,
File? voiceFile, File? voiceFile,
required bool isVoiceAttached}) async { required bool isVoiceAttached,
required List<GroupUserList> userList
}) async {
Uuid uuid = const Uuid(); Uuid uuid = const Uuid();
String contentNo = uuid.v4(); String contentNo = uuid.v4();
String msg; String msg;
@ -736,15 +860,13 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
groupName: targetUserName, groupName: targetUserName,
isReplied: false, isReplied: false,
fileTypeId: fileTypeId, fileTypeId: fileTypeId,
// userChatReplyResponse: isReply ? UserChatReplyResponse.fromJson(repliedMsg.first.toJson()) : null, fileTypeResponse: isAttachment
// fileTypeResponse: isAttachment ? groupchathistory.FileTypeResponse(
// ? FileTypeResponse( fileTypeId: fileTypeId,
// fileTypeId: fileTypeId, fileTypeName: isVoiceMsg ? getFileExtension(voiceFile!.path).toString() : getFileExtension(selectedFile.path).toString(),
// fileTypeName: isVoiceMsg ? getFileExtension(voiceFile!.path).toString() : getFileExtension(selectedFile.path).toString(), fileKind: "file",
// fileKind: "file", fileName: isVoiceMsg ? msg : selectedFile.path.split("/").last,
// fileName: isVoiceMsg ? msg : selectedFile.path.split("/").last, fileTypeDescription: isVoiceMsg ? getFileTypeDescription(getFileExtension(voiceFile!.path).toString()) : getFileTypeDescription(getFileExtension(selectedFile.path).toString())) : null,
// fileTypeDescription: isVoiceMsg ? getFileTypeDescription(getFileExtension(voiceFile!.path).toString()) : getFileTypeDescription(getFileExtension(selectedFile.path).toString()),
image: image, image: image,
isImageLoaded: isImageLoaded, isImageLoaded: isImageLoaded,
voice: isVoiceMsg ? voiceFile! : null, voice: isVoiceMsg ? voiceFile! : null,
@ -752,7 +874,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
if (kDebugMode) { if (kDebugMode) {
logger.i("model data: " + jsonEncode(data)); logger.i("model data: " + jsonEncode(data));
} }
// groupChatHistory.insert(0, data); groupChatHistory.insert(0, data);
isTextMsg = false; isTextMsg = false;
isReplyMsg = false; isReplyMsg = false;
isAttachmentMsg = false; isAttachmentMsg = false;
@ -761,11 +883,15 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
message.clear(); message.clear();
notifyListeners(); notifyListeners();
String chatData = List<TargetUsers> targetUsers =[];
'{"contant":"$msg","contantNo":"$contentNo","chatEventId":$chatEventId,"fileTypeId":$fileTypeId,"currentUserId":${AppState().chatDetails!.response!.id},"chatSource":1,"groupId":$targetGroupId,"groupChatHistoryLineRequestList":[{"isSeen":false,"isDelivered":false,"targetUserId":${AppState().chatDetails!.response!.id},"userAction":0,"userStatus":1}],"conversationId":"${uuid.v4()}"}';
for (GroupUserList element in userList) {
targetUsers.add(TargetUsers(isDelivered: false,isSeen: false, targetUserId: element.id, userAction: element.userAction, userStatus: element.userStatus));
}
// String chatData = 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"}'; '{"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", await chatHubConnection.invoke("AddGroupChatHistoryAsync",
args: <Object>[json.decode(chatData)]); args: <Object>[json.decode(chatData)]);
@ -775,7 +901,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
{required int targetUserId, {required int targetUserId,
required int userStatus, required int userStatus,
required String userEmail, required String userEmail,
required String targetUserName}) async { required String targetUserName,
required List<GroupUserList> userList,
}) async {
if (isTextMsg && !isAttachmentMsg && !isVoiceMsg && !isReplyMsg) { if (isTextMsg && !isAttachmentMsg && !isVoiceMsg && !isReplyMsg) {
logger.d("// Normal Text Message"); logger.d("// Normal Text Message");
if (message.text.isEmpty) { if (message.text.isEmpty) {
@ -793,7 +921,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
image: null, image: null,
isVoiceAttached: false, isVoiceAttached: false,
userEmail: userEmail, userEmail: userEmail,
userStatus: userStatus); userStatus: userStatus,
userList:userList
);
} else if (isTextMsg && !isAttachmentMsg && !isVoiceMsg && isReplyMsg) { } else if (isTextMsg && !isAttachmentMsg && !isVoiceMsg && isReplyMsg) {
logger.d("// Text Message as Reply"); logger.d("// Text Message as Reply");
if (message.text.isEmpty) { if (message.text.isEmpty) {
@ -804,15 +934,17 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
fileTypeId: null, fileTypeId: null,
targetGroupId: targetUserId, targetGroupId: targetUserId,
targetUserName: targetUserName, targetUserName: targetUserName,
chatReplyId: repliedMsg.first.userChatHistoryId, chatReplyId: groupChatReplyData.first.groupChatHistoryId,
isAttachment: false, isAttachment: false,
isReply: true, isReply: true,
isImageLoaded: repliedMsg.first.isImageLoaded!, isImageLoaded: groupChatReplyData.first.isImageLoaded!,
image: repliedMsg.first.image, image: groupChatReplyData.first.image,
isVoiceAttached: false, isVoiceAttached: false,
voiceFile: null, voiceFile: null,
userEmail: userEmail, userEmail: userEmail,
userStatus: userStatus); userStatus: userStatus,
userList:userList
);
} }
// Attachment // Attachment
else if (!isTextMsg && isAttachmentMsg && !isVoiceMsg && !isReplyMsg) { else if (!isTextMsg && isAttachmentMsg && !isVoiceMsg && !isReplyMsg) {
@ -820,12 +952,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
Utils.showLoading(context); Utils.showLoading(context);
dynamic value = await uploadAttachments( dynamic value = await uploadAttachments(
AppState().chatDetails!.response!.id.toString(), selectedFile); AppState().chatDetails!.response!.id.toString(), selectedFile);
// String? ext = getFileExtension(selectedFile.path); String? ext = getFileExtension(selectedFile.path);
Utils.hideLoading(context); Utils.hideLoading(context);
sendGroupChatToServer( sendGroupChatToServer(
chatEventId: 2, chatEventId: 2,
fileTypeId: "jpg", fileTypeId: getFileType(ext.toString()),
//getFileType(ext.toString()),
targetGroupId: targetUserId, targetGroupId: targetUserId,
targetUserName: targetUserName, targetUserName: targetUserName,
isAttachment: true, isAttachment: true,
@ -835,18 +966,20 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
image: selectedFile.readAsBytesSync(), image: selectedFile.readAsBytesSync(),
isVoiceAttached: false, isVoiceAttached: false,
userEmail: userEmail, userEmail: userEmail,
userStatus: userStatus); userStatus: userStatus,
userList:userList
);
} else if (!isTextMsg && isAttachmentMsg && !isVoiceMsg && isReplyMsg) { } else if (!isTextMsg && isAttachmentMsg && !isVoiceMsg && isReplyMsg) {
logger.d("// Image as Reply Msg"); logger.d("// Image as Reply Msg");
Utils.showLoading(context); Utils.showLoading(context);
dynamic value = await uploadAttachments( dynamic value = await uploadAttachments(
AppState().chatDetails!.response!.id.toString(), selectedFile); AppState().chatDetails!.response!.id.toString(), selectedFile);
// String? ext = getFileExtension(selectedFile.path); String? ext = getFileExtension(selectedFile.path);
Utils.hideLoading(context); Utils.hideLoading(context);
sendGroupChatToServer( sendGroupChatToServer(
chatEventId: 2, chatEventId: 2,
fileTypeId: "jpg", fileTypeId: getFileType(ext.toString()),
//getFileType(ext.toString()),
targetGroupId: targetUserId, targetGroupId: targetUserId,
targetUserName: targetUserName, targetUserName: targetUserName,
isAttachment: true, isAttachment: true,
@ -856,7 +989,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
image: selectedFile.readAsBytesSync(), image: selectedFile.readAsBytesSync(),
isVoiceAttached: false, isVoiceAttached: false,
userEmail: userEmail, userEmail: userEmail,
userStatus: userStatus); userStatus: userStatus,
userList:userList
);
} }
//Voice //Voice
@ -878,12 +1013,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
Utils.showLoading(context); Utils.showLoading(context);
dynamic value = await uploadAttachments( dynamic value = await uploadAttachments(
AppState().chatDetails!.response!.id.toString(), voiceFile); AppState().chatDetails!.response!.id.toString(), voiceFile);
// String? ext = getFileExtension(voiceFile.path); String? ext = getFileExtension(voiceFile.path);
Utils.hideLoading(context); Utils.hideLoading(context);
sendGroupChatToServer( sendGroupChatToServer(
chatEventId: 2, chatEventId: 2,
fileTypeId: "jpg", fileTypeId: getFileType(ext.toString()),
//getFileType(ext.toString()), //,
targetGroupId: targetUserId, targetGroupId: targetUserId,
targetUserName: targetUserName, targetUserName: targetUserName,
chatReplyId: null, chatReplyId: null,
@ -893,7 +1028,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
voiceFile: voiceFile, voiceFile: voiceFile,
isVoiceAttached: true, isVoiceAttached: true,
userEmail: userEmail, userEmail: userEmail,
userStatus: userStatus); userStatus: userStatus,
userList:userList
);
notifyListeners(); notifyListeners();
} else if (!isTextMsg && !isAttachmentMsg && isVoiceMsg && isReplyMsg) { } else if (!isTextMsg && !isAttachmentMsg && isVoiceMsg && isReplyMsg) {
logger.d("// Voice as Reply Msg"); logger.d("// Voice as Reply Msg");
@ -914,12 +1051,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
Utils.showLoading(context); Utils.showLoading(context);
dynamic value = await uploadAttachments( dynamic value = await uploadAttachments(
AppState().chatDetails!.response!.id.toString(), voiceFile); AppState().chatDetails!.response!.id.toString(), voiceFile);
// String? ext = getFileExtension(voiceFile.path); String? ext = getFileExtension(voiceFile.path);
Utils.hideLoading(context); Utils.hideLoading(context);
sendGroupChatToServer( sendGroupChatToServer(
chatEventId: 2, chatEventId: 2,
fileTypeId: "jpg", fileTypeId: getFileType(ext.toString()),
//getFileType(ext.toString()),
targetGroupId: targetUserId, targetGroupId: targetUserId,
targetUserName: targetUserName, targetUserName: targetUserName,
chatReplyId: null, chatReplyId: null,
@ -929,7 +1065,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
voiceFile: voiceFile, voiceFile: voiceFile,
isVoiceAttached: true, isVoiceAttached: true,
userEmail: userEmail, userEmail: userEmail,
userStatus: userStatus); userStatus: userStatus,
userList:userList
);
notifyListeners(); notifyListeners();
} }
if (searchedChats != null) { if (searchedChats != null) {
@ -964,7 +1102,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
{required int targetUserId, {required int targetUserId,
required int userStatus, required int userStatus,
required String userEmail, required String userEmail,
required String targetUserName}) async { required String targetUserName,
}) async {
if (kDebugMode) { if (kDebugMode) {
print("====================== Values ============================"); print("====================== Values ============================");
print("Is Text " + isTextMsg.toString()); print("Is Text " + isTextMsg.toString());
@ -1266,7 +1406,13 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
repliedMsg.add(data); repliedMsg.add(data);
notifyListeners(); notifyListeners();
} }
void groupChatReply(groupchathistory.GetGroupChatHistoryAsync data) {
groupChatReplyData = [];
data.isReplied = true;
isReplyMsg = true;
groupChatReplyData.add(data);
notifyListeners();
}
void closeMe() { void closeMe() {
repliedMsg = []; repliedMsg = [];
isReplyMsg = false; isReplyMsg = false;
@ -1551,6 +1697,13 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
await chatHubConnection await chatHubConnection
.invoke("UserTypingAsync", args: [reciptUser, currentUser]); .invoke("UserTypingAsync", args: [reciptUser, currentUser]);
} }
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 ]);
}
//////// Audio Recoding Work //////////////////// //////// Audio Recoding Work ////////////////////

@ -186,8 +186,8 @@ class _CreateGroupBottomSheetState extends State<CreateGroupBottomSheet> {
Row( Row(
children: [ children: [
DynamicTextFieldWidget( DynamicTextFieldWidget(
"Group Name", LocaleKeys.groupName.tr(),
groupName.isEmpty ? "Please enter group name" : groupName, groupName.isEmpty ? LocaleKeys.enterGroupNamePlease.tr() : groupName,
inputAction: TextInputAction.done, inputAction: TextInputAction.done,
onChange: (String text) { onChange: (String text) {
groupName = text; groupName = text;
@ -204,7 +204,7 @@ class _CreateGroupBottomSheetState extends State<CreateGroupBottomSheet> {
height: 35, height: 35,
child: CheckboxListTile( child: CheckboxListTile(
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
title: "Audio Call".toText10(), title: LocaleKeys.audioCall.tr().toText10(),
checkboxShape: RoundedRectangleBorder( checkboxShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)), borderRadius: BorderRadius.circular(10)),
@ -225,7 +225,7 @@ class _CreateGroupBottomSheetState extends State<CreateGroupBottomSheet> {
height: 35, height: 35,
child: CheckboxListTile( child: CheckboxListTile(
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
title: "Video Call".toText10(), title: LocaleKeys.videoCall.tr().toText10(),
checkboxShape: RoundedRectangleBorder( checkboxShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)), borderRadius: BorderRadius.circular(10)),
value: isVideoCall, value: isVideoCall,
@ -245,7 +245,7 @@ class _CreateGroupBottomSheetState extends State<CreateGroupBottomSheet> {
height: 35, height: 35,
child: CheckboxListTile( child: CheckboxListTile(
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
title: "Attachments".toText10(), title:LocaleKeys.attachments.tr().toText10(),
checkboxShape: RoundedRectangleBorder( checkboxShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)), borderRadius: BorderRadius.circular(10)),
value: isAttachments, value: isAttachments,
@ -263,7 +263,7 @@ class _CreateGroupBottomSheetState extends State<CreateGroupBottomSheet> {
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
checkboxShape: RoundedRectangleBorder( checkboxShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)), borderRadius: BorderRadius.circular(10)),
title: "Share Screen".toText10(), title:LocaleKeys.shareScreen.tr().toText10(),
value: isShareScreen, value: isShareScreen,
onChanged: (bool? newValue) { onChanged: (bool? newValue) {
setState(() { setState(() {
@ -276,22 +276,22 @@ class _CreateGroupBottomSheetState extends State<CreateGroupBottomSheet> {
], ],
), ),
11.height, 11.height,
"User Search".toText16(), LocaleKeys.userSearch.tr().toText16(),
11.height, 11.height,
Row( Row(
children: [ children: [
radioOption(widget.fromChat ? "UserId" : "Name", 0, radioOption(widget.fromChat ? LocaleKeys.userId.tr() : LocaleKeys.name.tr(), 0,
_selectedSearchIndex), _selectedSearchIndex),
radioOption("User Name", 1, _selectedSearchIndex), radioOption(LocaleKeys.userName.tr(), 1, _selectedSearchIndex),
radioOption("Email", 2, _selectedSearchIndex), radioOption(LocaleKeys.email.tr(), 2, _selectedSearchIndex),
], ],
), ),
14.height, 14.height,
Row( Row(
children: [ children: [
DynamicTextFieldWidget( DynamicTextFieldWidget(
"Search", LocaleKeys.search.tr(),
"Search By Username", LocaleKeys.searchByUserName.tr(),
inputAction: TextInputAction.done, inputAction: TextInputAction.done,
suffixIconData: Icons.search, suffixIconData: Icons.search,
onChange: (String text) { onChange: (String text) {
@ -302,6 +302,8 @@ class _CreateGroupBottomSheetState extends State<CreateGroupBottomSheet> {
IconButton( IconButton(
constraints: const BoxConstraints(), constraints: const BoxConstraints(),
onPressed: () async { onPressed: () async {
provider.chatUsersList!.clear();
provider.pageNo =1;
await SystemChannels.textInput await SystemChannels.textInput
.invokeMethod('TextInput.hide'); .invokeMethod('TextInput.hide');
widget.fromChat ? fetchChatUser() : fetchUserByInput(); widget.fromChat ? fetchChatUser() : fetchUserByInput();
@ -318,7 +320,7 @@ class _CreateGroupBottomSheetState extends State<CreateGroupBottomSheet> {
padding: EdgeInsets.only(top: 21, bottom: 8), padding: EdgeInsets.only(top: 21, bottom: 8),
children: [ children: [
if (favouriteUserList?.isNotEmpty ?? false) ...[ if (favouriteUserList?.isNotEmpty ?? false) ...[
"Favorites".toText16(), LocaleKeys.favorite.tr().toText16(),
12.height, 12.height,
ListView.separated( ListView.separated(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
@ -662,9 +664,9 @@ class _CreateGroupBottomSheetState extends State<CreateGroupBottomSheet> {
void createGroup() async { void createGroup() async {
RegExp validCharacters = RegExp(r'^[a-zA-Z0-9_\-=@,\.;]+$'); RegExp validCharacters = RegExp(r'^[a-zA-Z0-9_\-=@,\.;]+$');
if (!validCharacters.hasMatch(groupName)) { if (!validCharacters.hasMatch(groupName)) {
Utils.showToast("Please enter valid group Name"); Utils.showToast(LocaleKeys.enterGroupName.tr());
} else if (groupName.length < 10) { } else if (groupName.length < 10) {
Utils.showToast("Group name should be minimum 10 character long"); Utils.showToast(LocaleKeys.groupNameshouldbe.tr());
} else { } else {
List<ChatUser>? mainUsers = []; List<ChatUser>? mainUsers = [];
ChatUser admin = ChatUser admin =

@ -223,7 +223,7 @@ class _GropChatHomeScreenState extends State<GropChatHomeScreen> {
context, context,
callBackFunc: () {}, callBackFunc: () {},
child: CreateGroupBottomSheet( child: CreateGroupBottomSheet(
title:"Add users to the group", title:LocaleKeys.addUsers.tr(),
apiMode: LocaleKeys.delegate.tr(), apiMode: LocaleKeys.delegate.tr(),
fromChat: true, fromChat: true,
onSelectEmployee: (ReplacementList _selectedEmployee) {}, onSelectEmployee: (ReplacementList _selectedEmployee) {},
@ -295,7 +295,7 @@ void goToSelected(GroupResponse? groupDetails, ChatProviderModel m, String value
context, context,
callBackFunc: () {}, callBackFunc: () {},
child: CreateGroupBottomSheet( child: CreateGroupBottomSheet(
title:"Edit Group", title:LocaleKeys.editGroups.tr(),
apiMode: LocaleKeys.delegate.tr(), apiMode: LocaleKeys.delegate.tr(),
fromChat: true, fromChat: true,
onSelectEmployee: (ReplacementList _selectedEmployee) {}, onSelectEmployee: (ReplacementList _selectedEmployee) {},

@ -481,7 +481,7 @@ class GroupChatBubble extends StatelessWidget {
{required bool isReplyPreview, {required bool isReplyPreview,
required String fileName, required String fileName,
required String fileTypeDescription}) { required String fileTypeDescription}) {
if (cItem.isImageLoaded! && cItem.image != null) { if (cItem.isImageLoaded != null && cItem.image != null) {
return Image.memory( return Image.memory(
cItem.image!, cItem.image!,
height: isReplyPreview ? 32 : 140, height: isReplyPreview ? 32 : 140,

@ -148,9 +148,9 @@ class _GroupChatDetailScreenState extends State<GroupChatDetailScreen> {
cItem: m.groupChatHistory[i], cItem: m.groupChatHistory[i],
), ),
onRightSwipe: () { onRightSwipe: () {
// m.chatReply( m.groupChatReply(
// m.groupChatHistory[i], m.groupChatHistory[i],
// ); );
}, },
).onPress(() async { ).onPress(() async {
logger.w(m.userChatHistory[i].toJson()); logger.w(m.userChatHistory[i].toJson());
@ -184,15 +184,15 @@ class _GroupChatDetailScreenState extends State<GroupChatDetailScreen> {
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
(AppState().chatDetails!.response!.userName == m.repliedMsg.first.currentUserName.toString() (AppState().chatDetails!.response!.userName == m.groupChatReplyData.first.currentUserName.toString()
? "You" ? "You"
: m.repliedMsg.first.currentUserName.toString().replaceAll(".", " ")) : m.groupChatReplyData.first.currentUserName.toString().replaceAll(".", " "))
.toText14(color: MyColors.lightGreenColor), .toText14(color: MyColors.lightGreenColor),
(m.repliedMsg.isNotEmpty ? m.repliedMsg.first.contant! : "").toText12(color: MyColors.grey71Color, maxLine: 2) (m.groupChatReplyData.isNotEmpty ? m.groupChatReplyData.first.contant! : "").toText12(color: MyColors.grey71Color, maxLine: 2)
], ],
).expanded, ).expanded,
12.width, 12.width,
if (m.isReplyMsg && m.repliedMsg.isNotEmpty) showReplyImage(m.repliedMsg, m), if (m.isReplyMsg && m.groupChatReplyData.isNotEmpty) showReplyImage(m.groupChatReplyData, m),
12.width, 12.width,
const Icon(Icons.cancel, size: 23, color: MyColors.grey7BColor).onPress(m.closeMe), const Icon(Icons.cancel, size: 23, color: MyColors.grey7BColor).onPress(m.closeMe),
], ],
@ -249,11 +249,13 @@ class _GroupChatDetailScreenState extends State<GroupChatDetailScreen> {
}), }),
SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26) SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26)
.onPress( .onPress(
() => m.sendChatMessage(context, () => m.sendGroupChatMessage(context,
targetUserId: params!.groupChatDetails!.groupId!, targetUserId: params!.groupChatDetails!.groupId!,
userStatus: 0, userStatus: 0,
userEmail: "", userEmail: "",
targetUserName: params!.groupChatDetails!.groupName!), targetUserName: params!.groupChatDetails!.groupName!,
userList: params!.groupChatDetails!.groupUserList!
),
) )
.paddingOnly(right: 21), .paddingOnly(right: 21),
], ],
@ -292,7 +294,7 @@ class _GroupChatDetailScreenState extends State<GroupChatDetailScreen> {
), ),
onChanged: (String val) { onChanged: (String val) {
m.inputBoxDirection(val); m.inputBoxDirection(val);
m.userTypingInvoke(currentUser: AppState().chatDetails!.response!.id!, reciptUser: params!.groupChatDetails!.groupId!); m.groupTypingInvoke(groupDetails: params!.groupChatDetails!, groupId: params!.groupChatDetails!.groupId!);
}, },
).expanded, ).expanded,
), ),
@ -307,7 +309,9 @@ class _GroupChatDetailScreenState extends State<GroupChatDetailScreen> {
RotationTransition( RotationTransition(
turns: const AlwaysStoppedAnimation(45 / 360), turns: const AlwaysStoppedAnimation(45 / 360),
child: const Icon(Icons.attach_file_rounded, size: 26, color: MyColors.grey3AColor).onPress( child: const Icon(Icons.attach_file_rounded, size: 26, color: MyColors.grey3AColor).onPress(
() => m.selectImageToUpload(context), () => {
m.selectImageToUpload(context)
},
), ),
).paddingOnly(right: 15), ).paddingOnly(right: 15),
const Icon( const Icon(
@ -322,7 +326,9 @@ class _GroupChatDetailScreenState extends State<GroupChatDetailScreen> {
targetUserId: params!.groupChatDetails!.groupId!, targetUserId: params!.groupChatDetails!.groupId!,
userStatus: 0, userStatus: 0,
userEmail: "", userEmail: "",
targetUserName: params!.groupChatDetails!.groupName!), targetUserName: params!.groupChatDetails!.groupName!,
userList: params!.groupChatDetails!.groupUserList!
),
) )
.paddingOnly(right: 21), .paddingOnly(right: 21),
], ],
@ -335,7 +341,7 @@ class _GroupChatDetailScreenState extends State<GroupChatDetailScreen> {
); );
} }
Widget showReplyImage(List<SingleUserChatModel> data, ChatProviderModel m) { Widget showReplyImage(List<GetGroupChatHistoryAsync> data, ChatProviderModel m) {
if (data.first.isImageLoaded! && data.first.image != null) { if (data.first.isImageLoaded! && data.first.image != null) {
return Container( return Container(
width: 43, width: 43,
@ -381,4 +387,8 @@ class _GroupChatDetailScreenState extends State<GroupChatDetailScreen> {
// callPro.stopListeners(); // callPro.stopListeners();
// }); // });
} }
GroupUserList getCurrentUser(int id, GroupResponse groupChatDetails) {
return groupChatDetails.groupUserList!.firstWhere((GroupUserList item) => item.id ==id);
}
} }

@ -344,6 +344,7 @@ class _DynamicInputScreenState extends State<DynamicInputScreen> {
// commenting to test // commenting to test
// DateTime date = DateFormat('yyyy-MM-dd').parse(idColName!); // DateTime date = DateFormat('yyyy-MM-dd').parse(idColName!);
// idColName = DateFormat('yyyy-MM-dd HH:mm:ss').format(date); // idColName = DateFormat('yyyy-MM-dd HH:mm:ss').format(date);
} }
} }

Loading…
Cancel
Save