feat: Upgrade to 2.1.1 pre-release
This commit is contained in:
parent
be65bea65e
commit
2f001240cd
|
|
@ -1139,7 +1139,7 @@ packages:
|
||||||
path: ".."
|
path: ".."
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "2.1.0+1"
|
version: "2.1.0+2"
|
||||||
tencent_cloud_uikit_core:
|
tencent_cloud_uikit_core:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 8.9 KiB |
|
|
@ -1,5 +1,7 @@
|
||||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g opacity="0.795169">
|
||||||
<circle cx="8" cy="8" r="7.5" stroke="#232832"/>
|
<circle cx="8" cy="8" r="7.5" stroke="#232832"/>
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M5 5C5.55228 5 6 5.44772 6 6C6 6.55228 5.55228 7 5 7C4.44772 7 4 6.55228 4 6C4 5.44772 4.44772 5 5 5Z" fill="#232832"/>
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M5 5C5.55228 5 6 5.44772 6 6C6 6.55228 5.55228 7 5 7C4.44772 7 4 6.55228 4 6C4 5.44772 4.44772 5 5 5Z" fill="#232832"/>
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M11 5C11.5523 5 12 5.44772 12 6C12 6.55228 11.5523 7 11 7C10.4477 7 10 6.55228 10 6C10 5.44772 10.4477 5 11 5Z" fill="#232832"/>
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M11 5C11.5523 5 12 5.44772 12 6C12 6.55228 11.5523 7 11 7C10.4477 7 10 6.55228 10 6C10 5.44772 10.4477 5 11 5Z" fill="#232832"/>
|
||||||
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 499 B After Width: | Height: | Size: 559 B |
|
|
@ -20,6 +20,7 @@ import 'package:tencent_cloud_chat_uikit/data_services/message/message_services.
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/constants/history_message_constant.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/constants/history_message_constant.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/platform.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/platform.dart';
|
||||||
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/tim_uikit_cloud_custom_data.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
enum LoadDirection { previous, latest }
|
enum LoadDirection { previous, latest }
|
||||||
|
|
@ -53,7 +54,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier {
|
||||||
bool showC2cMessageEditStatus = true;
|
bool showC2cMessageEditStatus = true;
|
||||||
TIMUIKitChatConfig chatConfig = const TIMUIKitChatConfig();
|
TIMUIKitChatConfig chatConfig = const TIMUIKitChatConfig();
|
||||||
ValueChanged<String>? setInputField;
|
ValueChanged<String>? setInputField;
|
||||||
String Function(V2TimMessage message)? abstractMessageBuilder;
|
String? Function(V2TimMessage message)? abstractMessageBuilder;
|
||||||
Function(String userID, TapDownDetails tapDetails)? onTapAvatar;
|
Function(String userID, TapDownDetails tapDetails)? onTapAvatar;
|
||||||
V2TimGroupMemberFullInfo? _currentChatUserInfo;
|
V2TimGroupMemberFullInfo? _currentChatUserInfo;
|
||||||
V2TimGroupInfo? _groupInfo;
|
V2TimGroupInfo? _groupInfo;
|
||||||
|
|
@ -809,7 +810,25 @@ class TUIChatSeparateViewModel extends ChangeNotifier {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getAbstractMessage(V2TimMessage message) {
|
String _getMessageAbstract(V2TimMessage message){
|
||||||
|
final messageAbstract = RepliedMessageAbstract(
|
||||||
|
summary: TIM_t(_getMessageSummary(message)),
|
||||||
|
elemType: message.elemType,
|
||||||
|
msgID: message.msgID,
|
||||||
|
timestamp: message.timestamp,
|
||||||
|
seq: message.seq
|
||||||
|
);
|
||||||
|
return jsonEncode(messageAbstract.toJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
String _getMessageSummary(V2TimMessage message) {
|
||||||
|
final String? customAbstractMessage = abstractMessageBuilder != null
|
||||||
|
? abstractMessageBuilder!(message)
|
||||||
|
: null;
|
||||||
|
if (customAbstractMessage != null) {
|
||||||
|
return customAbstractMessage;
|
||||||
|
}
|
||||||
|
|
||||||
final elemType = message.elemType;
|
final elemType = message.elemType;
|
||||||
switch (elemType) {
|
switch (elemType) {
|
||||||
case MessageElemType.V2TIM_ELEM_TYPE_FACE:
|
case MessageElemType.V2TIM_ELEM_TYPE_FACE:
|
||||||
|
|
@ -831,7 +850,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier {
|
||||||
case MessageElemType.V2TIM_ELEM_TYPE_SOUND:
|
case MessageElemType.V2TIM_ELEM_TYPE_SOUND:
|
||||||
return "[语音消息]";
|
return "[语音消息]";
|
||||||
case MessageElemType.V2TIM_ELEM_TYPE_TEXT:
|
case MessageElemType.V2TIM_ELEM_TYPE_TEXT:
|
||||||
return "[文本消息]";
|
return message.textElem?.text ?? "[文本消息]";
|
||||||
case MessageElemType.V2TIM_ELEM_TYPE_VIDEO:
|
case MessageElemType.V2TIM_ELEM_TYPE_VIDEO:
|
||||||
return "[视频消息]";
|
return "[视频消息]";
|
||||||
default:
|
default:
|
||||||
|
|
@ -869,7 +888,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier {
|
||||||
final cloudCustomData = {
|
final cloudCustomData = {
|
||||||
"messageReply": {
|
"messageReply": {
|
||||||
"messageID": _repliedMessage!.msgID,
|
"messageID": _repliedMessage!.msgID,
|
||||||
"messageAbstract": _getAbstractMessage(_repliedMessage!),
|
"messageAbstract": _getMessageAbstract(_repliedMessage!),
|
||||||
"messageSender": hasNickName
|
"messageSender": hasNickName
|
||||||
? _repliedMessage!.nickName
|
? _repliedMessage!.nickName
|
||||||
: _repliedMessage?.sender,
|
: _repliedMessage?.sender,
|
||||||
|
|
@ -893,9 +912,10 @@ class TUIChatSeparateViewModel extends ChangeNotifier {
|
||||||
];
|
];
|
||||||
globalModel.setMessageList(conversationID, currentHistoryMsgList);
|
globalModel.setMessageList(conversationID, currentHistoryMsgList);
|
||||||
|
|
||||||
final sendMsgRes = await _messageService.sendReplyMessage(
|
_repliedMessage = null;
|
||||||
|
final sendMsgRes = await _messageService.sendMessage(
|
||||||
|
cloudCustomData: json.encode(cloudCustomData),
|
||||||
id: textMessageInfo.id as String,
|
id: textMessageInfo.id as String,
|
||||||
replyMessage: _repliedMessage!,
|
|
||||||
offlinePushInfo: tools.buildMessagePushInfo(
|
offlinePushInfo: tools.buildMessagePushInfo(
|
||||||
messageInfoWithSender, convID, convType),
|
messageInfoWithSender, convID, convType),
|
||||||
needReadReceipt: chatConfig.isShowGroupReadingStatus &&
|
needReadReceipt: chatConfig.isShowGroupReadingStatus &&
|
||||||
|
|
@ -908,7 +928,6 @@ class TUIChatSeparateViewModel extends ChangeNotifier {
|
||||||
.contains(oldGroupType))),
|
.contains(oldGroupType))),
|
||||||
groupID: groupID,
|
groupID: groupID,
|
||||||
receiver: receiver);
|
receiver: receiver);
|
||||||
_repliedMessage = null;
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
globalModel.updateMessage(sendMsgRes, convID,
|
globalModel.updateMessage(sendMsgRes, convID,
|
||||||
messageInfoWithSender.id ?? "", convType, groupType, setInputField);
|
messageInfoWithSender.id ?? "", convType, groupType, setInputField);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_self_info_view_model.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:tencent_im_base/tencent_im_base.dart';
|
import 'package:tencent_im_base/tencent_im_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/conversation_life_cycle.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/conversation_life_cycle.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_chat_global_model.dart';
|
||||||
|
|
@ -42,6 +43,7 @@ class TUIConversationViewModel extends ChangeNotifier {
|
||||||
late V2TimConversationListener _conversationListener;
|
late V2TimConversationListener _conversationListener;
|
||||||
List<V2TimConversation?> _conversationList = [];
|
List<V2TimConversation?> _conversationList = [];
|
||||||
static V2TimConversation? _selectedConversation;
|
static V2TimConversation? _selectedConversation;
|
||||||
|
Map<String, String> webDraftMap = {};
|
||||||
|
|
||||||
bool _haveMoreData = true;
|
bool _haveMoreData = true;
|
||||||
int _totalUnReadCount = 0;
|
int _totalUnReadCount = 0;
|
||||||
|
|
@ -66,8 +68,7 @@ class TUIConversationViewModel extends ChangeNotifier {
|
||||||
_conversationList.removeWhere((element) => element?.isPinned == true);
|
_conversationList.removeWhere((element) => element?.isPinned == true);
|
||||||
_conversationList = [...pinnedConversation, ..._conversationList];
|
_conversationList = [...pinnedConversation, ..._conversationList];
|
||||||
// ignore: empty_catches
|
// ignore: empty_catches
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
_conversationList.sort((a, b) => b!.orderkey!.compareTo(a!.orderkey!));
|
_conversationList.sort((a, b) => b!.orderkey!.compareTo(a!.orderkey!));
|
||||||
}
|
}
|
||||||
|
|
@ -259,11 +260,47 @@ class TUIConversationViewModel extends ChangeNotifier {
|
||||||
listener: _conversationListener);
|
listener: _conversationListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<V2TimCallback> setConversationDraft(
|
Future<V2TimCallback> setConversationDraft({
|
||||||
{required String conversationID, String? draftText}) async {
|
required String conversationID,
|
||||||
|
String? draftText,
|
||||||
|
bool isTopic = false,
|
||||||
|
String? groupID,
|
||||||
|
bool isAllowWeb = true,
|
||||||
|
}) async {
|
||||||
|
assert(!isTopic || (groupID != null && groupID.isNotEmpty),
|
||||||
|
"When 'isTopic' is true, 'groupID' must not be null or empty.");
|
||||||
|
if (PlatformUtils().isWeb && isAllowWeb) {
|
||||||
|
webDraftMap[conversationID] = draftText ?? "";
|
||||||
|
return V2TimCallback(code: 0, desc: "");
|
||||||
|
} else {
|
||||||
|
if (isTopic) {
|
||||||
|
final topicInfoList = await TencentImSDKPlugin.v2TIMManager
|
||||||
|
.getGroupManager()
|
||||||
|
.getTopicInfoList(groupID: groupID!, topicIDList: [conversationID]);
|
||||||
|
final topicInfo = topicInfoList.data?.first.topicInfo;
|
||||||
|
topicInfo?.draftText = draftText;
|
||||||
|
final res = await TencentImSDKPlugin.v2TIMManager
|
||||||
|
.getGroupManager()
|
||||||
|
.setTopicInfo(groupID: groupID, topicInfo: topicInfo!);
|
||||||
|
return res;
|
||||||
|
} else {
|
||||||
return _conversationService.setConversationDraft(
|
return _conversationService.setConversationDraft(
|
||||||
conversationID: conversationID, draftText: draftText);
|
conversationID: conversationID, draftText: draftText);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clearWebDraft({
|
||||||
|
required String conversationID,
|
||||||
|
}) {
|
||||||
|
webDraftMap[conversationID] = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
String? getWebDraft({
|
||||||
|
required String conversationID,
|
||||||
|
}) {
|
||||||
|
return TencentUtils.checkString(webDraftMap[conversationID]);
|
||||||
|
}
|
||||||
|
|
||||||
clearData() {
|
clearData() {
|
||||||
_conversationList = [];
|
_conversationList = [];
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:tencent_im_base/tencent_im_base.dart';
|
import 'package:tencent_im_base/tencent_im_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/core/tim_uikit_config.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/core/tim_uikit_config.dart';
|
||||||
|
|
||||||
|
|
@ -92,4 +93,6 @@ abstract class CoreServices {
|
||||||
setDarkTheme();
|
setDarkTheme();
|
||||||
|
|
||||||
setLightTheme();
|
setLightTheme();
|
||||||
|
|
||||||
|
setDeviceType(DeviceType deviceType);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_setting_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_setting_model.dart';
|
||||||
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:tencent_im_base/tencent_im_base.dart';
|
import 'package:tencent_im_base/tencent_im_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/listener_model/tui_group_listener_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/listener_model/tui_group_listener_model.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_chat_global_model.dart';
|
||||||
|
|
@ -74,7 +75,6 @@ class CoreServicesImpl implements CoreServices {
|
||||||
@override
|
@override
|
||||||
Future<bool?> init(
|
Future<bool?> init(
|
||||||
{
|
{
|
||||||
|
|
||||||
/// Callback from TUIKit invoke, includes IM SDK API error, notify information, Flutter error.
|
/// Callback from TUIKit invoke, includes IM SDK API error, notify information, Flutter error.
|
||||||
ValueChanged<TIMCallback>? onTUIKitCallbackListener,
|
ValueChanged<TIMCallback>? onTUIKitCallbackListener,
|
||||||
required int sdkAppID,
|
required int sdkAppID,
|
||||||
|
|
@ -83,7 +83,14 @@ class CoreServicesImpl implements CoreServices {
|
||||||
LanguageEnum? language,
|
LanguageEnum? language,
|
||||||
String? extraLanguage,
|
String? extraLanguage,
|
||||||
TIMUIKitConfig? config,
|
TIMUIKitConfig? config,
|
||||||
|
|
||||||
|
/// Specify the current device platform, mobile or desktop, based on your needs.
|
||||||
|
/// TUIKit will automatically determine the platform if no specification is provided. DeviceType? platform,
|
||||||
|
DeviceType? platform,
|
||||||
VoidCallback? onWebLoginSuccess}) async {
|
VoidCallback? onWebLoginSuccess}) async {
|
||||||
|
if (platform != null) {
|
||||||
|
TUIKitScreenUtils.deviceType = platform;
|
||||||
|
}
|
||||||
addIdentifier();
|
addIdentifier();
|
||||||
if (extraLanguage != null) {
|
if (extraLanguage != null) {
|
||||||
Future.delayed(const Duration(milliseconds: 1), () {
|
Future.delayed(const Duration(milliseconds: 1), () {
|
||||||
|
|
@ -247,8 +254,7 @@ class CoreServicesImpl implements CoreServices {
|
||||||
|
|
||||||
tuiFriendShipViewModel.userStatusList = currentUserStatusList;
|
tuiFriendShipViewModel.userStatusList = currentUserStatusList;
|
||||||
// ignore: empty_catches
|
// ignore: empty_catches
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -398,4 +404,9 @@ class CoreServicesImpl implements CoreServices {
|
||||||
.doBackground(unreadCount: totalCount ?? 0);
|
.doBackground(unreadCount: totalCount ?? 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
setDeviceType(DeviceType deviceType) {
|
||||||
|
TUIKitScreenUtils.deviceType = deviceType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,8 +138,8 @@ class TIMUIKitChatController {
|
||||||
assert((groupID == null) != (userID == null));
|
assert((groupID == null) != (userID == null));
|
||||||
assert(groupID != null || convType != ConvType.group);
|
assert(groupID != null || convType != ConvType.group);
|
||||||
assert(userID != null || convType != ConvType.c2c);
|
assert(userID != null || convType != ConvType.c2c);
|
||||||
if (isNavigateToMessageListBottom) {
|
if (isNavigateToMessageListBottom && scrollController != null) {
|
||||||
scrollController?.animateTo(
|
scrollController!.animateTo(
|
||||||
scrollController!.position.minScrollExtent,
|
scrollController!.position.minScrollExtent,
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
curve: Curves.ease,
|
curve: Curves.ease,
|
||||||
|
|
@ -159,7 +159,7 @@ class TIMUIKitChatController {
|
||||||
offlinePushInfo: offlinePushInfo);
|
offlinePushInfo: offlinePushInfo);
|
||||||
} else if (model != null) {
|
} else if (model != null) {
|
||||||
/// Sends a message to the current conversation specified on `TIMUIKitChat`. 发送到 `TIMUIKitChat` 中指定的当前对话。
|
/// Sends a message to the current conversation specified on `TIMUIKitChat`. 发送到 `TIMUIKitChat` 中指定的当前对话。
|
||||||
if (isNavigateToMessageListBottom) {
|
if (isNavigateToMessageListBottom && scrollController != null) {
|
||||||
scrollController?.animateTo(
|
scrollController?.animateTo(
|
||||||
scrollController!.position.minScrollExtent,
|
scrollController!.position.minScrollExtent,
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,9 @@ class TUIKitScreenUtils {
|
||||||
|
|
||||||
final diagonalInInches =
|
final diagonalInInches =
|
||||||
sqrt(pow(screenWidth, 2) + pow(screenHeight, 2)) / 96.0;
|
sqrt(pow(screenWidth, 2) + pow(screenHeight, 2)) / 96.0;
|
||||||
|
print("diagonalInInches $diagonalInInches");
|
||||||
|
|
||||||
deviceType = diagonalInInches < 8.0 ? DeviceType.Mobile : DeviceType.Desktop;
|
deviceType = diagonalInInches < 11.0 ? DeviceType.Mobile : DeviceType.Desktop;
|
||||||
return deviceType ?? DeviceType.Mobile;
|
return deviceType ?? DeviceType.Mobile;
|
||||||
}else{
|
}else{
|
||||||
if(context != null){
|
if(context != null){
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import '../TIMUIKitMessageItem/TIMUIKitMessageReaction/tim_uikit_message_reaction_select_emoji.dart';
|
import '../TIMUIKitMessageItem/TIMUIKitMessageReaction/tim_uikit_message_reaction_select_emoji.dart';
|
||||||
|
|
||||||
typedef MessageRowBuilder = Widget? Function(
|
typedef MessageRowBuilder = Widget? Function(
|
||||||
|
|
||||||
/// current message
|
/// current message
|
||||||
V2TimMessage message,
|
V2TimMessage message,
|
||||||
|
|
||||||
|
|
@ -140,8 +141,7 @@ class MessageToolTipItem {
|
||||||
final String iconImageAsset;
|
final String iconImageAsset;
|
||||||
final VoidCallback onClick;
|
final VoidCallback onClick;
|
||||||
|
|
||||||
MessageToolTipItem(
|
MessageToolTipItem({required this.label,
|
||||||
{required this.label,
|
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.iconImageAsset,
|
required this.iconImageAsset,
|
||||||
required this.onClick});
|
required this.onClick});
|
||||||
|
|
@ -177,8 +177,7 @@ class ToolTipsConfig {
|
||||||
List<MessageToolTipItem> Function(
|
List<MessageToolTipItem> Function(
|
||||||
V2TimMessage message, Function() closeTooltip)? additionalMessageToolTips;
|
V2TimMessage message, Function() closeTooltip)? additionalMessageToolTips;
|
||||||
|
|
||||||
ToolTipsConfig(
|
ToolTipsConfig({this.showDeleteMessage = true,
|
||||||
{this.showDeleteMessage = true,
|
|
||||||
this.showMultipleChoiceMessage = true,
|
this.showMultipleChoiceMessage = true,
|
||||||
this.showRecallMessage = true,
|
this.showRecallMessage = true,
|
||||||
this.showReplyMessage = true,
|
this.showReplyMessage = true,
|
||||||
|
|
@ -187,8 +186,7 @@ class ToolTipsConfig {
|
||||||
this.showForwardMessage = true,
|
this.showForwardMessage = true,
|
||||||
this.additionalMessageToolTips,
|
this.additionalMessageToolTips,
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
"Please use `additionalMessageToolTips` instead. You are now only expected to specify the data, rather than providing a whole widget. This makes usage easier, as you no longer need to worry about the UI display.")
|
"Please use `additionalMessageToolTips` instead. You are now only expected to specify the data, rather than providing a whole widget. This makes usage easier, as you no longer need to worry about the UI display.") this.additionalItemBuilder});
|
||||||
this.additionalItemBuilder});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class TIMUIKitHistoryMessageListItem extends StatefulWidget {
|
class TIMUIKitHistoryMessageListItem extends StatefulWidget {
|
||||||
|
|
@ -281,12 +279,10 @@ class TIMUIKitHistoryMessageListItem extends StatefulWidget {
|
||||||
|
|
||||||
final List customEmojiStickerList;
|
final List customEmojiStickerList;
|
||||||
|
|
||||||
const TIMUIKitHistoryMessageListItem(
|
const TIMUIKitHistoryMessageListItem({Key? key,
|
||||||
{Key? key,
|
|
||||||
required this.message,
|
required this.message,
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
"Nickname will not show in one-to-one chat, if you tend to control it in group chat, please use `isShowSelfNameInGroup` and `isShowOthersNameInGroup` from `config: TIMUIKitChatConfig` instead")
|
"Nickname will not show in one-to-one chat, if you tend to control it in group chat, please use `isShowSelfNameInGroup` and `isShowOthersNameInGroup` from `config: TIMUIKitChatConfig` instead") this.showNickName = false,
|
||||||
this.showNickName = false,
|
|
||||||
this.onScrollToIndex,
|
this.onScrollToIndex,
|
||||||
this.onScrollToIndexBegin,
|
this.onScrollToIndexBegin,
|
||||||
this.onTapForOthersPortrait,
|
this.onTapForOthersPortrait,
|
||||||
|
|
@ -395,8 +391,8 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _messageItemBuilder(
|
Widget _messageItemBuilder(V2TimMessage messageItem,
|
||||||
V2TimMessage messageItem, TUIChatSeparateViewModel model) {
|
TUIChatSeparateViewModel model) {
|
||||||
final msgType = messageItem.elemType;
|
final msgType = messageItem.elemType;
|
||||||
final isShowJump = (model.jumpMsgID == messageItem.msgID) &&
|
final isShowJump = (model.jumpMsgID == messageItem.msgID) &&
|
||||||
(messageItem.msgID?.isNotEmpty ?? false);
|
(messageItem.msgID?.isNotEmpty ?? false);
|
||||||
|
|
@ -649,13 +645,14 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
margin: const EdgeInsets.symmetric(vertical: 20),
|
margin: const EdgeInsets.symmetric(vertical: 20),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Text(
|
child: Text(
|
||||||
TIM_t_para("{{option2}}撤回了一条消息", "$option2撤回了一条消息")(option2: option2),
|
TIM_t_para("{{option2}}撤回了一条消息", "$option2撤回了一条消息")(
|
||||||
|
option2: option2),
|
||||||
style: TextStyle(color: theme.weakTextColor, fontSize: 12),
|
style: TextStyle(color: theme.weakTextColor, fontSize: 12),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _timeDividerBuilder(
|
Widget _timeDividerBuilder(theme, int timeStamp,
|
||||||
theme, int timeStamp, TUIChatSeparateViewModel model) {
|
TUIChatSeparateViewModel model) {
|
||||||
return Container(
|
return Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
margin: const EdgeInsets.symmetric(vertical: 20),
|
margin: const EdgeInsets.symmetric(vertical: 20),
|
||||||
|
|
@ -722,25 +719,31 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isRevocable(int timestamp) =>
|
bool isRevocable(int timestamp) =>
|
||||||
(DateTime.now().millisecondsSinceEpoch / 1000).ceil() - timestamp < 120;
|
(DateTime
|
||||||
|
.now()
|
||||||
|
.millisecondsSinceEpoch / 1000).ceil() - timestamp < 120;
|
||||||
|
|
||||||
_onOpenToolTip(
|
_onOpenToolTip(c,
|
||||||
c,
|
|
||||||
V2TimMessage message,
|
V2TimMessage message,
|
||||||
TUIChatSeparateViewModel model,
|
TUIChatSeparateViewModel model,
|
||||||
TUITheme theme,
|
TUITheme theme,
|
||||||
TapDownDetails? details,
|
TapDownDetails? details,
|
||||||
bool? isFromWideTooltip,
|
bool? isFromWideTooltip,
|
||||||
bool? isShowMoreSticker,
|
bool? isShowMoreSticker,) {
|
||||||
) {
|
|
||||||
if (tooltip != null && tooltip!.isOpen) {
|
if (tooltip != null && tooltip!.isOpen) {
|
||||||
tooltip!.close();
|
tooltip!.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tooltip = null;
|
tooltip = null;
|
||||||
|
|
||||||
final screenHeight = MediaQuery.of(context).size.height;
|
final screenHeight = MediaQuery
|
||||||
final screenWidth = MediaQuery.of(context).size.width;
|
.of(context)
|
||||||
|
.size
|
||||||
|
.height;
|
||||||
|
final screenWidth = MediaQuery
|
||||||
|
.of(context)
|
||||||
|
.size
|
||||||
|
.width;
|
||||||
final isLongMessage =
|
final isLongMessage =
|
||||||
context.size!.height + 350 > screenHeight && PlatformUtils().isMobile;
|
context.size!.height + 350 > screenHeight && PlatformUtils().isMobile;
|
||||||
final isDesktopScreen =
|
final isDesktopScreen =
|
||||||
|
|
@ -750,15 +753,24 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
final isSelf = message.isSelf ?? true;
|
final isSelf = message.isSelf ?? true;
|
||||||
|
|
||||||
final targetWidth =
|
final targetWidth =
|
||||||
min(MediaQuery.of(context).size.width * 0.84, 350).toDouble();
|
min(MediaQuery
|
||||||
|
.of(context)
|
||||||
|
.size
|
||||||
|
.width * 0.84, 350).toDouble();
|
||||||
final double dx = !isSelf
|
final double dx = !isSelf
|
||||||
? min(tapDetails?.globalPosition.dx ?? targetWidth,
|
? min(tapDetails?.globalPosition.dx ?? targetWidth,
|
||||||
screenWidth - targetWidth)
|
screenWidth - targetWidth)
|
||||||
: max(tapDetails?.globalPosition.dx ?? targetWidth, targetWidth)
|
: max(tapDetails?.globalPosition.dx ?? targetWidth, targetWidth)
|
||||||
.toDouble();
|
.toDouble();
|
||||||
final double dy = min(
|
final double dy = min(
|
||||||
tapDetails?.globalPosition.dy ?? MediaQuery.of(context).size.height,
|
tapDetails?.globalPosition.dy ?? MediaQuery
|
||||||
MediaQuery.of(context).size.height - 320)
|
.of(context)
|
||||||
|
.size
|
||||||
|
.height,
|
||||||
|
MediaQuery
|
||||||
|
.of(context)
|
||||||
|
.size
|
||||||
|
.height - 320)
|
||||||
.toDouble();
|
.toDouble();
|
||||||
final finalTapDetail = tapDetails != null
|
final finalTapDetail = tapDetails != null
|
||||||
? TapDownDetails(
|
? TapDownDetails(
|
||||||
|
|
@ -792,8 +804,7 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initTools(
|
initTools({BuildContext? context,
|
||||||
{BuildContext? context,
|
|
||||||
bool isLongMessage = false,
|
bool isLongMessage = false,
|
||||||
required TUIChatSeparateViewModel model,
|
required TUIChatSeparateViewModel model,
|
||||||
TUITheme? theme,
|
TUITheme? theme,
|
||||||
|
|
@ -818,7 +829,10 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
RenderBox? box = _key.currentContext?.findRenderObject() as RenderBox?;
|
RenderBox? box = _key.currentContext?.findRenderObject() as RenderBox?;
|
||||||
if (details != null && box != null) {
|
if (details != null && box != null) {
|
||||||
double screenWidth = MediaQuery.of(context).size.width;
|
double screenWidth = MediaQuery
|
||||||
|
.of(context)
|
||||||
|
.size
|
||||||
|
.width;
|
||||||
final mousePosition = details.globalPosition;
|
final mousePosition = details.globalPosition;
|
||||||
hasArrow = isDesktopScreen ? false : true;
|
hasArrow = isDesktopScreen ? false : true;
|
||||||
arrowTipDistance = 0;
|
arrowTipDistance = 0;
|
||||||
|
|
@ -832,8 +846,14 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (box != null) {
|
if (box != null) {
|
||||||
double screenWidth = MediaQuery.of(context).size.width;
|
double screenWidth = MediaQuery
|
||||||
double viewInsetsBottom = MediaQuery.of(context).viewInsets.bottom;
|
.of(context)
|
||||||
|
.size
|
||||||
|
.width;
|
||||||
|
double viewInsetsBottom = MediaQuery
|
||||||
|
.of(context)
|
||||||
|
.viewInsets
|
||||||
|
.bottom;
|
||||||
Offset offset = box.localToGlobal(Offset.zero);
|
Offset offset = box.localToGlobal(Offset.zero);
|
||||||
double boxWidth = box.size.width;
|
double boxWidth = box.size.width;
|
||||||
if (isSelf) {
|
if (isSelf) {
|
||||||
|
|
@ -966,7 +986,13 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
),
|
),
|
||||||
onClick: (details) {
|
onClick: (details) {
|
||||||
_onOpenToolTip(
|
_onOpenToolTip(
|
||||||
context, widget.message, model, theme, details, true, true);
|
context,
|
||||||
|
widget.message,
|
||||||
|
model,
|
||||||
|
theme,
|
||||||
|
details,
|
||||||
|
true,
|
||||||
|
true);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (widget.toolTipsConfig?.showReplyMessage ?? true)
|
if (widget.toolTipsConfig?.showReplyMessage ?? true)
|
||||||
|
|
@ -1009,12 +1035,19 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
context: context,
|
context: context,
|
||||||
title: TIM_t("转发"),
|
title: TIM_t("转发"),
|
||||||
submitWidget: Text(TIM_t("发送")),
|
submitWidget: Text(TIM_t("发送")),
|
||||||
width: MediaQuery.of(context).size.width * 0.5,
|
width: MediaQuery
|
||||||
height: MediaQuery.of(context).size.height * 0.8,
|
.of(context)
|
||||||
|
.size
|
||||||
|
.width * 0.5,
|
||||||
|
height: MediaQuery
|
||||||
|
.of(context)
|
||||||
|
.size
|
||||||
|
.height * 0.8,
|
||||||
onSubmit: () {
|
onSubmit: () {
|
||||||
forwardMessageScreenKey.currentState?.handleForwardMessage();
|
forwardMessageScreenKey.currentState?.handleForwardMessage();
|
||||||
},
|
},
|
||||||
child: (onClose) => Container(
|
child: (onClose) =>
|
||||||
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||||
child: ForwardMessageScreen(
|
child: ForwardMessageScreen(
|
||||||
conversationType: ConvType.c2c,
|
conversationType: ConvType.c2c,
|
||||||
|
|
@ -1035,7 +1068,13 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
),
|
),
|
||||||
onClick: (details) {
|
onClick: (details) {
|
||||||
_onOpenToolTip(
|
_onOpenToolTip(
|
||||||
context, widget.message, model, theme, details, true, false);
|
context,
|
||||||
|
widget.message,
|
||||||
|
model,
|
||||||
|
theme,
|
||||||
|
details,
|
||||||
|
true,
|
||||||
|
false);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
...?model.chatConfig.additionalDesktopMessageHoverBarItem
|
...?model.chatConfig.additionalDesktopMessageHoverBarItem
|
||||||
|
|
@ -1053,8 +1092,7 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
context);
|
context);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget renderHoverTipAndReadStatus(
|
Widget renderHoverTipAndReadStatus(TUIChatSeparateViewModel model,
|
||||||
TUIChatSeparateViewModel model,
|
|
||||||
bool isSelf,
|
bool isSelf,
|
||||||
V2TimMessage message,
|
V2TimMessage message,
|
||||||
bool isPeerRead,
|
bool isPeerRead,
|
||||||
|
|
@ -1082,7 +1120,8 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 4),
|
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: wideHoverTipList
|
children: wideHoverTipList
|
||||||
.map((e) => Tooltip(
|
.map((e) =>
|
||||||
|
Tooltip(
|
||||||
message: e.name,
|
message: e.name,
|
||||||
preferBelow: false,
|
preferBelow: false,
|
||||||
textStyle: TextStyle(fontSize: 12, color: theme.white),
|
textStyle: TextStyle(fontSize: 12, color: theme.white),
|
||||||
|
|
@ -1110,7 +1149,9 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
.toList(),
|
.toList(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!isDesktopScreen || !isShowWideToolTip)
|
if (!isDesktopScreen ||
|
||||||
|
(model.chatConfig.isUseMessageHoverBarOnDesktop &&
|
||||||
|
!isShowWideToolTip))
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 24,
|
height: 24,
|
||||||
),
|
),
|
||||||
|
|
@ -1233,7 +1274,8 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
}
|
}
|
||||||
|
|
||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (context, constraints) => Container(
|
builder: (context, constraints) =>
|
||||||
|
Container(
|
||||||
margin: widget.padding ?? const EdgeInsets.only(bottom: 20),
|
margin: widget.padding ?? const EdgeInsets.only(bottom: 20),
|
||||||
child: Row(
|
child: Row(
|
||||||
key: _key,
|
key: _key,
|
||||||
|
|
@ -1245,7 +1287,8 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
margin:
|
margin:
|
||||||
EdgeInsets.only(right: 12, top: 10, left: isSelf ? 16 : 0),
|
EdgeInsets.only(right: 12, top: 10, left: isSelf ? 16 : 0),
|
||||||
child: CheckBoxButton(
|
child: CheckBoxButton(
|
||||||
isChecked: model.multiSelectedMessageList.contains(message),
|
isChecked: model.multiSelectedMessageList.contains(
|
||||||
|
message),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
model.addToMultiSelectedMessageList(message);
|
model.addToMultiSelectedMessageList(message);
|
||||||
|
|
@ -1258,14 +1301,16 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
Expanded(
|
Expanded(
|
||||||
child: MouseRegion(
|
child: MouseRegion(
|
||||||
onEnter: (_) {
|
onEnter: (_) {
|
||||||
if (isDesktopScreen) {
|
if (isDesktopScreen &&
|
||||||
|
model.chatConfig.isUseMessageHoverBarOnDesktop) {
|
||||||
setState(() {
|
setState(() {
|
||||||
isShowWideToolTip = true;
|
isShowWideToolTip = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onExit: (_) {
|
onExit: (_) {
|
||||||
if (isDesktopScreen) {
|
if (isDesktopScreen &&
|
||||||
|
model.chatConfig.isUseMessageHoverBarOnDesktop) {
|
||||||
setState(() {
|
setState(() {
|
||||||
isShowWideToolTip = false;
|
isShowWideToolTip = false;
|
||||||
});
|
});
|
||||||
|
|
@ -1283,6 +1328,8 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
} else {
|
} else {
|
||||||
model.addToMultiSelectedMessageList(message);
|
model.addToMultiSelectedMessageList(message);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|
@ -1292,11 +1339,12 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
: MainAxisAlignment.start,
|
: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (!isSelf && widget.showAvatar)
|
if (!isSelf && widget.showAvatar)
|
||||||
InkWell(
|
GestureDetector(
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
if (widget.onLongPressForOthersHeadPortrait !=
|
if (widget.onLongPressForOthersHeadPortrait !=
|
||||||
null) {}
|
null) {}
|
||||||
if (model.chatConfig.isAllowLongPressAvatarToAt) {
|
if (model.chatConfig
|
||||||
|
.isAllowLongPressAvatarToAt) {
|
||||||
widget.onLongPressForOthersHeadPortrait!(
|
widget.onLongPressForOthersHeadPortrait!(
|
||||||
message.sender, message.nickName);
|
message.sender, message.nickName);
|
||||||
}
|
}
|
||||||
|
|
@ -1386,7 +1434,8 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
margin: const EdgeInsets.only(bottom: 4),
|
margin: const EdgeInsets.only(bottom: 4),
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxWidth: MediaQuery.of(context)
|
maxWidth: MediaQuery
|
||||||
|
.of(context)
|
||||||
.size
|
.size
|
||||||
.width /
|
.width /
|
||||||
1.7),
|
1.7),
|
||||||
|
|
@ -1430,7 +1479,8 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
message.status,
|
message.status,
|
||||||
model)),
|
model)),
|
||||||
onSecondaryTapDown: (details) {
|
onSecondaryTapDown: (details) {
|
||||||
if (widget.onLongPress != null) {
|
if (widget.onLongPress !=
|
||||||
|
null) {
|
||||||
widget.onLongPress!(
|
widget.onLongPress!(
|
||||||
context, message);
|
context, message);
|
||||||
return;
|
return;
|
||||||
|
|
@ -1449,13 +1499,14 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
if (widget.onLongPress != null) {
|
if (widget.onLongPress !=
|
||||||
|
null) {
|
||||||
widget.onLongPress!(
|
widget.onLongPress!(
|
||||||
context, message);
|
context, message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (widget.allowLongPress &&
|
if (widget.allowLongPress &&
|
||||||
PlatformUtils().isMobile) {
|
!isDesktopScreen) {
|
||||||
_onOpenToolTip(
|
_onOpenToolTip(
|
||||||
context,
|
context,
|
||||||
message,
|
message,
|
||||||
|
|
@ -1476,7 +1527,8 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
widget.isUseDefaultEmoji,
|
widget.isUseDefaultEmoji,
|
||||||
customEmojiStickerList:
|
customEmojiStickerList:
|
||||||
widget.customEmojiStickerList,
|
widget.customEmojiStickerList,
|
||||||
isFromSelf: message.isSelf ?? true,
|
isFromSelf: message.isSelf ??
|
||||||
|
true,
|
||||||
isShowJump: false,
|
isShowJump: false,
|
||||||
clearJump: () {},
|
clearJump: () {},
|
||||||
chatModel: model)
|
chatModel: model)
|
||||||
|
|
@ -1486,7 +1538,8 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
),
|
),
|
||||||
if (!isSelf &&
|
if (!isSelf &&
|
||||||
message.elemType ==
|
message.elemType ==
|
||||||
MessageElemType.V2TIM_ELEM_TYPE_SOUND &&
|
MessageElemType
|
||||||
|
.V2TIM_ELEM_TYPE_SOUND &&
|
||||||
message.localCustomInt != null &&
|
message.localCustomInt != null &&
|
||||||
message.localCustomInt !=
|
message.localCustomInt !=
|
||||||
HistoryMessageDartConstant.read)
|
HistoryMessageDartConstant.read)
|
||||||
|
|
@ -1494,7 +1547,8 @@ class _TIMUIKItHistoryMessageListItemState
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 5, bottom: 12),
|
left: 5, bottom: 12),
|
||||||
child: Icon(Icons.circle,
|
child: Icon(Icons.circle,
|
||||||
color: theme.cautionColor, size: 10)),
|
color: theme.cautionColor,
|
||||||
|
size: 10)),
|
||||||
if (!isSelf)
|
if (!isSelf)
|
||||||
renderHoverTipAndReadStatus(
|
renderHoverTipAndReadStatus(
|
||||||
model,
|
model,
|
||||||
|
|
|
||||||
|
|
@ -351,7 +351,9 @@ class TIMUIKitMessageTooltipState
|
||||||
children: [
|
children: [
|
||||||
Image.asset(
|
Image.asset(
|
||||||
item.iconImageAsset,
|
item.iconImageAsset,
|
||||||
package: 'tencent_cloud_chat_uikit',
|
package: defaultTipsIds.contains(item.id)
|
||||||
|
? 'tencent_cloud_chat_uikit'
|
||||||
|
: null,
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_model_tools.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/common_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/common_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/special_text/DefaultSpecialTextSpanBuilder.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/special_text/DefaultSpecialTextSpanBuilder.dart';
|
||||||
|
|
@ -57,7 +58,7 @@ class TIMUIKitReplyElem extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TIMUIKitReplyElemState extends TIMUIKitState<TIMUIKitReplyElem> {
|
class _TIMUIKitReplyElemState extends TIMUIKitState<TIMUIKitReplyElem> {
|
||||||
MessageRepliedData? repliedMessage;
|
MessageRepliedData? repliedMessage = null;
|
||||||
V2TimMessage? rawMessage;
|
V2TimMessage? rawMessage;
|
||||||
bool isShowJumpState = false;
|
bool isShowJumpState = false;
|
||||||
bool isShining = false;
|
bool isShining = false;
|
||||||
|
|
@ -81,10 +82,32 @@ class _TIMUIKitReplyElemState extends TIMUIKitState<TIMUIKitReplyElem> {
|
||||||
}
|
}
|
||||||
|
|
||||||
_getMessageByMessageID() async {
|
_getMessageByMessageID() async {
|
||||||
final cloudCustomData = _getRepliedMessage();
|
final MessageRepliedData? cloudCustomData = _getRepliedMessage();
|
||||||
if (cloudCustomData != null) {
|
if (cloudCustomData != null) {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
repliedMessage = cloudCustomData;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
final messageID = cloudCustomData.messageID;
|
final messageID = cloudCustomData.messageID;
|
||||||
final message = await widget.chatModel.findMessage(messageID);
|
V2TimMessage? message = await widget.chatModel.findMessage(messageID);
|
||||||
|
if (message == null) {
|
||||||
|
try {
|
||||||
|
final RepliedMessageAbstract repliedMessageAbstract =
|
||||||
|
RepliedMessageAbstract.fromJson(
|
||||||
|
jsonDecode(cloudCustomData.messageAbstract));
|
||||||
|
if (repliedMessageAbstract.isNotEmpty) {
|
||||||
|
message = V2TimMessage(
|
||||||
|
elemType: 0,
|
||||||
|
seq: repliedMessageAbstract.seq,
|
||||||
|
timestamp: repliedMessageAbstract.timestamp,
|
||||||
|
msgID: repliedMessageAbstract.msgID);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
@ -93,36 +116,53 @@ class _TIMUIKitReplyElemState extends TIMUIKitState<TIMUIKitReplyElem> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mounted) {
|
|
||||||
setState(() {
|
|
||||||
repliedMessage = cloudCustomData;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _defaultRawMessageText(String text, TUITheme? theme) {
|
Widget _defaultRawMessageText(String text, TUITheme? theme) {
|
||||||
return Text(text,
|
return Text(text,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: theme?.weakTextColor,
|
color: theme?.weakTextColor,
|
||||||
fontWeight: FontWeight.w400));
|
fontWeight: FontWeight.w400));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_renderMessageSummary(TUITheme? theme) {
|
||||||
|
try {
|
||||||
|
final RepliedMessageAbstract repliedMessageAbstract =
|
||||||
|
RepliedMessageAbstract.fromJson(
|
||||||
|
jsonDecode(repliedMessage?.messageAbstract ?? ""));
|
||||||
|
if (TencentUtils.checkString(repliedMessageAbstract.summary) != null) {
|
||||||
|
return _defaultRawMessageText(repliedMessageAbstract.summary!, theme);
|
||||||
|
}
|
||||||
|
return _defaultRawMessageText(
|
||||||
|
repliedMessage?.messageAbstract ?? TIM_t("[未知消息]"), theme);
|
||||||
|
} catch (e) {
|
||||||
|
return _defaultRawMessageText(
|
||||||
|
repliedMessage?.messageAbstract ?? TIM_t("[未知消息]"), theme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_rawMessageBuilder(V2TimMessage? message, TUITheme? theme) {
|
_rawMessageBuilder(V2TimMessage? message, TUITheme? theme) {
|
||||||
if (repliedMessage == null) {
|
if (repliedMessage == null) {
|
||||||
return const SizedBox(width: 0, height: 12);
|
return const SizedBox(width: 0, height: 12);
|
||||||
}
|
}
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
if (repliedMessage?.messageAbstract != null) {
|
if (repliedMessage?.messageAbstract != null) {
|
||||||
return _defaultRawMessageText(repliedMessage!.messageAbstract, theme);
|
_renderMessageSummary(theme);
|
||||||
}
|
}
|
||||||
return const SizedBox(width: 0, height: 12);
|
return const SizedBox(width: 0, height: 12);
|
||||||
}
|
}
|
||||||
final messageType = message.elemType;
|
final messageType = message.elemType;
|
||||||
final isSelf = message.isSelf ?? true;
|
final isSelf = message.isSelf ?? true;
|
||||||
if (widget.chatModel.abstractMessageBuilder != null) {
|
final customAbstractMessage =
|
||||||
|
widget.chatModel.abstractMessageBuilder != null
|
||||||
|
? widget.chatModel.abstractMessageBuilder!(message)
|
||||||
|
: null;
|
||||||
|
if (customAbstractMessage != null) {
|
||||||
return _defaultRawMessageText(
|
return _defaultRawMessageText(
|
||||||
widget.chatModel.abstractMessageBuilder!(message),
|
customAbstractMessage,
|
||||||
theme,
|
theme,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -173,7 +213,7 @@ class _TIMUIKitReplyElemState extends TIMUIKitState<TIMUIKitReplyElem> {
|
||||||
messageID: message.msgID ?? "",
|
messageID: message.msgID ?? "",
|
||||||
isSelf: isSelf);
|
isSelf: isSelf);
|
||||||
default:
|
default:
|
||||||
return _defaultRawMessageText(TIM_t("[未知消息]"), theme);
|
return _renderMessageSummary(theme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,8 @@ class TIMUIKitInputTextField extends StatefulWidget {
|
||||||
|
|
||||||
final String? groupType;
|
final String? groupType;
|
||||||
|
|
||||||
|
final String? groupID;
|
||||||
|
|
||||||
const TIMUIKitInputTextField(
|
const TIMUIKitInputTextField(
|
||||||
{Key? key,
|
{Key? key,
|
||||||
required this.conversationID,
|
required this.conversationID,
|
||||||
|
|
@ -113,7 +115,8 @@ class TIMUIKitInputTextField extends StatefulWidget {
|
||||||
required this.model,
|
required this.model,
|
||||||
required this.currentConversation,
|
required this.currentConversation,
|
||||||
this.groupType,
|
this.groupType,
|
||||||
this.atMemberPanelScroll})
|
this.atMemberPanelScroll,
|
||||||
|
this.groupID})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -166,21 +169,22 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
return text.replaceAll(RegExp(r'\ufeff'), "");
|
return text.replaceAll(RegExp(r'\ufeff'), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSetDraftText([String? id, ConvType? convType]) async {
|
Future handleSetDraftText([String? id, ConvType? convType]) async {
|
||||||
|
String text = textEditingController.text;
|
||||||
String convID = id ?? widget.conversationID;
|
String convID = id ?? widget.conversationID;
|
||||||
String conversationID = convID.contains("@TOPIC#")
|
final isTopic = convID.contains("@TOPIC#");
|
||||||
|
String conversationID = isTopic
|
||||||
? convID
|
? convID
|
||||||
: ((convType ?? widget.conversationType) == ConvType.c2c
|
: ((convType ?? widget.conversationType) == ConvType.c2c
|
||||||
? "c2c_$convID"
|
? "c2c_$convID"
|
||||||
: "group_$convID");
|
: "group_$convID");
|
||||||
String text = textEditingController.text;
|
String draftText = _filterU200b(text);
|
||||||
String? draftText = _filterU200b(text);
|
return await conversationModel.setConversationDraft(
|
||||||
|
groupID: widget.groupID,
|
||||||
if (draftText.isEmpty) {
|
isTopic: isTopic,
|
||||||
draftText = "";
|
isAllowWeb: widget.model.chatConfig.isUseDraftOnWeb,
|
||||||
}
|
conversationID: conversationID,
|
||||||
await conversationModel.setConversationDraft(
|
draftText: draftText);
|
||||||
conversationID: conversationID, draftText: draftText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
backSpaceText() {
|
backSpaceText() {
|
||||||
|
|
@ -189,11 +193,9 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
|
|
||||||
if (originalText == zeroWidthSpace) {
|
if (originalText == zeroWidthSpace) {
|
||||||
_handleSoftKeyBoardDelete();
|
_handleSoftKeyBoardDelete();
|
||||||
// _addDeleteTag();
|
|
||||||
} else {
|
} else {
|
||||||
text = originalText.characters.skipLast(1);
|
text = originalText.characters.skipLast(1);
|
||||||
textEditingController.text = text;
|
textEditingController.text = text;
|
||||||
// handleSetDraftText();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -202,6 +204,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
lastText = "";
|
lastText = "";
|
||||||
final text = textEditingController.text.trim();
|
final text = textEditingController.text.trim();
|
||||||
final convType = widget.conversationType;
|
final convType = widget.conversationType;
|
||||||
|
conversationModel.clearWebDraft(conversationID: widget.conversationID);
|
||||||
if (text.isNotEmpty && text != zeroWidthSpace) {
|
if (text.isNotEmpty && text != zeroWidthSpace) {
|
||||||
if (widget.model.repliedMessage != null) {
|
if (widget.model.repliedMessage != null) {
|
||||||
MessageUtils.handleMessageError(
|
MessageUtils.handleMessageError(
|
||||||
|
|
@ -259,6 +262,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmitted() async {
|
onSubmitted() async {
|
||||||
|
conversationModel.clearWebDraft(conversationID: widget.conversationID);
|
||||||
lastText = "";
|
lastText = "";
|
||||||
final text = textEditingController.text.trim();
|
final text = textEditingController.text.trim();
|
||||||
final convType = widget.conversationType;
|
final convType = widget.conversationType;
|
||||||
|
|
@ -417,6 +421,22 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
mentionedMembersMap = map;
|
mentionedMembersMap = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateMentionedMap() {
|
||||||
|
Map<String, V2TimGroupMemberFullInfo> map = {};
|
||||||
|
Iterable<Match> matches = atTextReg.allMatches(textEditingController.text);
|
||||||
|
List<String?> parseAtList = [];
|
||||||
|
for (final item in matches) {
|
||||||
|
final str = item.group(0);
|
||||||
|
parseAtList.add(str);
|
||||||
|
}
|
||||||
|
for (String? key in parseAtList) {
|
||||||
|
if (key != null && mentionedMembersMap[key] != null) {
|
||||||
|
map[key] = mentionedMembersMap[key]!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mentionedMembersMap = map;
|
||||||
|
}
|
||||||
|
|
||||||
_handleAtText(String text, TUIChatSeparateViewModel model) async {
|
_handleAtText(String text, TUIChatSeparateViewModel model) async {
|
||||||
final text = textEditingController.text;
|
final text = textEditingController.text;
|
||||||
String? groupID = widget.conversationType == ConvType.group
|
String? groupID = widget.conversationType == ConvType.group
|
||||||
|
|
@ -449,22 +469,11 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
textEditingController.selection =
|
textEditingController.selection =
|
||||||
TextSelection.collapsed(offset: atIndex);
|
TextSelection.collapsed(offset: atIndex);
|
||||||
lastText = newText;
|
lastText = newText;
|
||||||
Map<String, V2TimGroupMemberFullInfo> map = {};
|
updateMentionedMap();
|
||||||
Iterable<Match> matches = atTextReg.allMatches(text);
|
|
||||||
List<String?> parseAtList = [];
|
|
||||||
for (final item in matches) {
|
|
||||||
final str = item.group(0);
|
|
||||||
parseAtList.add(str);
|
|
||||||
}
|
|
||||||
for (String? key in parseAtList) {
|
|
||||||
if (key != null && mentionedMembersMap[key] != null) {
|
|
||||||
map[key] = mentionedMembersMap[key]!;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mentionedMembersMap = map;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateMentionedMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
final int selfRole = widget.model.selfMemberInfo?.role ?? 0;
|
final int selfRole = widget.model.selfMemberInfo?.role ?? 0;
|
||||||
|
|
@ -709,8 +718,8 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
void didUpdateWidget(TIMUIKitInputTextField oldWidget) {
|
void didUpdateWidget(TIMUIKitInputTextField oldWidget) {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
if (widget.conversationID != oldWidget.conversationID) {
|
if (widget.conversationID != oldWidget.conversationID) {
|
||||||
handleSetDraftText(oldWidget.conversationID, oldWidget.conversationType);
|
|
||||||
mentionedMembersMap.clear();
|
mentionedMembersMap.clear();
|
||||||
|
handleSetDraftText(oldWidget.conversationID, oldWidget.conversationType);
|
||||||
if (oldWidget.initText != widget.initText) {
|
if (oldWidget.initText != widget.initText) {
|
||||||
textEditingController.text = widget.initText ?? "";
|
textEditingController.text = widget.initText ?? "";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -309,12 +309,23 @@ class _TIMUIKitTextFieldLayoutNarrowState
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
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 ?? []);
|
||||||
|
}
|
||||||
|
|
||||||
_buildRepliedMessage(V2TimMessage? repliedMessage) {
|
_buildRepliedMessage(V2TimMessage? repliedMessage) {
|
||||||
final haveRepliedMessage = repliedMessage != null;
|
final haveRepliedMessage = repliedMessage != null;
|
||||||
if (haveRepliedMessage) {
|
if (haveRepliedMessage) {
|
||||||
final text =
|
final text =
|
||||||
"${MessageUtils.getDisplayName(widget.model.repliedMessage!)}:${widget.model.abstractMessageBuilder != null ? widget.model.abstractMessageBuilder!(widget.model.repliedMessage!) : MessageUtils.getAbstractMessageAsync(widget.model.repliedMessage!, widget.model.groupMemberList ?? [])}";
|
"${MessageUtils.getDisplayName(
|
||||||
|
widget.model.repliedMessage!)}:${getAbstractMessage(
|
||||||
|
repliedMessage
|
||||||
|
)}";
|
||||||
return Container(
|
return Container(
|
||||||
color: widget.backgroundColor ?? hexToColor("f5f5f6"),
|
color: widget.backgroundColor ?? hexToColor("f5f5f6"),
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
import 'dart:ui' as ui;
|
||||||
import 'package:fc_native_video_thumbnail/fc_native_video_thumbnail.dart';
|
import 'package:fc_native_video_thumbnail/fc_native_video_thumbnail.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
|
|
@ -32,6 +33,7 @@ import 'package:universal_html/html.dart' as html;
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
|
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
|
||||||
// ignore: unnecessary_import
|
// ignore: unnecessary_import
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
@ -262,36 +264,62 @@ 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 ?? []);
|
||||||
|
}
|
||||||
|
|
||||||
_buildRepliedMessage(V2TimMessage? repliedMessage) {
|
_buildRepliedMessage(V2TimMessage? repliedMessage) {
|
||||||
final haveRepliedMessage = repliedMessage != null;
|
final haveRepliedMessage = repliedMessage != null;
|
||||||
if (haveRepliedMessage) {
|
if (haveRepliedMessage) {
|
||||||
final text =
|
|
||||||
"${MessageUtils.getDisplayName(widget.model.repliedMessage!)}:${widget.model.abstractMessageBuilder != null ? widget.model.abstractMessageBuilder!(widget.model.repliedMessage!) : MessageUtils.getAbstractMessageAsync(widget.model.repliedMessage!, widget.model.groupMemberList ?? [])}";
|
|
||||||
return Container(
|
return Container(
|
||||||
color: widget.backgroundColor ?? hexToColor("f5f5f6"),
|
color: widget.backgroundColor ?? hexToColor("f5f5f6"),
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
Text(
|
||||||
|
TIM_t("回复 "),
|
||||||
|
style: TextStyle(
|
||||||
|
color: hexToColor("8f959e"), fontSize: 14),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
MessageUtils.getDisplayName(
|
||||||
|
widget.model.repliedMessage!),
|
||||||
|
softWrap: true,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
color: hexToColor("8f959e"),
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
text,
|
": ${getAbstractMessage(repliedMessage)}",
|
||||||
softWrap: true,
|
maxLines: 1,
|
||||||
maxLines: 3,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(color: hexToColor("8f959e"), fontSize: 14),
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: hexToColor("8f959e"),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 16,
|
width: 8,
|
||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
widget.model.repliedMessage = null;
|
widget.model.repliedMessage = null;
|
||||||
},
|
},
|
||||||
child: Icon(Icons.clear, color: hexToColor("8f959e"), size: 18),
|
child: Icon(Icons.cancel, color: hexToColor("8f959e"), size: 18),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
@ -314,8 +342,9 @@ class _TIMUIKitTextFieldLayoutWideState
|
||||||
entry = null;
|
entry = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
initOffset: offset ??
|
initOffset: offset != null
|
||||||
Offset(MediaQuery.of(context).size.height * 0.5 + 20,
|
? Offset(offset.dx, max(offset.dy, 16))
|
||||||
|
: Offset(MediaQuery.of(context).size.height * 0.5 + 20,
|
||||||
MediaQuery.of(context).size.height * 0.5 - 100),
|
MediaQuery.of(context).size.height * 0.5 - 100),
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|
@ -793,7 +822,7 @@ class _TIMUIKitTextFieldLayoutWideState
|
||||||
onClick: (offset) {
|
onClick: (offset) {
|
||||||
_sendEmoji(offset, widget.theme);
|
_sendEmoji(offset, widget.theme);
|
||||||
},
|
},
|
||||||
svgPath: "images/svg/send_face.svg"),
|
imgPath: "images/svg/send_face.png"),
|
||||||
if (config.showScreenshotButton && PlatformUtils().isDesktop)
|
if (config.showScreenshotButton && PlatformUtils().isDesktop)
|
||||||
DesktopControlBarItem(
|
DesktopControlBarItem(
|
||||||
item: "screenShot",
|
item: "screenShot",
|
||||||
|
|
@ -950,6 +979,7 @@ class _TIMUIKitTextFieldLayoutWideState
|
||||||
color: widget.backgroundColor ?? theme.desktopChatMessageInputBgColor,
|
color: widget.backgroundColor ?? theme.desktopChatMessageInputBgColor,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
_buildRepliedMessage(widget.repliedMessage),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 1,
|
height: 1,
|
||||||
child: Container(
|
child: Container(
|
||||||
|
|
@ -963,7 +993,6 @@ class _TIMUIKitTextFieldLayoutWideState
|
||||||
children: generateControlBar(widget.model, theme),
|
children: generateControlBar(widget.model, theme),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
_buildRepliedMessage(widget.repliedMessage),
|
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 6),
|
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 6),
|
||||||
constraints: const BoxConstraints(minHeight: 50),
|
constraints: const BoxConstraints(minHeight: 50),
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,14 @@ import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/chat_life_cyc
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/listener_model/tui_group_listener_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/listener_model/tui_group_listener_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.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_chat_global_model.dart';
|
||||||
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_conversation_view_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.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/tencent_cloud_chat_uikit.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/constants/history_message_constant.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/constants/history_message_constant.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/controller/tim_uikit_chat_controller.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/controller/tim_uikit_chat_controller.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/frame.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/frame.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/optimize_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/optimize_utils.dart';
|
||||||
|
import 'package:tencent_cloud_chat_uikit/ui/utils/platform.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/at_member_panel.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/at_member_panel.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/tim_uikit_multi_select_panel.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/tim_uikit_multi_select_panel.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/tim_uikit_send_file.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/tim_uikit_send_file.dart';
|
||||||
|
|
@ -108,18 +110,23 @@ class TIMUIKitChat extends StatefulWidget {
|
||||||
final TongueItemBuilder? tongueItemBuilder;
|
final TongueItemBuilder? tongueItemBuilder;
|
||||||
|
|
||||||
/// The `groupAtInfoList` from `V2TimConversation`.
|
/// The `groupAtInfoList` from `V2TimConversation`.
|
||||||
/// This field is not necessary to be provided, when `conversation` is provided, unless you want to cover this field manually.
|
/// This field is not necessary to be provided, when `conversation` is provided,
|
||||||
|
/// unless you want to cover this field manually.
|
||||||
final List<V2TimGroupAtInfo?>? groupAtInfoList;
|
final List<V2TimGroupAtInfo?>? groupAtInfoList;
|
||||||
|
|
||||||
/// The configuration for the whole `TIMUIKitChat` widget.
|
/// The configuration for the whole `TIMUIKitChat` widget.
|
||||||
final TIMUIKitChatConfig? config;
|
final TIMUIKitChatConfig? config;
|
||||||
|
|
||||||
/// The callback for jumping to the page for `TIMUIKitGroupApplicationList` or other pages to deal with enter group application for group administrator manually, in the case of [public group].
|
/// The callback for jumping to the page for `TIMUIKitGroupApplicationList`
|
||||||
|
/// or other pages to deal with enter group application for group administrator manually,
|
||||||
|
/// in the case of [public group].
|
||||||
/// The parameter here is `String groupID`
|
/// The parameter here is `String groupID`
|
||||||
final ValueChanged<String>? onDealWithGroupApplication;
|
final ValueChanged<String>? onDealWithGroupApplication;
|
||||||
|
|
||||||
/// The builder for abstract messages, normally used in replied message and forward message.
|
/// The generator for the abstract summary preview of a message,
|
||||||
final String Function(V2TimMessage message)? abstractMessageBuilder;
|
/// typically used in replied and forwarded messages.
|
||||||
|
/// Returns `null` to use the default message summary.
|
||||||
|
final String? Function(V2TimMessage message)? abstractMessageBuilder;
|
||||||
|
|
||||||
/// The configuration for tool tips panel, long press messages will show this panel.
|
/// The configuration for tool tips panel, long press messages will show this panel.
|
||||||
final ToolTipsConfig? toolTipsConfig;
|
final ToolTipsConfig? toolTipsConfig;
|
||||||
|
|
@ -140,8 +147,7 @@ class TIMUIKitChat extends StatefulWidget {
|
||||||
/// Custom text field
|
/// Custom text field
|
||||||
final Widget Function(BuildContext context)? textFieldBuilder;
|
final Widget Function(BuildContext context)? textFieldBuilder;
|
||||||
|
|
||||||
TIMUIKitChat(
|
TIMUIKitChat({Key? key,
|
||||||
{Key? key,
|
|
||||||
this.groupID,
|
this.groupID,
|
||||||
required this.conversation,
|
required this.conversation,
|
||||||
this.conversationID,
|
this.conversationID,
|
||||||
|
|
@ -150,12 +156,11 @@ class TIMUIKitChat extends StatefulWidget {
|
||||||
this.abstractMessageBuilder,
|
this.abstractMessageBuilder,
|
||||||
this.onTapAvatar,
|
this.onTapAvatar,
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
"Nickname will not show in one-to-one chat, if you tend to control it in group chat, please use `isShowSelfNameInGroup` and `isShowOthersNameInGroup` from `config: TIMUIKitChatConfig` instead")
|
"Nickname will not show in one-to-one chat, if you tend to control it in group chat, please use `isShowSelfNameInGroup` and `isShowOthersNameInGroup` from `config: TIMUIKitChatConfig` instead") this.showNickName = false,
|
||||||
this.showNickName = false,
|
|
||||||
this.showTotalUnReadCount = false,
|
this.showTotalUnReadCount = false,
|
||||||
this.messageItemBuilder,
|
this.messageItemBuilder,
|
||||||
@Deprecated("Please use [extraTipsActionItemBuilder] instead")
|
@Deprecated(
|
||||||
this.exteraTipsActionItemBuilder,
|
"Please use [extraTipsActionItemBuilder] instead") this.exteraTipsActionItemBuilder,
|
||||||
this.extraTipsActionItemBuilder,
|
this.extraTipsActionItemBuilder,
|
||||||
this.draftText,
|
this.draftText,
|
||||||
this.textFieldHintText,
|
this.textFieldHintText,
|
||||||
|
|
@ -178,7 +183,9 @@ class TIMUIKitChat extends StatefulWidget {
|
||||||
this.customAppBar,
|
this.customAppBar,
|
||||||
this.onSecondaryTapAvatar})
|
this.onSecondaryTapAvatar})
|
||||||
: super(key: key) {
|
: super(key: key) {
|
||||||
startTime = DateTime.now().millisecondsSinceEpoch;
|
startTime = DateTime
|
||||||
|
.now()
|
||||||
|
.millisecondsSinceEpoch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -188,6 +195,8 @@ class TIMUIKitChat extends StatefulWidget {
|
||||||
class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
TUIChatSeparateViewModel model = TUIChatSeparateViewModel();
|
TUIChatSeparateViewModel model = TUIChatSeparateViewModel();
|
||||||
final TUIThemeViewModel themeViewModel = serviceLocator<TUIThemeViewModel>();
|
final TUIThemeViewModel themeViewModel = serviceLocator<TUIThemeViewModel>();
|
||||||
|
final TUIConversationViewModel conversationViewModel =
|
||||||
|
serviceLocator<TUIConversationViewModel>();
|
||||||
final TIMUIKitInputTextFieldController textFieldController =
|
final TIMUIKitInputTextFieldController textFieldController =
|
||||||
TIMUIKitInputTextFieldController();
|
TIMUIKitInputTextFieldController();
|
||||||
bool isInit = false;
|
bool isInit = false;
|
||||||
|
|
@ -200,13 +209,19 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
|
|
||||||
late AutoScrollController autoController = AutoScrollController(
|
late AutoScrollController autoController = AutoScrollController(
|
||||||
viewportBoundaryGetter: () =>
|
viewportBoundaryGetter: () =>
|
||||||
Rect.fromLTRB(0, 0, 0, MediaQuery.of(context).padding.bottom),
|
Rect.fromLTRB(0, 0, 0, MediaQuery
|
||||||
|
.of(context)
|
||||||
|
.padding
|
||||||
|
.bottom),
|
||||||
axis: Axis.vertical,
|
axis: Axis.vertical,
|
||||||
);
|
);
|
||||||
|
|
||||||
late AutoScrollController atMemberPanelScroll = AutoScrollController(
|
late AutoScrollController atMemberPanelScroll = AutoScrollController(
|
||||||
viewportBoundaryGetter: () =>
|
viewportBoundaryGetter: () =>
|
||||||
Rect.fromLTRB(0, 0, 0, MediaQuery.of(context).padding.bottom),
|
Rect.fromLTRB(0, 0, 0, MediaQuery
|
||||||
|
.of(context)
|
||||||
|
.padding
|
||||||
|
.bottom),
|
||||||
axis: Axis.vertical,
|
axis: Axis.vertical,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -220,11 +235,16 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
model.onTapAvatar = widget.onTapAvatar;
|
model.onTapAvatar = widget.onTapAvatar;
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
if (kProfileMode) {
|
if (kProfileMode) {
|
||||||
widget.endTime = DateTime.now().millisecondsSinceEpoch;
|
widget.endTime = DateTime
|
||||||
|
.now()
|
||||||
|
.millisecondsSinceEpoch;
|
||||||
int timeSpend = widget.endTime - widget.startTime;
|
int timeSpend = widget.endTime - widget.startTime;
|
||||||
print("Page render time:$timeSpend ms");
|
print("Page render time:$timeSpend ms");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Future.delayed(const Duration(milliseconds: 500), () {
|
||||||
|
updateDraft();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -245,8 +265,8 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
model = TUIChatSeparateViewModel();
|
model = TUIChatSeparateViewModel();
|
||||||
model.abstractMessageBuilder = widget.abstractMessageBuilder;
|
model.abstractMessageBuilder = widget.abstractMessageBuilder;
|
||||||
model.onTapAvatar = widget.onTapAvatar;
|
model.onTapAvatar = widget.onTapAvatar;
|
||||||
textFieldController.requestFocus();
|
|
||||||
Future.delayed(const Duration(milliseconds: 50), () {
|
Future.delayed(const Duration(milliseconds: 50), () {
|
||||||
|
updateDraft();
|
||||||
textFieldController.requestFocus();
|
textFieldController.requestFocus();
|
||||||
try {
|
try {
|
||||||
autoController.jumpTo(
|
autoController.jumpTo(
|
||||||
|
|
@ -261,6 +281,22 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateDraft() async {
|
||||||
|
final isTopic = widget.conversation.conversationID.contains("@TOPIC#");
|
||||||
|
if (isTopic) {
|
||||||
|
final topicInfoList = await TencentImSDKPlugin.v2TIMManager
|
||||||
|
.getGroupManager()
|
||||||
|
.getTopicInfoList(
|
||||||
|
groupID: widget.groupID!,
|
||||||
|
topicIDList: [widget.conversation.conversationID]);
|
||||||
|
final topicInfo = topicInfoList.data?.first.topicInfo;
|
||||||
|
final draftText = topicInfo?.draftText;
|
||||||
|
if (TencentUtils.checkString(draftText) != null) {
|
||||||
|
textFieldController.setTextField(draftText!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Widget _renderJoinGroupApplication(int amount, TUITheme theme) {
|
Widget _renderJoinGroupApplication(int amount, TUITheme theme) {
|
||||||
String option1 = amount.toString();
|
String option1 = amount.toString();
|
||||||
return Container(
|
return Container(
|
||||||
|
|
@ -436,10 +472,12 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
widget.config!.isUseDefaultEmoji,
|
widget.config!.isUseDefaultEmoji,
|
||||||
key: listContainerKey,
|
key: listContainerKey,
|
||||||
isAllowScroll: true,
|
isAllowScroll: true,
|
||||||
userAvatarBuilder: widget.userAvatarBuilder,
|
userAvatarBuilder: widget
|
||||||
|
.userAvatarBuilder,
|
||||||
toolTipsConfig: widget.toolTipsConfig,
|
toolTipsConfig: widget.toolTipsConfig,
|
||||||
groupAtInfoList: widget.groupAtInfoList,
|
groupAtInfoList: widget.groupAtInfoList,
|
||||||
tongueItemBuilder: widget.tongueItemBuilder,
|
tongueItemBuilder: widget
|
||||||
|
.tongueItemBuilder,
|
||||||
onLongPressForOthersHeadPortrait:
|
onLongPressForOthersHeadPortrait:
|
||||||
(String? userId, String? nickName) {
|
(String? userId, String? nickName) {
|
||||||
textFieldController.longPressToAt(
|
textFieldController.longPressToAt(
|
||||||
|
|
@ -473,6 +511,7 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
: (widget.textFieldBuilder != null
|
: (widget.textFieldBuilder != null
|
||||||
? widget.textFieldBuilder!(context)
|
? widget.textFieldBuilder!(context)
|
||||||
: TIMUIKitInputTextField(
|
: TIMUIKitInputTextField(
|
||||||
|
groupID: widget.groupID,
|
||||||
atMemberPanelScroll:
|
atMemberPanelScroll:
|
||||||
atMemberPanelScroll,
|
atMemberPanelScroll,
|
||||||
groupType:
|
groupType:
|
||||||
|
|
@ -492,8 +531,15 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
scrollController: autoController,
|
scrollController: autoController,
|
||||||
conversationID: _getConvID(),
|
conversationID: _getConvID(),
|
||||||
conversationType: _getConvType(),
|
conversationType: _getConvType(),
|
||||||
initText: widget.draftText ??
|
initText: TencentUtils.checkString(
|
||||||
widget.conversation.draftText,
|
widget.draftText) ?? (PlatformUtils().isWeb
|
||||||
|
? TencentUtils.checkString(
|
||||||
|
conversationViewModel.getWebDraft(
|
||||||
|
conversationID: widget.conversation
|
||||||
|
.conversationID))
|
||||||
|
:
|
||||||
|
TencentUtils.checkString(widget
|
||||||
|
.conversation.draftText)),
|
||||||
hintText: widget.textFieldHintText,
|
hintText: widget.textFieldHintText,
|
||||||
showMorePanel: widget.config
|
showMorePanel: widget.config
|
||||||
?.isAllowShowMorePanel ??
|
?.isAllowShowMorePanel ??
|
||||||
|
|
@ -566,8 +612,7 @@ class TIMUIKitChatProviderScope extends StatelessWidget {
|
||||||
|
|
||||||
final AutoScrollController? scrollController;
|
final AutoScrollController? scrollController;
|
||||||
|
|
||||||
TIMUIKitChatProviderScope(
|
TIMUIKitChatProviderScope({Key? key,
|
||||||
{Key? key,
|
|
||||||
this.child,
|
this.child,
|
||||||
this.providers,
|
this.providers,
|
||||||
this.textFieldController,
|
this.textFieldController,
|
||||||
|
|
|
||||||
|
|
@ -185,6 +185,12 @@ class TIMUIKitChatConfig {
|
||||||
/// Define the lines in the text message input field on Desktop.
|
/// Define the lines in the text message input field on Desktop.
|
||||||
final int desktopMessageInputFieldLines;
|
final int desktopMessageInputFieldLines;
|
||||||
|
|
||||||
|
/// Specifies whether to use the draft feature on the Web, as the Chat SDK does not support this functionality.
|
||||||
|
/// If enabled, draft data will be stored in TUIKit's memory.
|
||||||
|
/// Note that the draft text will be lost upon refreshing the website.
|
||||||
|
/// [Default]: true.
|
||||||
|
final bool isUseDraftOnWeb;
|
||||||
|
|
||||||
const TIMUIKitChatConfig(
|
const TIMUIKitChatConfig(
|
||||||
{this.onTapLink,
|
{this.onTapLink,
|
||||||
this.timeDividerConfig,
|
this.timeDividerConfig,
|
||||||
|
|
@ -220,6 +226,7 @@ class TIMUIKitChatConfig {
|
||||||
this.isShowReadingStatus = true,
|
this.isShowReadingStatus = true,
|
||||||
this.desktopControlBarConfig,
|
this.desktopControlBarConfig,
|
||||||
this.isAllowLongPressMessage = true,
|
this.isAllowLongPressMessage = true,
|
||||||
|
this.isUseDraftOnWeb = true,
|
||||||
this.isAllowClickAvatar = true,
|
this.isAllowClickAvatar = true,
|
||||||
this.isEnableTextSelection,
|
this.isEnableTextSelection,
|
||||||
this.additionalDesktopMessageHoverBarItem,
|
this.additionalDesktopMessageHoverBarItem,
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||||
|
|
||||||
class MessageRepliedData {
|
class MessageRepliedData {
|
||||||
late String messageAbstract;
|
late String messageAbstract;
|
||||||
late String messageSender;
|
late String messageSender;
|
||||||
|
|
@ -10,6 +12,42 @@ class MessageRepliedData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RepliedMessageAbstract {
|
||||||
|
final int? elemType;
|
||||||
|
final String? msgID;
|
||||||
|
final int? timestamp;
|
||||||
|
final String? seq;
|
||||||
|
final String? summary;
|
||||||
|
|
||||||
|
RepliedMessageAbstract(
|
||||||
|
{this.elemType, this.msgID, this.timestamp, this.seq, this.summary});
|
||||||
|
|
||||||
|
// fromJson constructor
|
||||||
|
RepliedMessageAbstract.fromJson(Map<String, dynamic> json)
|
||||||
|
: elemType = json['elemType'],
|
||||||
|
msgID = json['msgID'],
|
||||||
|
timestamp = json['timestamp'],
|
||||||
|
seq = json['seq'],
|
||||||
|
summary = json['summary'];
|
||||||
|
|
||||||
|
// toJson function
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'summary': summary,
|
||||||
|
'elemType': elemType,
|
||||||
|
'msgID': msgID,
|
||||||
|
'timestamp': timestamp,
|
||||||
|
'seq': seq,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// isNotEmpty method
|
||||||
|
bool get isNotEmpty =>
|
||||||
|
TencentUtils.checkString(msgID) != null &&
|
||||||
|
TencentUtils.checkString(timestamp.toString()) != null &&
|
||||||
|
TencentUtils.checkString(seq) != null;
|
||||||
|
}
|
||||||
|
|
||||||
class CloudCustomData {
|
class CloudCustomData {
|
||||||
Map<String, dynamic>? messageReply;
|
Map<String, dynamic>? messageReply;
|
||||||
Map<String, dynamic>? messageReaction = {};
|
Map<String, dynamic>? messageReaction = {};
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ class LinkPreviewEntry {
|
||||||
return isMarkdown
|
return isMarkdown
|
||||||
? LinkTextMarkdown(
|
? LinkTextMarkdown(
|
||||||
isEnableTextSelection: isEnableTextSelection,
|
isEnableTextSelection: isEnableTextSelection,
|
||||||
messageText: replaceSingleNewlineWithTwo(messageText),
|
messageText: addSpaceAfterLeftBracket(
|
||||||
|
addSpaceBeforeHttp(replaceSingleNewlineWithTwo(messageText))),
|
||||||
style: style,
|
style: style,
|
||||||
onLinkTap: onLinkTap)
|
onLinkTap: onLinkTap)
|
||||||
: LinkText(
|
: LinkText(
|
||||||
|
|
@ -30,10 +31,27 @@ class LinkPreviewEntry {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String addSpaceAfterLeftBracket(String inputText) {
|
||||||
|
return inputText.splitMapJoin(
|
||||||
|
RegExp(r'<\w+[^<>]*>'),
|
||||||
|
onMatch: (match) {
|
||||||
|
return match.group(0)!.replaceFirst('<', '< ');
|
||||||
|
},
|
||||||
|
onNonMatch: (text) => text,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static String replaceSingleNewlineWithTwo(String inputText) {
|
static String replaceSingleNewlineWithTwo(String inputText) {
|
||||||
return inputText.replaceAllMapped(
|
return inputText.split('\n').join('\n\n');
|
||||||
RegExp(r'(?<!\n)\n(?!\n)'),
|
}
|
||||||
(match) => '\n\n',
|
|
||||||
|
static String addSpaceBeforeHttp(String inputText) {
|
||||||
|
return inputText.splitMapJoin(
|
||||||
|
RegExp(r'http'),
|
||||||
|
onMatch: (match) {
|
||||||
|
return ' http';
|
||||||
|
},
|
||||||
|
onNonMatch: (text) => text,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import 'package:flutter_markdown/flutter_markdown.dart';
|
||||||
import 'package:tencent_im_base/base_widgets/tim_stateless_widget.dart';
|
import 'package:tencent_im_base/base_widgets/tim_stateless_widget.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/special_text/DefaultSpecialTextSpanBuilder.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/special_text/DefaultSpecialTextSpanBuilder.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/widgets/link_preview/common/utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/widgets/link_preview/common/utils.dart';
|
||||||
|
import 'package:markdown/markdown.dart' as md;
|
||||||
|
|
||||||
class LinkTextMarkdown extends TIMStatelessWidget {
|
class LinkTextMarkdown extends TIMStatelessWidget {
|
||||||
/// Callback for when link is tapped
|
/// Callback for when link is tapped
|
||||||
|
|
@ -40,6 +41,7 @@ class LinkTextMarkdown extends TIMStatelessWidget {
|
||||||
.copyWith(
|
.copyWith(
|
||||||
a: TextStyle(color: LinkUtils.hexToColor("015fff")),
|
a: TextStyle(color: LinkUtils.hexToColor("015fff")),
|
||||||
),
|
),
|
||||||
|
extensionSet: md.ExtensionSet.gitHubWeb,
|
||||||
onTapLink: (
|
onTapLink: (
|
||||||
String link,
|
String link,
|
||||||
String? href,
|
String? href,
|
||||||
|
|
@ -155,3 +157,20 @@ class LinkText extends TIMStatelessWidget {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TextBuilder extends MarkdownElementBuilder {
|
||||||
|
@override
|
||||||
|
Widget? visitText(md.Text text, TextStyle? preferredStyle) {
|
||||||
|
return Text(text.textContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class RawHtmlSyntax extends md.InlineSyntax {
|
||||||
|
RawHtmlSyntax() : super(r'<.+?>');
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool onMatch(md.InlineParser parser, Match match) {
|
||||||
|
parser.addNode(md.Text(match[0]!));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import 'package:tencent_cloud_chat_uikit/ui/widgets/drag_widget.dart';
|
||||||
|
|
||||||
class TUIKitWidePopup {
|
class TUIKitWidePopup {
|
||||||
static OverlayEntry? entry;
|
static OverlayEntry? entry;
|
||||||
|
static bool isShow = false;
|
||||||
|
|
||||||
static showSecondaryConfirmDialog({
|
static showSecondaryConfirmDialog({
|
||||||
required TUIKitWideModalOperationKey operationKey,
|
required TUIKitWideModalOperationKey operationKey,
|
||||||
|
|
@ -56,6 +57,10 @@ class TUIKitWidePopup {
|
||||||
VoidCallback? onConfirm,
|
VoidCallback? onConfirm,
|
||||||
VoidCallback? onCancel,
|
VoidCallback? onCancel,
|
||||||
}) async {
|
}) async {
|
||||||
|
if (isShow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isShow = true;
|
||||||
|
|
||||||
final TUISelfInfoViewModel selfInfoViewModel =
|
final TUISelfInfoViewModel selfInfoViewModel =
|
||||||
serviceLocator<TUISelfInfoViewModel>();
|
serviceLocator<TUISelfInfoViewModel>();
|
||||||
|
|
@ -76,34 +81,16 @@ class TUIKitWidePopup {
|
||||||
onSubmit,
|
onSubmit,
|
||||||
submitWidget,
|
submitWidget,
|
||||||
onConfirm,
|
onConfirm,
|
||||||
onCancel
|
onCancel);
|
||||||
);
|
|
||||||
|
|
||||||
if (res == true) {
|
if (res == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry != null) {
|
final isUseMaterialAlert = (offset == null);
|
||||||
return;
|
|
||||||
}
|
final Widget contentWidget = Container(
|
||||||
entry = OverlayEntry(builder: (BuildContext context) {
|
|
||||||
return Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: TUIKitDragArea(
|
|
||||||
backgroundColor: isDarkBackground ? const Color(0x7F000000) : null,
|
|
||||||
closeFun: () {
|
|
||||||
if (entry != null) {
|
|
||||||
entry?.remove();
|
|
||||||
entry = null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
initOffset: offset ??
|
|
||||||
(width != null && height != null
|
|
||||||
? Offset(MediaQuery.of(context).size.width * 0.5 - width / 2,
|
|
||||||
MediaQuery.of(context).size.height * 0.5 - height / 2)
|
|
||||||
: null),
|
|
||||||
child: Container(
|
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|
@ -113,11 +100,10 @@ class TUIKitWidePopup {
|
||||||
border: isDarkBackground
|
border: isDarkBackground
|
||||||
? Border.all(
|
? Border.all(
|
||||||
width: 2,
|
width: 2,
|
||||||
color:
|
color: theme?.weakBackgroundColor ?? const Color(0xFFbebebe),
|
||||||
theme?.weakBackgroundColor ?? const Color(0xFFbebebe),
|
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
boxShadow: isDarkBackground
|
boxShadow: (isDarkBackground || isUseMaterialAlert)
|
||||||
? null
|
? null
|
||||||
: const [
|
: const [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
|
|
@ -147,16 +133,20 @@ class TUIKitWidePopup {
|
||||||
title,
|
title,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
color: theme?.darkTextColor ??
|
color: theme?.darkTextColor ?? const Color(0xFF444444)),
|
||||||
const Color(0xFF444444)),
|
|
||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (onSubmit != null) {
|
if (onSubmit != null) {
|
||||||
onSubmit();
|
onSubmit();
|
||||||
}
|
}
|
||||||
|
isShow = false;
|
||||||
|
if (offset == null) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
} else {
|
||||||
entry?.remove();
|
entry?.remove();
|
||||||
entry = null;
|
entry = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: onSubmit != null
|
child: onSubmit != null
|
||||||
? (submitWidget ?? const Icon(Icons.check))
|
? (submitWidget ?? const Icon(Icons.check))
|
||||||
|
|
@ -174,13 +164,23 @@ class TUIKitWidePopup {
|
||||||
),
|
),
|
||||||
if (height != null && width != null)
|
if (height != null && width != null)
|
||||||
Expanded(child: child(() {
|
Expanded(child: child(() {
|
||||||
|
isShow = false;
|
||||||
|
if (isUseMaterialAlert) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
} else {
|
||||||
entry?.remove();
|
entry?.remove();
|
||||||
entry = null;
|
entry = null;
|
||||||
|
}
|
||||||
})),
|
})),
|
||||||
if (height == null || width == null)
|
if (height == null || width == null)
|
||||||
child(() {
|
child(() {
|
||||||
|
isShow = false;
|
||||||
|
if (isUseMaterialAlert) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
} else {
|
||||||
entry?.remove();
|
entry?.remove();
|
||||||
entry = null;
|
entry = null;
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
if (onCancel != null || onConfirm != null)
|
if (onCancel != null || onConfirm != null)
|
||||||
Container(
|
Container(
|
||||||
|
|
@ -193,15 +193,19 @@ class TUIKitWidePopup {
|
||||||
margin: const EdgeInsets.only(right: 16),
|
margin: const EdgeInsets.only(right: 16),
|
||||||
child: OutlinedButton(
|
child: OutlinedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
isShow = false;
|
||||||
|
if (isUseMaterialAlert) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
} else {
|
||||||
entry?.remove();
|
entry?.remove();
|
||||||
entry = null;
|
entry = null;
|
||||||
|
}
|
||||||
onCancel();
|
onCancel();
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
TIM_t("取消"),
|
TIM_t("取消"),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: theme?.weakTextColor ?? Colors.black),
|
||||||
theme?.weakTextColor ?? Colors.black),
|
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
if (onConfirm != null)
|
if (onConfirm != null)
|
||||||
|
|
@ -209,8 +213,13 @@ class TUIKitWidePopup {
|
||||||
margin: const EdgeInsets.only(right: 16),
|
margin: const EdgeInsets.only(right: 16),
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
isShow = false;
|
||||||
|
if (isUseMaterialAlert) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
} else {
|
||||||
entry?.remove();
|
entry?.remove();
|
||||||
entry = null;
|
entry = null;
|
||||||
|
}
|
||||||
onConfirm();
|
onConfirm();
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
|
|
@ -223,10 +232,50 @@ class TUIKitWidePopup {
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)),
|
);
|
||||||
|
|
||||||
|
if (isUseMaterialAlert) {
|
||||||
|
return showDialog(
|
||||||
|
barrierDismissible: false,
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return WillPopScope(
|
||||||
|
child: AlertDialog(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
titlePadding: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
|
||||||
|
contentPadding: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
|
||||||
|
content: contentWidget,
|
||||||
|
),
|
||||||
|
onWillPop: () {
|
||||||
|
return Future.value(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
entry = OverlayEntry(builder: (BuildContext context) {
|
||||||
|
return Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: TUIKitDragArea(
|
||||||
|
backgroundColor: isDarkBackground ? const Color(0x7F000000) : null,
|
||||||
|
closeFun: () {
|
||||||
|
if (entry != null) {
|
||||||
|
entry?.remove();
|
||||||
|
entry = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
initOffset: offset ??
|
||||||
|
(width != null && height != null
|
||||||
|
? Offset(
|
||||||
|
MediaQuery.of(context).size.width * 0.5 - width / 2,
|
||||||
|
MediaQuery.of(context).size.height * 0.5 - height / 2)
|
||||||
|
: null),
|
||||||
|
child: contentWidget),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
Overlay.of(context).insert(entry!);
|
Overlay.of(context).insert(entry!);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
name: tencent_cloud_chat_uikit
|
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.
|
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.1.0+2
|
version: 2.1.1
|
||||||
homepage: https://www.tencentcloud.com/products/im?from=pub
|
homepage: https://www.tencentcloud.com/products/im?from=pub
|
||||||
repository: https://github.com/TencentCloud/tc-chat-uikit-flutter
|
repository: https://github.com/TencentCloud/tc-chat-uikit-flutter
|
||||||
documentation: https://comm.qq.com/im/doc/flutter/en/TUIKit/readme.html
|
documentation: https://comm.qq.com/im/doc/flutter/en/TUIKit/readme.html
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue