feat: Upgrade to 2.1.1 pre-release
This commit is contained in:
parent
be65bea65e
commit
2f001240cd
|
|
@ -1139,7 +1139,7 @@ packages:
|
|||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "2.1.0+1"
|
||||
version: "2.1.0+2"
|
||||
tencent_cloud_uikit_core:
|
||||
dependency: transitive
|
||||
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">
|
||||
<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="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 opacity="0.795169">
|
||||
<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="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>
|
||||
|
|
|
|||
|
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/ui/constants/history_message_constant.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';
|
||||
|
||||
enum LoadDirection { previous, latest }
|
||||
|
|
@ -53,7 +54,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier {
|
|||
bool showC2cMessageEditStatus = true;
|
||||
TIMUIKitChatConfig chatConfig = const TIMUIKitChatConfig();
|
||||
ValueChanged<String>? setInputField;
|
||||
String Function(V2TimMessage message)? abstractMessageBuilder;
|
||||
String? Function(V2TimMessage message)? abstractMessageBuilder;
|
||||
Function(String userID, TapDownDetails tapDetails)? onTapAvatar;
|
||||
V2TimGroupMemberFullInfo? _currentChatUserInfo;
|
||||
V2TimGroupInfo? _groupInfo;
|
||||
|
|
@ -228,7 +229,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier {
|
|||
globalModel.setChatConfig(chatConfig);
|
||||
globalModel.clearRecivedNewMessageCount();
|
||||
_isInit = true;
|
||||
Future.delayed(const Duration(milliseconds: 300), (){
|
||||
Future.delayed(const Duration(milliseconds: 300), () {
|
||||
markMessageAsRead();
|
||||
});
|
||||
}
|
||||
|
|
@ -809,7 +810,25 @@ class TUIChatSeparateViewModel extends ChangeNotifier {
|
|||
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;
|
||||
switch (elemType) {
|
||||
case MessageElemType.V2TIM_ELEM_TYPE_FACE:
|
||||
|
|
@ -831,7 +850,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier {
|
|||
case MessageElemType.V2TIM_ELEM_TYPE_SOUND:
|
||||
return "[语音消息]";
|
||||
case MessageElemType.V2TIM_ELEM_TYPE_TEXT:
|
||||
return "[文本消息]";
|
||||
return message.textElem?.text ?? "[文本消息]";
|
||||
case MessageElemType.V2TIM_ELEM_TYPE_VIDEO:
|
||||
return "[视频消息]";
|
||||
default:
|
||||
|
|
@ -869,7 +888,7 @@ class TUIChatSeparateViewModel extends ChangeNotifier {
|
|||
final cloudCustomData = {
|
||||
"messageReply": {
|
||||
"messageID": _repliedMessage!.msgID,
|
||||
"messageAbstract": _getAbstractMessage(_repliedMessage!),
|
||||
"messageAbstract": _getMessageAbstract(_repliedMessage!),
|
||||
"messageSender": hasNickName
|
||||
? _repliedMessage!.nickName
|
||||
: _repliedMessage?.sender,
|
||||
|
|
@ -893,9 +912,10 @@ class TUIChatSeparateViewModel extends ChangeNotifier {
|
|||
];
|
||||
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,
|
||||
replyMessage: _repliedMessage!,
|
||||
offlinePushInfo: tools.buildMessagePushInfo(
|
||||
messageInfoWithSender, convID, convType),
|
||||
needReadReceipt: chatConfig.isShowGroupReadingStatus &&
|
||||
|
|
@ -908,7 +928,6 @@ class TUIChatSeparateViewModel extends ChangeNotifier {
|
|||
.contains(oldGroupType))),
|
||||
groupID: groupID,
|
||||
receiver: receiver);
|
||||
_repliedMessage = null;
|
||||
notifyListeners();
|
||||
globalModel.updateMessage(sendMsgRes, convID,
|
||||
messageInfoWithSender.id ?? "", convType, groupType, setInputField);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
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/tencent_cloud_chat_uikit.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/view_models/tui_chat_global_model.dart';
|
||||
|
|
@ -42,6 +43,7 @@ class TUIConversationViewModel extends ChangeNotifier {
|
|||
late V2TimConversationListener _conversationListener;
|
||||
List<V2TimConversation?> _conversationList = [];
|
||||
static V2TimConversation? _selectedConversation;
|
||||
Map<String, String> webDraftMap = {};
|
||||
|
||||
bool _haveMoreData = true;
|
||||
int _totalUnReadCount = 0;
|
||||
|
|
@ -66,8 +68,7 @@ class TUIConversationViewModel extends ChangeNotifier {
|
|||
_conversationList.removeWhere((element) => element?.isPinned == true);
|
||||
_conversationList = [...pinnedConversation, ..._conversationList];
|
||||
// ignore: empty_catches
|
||||
} catch (e) {
|
||||
}
|
||||
} catch (e) {}
|
||||
} else {
|
||||
_conversationList.sort((a, b) => b!.orderkey!.compareTo(a!.orderkey!));
|
||||
}
|
||||
|
|
@ -259,11 +260,47 @@ class TUIConversationViewModel extends ChangeNotifier {
|
|||
listener: _conversationListener);
|
||||
}
|
||||
|
||||
Future<V2TimCallback> setConversationDraft(
|
||||
{required String conversationID, String? draftText}) async {
|
||||
Future<V2TimCallback> setConversationDraft({
|
||||
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(
|
||||
conversationID: conversationID, draftText: draftText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clearWebDraft({
|
||||
required String conversationID,
|
||||
}) {
|
||||
webDraftMap[conversationID] = "";
|
||||
}
|
||||
|
||||
String? getWebDraft({
|
||||
required String conversationID,
|
||||
}) {
|
||||
return TencentUtils.checkString(webDraftMap[conversationID]);
|
||||
}
|
||||
|
||||
clearData() {
|
||||
_conversationList = [];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
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_cloud_chat_uikit/data_services/core/tim_uikit_config.dart';
|
||||
|
||||
|
|
@ -92,4 +93,6 @@ abstract class CoreServices {
|
|||
setDarkTheme();
|
||||
|
||||
setLightTheme();
|
||||
|
||||
setDeviceType(DeviceType deviceType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
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/ui/utils/screen_utils.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/view_models/tui_chat_global_model.dart';
|
||||
|
|
@ -74,7 +75,6 @@ class CoreServicesImpl implements CoreServices {
|
|||
@override
|
||||
Future<bool?> init(
|
||||
{
|
||||
|
||||
/// Callback from TUIKit invoke, includes IM SDK API error, notify information, Flutter error.
|
||||
ValueChanged<TIMCallback>? onTUIKitCallbackListener,
|
||||
required int sdkAppID,
|
||||
|
|
@ -83,13 +83,20 @@ class CoreServicesImpl implements CoreServices {
|
|||
LanguageEnum? language,
|
||||
String? extraLanguage,
|
||||
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 {
|
||||
if (platform != null) {
|
||||
TUIKitScreenUtils.deviceType = platform;
|
||||
}
|
||||
addIdentifier();
|
||||
if(extraLanguage != null){
|
||||
if (extraLanguage != null) {
|
||||
Future.delayed(const Duration(milliseconds: 1), () {
|
||||
I18nUtils(null, extraLanguage);
|
||||
});
|
||||
}else if (language != null) {
|
||||
} else if (language != null) {
|
||||
Future.delayed(const Duration(milliseconds: 1), () {
|
||||
I18nUtils(null, languageEnumToString[language]);
|
||||
});
|
||||
|
|
@ -139,11 +146,11 @@ class CoreServicesImpl implements CoreServices {
|
|||
required String userId,
|
||||
}) async {
|
||||
_userID = userId;
|
||||
if(extraLanguage != null){
|
||||
if (extraLanguage != null) {
|
||||
Future.delayed(const Duration(milliseconds: 1), () {
|
||||
I18nUtils(null, extraLanguage);
|
||||
});
|
||||
}else if (language != null) {
|
||||
} else if (language != null) {
|
||||
Future.delayed(const Duration(milliseconds: 1), () {
|
||||
I18nUtils(null, languageEnumToString[language]);
|
||||
});
|
||||
|
|
@ -247,8 +254,7 @@ class CoreServicesImpl implements CoreServices {
|
|||
|
||||
tuiFriendShipViewModel.userStatusList = currentUserStatusList;
|
||||
// ignore: empty_catches
|
||||
} catch (e) {
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -398,4 +404,9 @@ class CoreServicesImpl implements CoreServices {
|
|||
.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 || convType != ConvType.group);
|
||||
assert(userID != null || convType != ConvType.c2c);
|
||||
if (isNavigateToMessageListBottom) {
|
||||
scrollController?.animateTo(
|
||||
if (isNavigateToMessageListBottom && scrollController != null) {
|
||||
scrollController!.animateTo(
|
||||
scrollController!.position.minScrollExtent,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.ease,
|
||||
|
|
@ -159,7 +159,7 @@ class TIMUIKitChatController {
|
|||
offlinePushInfo: offlinePushInfo);
|
||||
} else if (model != null) {
|
||||
/// Sends a message to the current conversation specified on `TIMUIKitChat`. 发送到 `TIMUIKitChat` 中指定的当前对话。
|
||||
if (isNavigateToMessageListBottom) {
|
||||
if (isNavigateToMessageListBottom && scrollController != null) {
|
||||
scrollController?.animateTo(
|
||||
scrollController!.position.minScrollExtent,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
|
|
|
|||
|
|
@ -28,8 +28,9 @@ class TUIKitScreenUtils {
|
|||
|
||||
final diagonalInInches =
|
||||
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;
|
||||
}else{
|
||||
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';
|
||||
|
||||
typedef MessageRowBuilder = Widget? Function(
|
||||
|
||||
/// current message
|
||||
V2TimMessage message,
|
||||
|
||||
|
|
@ -55,7 +56,7 @@ typedef MessageRowBuilder = Widget? Function(
|
|||
|
||||
/// scroll to specific message, it will shows on the screen top, without the call isNeedShowJumpStatus
|
||||
Function onScrollToIndexBegin,
|
||||
);
|
||||
);
|
||||
|
||||
typedef MessageNickNameBuilder = Widget Function(
|
||||
BuildContext context, V2TimMessage message, TUIChatSeparateViewModel model);
|
||||
|
|
@ -64,7 +65,7 @@ typedef MessageItemContent = Widget? Function(
|
|||
V2TimMessage message,
|
||||
bool isShowJump,
|
||||
VoidCallback clearJump,
|
||||
);
|
||||
);
|
||||
|
||||
class MessageHoverControlItem {
|
||||
String name;
|
||||
|
|
@ -140,8 +141,7 @@ class MessageToolTipItem {
|
|||
final String iconImageAsset;
|
||||
final VoidCallback onClick;
|
||||
|
||||
MessageToolTipItem(
|
||||
{required this.label,
|
||||
MessageToolTipItem({required this.label,
|
||||
required this.id,
|
||||
required this.iconImageAsset,
|
||||
required this.onClick});
|
||||
|
|
@ -177,8 +177,7 @@ class ToolTipsConfig {
|
|||
List<MessageToolTipItem> Function(
|
||||
V2TimMessage message, Function() closeTooltip)? additionalMessageToolTips;
|
||||
|
||||
ToolTipsConfig(
|
||||
{this.showDeleteMessage = true,
|
||||
ToolTipsConfig({this.showDeleteMessage = true,
|
||||
this.showMultipleChoiceMessage = true,
|
||||
this.showRecallMessage = true,
|
||||
this.showReplyMessage = true,
|
||||
|
|
@ -187,8 +186,7 @@ class ToolTipsConfig {
|
|||
this.showForwardMessage = true,
|
||||
this.additionalMessageToolTips,
|
||||
@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.")
|
||||
this.additionalItemBuilder});
|
||||
"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});
|
||||
}
|
||||
|
||||
class TIMUIKitHistoryMessageListItem extends StatefulWidget {
|
||||
|
|
@ -281,12 +279,10 @@ class TIMUIKitHistoryMessageListItem extends StatefulWidget {
|
|||
|
||||
final List customEmojiStickerList;
|
||||
|
||||
const TIMUIKitHistoryMessageListItem(
|
||||
{Key? key,
|
||||
const TIMUIKitHistoryMessageListItem({Key? key,
|
||||
required this.message,
|
||||
@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")
|
||||
this.showNickName = false,
|
||||
"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.onScrollToIndex,
|
||||
this.onScrollToIndexBegin,
|
||||
this.onTapForOthersPortrait,
|
||||
|
|
@ -395,8 +391,8 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
return false;
|
||||
}
|
||||
|
||||
Widget _messageItemBuilder(
|
||||
V2TimMessage messageItem, TUIChatSeparateViewModel model) {
|
||||
Widget _messageItemBuilder(V2TimMessage messageItem,
|
||||
TUIChatSeparateViewModel model) {
|
||||
final msgType = messageItem.elemType;
|
||||
final isShowJump = (model.jumpMsgID == messageItem.msgID) &&
|
||||
(messageItem.msgID?.isNotEmpty ?? false);
|
||||
|
|
@ -649,13 +645,14 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
margin: const EdgeInsets.symmetric(vertical: 20),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
TIM_t_para("{{option2}}撤回了一条消息", "$option2撤回了一条消息")(option2: option2),
|
||||
TIM_t_para("{{option2}}撤回了一条消息", "$option2撤回了一条消息")(
|
||||
option2: option2),
|
||||
style: TextStyle(color: theme.weakTextColor, fontSize: 12),
|
||||
));
|
||||
}
|
||||
|
||||
Widget _timeDividerBuilder(
|
||||
theme, int timeStamp, TUIChatSeparateViewModel model) {
|
||||
Widget _timeDividerBuilder(theme, int timeStamp,
|
||||
TUIChatSeparateViewModel model) {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
margin: const EdgeInsets.symmetric(vertical: 20),
|
||||
|
|
@ -722,25 +719,31 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
}
|
||||
|
||||
bool isRevocable(int timestamp) =>
|
||||
(DateTime.now().millisecondsSinceEpoch / 1000).ceil() - timestamp < 120;
|
||||
(DateTime
|
||||
.now()
|
||||
.millisecondsSinceEpoch / 1000).ceil() - timestamp < 120;
|
||||
|
||||
_onOpenToolTip(
|
||||
c,
|
||||
_onOpenToolTip(c,
|
||||
V2TimMessage message,
|
||||
TUIChatSeparateViewModel model,
|
||||
TUITheme theme,
|
||||
TapDownDetails? details,
|
||||
bool? isFromWideTooltip,
|
||||
bool? isShowMoreSticker,
|
||||
) {
|
||||
bool? isShowMoreSticker,) {
|
||||
if (tooltip != null && tooltip!.isOpen) {
|
||||
tooltip!.close();
|
||||
return;
|
||||
}
|
||||
tooltip = null;
|
||||
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final screenHeight = MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.height;
|
||||
final screenWidth = MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.width;
|
||||
final isLongMessage =
|
||||
context.size!.height + 350 > screenHeight && PlatformUtils().isMobile;
|
||||
final isDesktopScreen =
|
||||
|
|
@ -750,15 +753,24 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
final isSelf = message.isSelf ?? true;
|
||||
|
||||
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
|
||||
? min(tapDetails?.globalPosition.dx ?? targetWidth,
|
||||
screenWidth - targetWidth)
|
||||
: max(tapDetails?.globalPosition.dx ?? targetWidth, targetWidth)
|
||||
.toDouble();
|
||||
final double dy = min(
|
||||
tapDetails?.globalPosition.dy ?? MediaQuery.of(context).size.height,
|
||||
MediaQuery.of(context).size.height - 320)
|
||||
tapDetails?.globalPosition.dy ?? MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.height,
|
||||
MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.height - 320)
|
||||
.toDouble();
|
||||
final finalTapDetail = tapDetails != null
|
||||
? TapDownDetails(
|
||||
|
|
@ -792,8 +804,7 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
});
|
||||
}
|
||||
|
||||
initTools(
|
||||
{BuildContext? context,
|
||||
initTools({BuildContext? context,
|
||||
bool isLongMessage = false,
|
||||
required TUIChatSeparateViewModel model,
|
||||
TUITheme? theme,
|
||||
|
|
@ -818,7 +829,10 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
if (context != null) {
|
||||
RenderBox? box = _key.currentContext?.findRenderObject() as RenderBox?;
|
||||
if (details != null && box != null) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
double screenWidth = MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.width;
|
||||
final mousePosition = details.globalPosition;
|
||||
hasArrow = isDesktopScreen ? false : true;
|
||||
arrowTipDistance = 0;
|
||||
|
|
@ -832,8 +846,14 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
}
|
||||
} else {
|
||||
if (box != null) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
double viewInsetsBottom = MediaQuery.of(context).viewInsets.bottom;
|
||||
double screenWidth = MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.width;
|
||||
double viewInsetsBottom = MediaQuery
|
||||
.of(context)
|
||||
.viewInsets
|
||||
.bottom;
|
||||
Offset offset = box.localToGlobal(Offset.zero);
|
||||
double boxWidth = box.size.width;
|
||||
if (isSelf) {
|
||||
|
|
@ -966,7 +986,13 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
),
|
||||
onClick: (details) {
|
||||
_onOpenToolTip(
|
||||
context, widget.message, model, theme, details, true, true);
|
||||
context,
|
||||
widget.message,
|
||||
model,
|
||||
theme,
|
||||
details,
|
||||
true,
|
||||
true);
|
||||
},
|
||||
),
|
||||
if (widget.toolTipsConfig?.showReplyMessage ?? true)
|
||||
|
|
@ -1009,12 +1035,19 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
context: context,
|
||||
title: TIM_t("转发"),
|
||||
submitWidget: Text(TIM_t("发送")),
|
||||
width: MediaQuery.of(context).size.width * 0.5,
|
||||
height: MediaQuery.of(context).size.height * 0.8,
|
||||
width: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.width * 0.5,
|
||||
height: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.height * 0.8,
|
||||
onSubmit: () {
|
||||
forwardMessageScreenKey.currentState?.handleForwardMessage();
|
||||
},
|
||||
child: (onClose) => Container(
|
||||
child: (onClose) =>
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: ForwardMessageScreen(
|
||||
conversationType: ConvType.c2c,
|
||||
|
|
@ -1035,7 +1068,13 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
),
|
||||
onClick: (details) {
|
||||
_onOpenToolTip(
|
||||
context, widget.message, model, theme, details, true, false);
|
||||
context,
|
||||
widget.message,
|
||||
model,
|
||||
theme,
|
||||
details,
|
||||
true,
|
||||
false);
|
||||
},
|
||||
),
|
||||
...?model.chatConfig.additionalDesktopMessageHoverBarItem
|
||||
|
|
@ -1053,8 +1092,7 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
context);
|
||||
}
|
||||
|
||||
Widget renderHoverTipAndReadStatus(
|
||||
TUIChatSeparateViewModel model,
|
||||
Widget renderHoverTipAndReadStatus(TUIChatSeparateViewModel model,
|
||||
bool isSelf,
|
||||
V2TimMessage message,
|
||||
bool isPeerRead,
|
||||
|
|
@ -1082,7 +1120,8 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Row(
|
||||
children: wideHoverTipList
|
||||
.map((e) => Tooltip(
|
||||
.map((e) =>
|
||||
Tooltip(
|
||||
message: e.name,
|
||||
preferBelow: false,
|
||||
textStyle: TextStyle(fontSize: 12, color: theme.white),
|
||||
|
|
@ -1110,7 +1149,9 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
.toList(),
|
||||
),
|
||||
),
|
||||
if (!isDesktopScreen || !isShowWideToolTip)
|
||||
if (!isDesktopScreen ||
|
||||
(model.chatConfig.isUseMessageHoverBarOnDesktop &&
|
||||
!isShowWideToolTip))
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
|
|
@ -1233,7 +1274,8 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
}
|
||||
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) => Container(
|
||||
builder: (context, constraints) =>
|
||||
Container(
|
||||
margin: widget.padding ?? const EdgeInsets.only(bottom: 20),
|
||||
child: Row(
|
||||
key: _key,
|
||||
|
|
@ -1245,7 +1287,8 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
margin:
|
||||
EdgeInsets.only(right: 12, top: 10, left: isSelf ? 16 : 0),
|
||||
child: CheckBoxButton(
|
||||
isChecked: model.multiSelectedMessageList.contains(message),
|
||||
isChecked: model.multiSelectedMessageList.contains(
|
||||
message),
|
||||
onChanged: (value) {
|
||||
if (value) {
|
||||
model.addToMultiSelectedMessageList(message);
|
||||
|
|
@ -1258,14 +1301,16 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
Expanded(
|
||||
child: MouseRegion(
|
||||
onEnter: (_) {
|
||||
if (isDesktopScreen) {
|
||||
if (isDesktopScreen &&
|
||||
model.chatConfig.isUseMessageHoverBarOnDesktop) {
|
||||
setState(() {
|
||||
isShowWideToolTip = true;
|
||||
});
|
||||
}
|
||||
},
|
||||
onExit: (_) {
|
||||
if (isDesktopScreen) {
|
||||
if (isDesktopScreen &&
|
||||
model.chatConfig.isUseMessageHoverBarOnDesktop) {
|
||||
setState(() {
|
||||
isShowWideToolTip = false;
|
||||
});
|
||||
|
|
@ -1283,6 +1328,8 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
} else {
|
||||
model.addToMultiSelectedMessageList(message);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
|
|
@ -1292,11 +1339,12 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
: MainAxisAlignment.start,
|
||||
children: [
|
||||
if (!isSelf && widget.showAvatar)
|
||||
InkWell(
|
||||
GestureDetector(
|
||||
onLongPress: () {
|
||||
if (widget.onLongPressForOthersHeadPortrait !=
|
||||
null) {}
|
||||
if (model.chatConfig.isAllowLongPressAvatarToAt) {
|
||||
if (model.chatConfig
|
||||
.isAllowLongPressAvatarToAt) {
|
||||
widget.onLongPressForOthersHeadPortrait!(
|
||||
message.sender, message.nickName);
|
||||
}
|
||||
|
|
@ -1386,7 +1434,8 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
margin: const EdgeInsets.only(bottom: 4),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: MediaQuery.of(context)
|
||||
maxWidth: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.width /
|
||||
1.7),
|
||||
|
|
@ -1430,7 +1479,8 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
message.status,
|
||||
model)),
|
||||
onSecondaryTapDown: (details) {
|
||||
if (widget.onLongPress != null) {
|
||||
if (widget.onLongPress !=
|
||||
null) {
|
||||
widget.onLongPress!(
|
||||
context, message);
|
||||
return;
|
||||
|
|
@ -1449,13 +1499,14 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
if (widget.onLongPress != null) {
|
||||
if (widget.onLongPress !=
|
||||
null) {
|
||||
widget.onLongPress!(
|
||||
context, message);
|
||||
return;
|
||||
}
|
||||
if (widget.allowLongPress &&
|
||||
PlatformUtils().isMobile) {
|
||||
!isDesktopScreen) {
|
||||
_onOpenToolTip(
|
||||
context,
|
||||
message,
|
||||
|
|
@ -1476,7 +1527,8 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
widget.isUseDefaultEmoji,
|
||||
customEmojiStickerList:
|
||||
widget.customEmojiStickerList,
|
||||
isFromSelf: message.isSelf ?? true,
|
||||
isFromSelf: message.isSelf ??
|
||||
true,
|
||||
isShowJump: false,
|
||||
clearJump: () {},
|
||||
chatModel: model)
|
||||
|
|
@ -1486,7 +1538,8 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
),
|
||||
if (!isSelf &&
|
||||
message.elemType ==
|
||||
MessageElemType.V2TIM_ELEM_TYPE_SOUND &&
|
||||
MessageElemType
|
||||
.V2TIM_ELEM_TYPE_SOUND &&
|
||||
message.localCustomInt != null &&
|
||||
message.localCustomInt !=
|
||||
HistoryMessageDartConstant.read)
|
||||
|
|
@ -1494,7 +1547,8 @@ class _TIMUIKItHistoryMessageListItemState
|
|||
padding: const EdgeInsets.only(
|
||||
left: 5, bottom: 12),
|
||||
child: Icon(Icons.circle,
|
||||
color: theme.cautionColor, size: 10)),
|
||||
color: theme.cautionColor,
|
||||
size: 10)),
|
||||
if (!isSelf)
|
||||
renderHoverTipAndReadStatus(
|
||||
model,
|
||||
|
|
|
|||
|
|
@ -351,7 +351,9 @@ class TIMUIKitMessageTooltipState
|
|||
children: [
|
||||
Image.asset(
|
||||
item.iconImageAsset,
|
||||
package: 'tencent_cloud_chat_uikit',
|
||||
package: defaultTipsIds.contains(item.id)
|
||||
? 'tencent_cloud_chat_uikit'
|
||||
: null,
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
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/screen_utils.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> {
|
||||
MessageRepliedData? repliedMessage;
|
||||
MessageRepliedData? repliedMessage = null;
|
||||
V2TimMessage? rawMessage;
|
||||
bool isShowJumpState = false;
|
||||
bool isShining = false;
|
||||
|
|
@ -81,10 +82,32 @@ class _TIMUIKitReplyElemState extends TIMUIKitState<TIMUIKitReplyElem> {
|
|||
}
|
||||
|
||||
_getMessageByMessageID() async {
|
||||
final cloudCustomData = _getRepliedMessage();
|
||||
final MessageRepliedData? cloudCustomData = _getRepliedMessage();
|
||||
if (cloudCustomData != null) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
repliedMessage = cloudCustomData;
|
||||
});
|
||||
}
|
||||
|
||||
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 (mounted) {
|
||||
setState(() {
|
||||
|
|
@ -93,36 +116,53 @@ class _TIMUIKitReplyElemState extends TIMUIKitState<TIMUIKitReplyElem> {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
repliedMessage = cloudCustomData;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Widget _defaultRawMessageText(String text, TUITheme? theme) {
|
||||
return Text(text,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme?.weakTextColor,
|
||||
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) {
|
||||
if (repliedMessage == null) {
|
||||
return const SizedBox(width: 0, height: 12);
|
||||
}
|
||||
if (message == null) {
|
||||
if (repliedMessage?.messageAbstract != null) {
|
||||
return _defaultRawMessageText(repliedMessage!.messageAbstract, theme);
|
||||
_renderMessageSummary(theme);
|
||||
}
|
||||
return const SizedBox(width: 0, height: 12);
|
||||
}
|
||||
final messageType = message.elemType;
|
||||
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(
|
||||
widget.chatModel.abstractMessageBuilder!(message),
|
||||
customAbstractMessage,
|
||||
theme,
|
||||
);
|
||||
}
|
||||
|
|
@ -173,7 +213,7 @@ class _TIMUIKitReplyElemState extends TIMUIKitState<TIMUIKitReplyElem> {
|
|||
messageID: message.msgID ?? "",
|
||||
isSelf: isSelf);
|
||||
default:
|
||||
return _defaultRawMessageText(TIM_t("[未知消息]"), theme);
|
||||
return _renderMessageSummary(theme);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,6 +93,8 @@ class TIMUIKitInputTextField extends StatefulWidget {
|
|||
|
||||
final String? groupType;
|
||||
|
||||
final String? groupID;
|
||||
|
||||
const TIMUIKitInputTextField(
|
||||
{Key? key,
|
||||
required this.conversationID,
|
||||
|
|
@ -113,7 +115,8 @@ class TIMUIKitInputTextField extends StatefulWidget {
|
|||
required this.model,
|
||||
required this.currentConversation,
|
||||
this.groupType,
|
||||
this.atMemberPanelScroll})
|
||||
this.atMemberPanelScroll,
|
||||
this.groupID})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
|
|
@ -166,21 +169,22 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
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 conversationID = convID.contains("@TOPIC#")
|
||||
final isTopic = convID.contains("@TOPIC#");
|
||||
String conversationID = isTopic
|
||||
? convID
|
||||
: ((convType ?? widget.conversationType) == ConvType.c2c
|
||||
? "c2c_$convID"
|
||||
: "group_$convID");
|
||||
String text = textEditingController.text;
|
||||
String? draftText = _filterU200b(text);
|
||||
|
||||
if (draftText.isEmpty) {
|
||||
draftText = "";
|
||||
}
|
||||
await conversationModel.setConversationDraft(
|
||||
conversationID: conversationID, draftText: draftText);
|
||||
String draftText = _filterU200b(text);
|
||||
return await conversationModel.setConversationDraft(
|
||||
groupID: widget.groupID,
|
||||
isTopic: isTopic,
|
||||
isAllowWeb: widget.model.chatConfig.isUseDraftOnWeb,
|
||||
conversationID: conversationID,
|
||||
draftText: draftText);
|
||||
}
|
||||
|
||||
backSpaceText() {
|
||||
|
|
@ -189,11 +193,9 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
|
||||
if (originalText == zeroWidthSpace) {
|
||||
_handleSoftKeyBoardDelete();
|
||||
// _addDeleteTag();
|
||||
} else {
|
||||
text = originalText.characters.skipLast(1);
|
||||
textEditingController.text = text;
|
||||
// handleSetDraftText();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -202,6 +204,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
lastText = "";
|
||||
final text = textEditingController.text.trim();
|
||||
final convType = widget.conversationType;
|
||||
conversationModel.clearWebDraft(conversationID: widget.conversationID);
|
||||
if (text.isNotEmpty && text != zeroWidthSpace) {
|
||||
if (widget.model.repliedMessage != null) {
|
||||
MessageUtils.handleMessageError(
|
||||
|
|
@ -259,6 +262,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
}
|
||||
|
||||
onSubmitted() async {
|
||||
conversationModel.clearWebDraft(conversationID: widget.conversationID);
|
||||
lastText = "";
|
||||
final text = textEditingController.text.trim();
|
||||
final convType = widget.conversationType;
|
||||
|
|
@ -417,6 +421,22 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
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 {
|
||||
final text = textEditingController.text;
|
||||
String? groupID = widget.conversationType == ConvType.group
|
||||
|
|
@ -449,22 +469,11 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
textEditingController.selection =
|
||||
TextSelection.collapsed(offset: atIndex);
|
||||
lastText = newText;
|
||||
Map<String, V2TimGroupMemberFullInfo> map = {};
|
||||
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;
|
||||
updateMentionedMap();
|
||||
return;
|
||||
}
|
||||
}
|
||||
updateMentionedMap();
|
||||
}
|
||||
|
||||
final int selfRole = widget.model.selfMemberInfo?.role ?? 0;
|
||||
|
|
@ -709,8 +718,8 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
void didUpdateWidget(TIMUIKitInputTextField oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.conversationID != oldWidget.conversationID) {
|
||||
handleSetDraftText(oldWidget.conversationID, oldWidget.conversationType);
|
||||
mentionedMembersMap.clear();
|
||||
handleSetDraftText(oldWidget.conversationID, oldWidget.conversationType);
|
||||
if (oldWidget.initText != widget.initText) {
|
||||
textEditingController.text = widget.initText ?? "";
|
||||
} 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) {
|
||||
final haveRepliedMessage = repliedMessage != null;
|
||||
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 ?? [])}";
|
||||
"${MessageUtils.getDisplayName(
|
||||
widget.model.repliedMessage!)}:${getAbstractMessage(
|
||||
repliedMessage
|
||||
)}";
|
||||
return Container(
|
||||
color: widget.backgroundColor ?? hexToColor("f5f5f6"),
|
||||
alignment: Alignment.centerLeft,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'dart:ui' as ui;
|
||||
import 'package:fc_native_video_thumbnail/fc_native_video_thumbnail.dart';
|
||||
import 'package:flutter/services.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: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';
|
||||
|
|
@ -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) {
|
||||
final haveRepliedMessage = repliedMessage != null;
|
||||
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(
|
||||
color: widget.backgroundColor ?? hexToColor("f5f5f6"),
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
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(
|
||||
child: Text(
|
||||
text,
|
||||
softWrap: true,
|
||||
maxLines: 3,
|
||||
": ${getAbstractMessage(repliedMessage)}",
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: hexToColor("8f959e"), fontSize: 14),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: hexToColor("8f959e"),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
width: 8,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
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;
|
||||
}
|
||||
},
|
||||
initOffset: offset ??
|
||||
Offset(MediaQuery.of(context).size.height * 0.5 + 20,
|
||||
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(
|
||||
|
|
@ -793,7 +822,7 @@ class _TIMUIKitTextFieldLayoutWideState
|
|||
onClick: (offset) {
|
||||
_sendEmoji(offset, widget.theme);
|
||||
},
|
||||
svgPath: "images/svg/send_face.svg"),
|
||||
imgPath: "images/svg/send_face.png"),
|
||||
if (config.showScreenshotButton && PlatformUtils().isDesktop)
|
||||
DesktopControlBarItem(
|
||||
item: "screenShot",
|
||||
|
|
@ -950,6 +979,7 @@ class _TIMUIKitTextFieldLayoutWideState
|
|||
color: widget.backgroundColor ?? theme.desktopChatMessageInputBgColor,
|
||||
child: Column(
|
||||
children: [
|
||||
_buildRepliedMessage(widget.repliedMessage),
|
||||
SizedBox(
|
||||
height: 1,
|
||||
child: Container(
|
||||
|
|
@ -963,7 +993,6 @@ class _TIMUIKitTextFieldLayoutWideState
|
|||
children: generateControlBar(widget.model, theme),
|
||||
),
|
||||
),
|
||||
_buildRepliedMessage(widget.repliedMessage),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 6),
|
||||
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/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_conversation_view_model.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/controller/tim_uikit_chat_controller.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/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/tim_uikit_multi_select_panel.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;
|
||||
|
||||
/// 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;
|
||||
|
||||
/// The configuration for the whole `TIMUIKitChat` widget.
|
||||
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`
|
||||
final ValueChanged<String>? onDealWithGroupApplication;
|
||||
|
||||
/// The builder for abstract messages, normally used in replied message and forward message.
|
||||
final String Function(V2TimMessage message)? abstractMessageBuilder;
|
||||
/// The generator for the abstract summary preview of a message,
|
||||
/// 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.
|
||||
final ToolTipsConfig? toolTipsConfig;
|
||||
|
|
@ -140,8 +147,7 @@ class TIMUIKitChat extends StatefulWidget {
|
|||
/// Custom text field
|
||||
final Widget Function(BuildContext context)? textFieldBuilder;
|
||||
|
||||
TIMUIKitChat(
|
||||
{Key? key,
|
||||
TIMUIKitChat({Key? key,
|
||||
this.groupID,
|
||||
required this.conversation,
|
||||
this.conversationID,
|
||||
|
|
@ -150,12 +156,11 @@ class TIMUIKitChat extends StatefulWidget {
|
|||
this.abstractMessageBuilder,
|
||||
this.onTapAvatar,
|
||||
@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")
|
||||
this.showNickName = false,
|
||||
"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.showTotalUnReadCount = false,
|
||||
this.messageItemBuilder,
|
||||
@Deprecated("Please use [extraTipsActionItemBuilder] instead")
|
||||
this.exteraTipsActionItemBuilder,
|
||||
@Deprecated(
|
||||
"Please use [extraTipsActionItemBuilder] instead") this.exteraTipsActionItemBuilder,
|
||||
this.extraTipsActionItemBuilder,
|
||||
this.draftText,
|
||||
this.textFieldHintText,
|
||||
|
|
@ -178,7 +183,9 @@ class TIMUIKitChat extends StatefulWidget {
|
|||
this.customAppBar,
|
||||
this.onSecondaryTapAvatar})
|
||||
: super(key: key) {
|
||||
startTime = DateTime.now().millisecondsSinceEpoch;
|
||||
startTime = DateTime
|
||||
.now()
|
||||
.millisecondsSinceEpoch;
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -188,6 +195,8 @@ class TIMUIKitChat extends StatefulWidget {
|
|||
class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||
TUIChatSeparateViewModel model = TUIChatSeparateViewModel();
|
||||
final TUIThemeViewModel themeViewModel = serviceLocator<TUIThemeViewModel>();
|
||||
final TUIConversationViewModel conversationViewModel =
|
||||
serviceLocator<TUIConversationViewModel>();
|
||||
final TIMUIKitInputTextFieldController textFieldController =
|
||||
TIMUIKitInputTextFieldController();
|
||||
bool isInit = false;
|
||||
|
|
@ -200,13 +209,19 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
|||
|
||||
late AutoScrollController autoController = AutoScrollController(
|
||||
viewportBoundaryGetter: () =>
|
||||
Rect.fromLTRB(0, 0, 0, MediaQuery.of(context).padding.bottom),
|
||||
Rect.fromLTRB(0, 0, 0, MediaQuery
|
||||
.of(context)
|
||||
.padding
|
||||
.bottom),
|
||||
axis: Axis.vertical,
|
||||
);
|
||||
|
||||
late AutoScrollController atMemberPanelScroll = AutoScrollController(
|
||||
viewportBoundaryGetter: () =>
|
||||
Rect.fromLTRB(0, 0, 0, MediaQuery.of(context).padding.bottom),
|
||||
Rect.fromLTRB(0, 0, 0, MediaQuery
|
||||
.of(context)
|
||||
.padding
|
||||
.bottom),
|
||||
axis: Axis.vertical,
|
||||
);
|
||||
|
||||
|
|
@ -220,11 +235,16 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
|||
model.onTapAvatar = widget.onTapAvatar;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
if (kProfileMode) {
|
||||
widget.endTime = DateTime.now().millisecondsSinceEpoch;
|
||||
widget.endTime = DateTime
|
||||
.now()
|
||||
.millisecondsSinceEpoch;
|
||||
int timeSpend = widget.endTime - widget.startTime;
|
||||
print("Page render time:$timeSpend ms");
|
||||
}
|
||||
});
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
updateDraft();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -245,8 +265,8 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
|||
model = TUIChatSeparateViewModel();
|
||||
model.abstractMessageBuilder = widget.abstractMessageBuilder;
|
||||
model.onTapAvatar = widget.onTapAvatar;
|
||||
textFieldController.requestFocus();
|
||||
Future.delayed(const Duration(milliseconds: 50), () {
|
||||
updateDraft();
|
||||
textFieldController.requestFocus();
|
||||
try {
|
||||
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) {
|
||||
String option1 = amount.toString();
|
||||
return Container(
|
||||
|
|
@ -436,10 +472,12 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
|||
widget.config!.isUseDefaultEmoji,
|
||||
key: listContainerKey,
|
||||
isAllowScroll: true,
|
||||
userAvatarBuilder: widget.userAvatarBuilder,
|
||||
userAvatarBuilder: widget
|
||||
.userAvatarBuilder,
|
||||
toolTipsConfig: widget.toolTipsConfig,
|
||||
groupAtInfoList: widget.groupAtInfoList,
|
||||
tongueItemBuilder: widget.tongueItemBuilder,
|
||||
tongueItemBuilder: widget
|
||||
.tongueItemBuilder,
|
||||
onLongPressForOthersHeadPortrait:
|
||||
(String? userId, String? nickName) {
|
||||
textFieldController.longPressToAt(
|
||||
|
|
@ -473,6 +511,7 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
|||
: (widget.textFieldBuilder != null
|
||||
? widget.textFieldBuilder!(context)
|
||||
: TIMUIKitInputTextField(
|
||||
groupID: widget.groupID,
|
||||
atMemberPanelScroll:
|
||||
atMemberPanelScroll,
|
||||
groupType:
|
||||
|
|
@ -492,8 +531,15 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
|||
scrollController: autoController,
|
||||
conversationID: _getConvID(),
|
||||
conversationType: _getConvType(),
|
||||
initText: widget.draftText ??
|
||||
widget.conversation.draftText,
|
||||
initText: TencentUtils.checkString(
|
||||
widget.draftText) ?? (PlatformUtils().isWeb
|
||||
? TencentUtils.checkString(
|
||||
conversationViewModel.getWebDraft(
|
||||
conversationID: widget.conversation
|
||||
.conversationID))
|
||||
:
|
||||
TencentUtils.checkString(widget
|
||||
.conversation.draftText)),
|
||||
hintText: widget.textFieldHintText,
|
||||
showMorePanel: widget.config
|
||||
?.isAllowShowMorePanel ??
|
||||
|
|
@ -566,8 +612,7 @@ class TIMUIKitChatProviderScope extends StatelessWidget {
|
|||
|
||||
final AutoScrollController? scrollController;
|
||||
|
||||
TIMUIKitChatProviderScope(
|
||||
{Key? key,
|
||||
TIMUIKitChatProviderScope({Key? key,
|
||||
this.child,
|
||||
this.providers,
|
||||
this.textFieldController,
|
||||
|
|
|
|||
|
|
@ -185,6 +185,12 @@ class TIMUIKitChatConfig {
|
|||
/// Define the lines in the text message input field on Desktop.
|
||||
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(
|
||||
{this.onTapLink,
|
||||
this.timeDividerConfig,
|
||||
|
|
@ -220,6 +226,7 @@ class TIMUIKitChatConfig {
|
|||
this.isShowReadingStatus = true,
|
||||
this.desktopControlBarConfig,
|
||||
this.isAllowLongPressMessage = true,
|
||||
this.isUseDraftOnWeb = true,
|
||||
this.isAllowClickAvatar = true,
|
||||
this.isEnableTextSelection,
|
||||
this.additionalDesktopMessageHoverBarItem,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||
|
||||
class MessageRepliedData {
|
||||
late String messageAbstract;
|
||||
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 {
|
||||
Map<String, dynamic>? messageReply;
|
||||
Map<String, dynamic>? messageReaction = {};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ class LinkPreviewEntry {
|
|||
return isMarkdown
|
||||
? LinkTextMarkdown(
|
||||
isEnableTextSelection: isEnableTextSelection,
|
||||
messageText: replaceSingleNewlineWithTwo(messageText),
|
||||
messageText: addSpaceAfterLeftBracket(
|
||||
addSpaceBeforeHttp(replaceSingleNewlineWithTwo(messageText))),
|
||||
style: style,
|
||||
onLinkTap: onLinkTap)
|
||||
: 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) {
|
||||
return inputText.replaceAllMapped(
|
||||
RegExp(r'(?<!\n)\n(?!\n)'),
|
||||
(match) => '\n\n',
|
||||
return inputText.split('\n').join('\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_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:markdown/markdown.dart' as md;
|
||||
|
||||
class LinkTextMarkdown extends TIMStatelessWidget {
|
||||
/// Callback for when link is tapped
|
||||
|
|
@ -40,6 +41,7 @@ class LinkTextMarkdown extends TIMStatelessWidget {
|
|||
.copyWith(
|
||||
a: TextStyle(color: LinkUtils.hexToColor("015fff")),
|
||||
),
|
||||
extensionSet: md.ExtensionSet.gitHubWeb,
|
||||
onTapLink: (
|
||||
String link,
|
||||
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 {
|
||||
static OverlayEntry? entry;
|
||||
static bool isShow = false;
|
||||
|
||||
static showSecondaryConfirmDialog({
|
||||
required TUIKitWideModalOperationKey operationKey,
|
||||
|
|
@ -56,11 +57,15 @@ class TUIKitWidePopup {
|
|||
VoidCallback? onConfirm,
|
||||
VoidCallback? onCancel,
|
||||
}) async {
|
||||
if (isShow) {
|
||||
return;
|
||||
}
|
||||
isShow = true;
|
||||
|
||||
final TUISelfInfoViewModel selfInfoViewModel =
|
||||
serviceLocator<TUISelfInfoViewModel>();
|
||||
|
||||
if(selfInfoViewModel.globalConfig?.showDesktopModalFunc != null){
|
||||
if (selfInfoViewModel.globalConfig?.showDesktopModalFunc != null) {
|
||||
final res = await selfInfoViewModel.globalConfig!.showDesktopModalFunc!(
|
||||
operationKey,
|
||||
context,
|
||||
|
|
@ -76,34 +81,16 @@ class TUIKitWidePopup {
|
|||
onSubmit,
|
||||
submitWidget,
|
||||
onConfirm,
|
||||
onCancel
|
||||
);
|
||||
onCancel);
|
||||
|
||||
if(res == true){
|
||||
if (res == true) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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: Container(
|
||||
final isUseMaterialAlert = (offset == null);
|
||||
|
||||
final Widget contentWidget = Container(
|
||||
width: width,
|
||||
height: height,
|
||||
decoration: BoxDecoration(
|
||||
|
|
@ -113,11 +100,10 @@ class TUIKitWidePopup {
|
|||
border: isDarkBackground
|
||||
? Border.all(
|
||||
width: 2,
|
||||
color:
|
||||
theme?.weakBackgroundColor ?? const Color(0xFFbebebe),
|
||||
color: theme?.weakBackgroundColor ?? const Color(0xFFbebebe),
|
||||
)
|
||||
: null,
|
||||
boxShadow: isDarkBackground
|
||||
boxShadow: (isDarkBackground || isUseMaterialAlert)
|
||||
? null
|
||||
: const [
|
||||
BoxShadow(
|
||||
|
|
@ -147,16 +133,20 @@ class TUIKitWidePopup {
|
|||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
color: theme?.darkTextColor ??
|
||||
const Color(0xFF444444)),
|
||||
color: theme?.darkTextColor ?? const Color(0xFF444444)),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (onSubmit != null) {
|
||||
onSubmit();
|
||||
}
|
||||
isShow = false;
|
||||
if (offset == null) {
|
||||
Navigator.pop(context);
|
||||
} else {
|
||||
entry?.remove();
|
||||
entry = null;
|
||||
}
|
||||
},
|
||||
child: onSubmit != null
|
||||
? (submitWidget ?? const Icon(Icons.check))
|
||||
|
|
@ -174,13 +164,23 @@ class TUIKitWidePopup {
|
|||
),
|
||||
if (height != null && width != null)
|
||||
Expanded(child: child(() {
|
||||
isShow = false;
|
||||
if (isUseMaterialAlert) {
|
||||
Navigator.pop(context);
|
||||
} else {
|
||||
entry?.remove();
|
||||
entry = null;
|
||||
}
|
||||
})),
|
||||
if (height == null || width == null)
|
||||
child(() {
|
||||
isShow = false;
|
||||
if (isUseMaterialAlert) {
|
||||
Navigator.pop(context);
|
||||
} else {
|
||||
entry?.remove();
|
||||
entry = null;
|
||||
}
|
||||
}),
|
||||
if (onCancel != null || onConfirm != null)
|
||||
Container(
|
||||
|
|
@ -193,15 +193,19 @@ class TUIKitWidePopup {
|
|||
margin: const EdgeInsets.only(right: 16),
|
||||
child: OutlinedButton(
|
||||
onPressed: () {
|
||||
isShow = false;
|
||||
if (isUseMaterialAlert) {
|
||||
Navigator.pop(context);
|
||||
} else {
|
||||
entry?.remove();
|
||||
entry = null;
|
||||
}
|
||||
onCancel();
|
||||
},
|
||||
child: Text(
|
||||
TIM_t("取消"),
|
||||
style: TextStyle(
|
||||
color:
|
||||
theme?.weakTextColor ?? Colors.black),
|
||||
color: theme?.weakTextColor ?? Colors.black),
|
||||
)),
|
||||
),
|
||||
if (onConfirm != null)
|
||||
|
|
@ -209,8 +213,13 @@ class TUIKitWidePopup {
|
|||
margin: const EdgeInsets.only(right: 16),
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
isShow = false;
|
||||
if (isUseMaterialAlert) {
|
||||
Navigator.pop(context);
|
||||
} else {
|
||||
entry?.remove();
|
||||
entry = null;
|
||||
}
|
||||
onConfirm();
|
||||
},
|
||||
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!);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.1.0+2
|
||||
version: 2.1.1
|
||||
homepage: https://www.tencentcloud.com/products/im?from=pub
|
||||
repository: https://github.com/TencentCloud/tc-chat-uikit-flutter
|
||||
documentation: https://comm.qq.com/im/doc/flutter/en/TUIKit/readme.html
|
||||
|
|
|
|||
Loading…
Reference in New Issue