Merge branch 'master' into faiz_cs

merge-requests/104/head
Faiz Hashmi 3 years ago
commit c1be522331

@ -19,6 +19,8 @@ class SingleUserChatModel {
this.targetUserName, this.targetUserName,
this.encryptedTargetUserId, this.encryptedTargetUserId,
this.encryptedTargetUserName, this.encryptedTargetUserName,
this.currentUserEmail,
this.targetUserEmail,
this.chatEventId, this.chatEventId,
this.fileTypeId, this.fileTypeId,
this.isSeen, this.isSeen,
@ -38,8 +40,10 @@ class SingleUserChatModel {
String? contantNo; String? contantNo;
int? currentUserId; int? currentUserId;
String? currentUserName; String? currentUserName;
String? currentUserEmail;
int? targetUserId; int? targetUserId;
String? targetUserName; String? targetUserName;
String? targetUserEmail;
String? encryptedTargetUserId; String? encryptedTargetUserId;
String? encryptedTargetUserName; String? encryptedTargetUserName;
int? chatEventId; int? chatEventId;
@ -64,6 +68,8 @@ class SingleUserChatModel {
currentUserName: json["currentUserName"] == null ? null : json["currentUserName"], currentUserName: json["currentUserName"] == null ? null : json["currentUserName"],
targetUserId: json["targetUserId"] == null ? null : json["targetUserId"], targetUserId: json["targetUserId"] == null ? null : json["targetUserId"],
targetUserName: json["targetUserName"] == null ? null : json["targetUserName"], targetUserName: json["targetUserName"] == null ? null : json["targetUserName"],
targetUserEmail: json["targetUserEmail"] == null ? null : json["targetUserEmail"],
currentUserEmail: json["currentUserEmail"] == null ? null : json["currentUserEmail"],
encryptedTargetUserId: json["encryptedTargetUserId"] == null ? null : json["encryptedTargetUserId"], encryptedTargetUserId: json["encryptedTargetUserId"] == null ? null : json["encryptedTargetUserId"],
encryptedTargetUserName: json["encryptedTargetUserName"] == null ? null : json["encryptedTargetUserName"], encryptedTargetUserName: json["encryptedTargetUserName"] == null ? null : json["encryptedTargetUserName"],
chatEventId: json["chatEventId"] == null ? null : json["chatEventId"], chatEventId: json["chatEventId"] == null ? null : json["chatEventId"],
@ -90,6 +96,8 @@ class SingleUserChatModel {
"targetUserName": targetUserName == null ? null : targetUserName, "targetUserName": targetUserName == null ? null : targetUserName,
"encryptedTargetUserId": encryptedTargetUserId == null ? null : encryptedTargetUserId, "encryptedTargetUserId": encryptedTargetUserId == null ? null : encryptedTargetUserId,
"encryptedTargetUserName": encryptedTargetUserName == null ? null : encryptedTargetUserName, "encryptedTargetUserName": encryptedTargetUserName == null ? null : encryptedTargetUserName,
"currentUserEmail": currentUserEmail == null ? null : currentUserEmail,
"targetUserEmail": targetUserEmail == null ? null : targetUserEmail,
"chatEventId": chatEventId == null ? null : chatEventId, "chatEventId": chatEventId == null ? null : chatEventId,
"fileTypeId": fileTypeId, "fileTypeId": fileTypeId,
"isSeen": isSeen == null ? null : isSeen, "isSeen": isSeen == null ? null : isSeen,

@ -330,8 +330,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
temp = getSingleUserChatModel(jsonEncode(msg)); temp = getSingleUserChatModel(jsonEncode(msg));
data.first.targetUserId = temp.first.currentUserId; data.first.targetUserId = temp.first.currentUserId;
data.first.targetUserName = temp.first.currentUserName; data.first.targetUserName = temp.first.currentUserName;
data.first.targetUserEmail = temp.first.currentUserEmail;
data.first.currentUserId = temp.first.targetUserId; data.first.currentUserId = temp.first.targetUserId;
data.first.currentUserName = temp.first.targetUserName; 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) { 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"); data.first.image = await ChatApiClient().downloadURL(fileName: data.first.contant!, fileTypeDescription: data.first.fileTypeResponse!.fileTypeDescription ?? "image/jpg");
} }
@ -349,21 +352,24 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
if (searchedChats != null) { 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) { 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( searchedChats!.add(
ChatUser( ChatUser(
id: data.first.currentUserId, id: data.first.currentUserId,
userName: data.first.currentUserName, userName: data.first.currentUserName,
unreadMessageCount: 0, unreadMessageCount: 0,
isImageLoading: false, isImageLoading: false,
image: "", image: chatImages!.first.profilePicture ?? "",
isImageLoaded: true, isImageLoaded: true,
userStatus: 1, userStatus: 1,
isTyping: false, isTyping: false,
userLocalDownlaodedImage: null), userLocalDownlaodedImage: await downloadImageLocal(chatImages.first.profilePicture, data.first.currentUserId.toString()),
),
); );
} }
} }
setMsgTune(); setMsgTune();
userChatHistory.insert(0, data.first); userChatHistory.insert(0, data.first);
@ -526,21 +532,25 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
await chatHubConnection.invoke("AddChatUserAsync", args: <Object>[json.decode(chatData)]); await chatHubConnection.invoke("AddChatUserAsync", args: <Object>[json.decode(chatData)]);
} }
void sendChatMessage(int targetUserId, int userStatus, String targetUserName, BuildContext context) async { void sendChatMessage(BuildContext context, {required int targetUserId, required int userStatus, required String userEmail, required String targetUserName}) async {
dynamic contain = searchedChats!.where((ChatUser element) => element.id == targetUserId); dynamic contain = searchedChats!.where((ChatUser element) => element.id == targetUserId);
if (contain.isEmpty) { if (contain.isEmpty) {
List<String> emails = [];
emails.add(await EmailImageEncryption().encrypt(val: userEmail));
List<ChatUserImageModel> chatImages = await ChatApiClient().getUsersImages(encryptedEmails: emails);
searchedChats!.add( searchedChats!.add(
ChatUser( ChatUser(
id: targetUserId, id: targetUserId,
userName: targetUserName, userName: targetUserName,
unreadMessageCount: 0, unreadMessageCount: 0,
email: userEmail,
isImageLoading: false, isImageLoading: false,
image: "", image: chatImages.first.profilePicture ?? "",
isImageLoaded: true, isImageLoaded: true,
isTyping: false, isTyping: false,
isFav: false, isFav: false,
userStatus: userStatus, userStatus: userStatus,
userLocalDownlaodedImage: null, userLocalDownlaodedImage: await downloadImageLocal(chatImages.first.profilePicture, targetUserId.toString()),
), ),
); );
notifyListeners(); notifyListeners();

@ -223,7 +223,11 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
), ),
).paddingOnly(right: 25), ).paddingOnly(right: 25),
SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26).onPress( SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26).onPress(
() => m.sendChatMessage(params!.chatUser!.id!, params!.chatUser!.userStatus ?? 0, params!.chatUser!.userName!, context), () => m.sendChatMessage(context,
targetUserId: params!.chatUser!.id!,
userStatus: params!.chatUser!.userStatus ?? 0,
userEmail: params!.chatUser!.email!,
targetUserName: params!.chatUser!.userName!),
), ),
], ],
), ),

