From d78300178cd01842cae15f7e9f082d676c5281e3 Mon Sep 17 00:00:00 2001 From: anonymous Date: Tue, 19 Dec 2023 16:22:12 +0800 Subject: [PATCH] feat: Upgrade to 2.4.1+1 --- CHANGELOG.md | 6 + example/pubspec.lock | 10 +- .../separate_models/tui_chat_model_tools.dart | 4 +- .../tui_chat_separate_view_model.dart | 660 ++++++------------ ..._uikit_chat_history_message_list_item.dart | 9 +- .../tim_uikit_message_reaction_show_item.dart | 33 +- .../tim_uikit_chat_file_elem.dart | 127 ++-- .../tim_uikit_text_field_layout/wide.dart | 384 +++------- pubspec.lock | 8 +- pubspec.yaml | 4 +- 10 files changed, 443 insertions(+), 802 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33cfedb..a744134 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 2.4.1 + +## Bug Fixes + +* Fixed some bugs. + # 2.4.0 ## Breaking Changes diff --git a/example/pubspec.lock b/example/pubspec.lock index f65602e..51b3803 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -285,18 +285,18 @@ packages: dependency: transitive description: name: extended_image - sha256: d1b122d6f5cf5596ea61d703d116d89e2ece7e324db414cfeed12967b72b7aef + sha256: d7f091d068fcac7246c4b22a84b8dac59a62e04d29a5c172710c696e67a22f94 url: "https://pub.dev" source: hosted - version: "8.1.0" + version: "8.2.0" extended_image_library: dependency: transitive description: name: extended_image_library - sha256: "8bf87c0b14dcb59200c923a9a3952304e4732a0901e40811428834ef39018ee1" + sha256: "9b55fc5ebc65fad984de66b8f177a1bef2a84d79203c9c213f75ff83c2c29edd" url: "https://pub.dev" source: hosted - version: "3.6.0" + version: "4.0.1" extended_text: dependency: transitive description: @@ -1227,7 +1227,7 @@ packages: path: ".." relative: true source: path - version: "2.3.3+1" + version: "2.4.1" tencent_cloud_uikit_core: dependency: transitive description: diff --git a/lib/business_logic/separate_models/tui_chat_model_tools.dart b/lib/business_logic/separate_models/tui_chat_model_tools.dart index 6824df8..97040e8 100644 --- a/lib/business_logic/separate_models/tui_chat_model_tools.dart +++ b/lib/business_logic/separate_models/tui_chat_model_tools.dart @@ -81,8 +81,8 @@ class TUIChatModelTools { } return OfflinePushInfo.fromJson({ - "title": "title", - "desc": "desc", + "title": title, + "desc": desc, "disablePush": false, "ext": ext, "iOSSound": globalModel.chatConfig.notificationIOSSound, diff --git a/lib/business_logic/separate_models/tui_chat_separate_view_model.dart b/lib/business_logic/separate_models/tui_chat_separate_view_model.dart index 1fddb83..89cbb45 100644 --- a/lib/business_logic/separate_models/tui_chat_separate_view_model.dart +++ b/lib/business_logic/separate_models/tui_chat_separate_view_model.dart @@ -8,17 +8,17 @@ import 'package:flutter/cupertino.dart'; // ignore: unnecessary_import import 'package:flutter/foundation.dart'; -import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_self_info_view_model.dart'; -import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart'; import 'package:flutter_image_compress/flutter_image_compress.dart'; import 'package:path_provider/path_provider.dart'; import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/chat_life_cycle.dart'; import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_model_tools.dart'; import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart'; +import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_self_info_view_model.dart'; import 'package:tencent_cloud_chat_uikit/data_services/friendShip/friendship_services.dart'; import 'package:tencent_cloud_chat_uikit/data_services/group/group_services.dart'; import 'package:tencent_cloud_chat_uikit/data_services/message/message_services.dart'; import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart'; +import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart'; import 'package:tencent_cloud_chat_uikit/ui/constants/history_message_constant.dart'; import 'package:tencent_cloud_chat_uikit/ui/utils/logger.dart'; import 'package:tencent_cloud_chat_uikit/ui/utils/platform.dart'; @@ -27,8 +27,7 @@ import 'package:uuid/uuid.dart'; enum LoadDirection { previous, latest } class TUIChatSeparateViewModel extends ChangeNotifier { - final FriendshipServices _friendshipServices = - serviceLocator(); + final FriendshipServices _friendshipServices = serviceLocator(); final MessageService _messageService = serviceLocator(); final GroupServices _groupServices = serviceLocator(); final TUIChatGlobalModel globalModel = serviceLocator(); @@ -65,6 +64,15 @@ class TUIChatSeparateViewModel extends ChangeNotifier { double atPositionY = 0.0; int _activeAtIndex = -1; List _showAtMemberList = []; + Map _groupUserShowName = {}; + String? _groupID; + + Map get groupUserShowName => _groupUserShowName; + + set groupUserShowName(Map value) { + _groupUserShowName = value; + notifyListeners(); + } int get activeAtIndex => _activeAtIndex; @@ -159,21 +167,43 @@ class TUIChatSeparateViewModel extends ChangeNotifier { setLoadingMessageMap(String conversationID, V2TimMessage messageInfo) { if (PlatformUtils().isWeb) { - if (globalModel.loadingMessage[conversationID] != null && - globalModel.loadingMessage[conversationID]!.isNotEmpty) { + if (globalModel.loadingMessage[conversationID] != null && globalModel.loadingMessage[conversationID]!.isNotEmpty) { globalModel.loadingMessage[conversationID]!.add(messageInfo); } else { - globalModel.loadingMessage[conversationID] = [ - messageInfo - ]; + globalModel.loadingMessage[conversationID] = [messageInfo]; } } } - void initForEachConversation(ConvType convType, String convID, - ValueChanged? onChangeInputField, - {String? groupID, - List? preGroupMemberList}) async { + void getUserShowName(List userIDs) async { + final List filteredList = userIDs.where((element) => !_groupUserShowName.containsKey(element)).toList(); + for (final element in filteredList) { + _groupUserShowName[element] = element; + } + + final String groupID = TencentUtils.checkString(_groupID) ?? conversationID; + + + if(filteredList.isNotEmpty){ + final res = await TencentImSDKPlugin.manager?.getGroupManager().getGroupMembersInfo(groupID: groupID, memberList: filteredList); + if (res?.code == 0 && res?.data != null) { + final data = res!.data; + for (final userInfo in data!) { + final showName = TencentUtils.checkString(userInfo.nameCard) ?? TencentUtils.checkString(userInfo.nickName) ?? TencentUtils.checkString(userInfo.userID); + if (TencentUtils.checkString(showName) != null) { + _groupUserShowName[userInfo.userID] = showName ?? userInfo.userID; + } + } + if(data.isNotEmpty){ + notifyListeners(); + } + } + } + + } + + void initForEachConversation(ConvType convType, String convID, ValueChanged? onChangeInputField, + {String? groupID, List? preGroupMemberList}) async { if (_isInit) { return; } @@ -188,25 +218,24 @@ class TUIChatSeparateViewModel extends ChangeNotifier { selfMemberInfo = null; if (conversationType == ConvType.group) { + _groupID = groupID; globalModel.refreshGroupApplicationList(); loadGroupInfo(groupID ?? convID); - if(preGroupMemberList != null){ + if (preGroupMemberList != null) { groupMemberList = preGroupMemberList; - selfMemberInfo = preGroupMemberList - .firstWhereOrNull((e) => e?.userID == selfModel.loginInfo?.userID); - }else{ + selfMemberInfo = preGroupMemberList.firstWhereOrNull((e) => e?.userID == selfModel.loginInfo?.userID); + } else { await loadSelfMemberInfo(groupID: groupID ?? convID); loadGroupMemberList(groupID: groupID ?? convID); } - if(selfMemberInfo == null){ + if (selfMemberInfo == null) { await loadSelfMemberInfo(groupID: groupID ?? convID); } } else { notifyListeners(); } if (conversationType == ConvType.c2c) { - final List? friendRes = - await _friendshipServices.getFriendsInfo(userIDList: [convID]); + final List? friendRes = await _friendshipServices.getFriendsInfo(userIDList: [convID]); if (friendRes != null && friendRes.isNotEmpty) { final V2TimFriendInfoResult friendInfoResult = friendRes[0]; currentChatUserInfo = V2TimGroupMemberFullInfo( @@ -215,8 +244,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { nickName: friendInfoResult.friendInfo?.userProfile?.nickName, friendRemark: friendInfoResult.friendInfo?.friendRemark); } else { - final List? userRes = - await _friendshipServices.getUsersInfo(userIDList: [convID]); + final List? userRes = await _friendshipServices.getUsersInfo(userIDList: [convID]); if (userRes != null && userRes.isNotEmpty) { final V2TimUserFullInfo userFullInfo = userRes[0]; currentChatUserInfo = V2TimGroupMemberFullInfo( @@ -228,10 +256,8 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } } globalModel.lifeCycle = lifeCycle; - globalModel.setCurrentConversation( - CurrentConversation(conversationID, conversationType ?? ConvType.c2c)); - globalModel.setMessageListPosition( - conversationID, HistoryMessagePosition.bottom); + globalModel.setCurrentConversation(CurrentConversation(conversationID, conversationType ?? ConvType.c2c)); + globalModel.setMessageListPosition(conversationID, HistoryMessagePosition.bottom); globalModel.setChatConfig(chatConfig); globalModel.clearRecivedNewMessageCount(); _isInit = true; @@ -246,38 +272,25 @@ class TUIChatSeparateViewModel extends ChangeNotifier { List msgList = []; haveMoreData = false; - final previousResponse = - await _messageService.getHistoryMessageListWithComplete( - count: 20, - getType: HistoryMsgGetTypeEnum.V2TIM_GET_CLOUD_OLDER_MSG, - userID: conversationType == ConvType.c2c ? conversationID : null, - groupID: conversationType == ConvType.group ? conversationID : null, - lastMsgSeq: max(seq, 0)); + final previousResponse = await _messageService.getHistoryMessageListWithComplete( + count: 20, + getType: HistoryMsgGetTypeEnum.V2TIM_GET_CLOUD_OLDER_MSG, + userID: conversationType == ConvType.c2c ? conversationID : null, + groupID: conversationType == ConvType.group ? conversationID : null, + lastMsgSeq: max(seq, 0)); msgList = previousResponse?.messageList ?? []; haveMoreData = !(previousResponse?.isFinished ?? false); haveMoreLatestData = true; - globalModel.setMessageListPosition( - conversationID, HistoryMessagePosition.notShowLatest); + globalModel.setMessageListPosition(conversationID, HistoryMessagePosition.notShowLatest); msgList = await lifeCycle?.didGetHistoricalMessageList(msgList) ?? msgList; - msgList.insert( - 0, - V2TimMessage( - userID: '', - isSelf: false, - elemType: 101, - msgID: msgList[0].msgID, - seq: msgList[0].seq, - timestamp: 9999)); - globalModel.setMessageList(conversationID, msgList, - needResetNewMessageCount: false); + msgList.insert(0, V2TimMessage(userID: '', isSelf: false, elemType: 101, msgID: msgList[0].msgID, seq: msgList[0].seq, timestamp: 9999)); + globalModel.setMessageList(conversationID, msgList, needResetNewMessageCount: false); - if (chatConfig.isShowGroupReadingStatus && - conversationType == ConvType.group) { + if (chatConfig.isShowGroupReadingStatus && conversationType == ConvType.group) { _getMsgReadReceipt(msgList); } - if (chatConfig.isReportGroupReadingStatus && - conversationType == ConvType.group) { + if (chatConfig.isReportGroupReadingStatus && conversationType == ConvType.group) { _setMsgReadReceipt(msgList); } @@ -294,9 +307,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { }) async { try { // 根据加载方向设置是否还能继续加载更多消息 - direction == LoadDirection.latest - ? haveMoreLatestData = false - : haveMoreData = false; + direction == LoadDirection.latest ? haveMoreLatestData = false : haveMoreData = false; // 获取当前聊天对话的历史消息列表 final currentRecordList = globalModel.messageListMap[conversationID]; @@ -304,10 +315,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { // 调用MessageService获取聊天记录 final response = await _messageService.getHistoryMessageListWithComplete( count: count, - getType: getType ?? - (direction == LoadDirection.previous - ? HistoryMsgGetTypeEnum.V2TIM_GET_CLOUD_OLDER_MSG - : HistoryMsgGetTypeEnum.V2TIM_GET_CLOUD_NEWER_MSG), + getType: getType ?? (direction == LoadDirection.previous ? HistoryMsgGetTypeEnum.V2TIM_GET_CLOUD_OLDER_MSG : HistoryMsgGetTypeEnum.V2TIM_GET_CLOUD_NEWER_MSG), userID: conversationType == ConvType.c2c ? conversationID : null, groupID: conversationType == ConvType.group ? conversationID : null, lastMsgID: lastMsgID, @@ -333,8 +341,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { // 根据加载方向拼接消息列表 if (direction == LoadDirection.latest) { - globalModel.receivedNewMessageCount = - globalModel.receivedMessageListCount + messageList.length; + globalModel.receivedNewMessageCount = globalModel.receivedMessageListCount + messageList.length; messageList = messageList.reversed.toList(); newList = _combineMessageList(messageList, currentRecordList); } else { @@ -342,8 +349,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } // 处理新获取的消息列表后回调 - final List msgList = - await lifeCycle?.didGetHistoricalMessageList(newList) ?? newList; + final List msgList = await lifeCycle?.didGetHistoricalMessageList(newList) ?? newList; // 更新聊天记录到全局model globalModel.setMessageList( @@ -353,9 +359,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { ); } else { // 处理新获取的消息列表后回调 - List receivedList = await lifeCycle - ?.didGetHistoricalMessageList(response.messageList) ?? - response.messageList; + List receivedList = await lifeCycle?.didGetHistoricalMessageList(response.messageList) ?? response.messageList; globalModel.loadingMessage.remove(conversationID); // 更新聊天记录到全局model @@ -367,21 +371,16 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } // 获取已读未读状态 - if (chatConfig.isShowGroupReadingStatus && - conversationType == ConvType.group && - response.messageList.isNotEmpty) { + if (chatConfig.isShowGroupReadingStatus && conversationType == ConvType.group && response.messageList.isNotEmpty) { _getMsgReadReceipt(response.messageList); } - if (chatConfig.isReportGroupReadingStatus && - conversationType == ConvType.group && - response.messageList.isNotEmpty) { + if (chatConfig.isReportGroupReadingStatus && conversationType == ConvType.group && response.messageList.isNotEmpty) { _setMsgReadReceipt(response.messageList); } // 根据加载方向更新是否还能继续加载更多消息 if (direction == LoadDirection.latest && !haveMoreLatestData) { - globalModel.setMessageListPosition( - conversationID, HistoryMessagePosition.inTwoScreen); + globalModel.setMessageListPosition(conversationID, HistoryMessagePosition.inTwoScreen); } notifyListeners(); @@ -394,8 +393,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } // 拼接聊天记录 - List _combineMessageList( - List first, List second) { + List _combineMessageList(List first, List second) { return [...first, ...second]; } @@ -405,16 +403,12 @@ class TUIChatSeparateViewModel extends ChangeNotifier { ); } - Future>> getMessageReadReceipts( - List messageIDList) { + Future>> getMessageReadReceipts(List messageIDList) { return _messageService.getMessageReadReceipts(messageIDList: messageIDList); } _getMsgReadReceipt(List message) async { - final msgID = message - .where((e) => (e.isSelf ?? true) && (e.needReadReceipt ?? false)) - .map((e) => e.msgID ?? '') - .toList(); + final msgID = message.where((e) => (e.isSelf ?? true) && (e.needReadReceipt ?? false)).map((e) => e.msgID ?? '').toList(); if (msgID.isNotEmpty) { final res = await getMessageReadReceipts(msgID); if (res.code == 0) { @@ -433,16 +427,13 @@ class TUIChatSeparateViewModel extends ChangeNotifier { final String originText = message.textElem?.text ?? ""; final String deviceLocale = TIM_getCurrentDeviceLocale(); final String targetMessage = deviceLocale.split("-")[0]; - final translatedText = - await _messageService.translateText(originText, targetMessage); + final translatedText = await _messageService.translateText(originText, targetMessage); - final LocalCustomDataModel localCustomData = LocalCustomDataModel.fromMap( - json.decode(TencentUtils.checkString(message.localCustomData) ?? "{}")); + final LocalCustomDataModel localCustomData = LocalCustomDataModel.fromMap(json.decode(TencentUtils.checkString(message.localCustomData) ?? "{}")); localCustomData.translatedText = translatedText; message.localCustomData = json.encode(localCustomData.toMap()); globalModel.onMessageModified(message); - TencentImSDKPlugin.v2TIMManager.v2TIMMessageManager.setLocalCustomData( - msgID: message.msgID!, localCustomData: message.localCustomData ?? ""); + TencentImSDKPlugin.v2TIMManager.v2TIMMessageManager.setLocalCustomData(msgID: message.msgID!, localCustomData: message.localCustomData ?? ""); } _setMsgReadReceipt(List message) async { @@ -461,8 +452,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } sendMessageReadReceipts(List messageIDList) async { - final res = await _messageService.sendMessageReadReceipts( - messageIDList: messageIDList); + final res = await _messageService.sendMessageReadReceipts(messageIDList: messageIDList); return res; } @@ -472,55 +462,42 @@ class TUIChatSeparateViewModel extends ChangeNotifier { return _messageService.markC2CMessageAsRead(userID: conversationID); } - final res = - await _messageService.markGroupMessageAsRead(groupID: conversationID); + final res = await _messageService.markGroupMessageAsRead(groupID: conversationID); if (res.code == 10015) { isGroupExist = false; } } Future loadSelfMemberInfo({required String groupID}) async { - V2TimValueCallback> getGroupMembersInfoRes = - await TencentImSDKPlugin.v2TIMManager - .getGroupManager() - .getGroupMembersInfo( + V2TimValueCallback> getGroupMembersInfoRes = await TencentImSDKPlugin.v2TIMManager.getGroupManager().getGroupMembersInfo( groupID: groupID, memberList: [selfModel.loginInfo?.userID ?? ""], ); if (getGroupMembersInfoRes.code == 0) { final userList = getGroupMembersInfoRes.data; - selfMemberInfo = userList - ?.firstWhereOrNull((e) => e.userID == selfModel.loginInfo?.userID); + selfMemberInfo = userList?.firstWhereOrNull((e) => e.userID == selfModel.loginInfo?.userID); notifyListeners(); } return; } - Future loadGroupMemberList( - {required String groupID, int count = 100, String? seq}) async { - final String? nextSeq = await _loadGroupMemberListFunction( - groupID: groupID, seq: seq, count: count); + Future loadGroupMemberList({required String groupID, int count = 100, String? seq}) async { + final String? nextSeq = await _loadGroupMemberListFunction(groupID: groupID, seq: seq, count: count); if (nextSeq != null && nextSeq != "0" && nextSeq != "") { - return await loadGroupMemberList( - groupID: groupID, count: count, seq: nextSeq); + return await loadGroupMemberList(groupID: groupID, count: count, seq: nextSeq); } else { - selfMemberInfo = groupMemberList - ?.firstWhereOrNull((e) => e?.userID == selfModel.loginInfo?.userID); + selfMemberInfo = groupMemberList?.firstWhereOrNull((e) => e?.userID == selfModel.loginInfo?.userID); notifyListeners(); } } - Future _loadGroupMemberListFunction( - {required String groupID, int count = 100, String? seq}) async { + Future _loadGroupMemberListFunction({required String groupID, int count = 100, String? seq}) async { if (seq == null || seq == "" || seq == "0") { groupMemberList?.clear(); } try { final res = await _groupServices.getGroupMemberList( - groupID: groupID, - filter: GroupMemberFilterTypeEnum.V2TIM_GROUP_MEMBER_FILTER_ALL, - count: count, - nextSeq: seq ?? groupMemberListSeq); + groupID: groupID, filter: GroupMemberFilterTypeEnum.V2TIM_GROUP_MEMBER_FILTER_ALL, count: count, nextSeq: seq ?? groupMemberListSeq); final groupMemberListRes = res.data; if (res.code == 0 && groupMemberListRes != null) { final groupMemberListTemp = groupMemberListRes.memberInfoList ?? []; @@ -537,20 +514,14 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } } - Future<(V2TimGroupInfo?, GroupReceiptAllowType?)> loadGroupInfo( - String groupID) async { - final groupInfoList = - await _groupServices.getGroupsInfo(groupIDList: [groupID]); + Future<(V2TimGroupInfo?, GroupReceiptAllowType?)> loadGroupInfo(String groupID) async { + final groupInfoList = await _groupServices.getGroupsInfo(groupIDList: [groupID]); if (groupInfoList != null && groupInfoList.isNotEmpty) { final groupRes = groupInfoList.first; if (groupRes.resultCode == 0) { _groupInfo = groupRes.groupInfo; - const groupTypeMap = { - "Meeting": GroupReceiptAllowType.meeting, - "Public": GroupReceiptAllowType.public, - "Work": GroupReceiptAllowType.work - }; + const groupTypeMap = {"Meeting": GroupReceiptAllowType.meeting, "Public": GroupReceiptAllowType.public, "Work": GroupReceiptAllowType.work}; _groupType = groupTypeMap[groupRes.groupInfo?.groupType]; notifyListeners(); @@ -560,13 +531,8 @@ class TUIChatSeparateViewModel extends ChangeNotifier { return (null, null); } - Future updateMessageFromController( - {required String msgID, V2TimMessage? message}) async { - V2TimMessage? newMessage = message ?? - await tools.getExistingMessageByID( - msgID: msgID, - conversationType: conversationType ?? ConvType.c2c, - conversationID: conversationID); + Future updateMessageFromController({required String msgID, V2TimMessage? message}) async { + V2TimMessage? newMessage = message ?? await tools.getExistingMessageByID(msgID: msgID, conversationType: conversationType ?? ConvType.c2c, conversationID: conversationID); if (newMessage != null) { globalModel.onMessageModified(newMessage, conversationID); } else { @@ -576,8 +542,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } } - Future?> modifyMessage( - {required V2TimMessage message}) async { + Future?> modifyMessage({required V2TimMessage message}) async { return _messageService.modifyMessage(message: message); } @@ -600,9 +565,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { if (convType == ConvType.group && _groupType == null) { await loadGroupInfo(groupID); } - final oldGroupType = _groupType != null - ? GroupReceptAllowType.values[_groupType!.index] - : null; + final oldGroupType = _groupType != null ? GroupReceptAllowType.values[_groupType!.index] : null; if (messageInfo != null) { setLoadingMessageMap(convID, messageInfo); } @@ -615,12 +578,8 @@ class TUIChatSeparateViewModel extends ChangeNotifier { needReadReceipt: needReadReceipt ?? chatConfig.isShowGroupReadingStatus && convType == ConvType.group && - ((chatConfig.groupReadReceiptPermissionList != null && - chatConfig.groupReadReceiptPermissionList! - .contains(_groupType)) || - (chatConfig.groupReadReceiptPermisionList != null && - chatConfig.groupReadReceiptPermisionList! - .contains(oldGroupType))), + ((chatConfig.groupReadReceiptPermissionList != null && chatConfig.groupReadReceiptPermissionList!.contains(_groupType)) || + (chatConfig.groupReadReceiptPermisionList != null && chatConfig.groupReadReceiptPermisionList!.contains(oldGroupType))), groupID: groupID, offlinePushInfo: offlinePushInfo, onlineUserOnly: onlineUserOnly ?? false, @@ -634,11 +593,8 @@ class TUIChatSeparateViewModel extends ChangeNotifier { }) : ""), ); - if (isEditStatusMessage == false && - globalModel.getMessageListPosition(conversationID) != - HistoryMessagePosition.notShowLatest) { - globalModel.updateMessage( - sendMsgRes, convID, id, convType, groupType, setInputField); + if (isEditStatusMessage == false && globalModel.getMessageListPosition(conversationID) != HistoryMessagePosition.notShowLatest) { + globalModel.updateMessage(sendMsgRes, convID, id, convType, groupType, setInputField); } if (lifeCycle?.messageDidSend != null) { lifeCycle!.messageDidSend(sendMsgRes); @@ -655,21 +611,15 @@ class TUIChatSeparateViewModel extends ChangeNotifier { return globalModel.unreadCountForConversation; } - Future?> sendTextAtMessage( - {required String text, - required String convID, - required ConvType convType, - required List atUserList}) async { + Future?> sendTextAtMessage({required String text, required String convID, required ConvType convType, required List atUserList}) async { if (text.isEmpty) { return null; } - final textATMessageInfo = await _messageService.createTextAtMessage( - text: text, atUserList: atUserList); + final textATMessageInfo = await _messageService.createTextAtMessage(text: text, atUserList: atUserList); List currentHistoryMsgList = getOriginMessageList(); final messageInfo = textATMessageInfo!.messageInfo; if (messageInfo != null) { - final messageInfoWithSender = - tools.setUserInfoForMessage(messageInfo, textATMessageInfo.id!); + final messageInfoWithSender = tools.setUserInfoForMessage(messageInfo, textATMessageInfo.id!); V2TimMessage? lifeCycleMsg; if (lifeCycle?.messageWillSend != null) { lifeCycleMsg = await lifeCycle?.messageWillSend(messageInfoWithSender); @@ -678,12 +628,8 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } } - if (globalModel.getMessageListPosition(conversationID) != - HistoryMessagePosition.notShowLatest) { - currentHistoryMsgList = [ - lifeCycleMsg ?? messageInfoWithSender, - ...currentHistoryMsgList - ]; + if (globalModel.getMessageListPosition(conversationID) != HistoryMessagePosition.notShowLatest) { + currentHistoryMsgList = [lifeCycleMsg ?? messageInfoWithSender, ...currentHistoryMsgList]; globalModel.setMessageList(conversationID, currentHistoryMsgList); notifyListeners(); } @@ -692,23 +638,17 @@ class TUIChatSeparateViewModel extends ChangeNotifier { convID: convID, id: textATMessageInfo.id as String, convType: ConvType.group, - offlinePushInfo: tools.buildMessagePushInfo( - textATMessageInfo.messageInfo!, convID, convType)); + offlinePushInfo: tools.buildMessagePushInfo(textATMessageInfo.messageInfo!, convID, convType)); } return null; } - Future?> sendCustomMessage( - {required String data, - required String convID, - required ConvType convType}) async { - final textATMessageInfo = - await _messageService.createCustomMessage(data: data); + Future?> sendCustomMessage({required String data, required String convID, required ConvType convType}) async { + final textATMessageInfo = await _messageService.createCustomMessage(data: data); List currentHistoryMsgList = getOriginMessageList(); final messageInfo = textATMessageInfo!.messageInfo; if (messageInfo != null) { - final messageInfoWithSender = - tools.setUserInfoForMessage(messageInfo, textATMessageInfo.id!); + final messageInfoWithSender = tools.setUserInfoForMessage(messageInfo, textATMessageInfo.id!); V2TimMessage? lifeCycleMsg; if (lifeCycle?.messageWillSend != null) { lifeCycleMsg = await lifeCycle?.messageWillSend(messageInfoWithSender); @@ -717,38 +657,24 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } } - if (globalModel.getMessageListPosition(conversationID) != - HistoryMessagePosition.notShowLatest) { - currentHistoryMsgList = [ - lifeCycleMsg ?? messageInfoWithSender, - ...currentHistoryMsgList - ]; + if (globalModel.getMessageListPosition(conversationID) != HistoryMessagePosition.notShowLatest) { + currentHistoryMsgList = [lifeCycleMsg ?? messageInfoWithSender, ...currentHistoryMsgList]; globalModel.setMessageList(conversationID, currentHistoryMsgList); notifyListeners(); } return _sendMessage( - convID: convID, - id: textATMessageInfo.id as String, - convType: convType, - offlinePushInfo: tools.buildMessagePushInfo( - textATMessageInfo.messageInfo!, convID, convType)); + convID: convID, id: textATMessageInfo.id as String, convType: convType, offlinePushInfo: tools.buildMessagePushInfo(textATMessageInfo.messageInfo!, convID, convType)); } return null; } - Future?> sendFaceMessage( - {required int index, - required String data, - required String convID, - required ConvType convType}) async { - final textMessageInfo = - await _messageService.createFaceMessage(index: index, data: data); + Future?> sendFaceMessage({required int index, required String data, required String convID, required ConvType convType}) async { + final textMessageInfo = await _messageService.createFaceMessage(index: index, data: data); List currentHistoryMsgList = getOriginMessageList(); final messageInfo = textMessageInfo!.messageInfo; if (messageInfo != null) { - final messageInfoWithSender = - tools.setUserInfoForMessage(messageInfo, textMessageInfo.id!); + final messageInfoWithSender = tools.setUserInfoForMessage(messageInfo, textMessageInfo.id!); V2TimMessage? lifeCycleMsg; if (lifeCycle?.messageWillSend != null) { lifeCycleMsg = await lifeCycle?.messageWillSend(messageInfoWithSender); @@ -757,12 +683,8 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } } - if (globalModel.getMessageListPosition(conversationID) != - HistoryMessagePosition.notShowLatest) { - currentHistoryMsgList = [ - lifeCycleMsg ?? messageInfoWithSender, - ...currentHistoryMsgList - ]; + if (globalModel.getMessageListPosition(conversationID) != HistoryMessagePosition.notShowLatest) { + currentHistoryMsgList = [lifeCycleMsg ?? messageInfoWithSender, ...currentHistoryMsgList]; globalModel.setMessageList(conversationID, currentHistoryMsgList); notifyListeners(); } @@ -772,8 +694,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { id: textMessageInfo.id as String, convType: convType, messageInfo: lifeCycleMsg ?? messageInfoWithSender, - offlinePushInfo: tools.buildMessagePushInfo( - textMessageInfo.messageInfo!, convID, convType)); + offlinePushInfo: tools.buildMessagePushInfo(textMessageInfo.messageInfo!, convID, convType)); } return null; } @@ -784,13 +705,11 @@ class TUIChatSeparateViewModel extends ChangeNotifier { required String convID, required ConvType convType, }) async { - final soundMessageInfo = await _messageService.createSoundMessage( - soundPath: soundPath, duration: duration); + final soundMessageInfo = await _messageService.createSoundMessage(soundPath: soundPath, duration: duration); List currentHistoryMsgList = getOriginMessageList(); final messageInfo = soundMessageInfo!.messageInfo; if (messageInfo != null) { - final messageInfoWithSender = - tools.setUserInfoForMessage(messageInfo, soundMessageInfo.id!); + final messageInfoWithSender = tools.setUserInfoForMessage(messageInfo, soundMessageInfo.id!); V2TimMessage? lifeCycleMsg; if (lifeCycle?.messageWillSend != null) { lifeCycleMsg = await lifeCycle?.messageWillSend(messageInfoWithSender); @@ -799,12 +718,8 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } } - if (globalModel.getMessageListPosition(conversationID) != - HistoryMessagePosition.notShowLatest) { - currentHistoryMsgList = [ - lifeCycleMsg ?? messageInfoWithSender, - ...currentHistoryMsgList - ]; + if (globalModel.getMessageListPosition(conversationID) != HistoryMessagePosition.notShowLatest) { + currentHistoryMsgList = [lifeCycleMsg ?? messageInfoWithSender, ...currentHistoryMsgList]; globalModel.setMessageList(conversationID, currentHistoryMsgList); notifyListeners(); } @@ -813,8 +728,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { convID: convID, id: soundMessageInfo.id as String, convType: convType, - offlinePushInfo: tools.buildMessagePushInfo( - soundMessageInfo.messageInfo!, convID, convType), + offlinePushInfo: tools.buildMessagePushInfo(soundMessageInfo.messageInfo!, convID, convType), ); } return null; @@ -830,31 +744,22 @@ class TUIChatSeparateViewModel extends ChangeNotifier { return null; } if (_repliedMessage != null) { - V2TimMsgCreateInfoResult? textMessageInfo = - await _messageService.createTextMessage(text: text); + V2TimMsgCreateInfoResult? textMessageInfo = await _messageService.createTextMessage(text: text); if (atUserIDList != null && atUserIDList.isNotEmpty) { - textMessageInfo = await _messageService.createTextAtMessage( - text: text, atUserList: atUserIDList); + textMessageInfo = await _messageService.createTextAtMessage(text: text, atUserList: atUserIDList); } final V2TimMessage? messageInfo = textMessageInfo!.messageInfo; final receiver = convType == ConvType.c2c ? convID : ''; final groupID = convType == ConvType.group ? convID : ''; - final oldGroupType = _groupType != null - ? GroupReceptAllowType.values[_groupType!.index] - : null; + final oldGroupType = _groupType != null ? GroupReceptAllowType.values[_groupType!.index] : null; if (messageInfo != null) { - V2TimMessage messageInfoWithSender = - tools.setUserInfoForMessage(messageInfo, textMessageInfo.id!); - final hasNickName = _repliedMessage?.nickName != null && - _repliedMessage?.nickName != ""; + V2TimMessage messageInfoWithSender = tools.setUserInfoForMessage(messageInfo, textMessageInfo.id!); + final hasNickName = _repliedMessage?.nickName != null && _repliedMessage?.nickName != ""; final cloudCustomData = { "messageReply": { "messageID": _repliedMessage!.msgID, - "messageAbstract": tools.getMessageAbstract( - _repliedMessage!, abstractMessageBuilder), - "messageSender": hasNickName - ? _repliedMessage!.nickName - : _repliedMessage?.sender, + "messageAbstract": tools.getMessageAbstract(_repliedMessage!, abstractMessageBuilder), + "messageSender": hasNickName ? _repliedMessage!.nickName : _repliedMessage?.sender, "messageType": _repliedMessage?.elemType, "version": 1 } @@ -862,38 +767,28 @@ class TUIChatSeparateViewModel extends ChangeNotifier { messageInfoWithSender.cloudCustomData = json.encode(cloudCustomData); V2TimMessage? lifeCycleMsg; if (lifeCycle?.messageWillSend != null) { - lifeCycleMsg = - await lifeCycle?.messageWillSend(messageInfoWithSender); + lifeCycleMsg = await lifeCycle?.messageWillSend(messageInfoWithSender); if (lifeCycleMsg == null) { return null; } } List currentHistoryMsgList = getOriginMessageList(); - currentHistoryMsgList = [ - lifeCycleMsg ?? messageInfoWithSender, - ...currentHistoryMsgList - ]; + currentHistoryMsgList = [lifeCycleMsg ?? messageInfoWithSender, ...currentHistoryMsgList]; globalModel.setMessageList(conversationID, currentHistoryMsgList); _repliedMessage = null; final sendMsgRes = await _messageService.sendMessage( cloudCustomData: json.encode(cloudCustomData), id: textMessageInfo.id as String, - offlinePushInfo: tools.buildMessagePushInfo( - messageInfoWithSender, convID, convType), + offlinePushInfo: tools.buildMessagePushInfo(messageInfoWithSender, convID, convType), needReadReceipt: chatConfig.isShowGroupReadingStatus && convType == ConvType.group && - ((chatConfig.groupReadReceiptPermissionList != null && - chatConfig.groupReadReceiptPermissionList! - .contains(_groupType)) || - (chatConfig.groupReadReceiptPermisionList != null && - chatConfig.groupReadReceiptPermisionList! - .contains(oldGroupType))), + ((chatConfig.groupReadReceiptPermissionList != null && chatConfig.groupReadReceiptPermissionList!.contains(_groupType)) || + (chatConfig.groupReadReceiptPermisionList != null && chatConfig.groupReadReceiptPermisionList!.contains(oldGroupType))), groupID: groupID, receiver: receiver); notifyListeners(); - globalModel.updateMessage(sendMsgRes, convID, - messageInfoWithSender.id ?? "", convType, groupType, setInputField); + globalModel.updateMessage(sendMsgRes, convID, messageInfoWithSender.id ?? "", convType, groupType, setInputField); if (lifeCycle?.messageDidSend != null) { lifeCycle!.messageDidSend(sendMsgRes); } @@ -918,39 +813,25 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } Future?> sendImageMessage( - {String? imagePath, - String? imageName, - required String convID, - dynamic inputElement, - required ConvType convType}) async { + {String? imagePath, String? imageName, required String convID, dynamic inputElement, required ConvType convType}) async { String? image; - if ((PlatformUtils().isAndroid || PlatformUtils().isIOS) && - imagePath != null && - imagePath.isNotEmpty) { + if ((PlatformUtils().isAndroid || PlatformUtils().isIOS) && imagePath != null && imagePath.isNotEmpty) { try { final size = getFileSize(File(imagePath)); - final format = - imagePath.split(".")[imagePath.split(".").length - 1].toLowerCase(); - if (size > 20 || - (format != "jpg" && format != "png" && format != "gif")) { + final format = imagePath.split(".")[imagePath.split(".").length - 1].toLowerCase(); + if (size > 20 || (format != "jpg" && format != "png" && format != "gif")) { final target = await getTempPath(); - final result = await FlutterImageCompress.compressAndGetFile( - imagePath, target, - format: CompressFormat.jpeg, quality: 85); + final result = await FlutterImageCompress.compressAndGetFile(imagePath, target, format: CompressFormat.jpeg, quality: 85); image = result?.path; } // ignore: empty_catches } catch (e) {} } - final imageMessageInfo = await _messageService.createImageMessage( - imageName: imageName, - imagePath: image ?? imagePath, - inputElement: inputElement); + final imageMessageInfo = await _messageService.createImageMessage(imageName: imageName, imagePath: image ?? imagePath, inputElement: inputElement); List currentHistoryMsgList = getOriginMessageList(); final messageInfo = imageMessageInfo!.messageInfo; if (messageInfo != null) { - final messageInfoWithSender = - tools.setUserInfoForMessage(messageInfo, imageMessageInfo.id); + final messageInfoWithSender = tools.setUserInfoForMessage(messageInfo, imageMessageInfo.id); V2TimMessage? lifeCycleMsg; if (lifeCycle?.messageWillSend != null) { @@ -960,12 +841,8 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } } - if (globalModel.getMessageListPosition(conversationID) != - HistoryMessagePosition.notShowLatest) { - currentHistoryMsgList = [ - lifeCycleMsg ?? messageInfoWithSender, - ...currentHistoryMsgList - ]; + if (globalModel.getMessageListPosition(conversationID) != HistoryMessagePosition.notShowLatest) { + currentHistoryMsgList = [lifeCycleMsg ?? messageInfoWithSender, ...currentHistoryMsgList]; globalModel.setMessageList(conversationID, currentHistoryMsgList); notifyListeners(); } @@ -975,33 +852,24 @@ class TUIChatSeparateViewModel extends ChangeNotifier { messageInfo: lifeCycleMsg ?? messageInfoWithSender, id: imageMessageInfo.id as String, convType: convType, - offlinePushInfo: tools.buildMessagePushInfo( - imageMessageInfo.messageInfo!, convID, convType), + offlinePushInfo: tools.buildMessagePushInfo(imageMessageInfo.messageInfo!, convID, convType), ); } return null; } Future?> sendVideoMessage( - {String? videoPath, - int? duration, - String? snapshotPath, - required String convID, - required ConvType convType, - dynamic inputElement}) async { + {String? videoPath, int? duration, String? snapshotPath, required String convID, required ConvType convType, dynamic inputElement}) async { List currentHistoryMsgList = getOriginMessageList(); final videoMessageInfo = await _messageService.createVideoMessage( videoPath: videoPath, - type: videoPath != null - ? videoPath.split(".")[videoPath.split(".").length - 1] - : 'mp4', + type: videoPath != null ? videoPath.split(".")[videoPath.split(".").length - 1] : 'mp4', duration: duration, inputElement: inputElement, snapshotPath: snapshotPath); final messageInfo = videoMessageInfo!.messageInfo; if (messageInfo != null) { - final messageInfoWithSender = - tools.setUserInfoForMessage(messageInfo, videoMessageInfo.id); + final messageInfoWithSender = tools.setUserInfoForMessage(messageInfo, videoMessageInfo.id); V2TimMessage? lifeCycleMsg; if (lifeCycle?.messageWillSend != null) { lifeCycleMsg = await lifeCycle?.messageWillSend(messageInfoWithSender); @@ -1010,12 +878,8 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } } - if (globalModel.getMessageListPosition(conversationID) != - HistoryMessagePosition.notShowLatest) { - currentHistoryMsgList = [ - lifeCycleMsg ?? messageInfoWithSender, - ...currentHistoryMsgList - ]; + if (globalModel.getMessageListPosition(conversationID) != HistoryMessagePosition.notShowLatest) { + currentHistoryMsgList = [lifeCycleMsg ?? messageInfoWithSender, ...currentHistoryMsgList]; globalModel.setMessageList(conversationID, currentHistoryMsgList); notifyListeners(); } @@ -1025,37 +889,24 @@ class TUIChatSeparateViewModel extends ChangeNotifier { messageInfo: lifeCycleMsg ?? messageInfoWithSender, id: videoMessageInfo.id as String, convType: convType, - offlinePushInfo: tools.buildMessagePushInfo( - videoMessageInfo.messageInfo!, convID, convType), + offlinePushInfo: tools.buildMessagePushInfo(videoMessageInfo.messageInfo!, convID, convType), ); } return null; } Future?> sendFileMessage( - {String? filePath, - String? fileName, - int? size, - dynamic inputElement, - required String convID, - required ConvType convType}) async { + {String? filePath, String? fileName, int? size, dynamic inputElement, required String convID, required ConvType convType}) async { if (await tools.hasZeroSize(filePath ?? "")) { final CoreServicesImpl _coreServices = serviceLocator(); - _coreServices.callOnCallback(TIMCallback( - type: TIMCallbackType.INFO, - infoRecommendText: "不支持 0KB 文件的传输", - infoCode: 6660417)); + _coreServices.callOnCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: "不支持 0KB 文件的传输", infoCode: 6660417)); return null; } - final fileMessageInfo = await _messageService.createFileMessage( - inputElement: inputElement, - fileName: fileName ?? filePath?.split('/').last ?? "", - filePath: filePath); + final fileMessageInfo = await _messageService.createFileMessage(inputElement: inputElement, fileName: fileName ?? filePath?.split('/').last ?? "", filePath: filePath); List currentHistoryMsgList = getOriginMessageList(); final messageInfo = fileMessageInfo!.messageInfo; if (messageInfo != null) { - final messageInfoWithSender = - tools.setUserInfoForMessage(messageInfo, fileMessageInfo.id); + final messageInfoWithSender = tools.setUserInfoForMessage(messageInfo, fileMessageInfo.id); messageInfoWithSender.fileElem!.fileSize = size; V2TimMessage? lifeCycleMsg; if (lifeCycle?.messageWillSend != null) { @@ -1065,12 +916,8 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } } - if (globalModel.getMessageListPosition(conversationID) != - HistoryMessagePosition.notShowLatest) { - currentHistoryMsgList = [ - lifeCycleMsg ?? messageInfoWithSender, - ...currentHistoryMsgList - ]; + if (globalModel.getMessageListPosition(conversationID) != HistoryMessagePosition.notShowLatest) { + currentHistoryMsgList = [lifeCycleMsg ?? messageInfoWithSender, ...currentHistoryMsgList]; globalModel.setMessageList(conversationID, currentHistoryMsgList); notifyListeners(); } @@ -1080,26 +927,19 @@ class TUIChatSeparateViewModel extends ChangeNotifier { messageInfo: lifeCycleMsg ?? messageInfoWithSender, id: fileMessageInfo.id as String, convType: convType, - offlinePushInfo: tools.buildMessagePushInfo( - fileMessageInfo.messageInfo!, convID, convType), + offlinePushInfo: tools.buildMessagePushInfo(fileMessageInfo.messageInfo!, convID, convType), ); } return null; } Future?> sendLocationMessage( - {required String desc, - required double longitude, - required double latitude, - required String convID, - required ConvType convType}) async { + {required String desc, required double longitude, required double latitude, required String convID, required ConvType convType}) async { List currentHistoryMsgList = getOriginMessageList(); - final locationMessageInfo = await _messageService.createLocationMessage( - desc: desc, longitude: longitude, latitude: latitude); + final locationMessageInfo = await _messageService.createLocationMessage(desc: desc, longitude: longitude, latitude: latitude); final messageInfo = locationMessageInfo!.messageInfo; if (messageInfo != null) { - final messageInfoWithSender = - tools.setUserInfoForMessage(messageInfo, locationMessageInfo.id); + final messageInfoWithSender = tools.setUserInfoForMessage(messageInfo, locationMessageInfo.id); V2TimMessage? lifeCycleMsg; if (lifeCycle?.messageWillSend != null) { lifeCycleMsg = await lifeCycle?.messageWillSend(messageInfoWithSender); @@ -1108,12 +948,8 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } } - if (globalModel.getMessageListPosition(conversationID) != - HistoryMessagePosition.notShowLatest) { - currentHistoryMsgList = [ - lifeCycleMsg ?? messageInfoWithSender, - ...currentHistoryMsgList - ]; + if (globalModel.getMessageListPosition(conversationID) != HistoryMessagePosition.notShowLatest) { + currentHistoryMsgList = [lifeCycleMsg ?? messageInfoWithSender, ...currentHistoryMsgList]; globalModel.setMessageList(conversationID, currentHistoryMsgList); notifyListeners(); } @@ -1121,8 +957,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { convID: convID, id: locationMessageInfo.id as String, convType: convType, - offlinePushInfo: tools.buildMessagePushInfo( - locationMessageInfo.messageInfo!, convID, convType), + offlinePushInfo: tools.buildMessagePushInfo(locationMessageInfo.messageInfo!, convID, convType), ); } return null; @@ -1136,16 +971,13 @@ class TUIChatSeparateViewModel extends ChangeNotifier { final convID = conversation.groupID ?? conversation.userID ?? ""; final convType = conversation.type; for (var message in _multiSelectedMessageList) { - final forwardMessageInfo = - await _messageService.createForwardMessage(msgID: message.msgID!); + final forwardMessageInfo = await _messageService.createForwardMessage(msgID: message.msgID!); final messageInfo = forwardMessageInfo!.messageInfo; if (messageInfo != null) { - final messageInfoWithSender = - tools.setUserInfoForMessage(messageInfo, forwardMessageInfo.id); + final messageInfoWithSender = tools.setUserInfoForMessage(messageInfo, forwardMessageInfo.id); V2TimMessage? lifeCycleMsg; if (lifeCycle?.messageWillSend != null) { - lifeCycleMsg = - await lifeCycle?.messageWillSend(messageInfoWithSender); + lifeCycleMsg = await lifeCycle?.messageWillSend(messageInfoWithSender); if (lifeCycleMsg == null) { return null; } @@ -1154,10 +986,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { id: forwardMessageInfo.id!, convID: convID, convType: convType == 1 ? ConvType.c2c : ConvType.group, - offlinePushInfo: tools.buildMessagePushInfo( - forwardMessageInfo.messageInfo!, - convID, - convType == 1 ? ConvType.c2c : ConvType.group), + offlinePushInfo: tools.buildMessagePushInfo(forwardMessageInfo.messageInfo!, convID, convType == 1 ? ConvType.c2c : ConvType.group), ); } } @@ -1174,24 +1003,15 @@ class TUIChatSeparateViewModel extends ChangeNotifier { for (var conversation in conversationList) { final convID = conversation.groupID ?? conversation.userID ?? ""; final convType = conversation.type; - final List msgIDList = _multiSelectedMessageList - .map((e) => e.msgID ?? "") - .where((element) => element != "") - .toList(); - final mergerMessageInfo = await _messageService.createMergerMessage( - msgIDList: msgIDList, - title: title, - abstractList: abstractList, - compatibleText: TIM_t("该版本不支持此消息")); + final List msgIDList = _multiSelectedMessageList.map((e) => e.msgID ?? "").where((element) => element != "").toList(); + final mergerMessageInfo = await _messageService.createMergerMessage(msgIDList: msgIDList, title: title, abstractList: abstractList, compatibleText: TIM_t("该版本不支持此消息")); final messageInfo = mergerMessageInfo!.messageInfo; if (messageInfo != null) { - final messageInfoWithSender = - tools.setUserInfoForMessage(messageInfo, mergerMessageInfo.id); + final messageInfoWithSender = tools.setUserInfoForMessage(messageInfo, mergerMessageInfo.id); V2TimMessage? lifeCycleMsg; if (lifeCycle?.messageWillSend != null) { - lifeCycleMsg = - await lifeCycle?.messageWillSend(messageInfoWithSender); + lifeCycleMsg = await lifeCycle?.messageWillSend(messageInfoWithSender); if (lifeCycleMsg == null) { continue; } @@ -1200,28 +1020,20 @@ class TUIChatSeparateViewModel extends ChangeNotifier { id: mergerMessageInfo.id!, convID: convID, convType: convType == 1 ? ConvType.c2c : ConvType.group, - offlinePushInfo: tools.buildMessagePushInfo( - mergerMessageInfo.messageInfo!, - convID, - convType == 1 ? ConvType.c2c : ConvType.group), + offlinePushInfo: tools.buildMessagePushInfo(mergerMessageInfo.messageInfo!, convID, convType == 1 ? ConvType.c2c : ConvType.group), ); } } return null; } - Future?> reSendMessage( - {required String msgID, - required String convID, - bool? onlineUserOnly}) async { - final res = await _messageService.reSendMessage( - msgID: msgID, onlineUserOnly: onlineUserOnly ?? false); + Future?> reSendMessage({required String msgID, required String convID, bool? onlineUserOnly}) async { + final res = await _messageService.reSendMessage(msgID: msgID, onlineUserOnly: onlineUserOnly ?? false); final messageInfo = res.data; List currentHistoryMsgList = getOriginMessageList(); // final messageInfo = textMessageInfo!.messageInfo; if (messageInfo != null) { - final messageInfoWithSender = - tools.setUserInfoForMessage(messageInfo, messageInfo.id!); + final messageInfoWithSender = tools.setUserInfoForMessage(messageInfo, messageInfo.id!); V2TimMessage? lifeCycleMsg; if (lifeCycle?.messageWillSend != null) { lifeCycleMsg = await lifeCycle?.messageWillSend(messageInfoWithSender); @@ -1229,10 +1041,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { return null; } } - currentHistoryMsgList = [ - lifeCycleMsg ?? messageInfoWithSender, - ...currentHistoryMsgList - ]; + currentHistoryMsgList = [lifeCycleMsg ?? messageInfoWithSender, ...currentHistoryMsgList]; globalModel.setMessageList(convID, currentHistoryMsgList); } return res; @@ -1245,8 +1054,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { required ConvType convType, List? atUserIDList, }) async { - await deleteMsg(message.msgID ?? "", - id: message.id, webMessageInstance: message.messageFromWeb); + await deleteMsg(message.msgID ?? "", id: message.id, webMessageInstance: message.messageFromWeb); int messageType = message.elemType; V2TimValueCallback? res; if (messageType == MessageElemType.V2TIM_ELEM_TYPE_TEXT) { @@ -1259,53 +1067,37 @@ class TUIChatSeparateViewModel extends ChangeNotifier { atUserIDList: atUserIDList, ); } else { - res = await sendTextMessage( - text: text, convID: convID, convType: convType); + res = await sendTextMessage(text: text, convID: convID, convType: convType); } } if (messageType == MessageElemType.V2TIM_ELEM_TYPE_SOUND) { String soundPath = message.soundElem!.path!; int duration = message.soundElem!.duration!; - res = await sendSoundMessage( - soundPath: soundPath, - duration: duration, - convID: convID, - convType: convType); + res = await sendSoundMessage(soundPath: soundPath, duration: duration, convID: convID, convType: convType); } if (messageType == MessageElemType.V2TIM_ELEM_TYPE_IMAGE) { String imagePath = message.imageElem!.path!; - res = await sendImageMessage( - imagePath: imagePath, convID: convID, convType: convType); + res = await sendImageMessage(imagePath: imagePath, convID: convID, convType: convType); } if (messageType == MessageElemType.V2TIM_ELEM_TYPE_VIDEO) { String videoPath = message.videoElem?.videoPath ?? ""; int duration = message.videoElem?.duration ?? 0; String snapshotPath = message.videoElem?.snapshotPath ?? ""; - res = await sendVideoMessage( - videoPath: videoPath, - duration: duration, - snapshotPath: snapshotPath, - convID: convID, - convType: convType); + res = await sendVideoMessage(videoPath: videoPath, duration: duration, snapshotPath: snapshotPath, convID: convID, convType: convType); } if (messageType == MessageElemType.V2TIM_ELEM_TYPE_FILE) { String filePath = message.fileElem?.path ?? ""; int size = message.fileElem?.fileSize ?? 0; - res = await sendFileMessage( - filePath: filePath, size: size, convID: convID, convType: convType); + res = await sendFileMessage(filePath: filePath, size: size, convID: convID, convType: convType); } if (messageType == MessageElemType.V2TIM_ELEM_TYPE_CUSTOM) { String data = message.customElem?.data ?? ""; - res = await sendCustomMessage( - convID: convID, convType: convType, data: data); + res = await sendCustomMessage(convID: convID, convType: convType, data: data); } return res; } - Future?> sendTextMessage( - {required String text, - required String convID, - required ConvType convType}) async { + Future?> sendTextMessage({required String text, required String convID, required ConvType convType}) async { if (text.isEmpty) { return null; } @@ -1313,8 +1105,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { List currentHistoryMsgList = getOriginMessageList(); final messageInfo = textMessageInfo!.messageInfo; if (messageInfo != null) { - final messageInfoWithSender = - tools.setUserInfoForMessage(messageInfo, textMessageInfo.id!); + final messageInfoWithSender = tools.setUserInfoForMessage(messageInfo, textMessageInfo.id!); V2TimMessage? lifeCycleMsg; if (lifeCycle?.messageWillSend != null) { lifeCycleMsg = await lifeCycle?.messageWillSend(messageInfoWithSender); @@ -1323,22 +1114,14 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } } - if (globalModel.getMessageListPosition(conversationID) != - HistoryMessagePosition.notShowLatest) { - currentHistoryMsgList = [ - lifeCycleMsg ?? messageInfoWithSender, - ...currentHistoryMsgList - ]; + if (globalModel.getMessageListPosition(conversationID) != HistoryMessagePosition.notShowLatest) { + currentHistoryMsgList = [lifeCycleMsg ?? messageInfoWithSender, ...currentHistoryMsgList]; globalModel.setMessageList(conversationID, currentHistoryMsgList); notifyListeners(); } return _sendMessage( - convID: convID, - id: textMessageInfo.id as String, - convType: convType, - offlinePushInfo: tools.buildMessagePushInfo( - textMessageInfo.messageInfo!, convID, convType)); + convID: convID, id: textMessageInfo.id as String, convType: convType, offlinePushInfo: tools.buildMessagePushInfo(textMessageInfo.messageInfo!, convID, convType)); } return null; } @@ -1357,16 +1140,10 @@ class TUIChatSeparateViewModel extends ChangeNotifier { }) { List currentHistoryMsgList = getOriginMessageList(); if (messageInfo != null) { - final messageInfoWithSender = messageInfo.sender == null - ? tools.setUserInfoForMessage(messageInfo, messageInfo.id!) - : messageInfo; + final messageInfoWithSender = messageInfo.sender == null ? tools.setUserInfoForMessage(messageInfo, messageInfo.id!) : messageInfo; - if (globalModel.getMessageListPosition(conversationID) != - HistoryMessagePosition.notShowLatest) { - currentHistoryMsgList = [ - messageInfoWithSender, - ...currentHistoryMsgList - ]; + if (globalModel.getMessageListPosition(conversationID) != HistoryMessagePosition.notShowLatest) { + currentHistoryMsgList = [messageInfoWithSender, ...currentHistoryMsgList]; globalModel.setMessageList(conversationID, currentHistoryMsgList); } @@ -1380,22 +1157,18 @@ class TUIChatSeparateViewModel extends ChangeNotifier { convID: conversationID, id: messageInfo.id as String, convType: conversationType ?? ConvType.c2c, - offlinePushInfo: offlinePushInfo ?? - tools.buildMessagePushInfo( - messageInfo, conversationID, conversationType ?? ConvType.c2c), + offlinePushInfo: offlinePushInfo ?? tools.buildMessagePushInfo(messageInfo, conversationID, conversationType ?? ConvType.c2c), ); } return null; } deleteMsg(String msgID, {String? id, Object? webMessageInstance}) async { - if (lifeCycle?.shouldDeleteMessage != null && - await lifeCycle!.shouldDeleteMessage(msgID) == false) { + if (lifeCycle?.shouldDeleteMessage != null && await lifeCycle!.shouldDeleteMessage(msgID) == false) { return; } final messageList = getOriginMessageList(); - final res = await _messageService.deleteMessageFromLocalStorage( - msgID: msgID, webMessageInstance: webMessageInstance); + final res = await _messageService.deleteMessageFromLocalStorage(msgID: msgID, webMessageInstance: webMessageInstance); if (res.code == 0) { messageList.removeWhere((element) { return element.msgID == msgID || (id != null && element.id == id); @@ -1405,35 +1178,28 @@ class TUIChatSeparateViewModel extends ChangeNotifier { } clearHistory() async { - if (lifeCycle?.shouldClearHistoricalMessageList != null && - await lifeCycle!.shouldClearHistoricalMessageList(conversationID) == - false) { + if (lifeCycle?.shouldClearHistoricalMessageList != null && await lifeCycle!.shouldClearHistoricalMessageList(conversationID) == false) { return; } globalModel.setMessageList(conversationID, []); } - Future revokeMsg(String msgID, bool isAdmin, - [Object? webMessageInstance]) async { + Future revokeMsg(String msgID, bool isAdmin, [Object? webMessageInstance]) async { if (chatConfig.isGroupAdminRecallEnabled) { - final V2TimMessage? message = globalModel.messageListMap[conversationID] - ?.firstWhere((element) => element.msgID == msgID); + final V2TimMessage? message = globalModel.messageListMap[conversationID]?.firstWhere((element) => element.msgID == msgID); if (message != null) { if (PlatformUtils().isWeb) { final decodedMessage = jsonDecode(message.messageFromWeb!); - decodedMessage["cloudCustomData"] = - jsonEncode({"isRevoke": true, "revokeByAdmin": isAdmin}); + decodedMessage["cloudCustomData"] = jsonEncode({"isRevoke": true, "revokeByAdmin": isAdmin}); message.messageFromWeb = jsonEncode(decodedMessage); } else { - message.cloudCustomData = - jsonEncode({"isRevoke": true, "revokeByAdmin": isAdmin}); + message.cloudCustomData = jsonEncode({"isRevoke": true, "revokeByAdmin": isAdmin}); } return await modifyMessage(message: message); } } - final res = await _messageService.revokeMessage( - msgID: msgID, webMessageInstance: webMessageInstance); + final res = await _messageService.revokeMessage(msgID: msgID, webMessageInstance: webMessageInstance); if (res.code == 0) { globalModel.onMessageRevoked(msgID, conversationID); } @@ -1452,17 +1218,10 @@ class TUIChatSeparateViewModel extends ChangeNotifier { deleteSelectedMsg() async { List messageList = getOriginMessageList(); - final msgIDs = _multiSelectedMessageList - .map((e) => e.msgID ?? "") - .where((element) => element != "") - .toList(); - final webMessageInstanceList = _multiSelectedMessageList - .map((e) => e.messageFromWeb) - .where((element) => element != null) - .toList(); + final msgIDs = _multiSelectedMessageList.map((e) => e.msgID ?? "").where((element) => element != "").toList(); + final webMessageInstanceList = _multiSelectedMessageList.map((e) => e.messageFromWeb).where((element) => element != null).toList(); - final res = await _messageService.deleteMessages( - msgIDs: msgIDs, webMessageInstanceList: webMessageInstanceList); + final res = await _messageService.deleteMessages(msgIDs: msgIDs, webMessageInstanceList: webMessageInstanceList); if (res.code == 0) { for (var msgID in msgIDs) { messageList.removeWhere((element) => element.msgID == msgID); @@ -1479,11 +1238,8 @@ class TUIChatSeparateViewModel extends ChangeNotifier { notifyListeners(); } - Future> - getGroupMessageReadMemberList(String messageID, - GetGroupMessageReadMemberListFilter fileter, int nextSeq) async { - final res = await _messageService.getGroupMessageReadMemberList( - nextSeq: nextSeq, messageID: messageID, filter: fileter); + Future> getGroupMessageReadMemberList(String messageID, GetGroupMessageReadMemberListFilter fileter, int nextSeq) async { + final res = await _messageService.getGroupMessageReadMemberList(nextSeq: nextSeq, messageID: messageID, filter: fileter); return res; } @@ -1499,8 +1255,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { Future findMessage(String msgID) async { List messageList = getOriginMessageList(); - final repliedMessage = - messageList.where((element) => element.msgID == msgID).toList(); + final repliedMessage = messageList.where((element) => element.msgID == msgID).toList(); if (repliedMessage.isNotEmpty) { return repliedMessage.first; } @@ -1513,8 +1268,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier { showLatestUnread() { markMessageAsRead(); - globalModel.setMessageListPosition( - conversationID, HistoryMessagePosition.bottom); + globalModel.setMessageListPosition(conversationID, HistoryMessagePosition.bottom); } @override diff --git a/lib/ui/views/TIMUIKitChat/TIMUIKItMessageList/tim_uikit_chat_history_message_list_item.dart b/lib/ui/views/TIMUIKitChat/TIMUIKItMessageList/tim_uikit_chat_history_message_list_item.dart index 70688ee..0cc1ae2 100644 --- a/lib/ui/views/TIMUIKitChat/TIMUIKItMessageList/tim_uikit_chat_history_message_list_item.dart +++ b/lib/ui/views/TIMUIKitChat/TIMUIKItMessageList/tim_uikit_chat_history_message_list_item.dart @@ -1096,10 +1096,12 @@ class _TIMUIKItHistoryMessageListItemState final customHoverBar = widget.customMessageHoverBarOnDesktop != null ? widget.customMessageHoverBarOnDesktop!(message) : null; + final wideHoverTipList = (model.chatConfig.isUseMessageHoverBarOnDesktop && customHoverBar == null) ? getMessageHoverControlBar(model, theme) : []; + final lastItemName = wideHoverTipList.isNotEmpty ? wideHoverTipList.last.name : ""; return Column( @@ -1318,8 +1320,11 @@ class _TIMUIKItHistoryMessageListItemState onExit: (_) { if (isDesktopScreen && model.chatConfig.isUseMessageHoverBarOnDesktop) { - setState(() { - isShowWideToolTip = false; + Tooltip.dismissAllToolTips(); + Future.delayed(const Duration(milliseconds: 100), () { + setState(() { + isShowWideToolTip = false; + }); }); } }, diff --git a/lib/ui/views/TIMUIKitChat/TIMUIKitMessageItem/TIMUIKitMessageReaction/tim_uikit_message_reaction_show_item.dart b/lib/ui/views/TIMUIKitChat/TIMUIKitMessageItem/TIMUIKitMessageReaction/tim_uikit_message_reaction_show_item.dart index 2506e71..d7d3e5e 100644 --- a/lib/ui/views/TIMUIKitChat/TIMUIKitMessageItem/TIMUIKitMessageReaction/tim_uikit_message_reaction_show_item.dart +++ b/lib/ui/views/TIMUIKitChat/TIMUIKitMessageItem/TIMUIKitMessageReaction/tim_uikit_message_reaction_show_item.dart @@ -1,7 +1,9 @@ // ignore_for_file: unused_field +import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart'; import 'package:tencent_im_base/tencent_im_base.dart'; import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart'; import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart'; @@ -64,6 +66,20 @@ class TIMUIKitMessageReactionShowItem extends TIMUIKitStatelessWidget { final option1 = nameList.length; final TUIChatSeparateViewModel model = Provider.of(context); + + final List userIDs = []; + for (final user in nameList) { + final V2TimGroupMemberFullInfo? memberInfo = memberList + .firstWhereOrNull((element) => element?.userID == user && TencentUtils.checkString(user) != null); + if((memberInfo == null || TencentUtils.checkString(memberInfo.userID) == null) && TencentUtils.checkString(user.toString()) != null){ + userIDs.add(user.toString()); + } + } + if(userIDs.isNotEmpty){ + model.getUserShowName(userIDs); + } + + return LayoutBuilder(builder: (context, constraints) { return Container( padding: const EdgeInsets.only( @@ -140,9 +156,22 @@ class TIMUIKitMessageReactionShowItem extends TIMUIKitStatelessWidget { } else { showName = memberInfo.userID; } + }else{ + final String? data = model.groupUserShowName[e]; + if(TencentUtils.checkString(data) != null){ + showName = data ?? e; + } } - } catch (e) { - // e + } catch (error) { + final String? data = model.groupUserShowName[e]; + if(TencentUtils.checkString(data) != null){ + showName = data ?? e; + } + } + }else{ + final String? data = model.groupUserShowName[e]; + if(TencentUtils.checkString(data) != null){ + showName = data ?? e; } } return InkWell( diff --git a/lib/ui/views/TIMUIKitChat/TIMUIKitMessageItem/tim_uikit_chat_file_elem.dart b/lib/ui/views/TIMUIKitChat/TIMUIKitMessageItem/tim_uikit_chat_file_elem.dart index ee3ab0e..728ba6c 100644 --- a/lib/ui/views/TIMUIKitChat/TIMUIKitMessageItem/tim_uikit_chat_file_elem.dart +++ b/lib/ui/views/TIMUIKitChat/TIMUIKitMessageItem/tim_uikit_chat_file_elem.dart @@ -373,69 +373,74 @@ class _TIMUIKitFileElemState extends TIMUIKitState { infoCode: 6660416)); } }, - child: Container( - width: 237, - decoration: BoxDecoration( - border: Border.all( - color: theme.weakDividerColor ?? - CommonColor.weakDividerColor, + child: ConstrainedBox( + constraints: const BoxConstraints(maxHeight: 72), + child: Container( + width: 237, + decoration: BoxDecoration( + border: Border.all( + color: theme.weakDividerColor ?? + CommonColor.weakDividerColor, + ), + borderRadius: borderRadius), + child: Stack(children: [ + ClipRRect( + borderRadius: borderRadius, + child: LinearProgressIndicator( + minHeight: ((containerHeight) ?? 72) - 6, + value: (received == 100 ? 0 : received) / 100, + backgroundColor: received == 100 + ? theme.weakBackgroundColor + : Colors.white, + valueColor: AlwaysStoppedAnimation( + theme.lightPrimaryMaterialColor.shade50),), ), - borderRadius: borderRadius), - child: Stack(children: [ - ClipRRect( - borderRadius: borderRadius, - child: LinearProgressIndicator( - minHeight: ((containerHeight) ?? 72) - 6, - value: (received == 100 ? 0 : received) / 100, - backgroundColor: received == 100 - ? theme.weakBackgroundColor - : Colors.white, - valueColor: AlwaysStoppedAnimation( - theme.lightPrimaryMaterialColor.shade50)), - ), - Padding( - padding: const EdgeInsets.symmetric( - vertical: 8, horizontal: 12), - child: Row( - mainAxisAlignment: widget.isSelf - ? MainAxisAlignment.end - : MainAxisAlignment.start, - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - constraints: - const BoxConstraints(maxWidth: 160), - child: LayoutBuilder( - builder: (buildContext, boxConstraints) { - return CustomText( - fileName, - width: boxConstraints.maxWidth, - style: TextStyle( - color: theme.darkTextColor, - fontSize: 16, + Padding( + padding: const EdgeInsets.symmetric( + vertical: 8, horizontal: 12), + child: Row( + mainAxisAlignment: widget.isSelf + ? MainAxisAlignment.end + : MainAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + constraints: + const BoxConstraints(maxWidth: 160), + child: LayoutBuilder( + builder: (buildContext, boxConstraints) { + return CustomText( + fileName, + width: boxConstraints.maxWidth, + maxLines: 1, + style: TextStyle( + color: theme.darkTextColor, + fontSize: 16, + ), + ); + }, ), - ); - }, - ), - ), - if (fileSize != null) - Text( - showFileSize(fileSize), - style: TextStyle( - fontSize: 14, - color: theme.weakTextColor), - ) - ], - )), - TIMUIKitFileIcon( - fileFormat: fileFormat, - ), - ])), - ]), - ))), + ), + if (fileSize != null) + Text( + showFileSize(fileSize), + style: TextStyle( + fontSize: 14, + color: theme.weakTextColor), + ) + ], + )), + TIMUIKitFileIcon( + fileFormat: fileFormat, + ), + ])), + ]), + ), + ), + )), if (!widget.isSelf && isWebDownloading) Container( margin: const EdgeInsets.only(top: 2), diff --git a/lib/ui/views/TIMUIKitChat/TIMUIKitTextField/tim_uikit_text_field_layout/wide.dart b/lib/ui/views/TIMUIKitChat/TIMUIKitTextField/tim_uikit_text_field_layout/wide.dart index 3b5c198..84efff1 100644 --- a/lib/ui/views/TIMUIKitChat/TIMUIKitTextField/tim_uikit_text_field_layout/wide.dart +++ b/lib/ui/views/TIMUIKitChat/TIMUIKitTextField/tim_uikit_text_field_layout/wide.dart @@ -1,15 +1,21 @@ import 'dart:async'; import 'dart:io'; import 'dart:math'; + +// ignore: unnecessary_import +import 'dart:typed_data'; + +import 'package:extended_text_field/extended_text_field.dart'; import 'package:fc_native_video_thumbnail/fc_native_video_thumbnail.dart'; +import 'package:file_picker/file_picker.dart'; +import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:image_picker/image_picker.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:pasteboard/pasteboard.dart'; import 'package:path/path.dart' as p; -import 'package:file_picker/file_picker.dart'; -import 'package:flutter/material.dart'; -import 'package:image_picker/image_picker.dart'; import 'package:path_provider/path_provider.dart'; import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart'; import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart'; @@ -19,23 +25,18 @@ import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_setting_ import 'package:tencent_cloud_chat_uikit/data_services/core/tim_uikit_wide_modal_operation_key.dart'; import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart'; import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart'; +import 'package:tencent_cloud_chat_uikit/ui/utils/logger.dart'; import 'package:tencent_cloud_chat_uikit/ui/utils/message.dart'; import 'package:tencent_cloud_chat_uikit/ui/utils/optimize_utils.dart'; -import 'package:tencent_cloud_chat_uikit/ui/utils/screen_shot.dart'; -import 'package:tencent_cloud_chat_uikit/ui/widgets/wide_popup.dart'; import 'package:tencent_cloud_chat_uikit/ui/utils/platform.dart'; +import 'package:tencent_cloud_chat_uikit/ui/utils/screen_shot.dart'; import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/special_text/DefaultSpecialTextSpanBuilder.dart'; import 'package:tencent_cloud_chat_uikit/ui/widgets/drag_widget.dart'; -import 'package:extended_text_field/extended_text_field.dart'; +import 'package:tencent_cloud_chat_uikit/ui/widgets/wide_popup.dart'; import 'package:universal_html/html.dart' as html; import 'package:url_launcher/url_launcher.dart'; import 'package:uuid/uuid.dart'; import 'package:wechat_assets_picker/wechat_assets_picker.dart'; -import 'package:flutter_svg/flutter_svg.dart'; - -// ignore: unnecessary_import -import 'dart:typed_data'; -import 'package:tencent_cloud_chat_uikit/ui/utils/logger.dart'; class DesktopControlBarItem { final String item; @@ -47,18 +48,8 @@ class DesktopControlBarItem { final String? showName; final double? size; - DesktopControlBarItem( - {required this.item, - this.icon, - this.color, - this.imgPath, - this.svgPath, - required this.onClick, - this.showName, - this.size}) - : assert(icon != null || - TencentUtils.checkString(imgPath) != null || - TencentUtils.checkString(svgPath) != null); + DesktopControlBarItem({required this.item, this.icon, this.color, this.imgPath, this.svgPath, required this.onClick, this.showName, this.size}) + : assert(icon != null || TencentUtils.checkString(imgPath) != null || TencentUtils.checkString(svgPath) != null); } class DesktopControlBarConfig { @@ -193,12 +184,10 @@ class TIMUIKitTextFieldLayoutWide extends StatefulWidget { : super(key: key); @override - State createState() => - _TIMUIKitTextFieldLayoutWideState(); + State createState() => _TIMUIKitTextFieldLayoutWideState(); } -class _TIMUIKitTextFieldLayoutWideState - extends TIMUIKitState { +class _TIMUIKitTextFieldLayoutWideState extends TIMUIKitState { final TUISettingModel settingModel = serviceLocator(); OverlayEntry? entry; final ImagePicker _picker = ImagePicker(); @@ -272,13 +261,8 @@ class _TIMUIKitTextFieldLayoutWideState } String getAbstractMessage(V2TimMessage message) { - final String? customAbstractMessage = - widget.model.abstractMessageBuilder != null - ? widget.model.abstractMessageBuilder!(widget.model.repliedMessage!) - : null; - return customAbstractMessage ?? - MessageUtils.getAbstractMessageAsync( - widget.model.repliedMessage!, widget.model.groupMemberList ?? []); + final String? customAbstractMessage = widget.model.abstractMessageBuilder != null ? widget.model.abstractMessageBuilder!(widget.model.repliedMessage!) : null; + return customAbstractMessage ?? MessageUtils.getAbstractMessageAsync(widget.model.repliedMessage!, widget.model.groupMemberList ?? []); } _buildRepliedMessage(V2TimMessage? repliedMessage) { @@ -301,10 +285,7 @@ class _TIMUIKitTextFieldLayoutWideState softWrap: true, maxLines: 1, overflow: TextOverflow.ellipsis, - style: TextStyle( - color: hexToColor("8f959e"), - fontSize: 14, - fontWeight: FontWeight.bold), + style: TextStyle(color: hexToColor("8f959e"), fontSize: 14, fontWeight: FontWeight.bold), ), Expanded( child: Text( @@ -347,10 +328,8 @@ class _TIMUIKitTextFieldLayoutWideState entry = null; } }, - initOffset: offset != null - ? Offset(offset.dx, max(offset.dy, 16)) - : Offset(MediaQuery.of(context).size.height * 0.5 + 20, - MediaQuery.of(context).size.height * 0.5 - 100), + initOffset: + offset != null ? Offset(offset.dx, max(offset.dy, 16)) : Offset(MediaQuery.of(context).size.height * 0.5 + 20, MediaQuery.of(context).size.height * 0.5 - 100), child: Container( decoration: BoxDecoration( borderRadius: const BorderRadius.all(Radius.circular(8)), @@ -390,60 +369,55 @@ class _TIMUIKitTextFieldLayoutWideState String? emojiName = singleEmojiName.split('.png')[0]; if (widget.isUseDefaultEmoji && widget.languageType == 'zh' && - TUIKitStickerConstData.emojiMapList[emojiName] != - null && - TUIKitStickerConstData.emojiMapList[emojiName] != - '') { - emojiName = - TUIKitStickerConstData.emojiMapList[emojiName]; + TUIKitStickerConstData.emojiMapList[emojiName] != null && + TUIKitStickerConstData.emojiMapList[emojiName] != '') { + emojiName = TUIKitStickerConstData.emojiMapList[emojiName]; } final newText = '[$emojiName]'; widget.addStickerToText(newText); entry?.remove(); entry = null; }), - defaultCustomEmojiStickerList: widget.isUseDefaultEmoji - ? TUIKitStickerConstData.emojiList - : []) - : StickerPanel( - isWideScreen: true, - height: widget.chatConfig.desktopStickerPanelHeight, - width: 350, - sendTextMsg: null, - sendFaceMsg: (_, __){ - widget.onCustomEmojiFaceSubmitted(_, __); - entry?.remove(); - entry = null; - }, - deleteText: () { - widget.backSpaceText(); - }, - addText: (int unicode) { - final newText = String.fromCharCode(unicode); - widget.addStickerToText(newText); - entry?.remove(); - entry = null; - }, - addCustomEmojiText: ((String singleEmojiName) { - String? emojiName = singleEmojiName.split('.png')[0]; - if (widget.isUseDefaultEmoji && - widget.languageType == 'zh' && - TUIKitStickerConstData.emojiMapList[emojiName] != - null && - TUIKitStickerConstData.emojiMapList[emojiName] != - '') { - emojiName = - TUIKitStickerConstData.emojiMapList[emojiName]; - } - final newText = '[$emojiName]'; - widget.addStickerToText(newText); - entry?.remove(); - entry = null; - }), - customStickerPackageList: widget.stickerPackageList, - bottomColor: theme.weakBackgroundColor, - backgroundColor: theme.wideBackgroundColor, - lightPrimaryColor: theme.lightPrimaryColor), + defaultCustomEmojiStickerList: widget.isUseDefaultEmoji ? TUIKitStickerConstData.emojiList : []) + : Material( + color: Colors.transparent, + child: StickerPanel( + isWideScreen: true, + height: widget.chatConfig.desktopStickerPanelHeight, + width: 350, + sendTextMsg: null, + sendFaceMsg: (_, __) { + widget.onCustomEmojiFaceSubmitted(_, __); + entry?.remove(); + entry = null; + }, + deleteText: () { + widget.backSpaceText(); + }, + addText: (int unicode) { + final newText = String.fromCharCode(unicode); + widget.addStickerToText(newText); + entry?.remove(); + entry = null; + }, + addCustomEmojiText: ((String singleEmojiName) { + String? emojiName = singleEmojiName.split('.png')[0]; + if (widget.isUseDefaultEmoji && + widget.languageType == 'zh' && + TUIKitStickerConstData.emojiMapList[emojiName] != null && + TUIKitStickerConstData.emojiMapList[emojiName] != '') { + emojiName = TUIKitStickerConstData.emojiMapList[emojiName]; + } + final newText = '[$emojiName]'; + widget.addStickerToText(newText); + entry?.remove(); + entry = null; + }), + customStickerPackageList: widget.stickerPackageList, + bottomColor: theme.weakBackgroundColor, + backgroundColor: theme.wideBackgroundColor, + lightPrimaryColor: theme.lightPrimaryColor), + ), ), )); }); @@ -485,30 +459,16 @@ class _TIMUIKitTextFieldLayoutWideState if (result != null && result.files.isNotEmpty) { if (PlatformUtils().isWeb) { html.Node? inputElem; - inputElem = html.document - .getElementById("__file_picker_web-file-input") - ?.querySelector("input"); + inputElem = html.document.getElementById("__file_picker_web-file-input")?.querySelector("input"); fileName = result.files.single.name; - MessageUtils.handleMessageError( - model.sendFileMessage( - inputElement: inputElem, - fileName: fileName, - convID: convID, - convType: convType), - context); + MessageUtils.handleMessageError(model.sendFileMessage(inputElement: inputElem, fileName: fileName, convID: convID, convType: convType), context); } else { File file = File(result.files.single.path!); final int size = file.lengthSync(); final String savePath = file.path; - MessageUtils.handleMessageError( - model.sendFileMessage( - filePath: savePath, - size: size, - convID: convID, - convType: convType), - context); + MessageUtils.handleMessageError(model.sendFileMessage(filePath: savePath, size: size, convID: convID, convType: convType), context); } } else { throw TypeError(); @@ -519,8 +479,7 @@ class _TIMUIKitTextFieldLayoutWideState } } - List generateBarIcons( - List items, TUITheme theme) { + List generateBarIcons(List items, TUITheme theme) { final defaultItems = defaultControlBarItems.map((e) => e.item); return items.map((e) { final GlobalKey key = GlobalKey(); @@ -528,15 +487,10 @@ class _TIMUIKitTextFieldLayoutWideState margin: const EdgeInsets.only(right: 10), child: InkWell( onTap: () { - final alignBox = - key.currentContext?.findRenderObject() as RenderBox?; + final alignBox = key.currentContext?.findRenderObject() as RenderBox?; var offset = alignBox?.localToGlobal(Offset.zero); final double? dx = (offset?.dx != null) ? offset!.dx : null; - final double? dy = - (offset?.dy != null && alignBox?.size.height != null) - ? offset!.dy - - (widget.chatConfig.desktopStickerPanelHeight + 20) - : null; + final double? dy = (offset?.dy != null && alignBox?.size.height != null) ? offset!.dy - (widget.chatConfig.desktopStickerPanelHeight + 20) : null; e.onClick((dx != null && dy != null) ? Offset(dx, dy) : null); }, child: Tooltip( @@ -550,9 +504,7 @@ class _TIMUIKitTextFieldLayoutWideState if (TencentUtils.checkString(e.svgPath) != null) { return SvgPicture.asset( e.svgPath!, - package: defaultItems.contains(e.item) - ? 'tencent_cloud_chat_uikit' - : null, + package: defaultItems.contains(e.item) ? 'tencent_cloud_chat_uikit' : null, key: key, width: e.size ?? 16, height: e.size ?? 16, @@ -561,9 +513,7 @@ class _TIMUIKitTextFieldLayoutWideState if (TencentUtils.checkString(e.imgPath) != null) { return Image.asset( e.imgPath!, - package: defaultItems.contains(e.item) - ? 'tencent_cloud_chat_uikit' - : null, + package: defaultItems.contains(e.item) ? 'tencent_cloud_chat_uikit' : null, key: key, width: e.size ?? 16, height: e.size ?? 16, @@ -592,18 +542,10 @@ class _TIMUIKitTextFieldLayoutWideState fileContent = imageContent; html.Node? inputElem; - inputElem = html.document - .getElementById("__image_picker_web-file-input") - ?.querySelector("input"); + inputElem = html.document.getElementById("__image_picker_web-file-input")?.querySelector("input"); final convID = widget.conversationID; final convType = widget.conversationType; - MessageUtils.handleMessageError( - model.sendImageMessage( - inputElement: inputElem, - imagePath: tempFile?.path, - convID: convID, - convType: convType), - context); + MessageUtils.handleMessageError(model.sendImageMessage(inputElement: inputElem, imagePath: tempFile?.path, convID: convID, convType: convType), context); } catch (e) { // ignore: avoid_print outputLogger.i("_sendFileErr: ${e.toString()}"); @@ -619,26 +561,15 @@ class _TIMUIKitTextFieldLayoutWideState fileContent = videoContent; if (fileName!.split(".")[fileName!.split(".").length - 1] != "mp4") { - onTIMCallback(TIMCallback( - type: TIMCallbackType.INFO, - infoRecommendText: TIM_t("视频消息仅限 mp4 格式"), - infoCode: 6660412)); + onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("视频消息仅限 mp4 格式"), infoCode: 6660412)); return; } html.Node? inputElem; - inputElem = html.document - .getElementById("__image_picker_web-file-input") - ?.querySelector("input"); + inputElem = html.document.getElementById("__image_picker_web-file-input")?.querySelector("input"); final convID = widget.conversationID; final convType = widget.conversationType; - MessageUtils.handleMessageError( - model.sendVideoMessage( - inputElement: inputElem, - videoPath: tempFile?.path, - convID: convID, - convType: convType), - context); + MessageUtils.handleMessageError(model.sendVideoMessage(inputElement: inputElem, videoPath: tempFile?.path, convID: convID, convType: convType), context); } catch (e) { // ignore: avoid_print outputLogger.i("_sendFileErr: ${e.toString()}"); @@ -651,10 +582,7 @@ class _TIMUIKitTextFieldLayoutWideState final originFile = await asset.originFile; final size = await originFile!.length(); if (size >= 104857600) { - onTIMCallback(TIMCallback( - type: TIMCallbackType.INFO, - infoRecommendText: TIM_t("发送失败,视频不能大于100MB"), - infoCode: 6660405)); + onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("发送失败,视频不能大于100MB"), infoCode: 6660405)); return; } @@ -663,9 +591,7 @@ class _TIMUIKitTextFieldLayoutWideState final convID = widget.conversationID; final convType = widget.conversationType; - String tempPath = (await getTemporaryDirectory()).path + - p.extension(originFile.path, 3) + - ".jpeg"; + String tempPath = (await getTemporaryDirectory()).path + p.extension(originFile.path, 3) + ".jpeg"; await plugin.getVideoThumbnail( srcFile: originFile.path, @@ -676,24 +602,13 @@ class _TIMUIKitTextFieldLayoutWideState quality: 100, height: 128, ); - MessageUtils.handleMessageError( - model.sendVideoMessage( - videoPath: filePath, - duration: duration, - snapshotPath: tempPath, - convID: convID, - convType: convType), - context); + MessageUtils.handleMessageError(model.sendVideoMessage(videoPath: filePath, duration: duration, snapshotPath: tempPath, convID: convID, convType: convType), context); } catch (e) { - onTIMCallback(TIMCallback( - type: TIMCallbackType.INFO, - infoRecommendText: TIM_t("视频文件异常"), - infoCode: 6660415)); + onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("视频文件异常"), infoCode: 6660415)); } } - _sendMediaMessage( - TUIChatSeparateViewModel model, TUITheme theme, FileType fileType) async { + _sendMediaMessage(TUIChatSeparateViewModel model, TUITheme theme, FileType fileType) async { try { final convID = widget.conversationID; final convType = widget.conversationType; @@ -708,12 +623,7 @@ class _TIMUIKitTextFieldLayoutWideState final type = asset.type; if (filePath != null) { if (type == AssetType.image) { - MessageUtils.handleMessageError( - model.sendImageMessage( - imagePath: filePath, - convID: convID, - convType: convType), - context); + MessageUtils.handleMessageError(model.sendImageMessage(imagePath: filePath, convID: convID, convType: convType), context); } if (type == AssetType.video) { @@ -725,26 +635,17 @@ class _TIMUIKitTextFieldLayoutWideState } else { final plugin = FcNativeVideoThumbnail(); _addGreyOverlay(); - FilePickerResult? result = - await FilePicker.platform.pickFiles(type: fileType); + FilePickerResult? result = await FilePicker.platform.pickFiles(type: fileType); _removeOverlay(); if (result != null && result.files.isNotEmpty) { File file = File(result.files.single.path!); final String savePath = file.path; - final String type = TencentUtils.getFileType( - (savePath.split(".")[savePath.split(".").length - 1]) - .toLowerCase()) - .split("/")[0]; + final String type = TencentUtils.getFileType((savePath.split(".")[savePath.split(".").length - 1]).toLowerCase()).split("/")[0]; if (type == "image") { - MessageUtils.handleMessageError( - model.sendImageMessage( - imagePath: savePath, convID: convID, convType: convType), - context); + MessageUtils.handleMessageError(model.sendImageMessage(imagePath: savePath, convID: convID, convType: convType), context); } else if (type == "video") { - String tempPath = (await getTemporaryDirectory()).path + - p.basename(savePath) + - ".jpeg"; + String tempPath = (await getTemporaryDirectory()).path + p.basename(savePath) + ".jpeg"; await plugin.getVideoThumbnail( srcFile: savePath, keepAspectRatio: true, @@ -754,13 +655,7 @@ class _TIMUIKitTextFieldLayoutWideState quality: 100, height: 128, ); - MessageUtils.handleMessageError( - model.sendVideoMessage( - videoPath: savePath, - convID: convID, - convType: convType, - snapshotPath: tempPath), - context); + MessageUtils.handleMessageError(model.sendVideoMessage(videoPath: savePath, convID: convID, convType: convType, snapshotPath: tempPath), context); } } else { throw TypeError(); @@ -769,17 +664,12 @@ class _TIMUIKitTextFieldLayoutWideState } catch (err) { // ignore: avoid_print outputLogger.i("send media err: $err"); - onTIMCallback(TIMCallback( - type: TIMCallbackType.INFO, - infoRecommendText: TIM_t("视频文件异常"), - infoCode: 6660415)); + onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("视频文件异常"), infoCode: 6660415)); } } - _sendImageWithConfirmation( - {String? fileName, Size? fileSize, required String filePath}) async { - final option1 = widget.currentConversation.showName ?? - (widget.conversationType == ConvType.group ? TIM_t("群聊") : TIM_t("对方")); + _sendImageWithConfirmation({String? fileName, Size? fileSize, required String filePath}) async { + final option1 = widget.currentConversation.showName ?? (widget.conversationType == ConvType.group ? TIM_t("群聊") : TIM_t("对方")); final size = fileSize ?? await ScreenshotHelper.getImageSize(filePath); TUIKitWidePopup.showPopupWindow( @@ -798,9 +688,7 @@ class _TIMUIKitTextFieldLayoutWideState height: min(360, size.height / 2), child: InkWell( onTap: () { - launchUrl(PlatformUtils().isWeb - ? Uri.parse(filePath) - : Uri.file(filePath)); + launchUrl(PlatformUtils().isWeb ? Uri.parse(filePath) : Uri.file(filePath)); }, child: PlatformUtils().isWeb ? Image.network( @@ -828,12 +716,7 @@ class _TIMUIKitTextFieldLayoutWideState ElevatedButton( onPressed: () { MessageUtils.handleMessageError( - widget.model.sendImageMessage( - imagePath: filePath, - imageName: fileName, - convID: widget.conversationID, - convType: widget.conversationType), - context); + widget.model.sendImageMessage(imagePath: filePath, imageName: fileName, convID: widget.conversationID, convType: widget.conversationType), context); closeFunc(); }, child: Text(TIM_t("发送"))) @@ -852,8 +735,7 @@ class _TIMUIKitTextFieldLayoutWideState } generateDefaultControlBarItems() { - final DesktopControlBarConfig config = - widget.chatConfig.desktopControlBarConfig ?? DesktopControlBarConfig(); + final DesktopControlBarConfig config = widget.chatConfig.desktopControlBarConfig ?? DesktopControlBarConfig(); final List itemsList = [ if (config.showStickerPanel) DesktopControlBarItem( @@ -916,15 +798,8 @@ class _TIMUIKitTextFieldLayoutWideState child: (onClose) => TIMUIKitSearchMsgDetail( currentConversation: widget.currentConversation, keyword: '', - initMessageList: widget.model - .getOriginMessageList() - .getRange( - 0, - min(widget.model.getOriginMessageList().length, - 100)) - .toList(), - onTapConversation: (V2TimConversation conversation, - V2TimMessage? message) {}, + initMessageList: widget.model.getOriginMessageList().getRange(0, min(widget.model.getOriginMessageList().length, 100)).toList(), + onTapConversation: (V2TimConversation conversation, V2TimMessage? message) {}, ), theme: widget.theme); }, @@ -933,12 +808,8 @@ class _TIMUIKitTextFieldLayoutWideState defaultControlBarItems = itemsList; } - List generateControlBar( - TUIChatSeparateViewModel model, TUITheme theme) { - final List itemsList = [ - ...defaultControlBarItems, - ...(widget.chatConfig.additionalDesktopControlBarItems ?? []) - ]; + List generateControlBar(TUIChatSeparateViewModel model, TUITheme theme) { + final List itemsList = [...defaultControlBarItems, ...(widget.chatConfig.additionalDesktopControlBarItems ?? [])]; return generateBarIcons(itemsList, theme); } @@ -948,29 +819,22 @@ class _TIMUIKitTextFieldLayoutWideState final type = mimeType[0]; final blobUrl = html.Url.createObjectUrl(file); if (type == 'image') { - _sendImageWithConfirmation( - filePath: blobUrl, - fileName: file.name, - fileSize: const Size(500, 500)); + _sendImageWithConfirmation(filePath: blobUrl, fileName: file.name, fileSize: const Size(500, 500)); } } Future _handleKeyEvent(RawKeyEvent event) async { if (PlatformUtils().isDesktop && - ((event.isKeyPressed(LogicalKeyboardKey.controlLeft) && - event.logicalKey == LogicalKeyboardKey.keyV) || - (event.isMetaPressed && - event.logicalKey == LogicalKeyboardKey.keyV))) { + ((event.isKeyPressed(LogicalKeyboardKey.controlLeft) && event.logicalKey == LogicalKeyboardKey.keyV) || + (event.isMetaPressed && event.logicalKey == LogicalKeyboardKey.keyV))) { final bytes = await Pasteboard.image; if (bytes != null) { String directory; if (PlatformUtils().isWindows) { - final String documentsDirectoryPath = - "${Platform.environment['USERPROFILE']}"; + final String documentsDirectoryPath = "${Platform.environment['USERPROFILE']}"; PackageInfo packageInfo = await PackageInfo.fromPlatform(); String pkgName = packageInfo.packageName; - directory = p.join(documentsDirectoryPath, "Documents", - ".TencentCloudChat", pkgName, "screenshots"); + directory = p.join(documentsDirectoryPath, "Documents", ".TencentCloudChat", pkgName, "screenshots"); } else { final dic = await getApplicationSupportDirectory(); directory = dic.path; @@ -978,8 +842,7 @@ class _TIMUIKitTextFieldLayoutWideState const uuid = Uuid(); final fileName = 'paste_image_${uuid.v4()}.png'; final scDirectory = Directory(directory); - final filePath = - '${scDirectory.path}${PlatformUtils().isWindows ? "\\" : "/"}$fileName'; + final filePath = '${scDirectory.path}${PlatformUtils().isWindows ? "\\" : "/"}$fileName'; final file = File(filePath); if (!await scDirectory.exists()) { await scDirectory.create(recursive: true); @@ -1020,14 +883,10 @@ class _TIMUIKitTextFieldLayoutWideState child: Column( children: [ _buildRepliedMessage(widget.repliedMessage), - SizedBox( - height: 1, - child: Container( - color: theme.weakDividerColor ?? Colors.black12)), + SizedBox(height: 1, child: Container(color: theme.weakDividerColor ?? Colors.black12)), if (widget.forbiddenText == null) Container( - padding: - const EdgeInsets.symmetric(vertical: 4, horizontal: 12), + padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 12), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: generateControlBar(widget.model, theme), @@ -1042,8 +901,7 @@ class _TIMUIKitTextFieldLayoutWideState Expanded( child: Container( height: 35, - color: widget.backgroundColor ?? - theme.desktopChatMessageInputBgColor, + color: widget.backgroundColor ?? theme.desktopChatMessageInputBgColor, alignment: Alignment.center, child: Text( TIM_t(widget.forbiddenText!), @@ -1060,10 +918,8 @@ class _TIMUIKitTextFieldLayoutWideState child: ExtendedTextField( scrollController: _scrollController, autofocus: true, - maxLines: - widget.chatConfig.desktopMessageInputFieldLines, - minLines: - widget.chatConfig.desktopMessageInputFieldLines, + maxLines: widget.chatConfig.desktopMessageInputFieldLines, + minLines: widget.chatConfig.desktopMessageInputFieldLines, focusNode: widget.focusNode, onChanged: debounceFunc, keyboardType: TextInputType.multiline, @@ -1078,9 +934,7 @@ class _TIMUIKitTextFieldLayoutWideState hintStyle: const TextStyle( color: Color(0xffAEA4A3), ), - fillColor: widget.backgroundColor ?? - theme.desktopChatMessageInputBgColor ?? - hexToColor("fafafa"), + fillColor: widget.backgroundColor ?? theme.desktopChatMessageInputBgColor ?? hexToColor("fafafa"), filled: true, isDense: true, hintText: widget.hintText ?? '', @@ -1089,21 +943,9 @@ class _TIMUIKitTextFieldLayoutWideState specialTextSpanBuilder: PlatformUtils().isWeb ? null : DefaultSpecialTextSpanBuilder( - isUseQQPackage: (widget - .model - .chatConfig - .stickerPanelConfig - ?.useTencentCloudChatStickerPackage ?? - true) || - widget.isUseDefaultEmoji, - isUseTencentCloudChatPackage: widget - .model - .chatConfig - .stickerPanelConfig - ?.useTencentCloudChatStickerPackage ?? - true, - customEmojiStickerList: - widget.customEmojiStickerList, + isUseQQPackage: (widget.model.chatConfig.stickerPanelConfig?.useTencentCloudChatStickerPackage ?? true) || widget.isUseDefaultEmoji, + isUseTencentCloudChatPackage: widget.model.chatConfig.stickerPanelConfig?.useTencentCloudChatStickerPackage ?? true, + customEmojiStickerList: widget.customEmojiStickerList, showAtBackground: true, )), ), diff --git a/pubspec.lock b/pubspec.lock index 40c4da0..9f072b5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -357,18 +357,18 @@ packages: dependency: "direct main" description: name: extended_image - sha256: d1b122d6f5cf5596ea61d703d116d89e2ece7e324db414cfeed12967b72b7aef + sha256: d7f091d068fcac7246c4b22a84b8dac59a62e04d29a5c172710c696e67a22f94 url: "https://pub.dev" source: hosted - version: "8.1.0" + version: "8.2.0" extended_image_library: dependency: transitive description: name: extended_image_library - sha256: "8bf87c0b14dcb59200c923a9a3952304e4732a0901e40811428834ef39018ee1" + sha256: "9b55fc5ebc65fad984de66b8f177a1bef2a84d79203c9c213f75ff83c2c29edd" url: "https://pub.dev" source: hosted - version: "3.6.0" + version: "4.0.1" extended_text: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 5fadd1a..b81e686 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: tencent_cloud_chat_uikit description: A powerful chat UI component library and business logic for Tencent Cloud Chat, creating seamless in-app chat modules for delightful user experiences. -version: 2.4.0 +version: 2.4.1 homepage: https://trtc.io/products/chat?utm_source=gfs&utm_medium=link&utm_campaign=%E6%B8%A0%E9%81%93&_channel_track_key=k6WgfCKn repository: https://github.com/TencentCloud/chat-uikit-flutter documentation: https://comm.qq.com/im/doc/flutter/en/TUIKit/readme.html @@ -44,7 +44,7 @@ dependencies: wechat_assets_picker: ^8.9.0-dev.1 wechat_camera_picker: ^4.2.0-dev.2 flutter_easyrefresh: ^2.2.1 - extended_image: ^8.1.0 + extended_image: ^8.2.0 extended_text_field: ^13.0.0 extended_text: ^12.0.0 package_info_plus: ^4.0.1