diff --git a/lib/im/chat_details_page.dart b/lib/im/chat_details_page.dart index e99971cc..93d0a179 100644 --- a/lib/im/chat_details_page.dart +++ b/lib/im/chat_details_page.dart @@ -315,7 +315,15 @@ class _ChatDetailsPage extends State List filePath = mediaPaths.map((e) => e.path).toList(); Future.forEach(filePath.toSet(), (path) async { String fileUrl = await qiniu.uploadFile(apiService, path); - socketClient.sendMessage(_toUser.mid, fileUrl, attach: path, msgType: galleryMode == GalleryMode.image ? 2 : 4); + socketClient.sendMessage(_toUser.mid, fileUrl, attach: path, msgType: galleryMode == GalleryMode.image ? 2 : 4).then((value) { + Message message = value; + messages.insert(0, message); + chatController.clear(); + messageShowTime().then((value) { + refreshState(); + jumpToBottom(); + }); + }); }); } @@ -954,6 +962,7 @@ class _ChatDetailsPage extends State } Future fetchImageSize(String imagePath) async { + debugPrint("$imagePath"); Size size = Size.zero; Completer completer = Completer(); Image.file( diff --git a/lib/im/im_view/im_page.dart b/lib/im/im_view/im_page.dart index d9fe14e7..d0d64d25 100644 --- a/lib/im/im_view/im_page.dart +++ b/lib/im/im_view/im_page.dart @@ -17,7 +17,6 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import '../../retrofit/data/im_user.dart'; -import '../../retrofit/data/page.dart'; import '../../utils/flutter_utils.dart'; import '../../view_widget/custom_image.dart'; import 'on_chat_message.dart'; @@ -641,7 +640,7 @@ class _IMPage extends State implements OnChatMessage { children: [ Expanded( child: Text( - (lastMessageMap[conversationId]?.content ?? "").contains(".png")?"[图片]":lastMessageMap[conversationId]?.content, + messageContent(lastMessageMap[conversationId]), maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -679,6 +678,26 @@ class _IMPage extends State implements OnChatMessage { ); } + String messageContent(Message message) { + if (message.msgType == 1) { + return message.content ?? ""; + } else if (message.msgType == 2) { + return "【图片】"; + } else if (message.msgType == 3) { + return "【语音】"; + } else if (message.msgType == 4) { + return "【视频】"; + } else if (message.msgType == 5) { + return "【红包】"; + } else if (message.msgType == 6) { + return "【转账】"; + } else if (message.msgType == 7) { + return "【位置】"; + } else { + return "【未知的消息类型】"; + } + } + Widget messageItem(img, title, messageNum) { return Container( padding: EdgeInsets.only(top: 8.h, bottom: 8.h, left: 16.w, right: 15.w),