From ab6f265ef45e94fa60ad15cd8de85f9ecd611fd8 Mon Sep 17 00:00:00 2001 From: "Aamir.Muhammad" Date: Tue, 15 Nov 2022 16:09:34 +0300 Subject: [PATCH] Chat Favorite Screen & Fixes --- lib/api/chat/chat_provider_model.dart | 8 +++++--- lib/classes/consts.dart | 4 ++-- lib/ui/chat/chat_home.dart | 2 -- lib/ui/chat/chat_home_screen.dart | 5 ++--- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/api/chat/chat_provider_model.dart b/lib/api/chat/chat_provider_model.dart index b09ad50..ead29d7 100644 --- a/lib/api/chat/chat_provider_model.dart +++ b/lib/api/chat/chat_provider_model.dart @@ -380,10 +380,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { Future sendChatToServer( {required int chatEventId, required fileTypeId, required int targetUserId, required String targetUserName, required chatReplyId, required bool isAttachment, required bool isReply}) async { Uuid uuid = const Uuid(); + String msg = message.text; SingleUserChatModel data = SingleUserChatModel( chatEventId: chatEventId, chatSource: 1, - contant: message.text, + contant: msg, contantNo: uuid.v4(), conversationId: uuid.v4(), createdDate: DateTime.now(), @@ -412,7 +413,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { notifyListeners(); String chatData = - '{"contant":"${message.text}","contantNo":"${uuid.v4()}","chatEventId":$chatEventId,"fileTypeId": $fileTypeId,"currentUserId":${AppState().chatDetails!.response!.id},"chatSource":1,"userChatHistoryLineRequestList":[{"isSeen":false,"isDelivered":false,"targetUserId":$targetUserId,"targetUserStatus":1}],"chatReplyId":$chatReplyId,"conversationId":"${uuid.v4()}"}'; + '{"contant":"$msg","contantNo":"${uuid.v4()}","chatEventId":$chatEventId,"fileTypeId": $fileTypeId,"currentUserId":${AppState().chatDetails!.response!.id},"chatSource":1,"userChatHistoryLineRequestList":[{"isSeen":false,"isDelivered":false,"targetUserId":$targetUserId,"targetUserStatus":1}],"chatReplyId":$chatReplyId,"conversationId":"${uuid.v4()}"}'; await hubConnection.invoke("AddChatUserAsync", args: [json.decode(chatData)]); } @@ -452,9 +453,10 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } if (isFileSelected && isMsgReply) { logger.d("Attachment Message With Reply"); - logger.d(repliedMsg.first.userChatHistoryId); + Utils.showLoading(context); dynamic value = await uploadAttachments(AppState().chatDetails!.response!.id.toString(), selectedFile); String? ext = getFileExtension(selectedFile.path); + Utils.hideLoading(context); sendChatToServer( chatEventId: 2, fileTypeId: getFileType(ext.toString()), diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index c5788f9..ede22e3 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -1,7 +1,7 @@ class ApiConsts { //static String baseUrl = "http://10.200.204.20:2801/"; // Local server - //static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server - static String baseUrl = "https://hmgwebservices.com"; // Live server + static String baseUrl = "https://uat.hmgwebservices.com"; // UAT 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/"; diff --git a/lib/ui/chat/chat_home.dart b/lib/ui/chat/chat_home.dart index 1fdcb33..738fc17 100644 --- a/lib/ui/chat/chat_home.dart +++ b/lib/ui/chat/chat_home.dart @@ -26,7 +26,6 @@ class _ChatHomeState extends State { PageController controller = PageController(); late ChatProviderModel data; - @override void initState() { // TODO: implement initState @@ -46,7 +45,6 @@ class _ChatHomeState extends State { @override Widget build(BuildContext context) { - return Scaffold( backgroundColor: MyColors.white, appBar: AppBarWidget( diff --git a/lib/ui/chat/chat_home_screen.dart b/lib/ui/chat/chat_home_screen.dart index d146891..38bf42c 100644 --- a/lib/ui/chat/chat_home_screen.dart +++ b/lib/ui/chat/chat_home_screen.dart @@ -141,12 +141,11 @@ class _ChatHomeScreenState extends State { icon: Icon(m.searchedChats![index].isFav != null && m.searchedChats![index].isFav == false ? Icons.star_sharp : Icons.star_sharp), color: m.searchedChats![index].isFav != null && m.searchedChats![index].isFav == true ? MyColors.yellowColor : MyColors.grey35Color, onPressed: () { - if (m.searchedChats![index].isFav == null || m.searchedChats![index].isFav == false) { m.favoriteUser(userID: AppState().chatDetails!.response!.id!, targetUserID: m.searchedChats![index].id!); - }else if( m.searchedChats![index].isFav == true){ + } else if (m.searchedChats![index].isFav == true) { m.unFavoriteUser(userID: AppState().chatDetails!.response!.id!, targetUserID: m.searchedChats![index].id!); - } else{ + } else { m.favoriteUser(userID: AppState().chatDetails!.response!.id!, targetUserID: m.searchedChats![index].id!); } },