@ -111,7 +111,7 @@ class ChatFavoriteUsersScreen extends StatelessWidget {
Navigator.pushNamed( Navigator.pushNamed(
context, context,
AppRoutes.chatDetailed, AppRoutes.chatDetailed,
arguments: ChatDetailedScreenParams(m.favUsersList![index], false), arguments: ChatDetailedScreenParams(m.favUsersList![index], true),
).then( ).then(
(Object? value) { (Object? value) {
m.clearSelections(); m.clearSelections();

@ -58,6 +58,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
data = Provider.of<DashboardProviderModel>(context, listen: false); data = Provider.of<DashboardProviderModel>(context, listen: false);
marathonProvider = Provider.of<MarathonProvider>(context, listen: false); marathonProvider = Provider.of<MarathonProvider>(context, listen: false);
cProvider = Provider.of<ChatProviderModel>(context, listen: false); cProvider = Provider.of<ChatProviderModel>(context, listen: false);
_onRefresh(); _onRefresh();
}); });
} }
@ -199,7 +200,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
LocaleKeys.welcomeBack.tr().toText14(color: MyColors.grey77Color), LocaleKeys.goodMorning.tr().toText14(color: MyColors.grey77Color),
(AppState().memberInformationList!.eMPLOYEENAME ?? "").toText24(isBold: true), (AppState().memberInformationList!.eMPLOYEENAME ?? "").toText24(isBold: true),
16.height, 16.height,
Row( Row(

Loading…
Cancel
Save