feat: Upgrade to 2.4.1+1

This commit is contained in:
anonymous 2023-12-19 16:22:12 +08:00
parent f22c812070
commit d78300178c
10 changed files with 443 additions and 802 deletions

View File

@ -1,3 +1,9 @@
# 2.4.1
## Bug Fixes
* Fixed some bugs.
# 2.4.0 # 2.4.0
## Breaking Changes ## Breaking Changes

View File

@ -285,18 +285,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: extended_image name: extended_image
sha256: d1b122d6f5cf5596ea61d703d116d89e2ece7e324db414cfeed12967b72b7aef sha256: d7f091d068fcac7246c4b22a84b8dac59a62e04d29a5c172710c696e67a22f94
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "8.1.0" version: "8.2.0"
extended_image_library: extended_image_library:
dependency: transitive dependency: transitive
description: description:
name: extended_image_library name: extended_image_library
sha256: "8bf87c0b14dcb59200c923a9a3952304e4732a0901e40811428834ef39018ee1" sha256: "9b55fc5ebc65fad984de66b8f177a1bef2a84d79203c9c213f75ff83c2c29edd"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.6.0" version: "4.0.1"
extended_text: extended_text:
dependency: transitive dependency: transitive
description: description:
@ -1227,7 +1227,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "2.3.3+1" version: "2.4.1"
tencent_cloud_uikit_core: tencent_cloud_uikit_core:
dependency: transitive dependency: transitive
description: description:

View File

@ -81,8 +81,8 @@ class TUIChatModelTools {
} }
return OfflinePushInfo.fromJson({ return OfflinePushInfo.fromJson({
"title": "title", "title": title,
"desc": "desc", "desc": desc,
"disablePush": false, "disablePush": false,
"ext": ext, "ext": ext,
"iOSSound": globalModel.chatConfig.notificationIOSSound, "iOSSound": globalModel.chatConfig.notificationIOSSound,

View File

@ -1096,10 +1096,12 @@ class _TIMUIKItHistoryMessageListItemState
final customHoverBar = widget.customMessageHoverBarOnDesktop != null final customHoverBar = widget.customMessageHoverBarOnDesktop != null
? widget.customMessageHoverBarOnDesktop!(message) ? widget.customMessageHoverBarOnDesktop!(message)
: null; : null;
final wideHoverTipList = (model.chatConfig.isUseMessageHoverBarOnDesktop && final wideHoverTipList = (model.chatConfig.isUseMessageHoverBarOnDesktop &&
customHoverBar == null) customHoverBar == null)
? getMessageHoverControlBar(model, theme) ? getMessageHoverControlBar(model, theme)
: []; : [];
final lastItemName = final lastItemName =
wideHoverTipList.isNotEmpty ? wideHoverTipList.last.name : ""; wideHoverTipList.isNotEmpty ? wideHoverTipList.last.name : "";
return Column( return Column(
@ -1318,8 +1320,11 @@ class _TIMUIKItHistoryMessageListItemState
onExit: (_) { onExit: (_) {
if (isDesktopScreen && if (isDesktopScreen &&
model.chatConfig.isUseMessageHoverBarOnDesktop) { model.chatConfig.isUseMessageHoverBarOnDesktop) {
setState(() { Tooltip.dismissAllToolTips();
isShowWideToolTip = false; Future.delayed(const Duration(milliseconds: 100), () {
setState(() {
isShowWideToolTip = false;
});
}); });
} }
}, },

View File

@ -1,7 +1,9 @@
// ignore_for_file: unused_field // ignore_for_file: unused_field
import 'package:collection/collection.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
import 'package:tencent_im_base/tencent_im_base.dart'; import 'package:tencent_im_base/tencent_im_base.dart';
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart'; import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart'; import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
@ -64,6 +66,20 @@ class TIMUIKitMessageReactionShowItem extends TIMUIKitStatelessWidget {
final option1 = nameList.length; final option1 = nameList.length;
final TUIChatSeparateViewModel model = final TUIChatSeparateViewModel model =
Provider.of<TUIChatSeparateViewModel>(context); Provider.of<TUIChatSeparateViewModel>(context);
final List<String> userIDs = [];
for (final user in nameList) {
final V2TimGroupMemberFullInfo? memberInfo = memberList
.firstWhereOrNull((element) => element?.userID == user && TencentUtils.checkString(user) != null);
if((memberInfo == null || TencentUtils.checkString(memberInfo.userID) == null) && TencentUtils.checkString(user.toString()) != null){
userIDs.add(user.toString());
}
}
if(userIDs.isNotEmpty){
model.getUserShowName(userIDs);
}
return LayoutBuilder(builder: (context, constraints) { return LayoutBuilder(builder: (context, constraints) {
return Container( return Container(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
@ -140,9 +156,22 @@ class TIMUIKitMessageReactionShowItem extends TIMUIKitStatelessWidget {
} else { } else {
showName = memberInfo.userID; showName = memberInfo.userID;
} }
}else{
final String? data = model.groupUserShowName[e];
if(TencentUtils.checkString(data) != null){
showName = data ?? e;
}
} }
} catch (e) { } catch (error) {
// e final String? data = model.groupUserShowName[e];
if(TencentUtils.checkString(data) != null){
showName = data ?? e;
}
}
}else{
final String? data = model.groupUserShowName[e];
if(TencentUtils.checkString(data) != null){
showName = data ?? e;
} }
} }
return InkWell( return InkWell(

View File

@ -373,69 +373,74 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
infoCode: 6660416)); infoCode: 6660416));
} }
}, },
child: Container( child: ConstrainedBox(
width: 237, constraints: const BoxConstraints(maxHeight: 72),
decoration: BoxDecoration( child: Container(
border: Border.all( width: 237,
color: theme.weakDividerColor ?? decoration: BoxDecoration(
CommonColor.weakDividerColor, border: Border.all(
color: theme.weakDividerColor ??
CommonColor.weakDividerColor,
),
borderRadius: borderRadius),
child: Stack(children: [
ClipRRect(
borderRadius: borderRadius,
child: LinearProgressIndicator(
minHeight: ((containerHeight) ?? 72) - 6,
value: (received == 100 ? 0 : received) / 100,
backgroundColor: received == 100
? theme.weakBackgroundColor
: Colors.white,
valueColor: AlwaysStoppedAnimation(
theme.lightPrimaryMaterialColor.shade50),),
), ),
borderRadius: borderRadius), Padding(
child: Stack(children: [ padding: const EdgeInsets.symmetric(
ClipRRect( vertical: 8, horizontal: 12),
borderRadius: borderRadius, child: Row(
child: LinearProgressIndicator( mainAxisAlignment: widget.isSelf
minHeight: ((containerHeight) ?? 72) - 6, ? MainAxisAlignment.end
value: (received == 100 ? 0 : received) / 100, : MainAxisAlignment.start,
backgroundColor: received == 100 children: [
? theme.weakBackgroundColor Expanded(
: Colors.white, child: Column(
valueColor: AlwaysStoppedAnimation( crossAxisAlignment: CrossAxisAlignment.start,
theme.lightPrimaryMaterialColor.shade50)), children: [
), Container(
Padding( constraints:
padding: const EdgeInsets.symmetric( const BoxConstraints(maxWidth: 160),
vertical: 8, horizontal: 12), child: LayoutBuilder(
child: Row( builder: (buildContext, boxConstraints) {
mainAxisAlignment: widget.isSelf return CustomText(
? MainAxisAlignment.end fileName,
: MainAxisAlignment.start, width: boxConstraints.maxWidth,
children: [ maxLines: 1,
Expanded( style: TextStyle(
child: Column( color: theme.darkTextColor,
crossAxisAlignment: CrossAxisAlignment.start, fontSize: 16,
children: [ ),
Container( );
constraints: },
const BoxConstraints(maxWidth: 160),
child: LayoutBuilder(
builder: (buildContext, boxConstraints) {
return CustomText(
fileName,
width: boxConstraints.maxWidth,
style: TextStyle(
color: theme.darkTextColor,
fontSize: 16,
), ),
); ),
}, if (fileSize != null)
), Text(
), showFileSize(fileSize),
if (fileSize != null) style: TextStyle(
Text( fontSize: 14,
showFileSize(fileSize), color: theme.weakTextColor),
style: TextStyle( )
fontSize: 14, ],
color: theme.weakTextColor), )),
) TIMUIKitFileIcon(
], fileFormat: fileFormat,
)), ),
TIMUIKitFileIcon( ])),
fileFormat: fileFormat, ]),
), ),
])), ),
]), )),
))),
if (!widget.isSelf && isWebDownloading) if (!widget.isSelf && isWebDownloading)
Container( Container(
margin: const EdgeInsets.only(top: 2), margin: const EdgeInsets.only(top: 2),

View File

@ -1,15 +1,21 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'dart:math'; import 'dart:math';
// ignore: unnecessary_import
import 'dart:typed_data';
import 'package:extended_text_field/extended_text_field.dart';
import 'package:fc_native_video_thumbnail/fc_native_video_thumbnail.dart'; import 'package:fc_native_video_thumbnail/fc_native_video_thumbnail.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:image_picker/image_picker.dart';
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:pasteboard/pasteboard.dart'; import 'package:pasteboard/pasteboard.dart';
import 'package:path/path.dart' as p; import 'package:path/path.dart' as p;
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart'; import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart'; import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
@ -19,23 +25,18 @@ import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_setting_
import 'package:tencent_cloud_chat_uikit/data_services/core/tim_uikit_wide_modal_operation_key.dart'; import 'package:tencent_cloud_chat_uikit/data_services/core/tim_uikit_wide_modal_operation_key.dart';
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart'; import 'package:tencent_cloud_chat_uikit/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/utils/logger.dart';
import 'package:tencent_cloud_chat_uikit/ui/utils/message.dart'; import 'package:tencent_cloud_chat_uikit/ui/utils/message.dart';
import 'package:tencent_cloud_chat_uikit/ui/utils/optimize_utils.dart'; import 'package:tencent_cloud_chat_uikit/ui/utils/optimize_utils.dart';
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_shot.dart';
import 'package:tencent_cloud_chat_uikit/ui/widgets/wide_popup.dart';
import 'package:tencent_cloud_chat_uikit/ui/utils/platform.dart'; import 'package:tencent_cloud_chat_uikit/ui/utils/platform.dart';
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_shot.dart';
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/special_text/DefaultSpecialTextSpanBuilder.dart'; import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/special_text/DefaultSpecialTextSpanBuilder.dart';
import 'package:tencent_cloud_chat_uikit/ui/widgets/drag_widget.dart'; import 'package:tencent_cloud_chat_uikit/ui/widgets/drag_widget.dart';
import 'package:extended_text_field/extended_text_field.dart'; import 'package:tencent_cloud_chat_uikit/ui/widgets/wide_popup.dart';
import 'package:universal_html/html.dart' as html; import 'package: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
import 'dart:typed_data';
import 'package:tencent_cloud_chat_uikit/ui/utils/logger.dart';
class DesktopControlBarItem { class DesktopControlBarItem {
final String item; final String item;
@ -47,18 +48,8 @@ class DesktopControlBarItem {
final String? showName; final String? showName;
final double? size; final double? size;
DesktopControlBarItem( DesktopControlBarItem({required this.item, this.icon, this.color, this.imgPath, this.svgPath, required this.onClick, this.showName, this.size})
{required this.item, : assert(icon != null || TencentUtils.checkString(imgPath) != null || TencentUtils.checkString(svgPath) != null);
this.icon,
this.color,
this.imgPath,
this.svgPath,
required this.onClick,
this.showName,
this.size})
: assert(icon != null ||
TencentUtils.checkString(imgPath) != null ||
TencentUtils.checkString(svgPath) != null);
} }
class DesktopControlBarConfig { class DesktopControlBarConfig {
@ -193,12 +184,10 @@ class TIMUIKitTextFieldLayoutWide extends StatefulWidget {
: super(key: key); : super(key: key);
@override @override
State<TIMUIKitTextFieldLayoutWide> createState() => State<TIMUIKitTextFieldLayoutWide> createState() => _TIMUIKitTextFieldLayoutWideState();
_TIMUIKitTextFieldLayoutWideState();
} }
class _TIMUIKitTextFieldLayoutWideState class _TIMUIKitTextFieldLayoutWideState extends TIMUIKitState<TIMUIKitTextFieldLayoutWide> {
extends TIMUIKitState<TIMUIKitTextFieldLayoutWide> {
final TUISettingModel settingModel = serviceLocator<TUISettingModel>(); final TUISettingModel settingModel = serviceLocator<TUISettingModel>();
OverlayEntry? entry; OverlayEntry? entry;
final ImagePicker _picker = ImagePicker(); final ImagePicker _picker = ImagePicker();
@ -272,13 +261,8 @@ class _TIMUIKitTextFieldLayoutWideState
} }
String getAbstractMessage(V2TimMessage message) { String getAbstractMessage(V2TimMessage message) {
final String? customAbstractMessage = final String? customAbstractMessage = widget.model.abstractMessageBuilder != null ? widget.model.abstractMessageBuilder!(widget.model.repliedMessage!) : null;
widget.model.abstractMessageBuilder != null return customAbstractMessage ?? MessageUtils.getAbstractMessageAsync(widget.model.repliedMessage!, widget.model.groupMemberList ?? []);
? widget.model.abstractMessageBuilder!(widget.model.repliedMessage!)
: null;
return customAbstractMessage ??
MessageUtils.getAbstractMessageAsync(
widget.model.repliedMessage!, widget.model.groupMemberList ?? []);
} }
_buildRepliedMessage(V2TimMessage? repliedMessage) { _buildRepliedMessage(V2TimMessage? repliedMessage) {
@ -301,10 +285,7 @@ class _TIMUIKitTextFieldLayoutWideState
softWrap: true, softWrap: true,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(color: hexToColor("8f959e"), fontSize: 14, fontWeight: FontWeight.bold),
color: hexToColor("8f959e"),
fontSize: 14,
fontWeight: FontWeight.bold),
), ),
Expanded( Expanded(
child: Text( child: Text(
@ -347,10 +328,8 @@ class _TIMUIKitTextFieldLayoutWideState
entry = null; entry = null;
} }
}, },
initOffset: offset != null initOffset:
? Offset(offset.dx, max(offset.dy, 16)) 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),
: Offset(MediaQuery.of(context).size.height * 0.5 + 20,
MediaQuery.of(context).size.height * 0.5 - 100),
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(8)), borderRadius: const BorderRadius.all(Radius.circular(8)),
@ -390,60 +369,55 @@ class _TIMUIKitTextFieldLayoutWideState
String? emojiName = singleEmojiName.split('.png')[0]; String? emojiName = singleEmojiName.split('.png')[0];
if (widget.isUseDefaultEmoji && if (widget.isUseDefaultEmoji &&
widget.languageType == 'zh' && widget.languageType == 'zh' &&
TUIKitStickerConstData.emojiMapList[emojiName] != TUIKitStickerConstData.emojiMapList[emojiName] != null &&
null && TUIKitStickerConstData.emojiMapList[emojiName] != '') {
TUIKitStickerConstData.emojiMapList[emojiName] != emojiName = TUIKitStickerConstData.emojiMapList[emojiName];
'') {
emojiName =
TUIKitStickerConstData.emojiMapList[emojiName];
} }
final newText = '[$emojiName]'; final newText = '[$emojiName]';
widget.addStickerToText(newText); widget.addStickerToText(newText);
entry?.remove(); entry?.remove();
entry = null; entry = null;
}), }),
defaultCustomEmojiStickerList: widget.isUseDefaultEmoji defaultCustomEmojiStickerList: widget.isUseDefaultEmoji ? TUIKitStickerConstData.emojiList : [])
? TUIKitStickerConstData.emojiList : Material(
: []) color: Colors.transparent,
: StickerPanel( child: StickerPanel(
isWideScreen: true, isWideScreen: true,
height: widget.chatConfig.desktopStickerPanelHeight, height: widget.chatConfig.desktopStickerPanelHeight,
width: 350, width: 350,
sendTextMsg: null, sendTextMsg: null,
sendFaceMsg: (_, __){ sendFaceMsg: (_, __) {
widget.onCustomEmojiFaceSubmitted(_, __); widget.onCustomEmojiFaceSubmitted(_, __);
entry?.remove(); entry?.remove();
entry = null; entry = null;
}, },
deleteText: () { deleteText: () {
widget.backSpaceText(); widget.backSpaceText();
}, },
addText: (int unicode) { addText: (int unicode) {
final newText = String.fromCharCode(unicode); final newText = String.fromCharCode(unicode);
widget.addStickerToText(newText); widget.addStickerToText(newText);
entry?.remove(); entry?.remove();
entry = null; entry = null;
}, },
addCustomEmojiText: ((String singleEmojiName) { addCustomEmojiText: ((String singleEmojiName) {
String? emojiName = singleEmojiName.split('.png')[0]; String? emojiName = singleEmojiName.split('.png')[0];
if (widget.isUseDefaultEmoji && if (widget.isUseDefaultEmoji &&
widget.languageType == 'zh' && widget.languageType == 'zh' &&
TUIKitStickerConstData.emojiMapList[emojiName] != TUIKitStickerConstData.emojiMapList[emojiName] != null &&
null && TUIKitStickerConstData.emojiMapList[emojiName] != '') {
TUIKitStickerConstData.emojiMapList[emojiName] != emojiName = TUIKitStickerConstData.emojiMapList[emojiName];
'') { }
emojiName = final newText = '[$emojiName]';
TUIKitStickerConstData.emojiMapList[emojiName]; widget.addStickerToText(newText);
} entry?.remove();
final newText = '[$emojiName]'; entry = null;
widget.addStickerToText(newText); }),
entry?.remove(); customStickerPackageList: widget.stickerPackageList,
entry = null; bottomColor: theme.weakBackgroundColor,
}), backgroundColor: theme.wideBackgroundColor,
customStickerPackageList: widget.stickerPackageList, lightPrimaryColor: theme.lightPrimaryColor),
bottomColor: theme.weakBackgroundColor, ),
backgroundColor: theme.wideBackgroundColor,
lightPrimaryColor: theme.lightPrimaryColor),
), ),
)); ));
}); });
@ -485,30 +459,16 @@ class _TIMUIKitTextFieldLayoutWideState
if (result != null && result.files.isNotEmpty) { if (result != null && result.files.isNotEmpty) {
if (PlatformUtils().isWeb) { if (PlatformUtils().isWeb) {
html.Node? inputElem; html.Node? inputElem;
inputElem = html.document inputElem = html.document.getElementById("__file_picker_web-file-input")?.querySelector("input");
.getElementById("__file_picker_web-file-input")
?.querySelector("input");
fileName = result.files.single.name; fileName = result.files.single.name;
MessageUtils.handleMessageError( MessageUtils.handleMessageError(model.sendFileMessage(inputElement: inputElem, fileName: fileName, convID: convID, convType: convType), context);
model.sendFileMessage(
inputElement: inputElem,
fileName: fileName,
convID: convID,
convType: convType),
context);
} else { } else {
File file = File(result.files.single.path!); File file = File(result.files.single.path!);
final int size = file.lengthSync(); final int size = file.lengthSync();
final String savePath = file.path; final String savePath = file.path;
MessageUtils.handleMessageError( MessageUtils.handleMessageError(model.sendFileMessage(filePath: savePath, size: size, convID: convID, convType: convType), context);
model.sendFileMessage(
filePath: savePath,
size: size,
convID: convID,
convType: convType),
context);
} }
} else { } else {
throw TypeError(); throw TypeError();
@ -519,8 +479,7 @@ class _TIMUIKitTextFieldLayoutWideState
} }
} }
List<Widget> generateBarIcons( List<Widget> generateBarIcons(List<DesktopControlBarItem> items, TUITheme theme) {
List<DesktopControlBarItem> items, TUITheme theme) {
final defaultItems = defaultControlBarItems.map((e) => e.item); final defaultItems = defaultControlBarItems.map((e) => e.item);
return items.map((e) { return items.map((e) {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
@ -528,15 +487,10 @@ class _TIMUIKitTextFieldLayoutWideState
margin: const EdgeInsets.only(right: 10), margin: const EdgeInsets.only(right: 10),
child: InkWell( child: InkWell(
onTap: () { onTap: () {
final alignBox = final alignBox = key.currentContext?.findRenderObject() as RenderBox?;
key.currentContext?.findRenderObject() as RenderBox?;
var offset = alignBox?.localToGlobal(Offset.zero); var offset = alignBox?.localToGlobal(Offset.zero);
final double? dx = (offset?.dx != null) ? offset!.dx : null; final double? dx = (offset?.dx != null) ? offset!.dx : null;
final double? dy = final double? dy = (offset?.dy != null && alignBox?.size.height != null) ? offset!.dy - (widget.chatConfig.desktopStickerPanelHeight + 20) : null;
(offset?.dy != null && alignBox?.size.height != null)
? offset!.dy -
(widget.chatConfig.desktopStickerPanelHeight + 20)
: null;
e.onClick((dx != null && dy != null) ? Offset(dx, dy) : null); e.onClick((dx != null && dy != null) ? Offset(dx, dy) : null);
}, },
child: Tooltip( child: Tooltip(
@ -550,9 +504,7 @@ class _TIMUIKitTextFieldLayoutWideState
if (TencentUtils.checkString(e.svgPath) != null) { if (TencentUtils.checkString(e.svgPath) != null) {
return SvgPicture.asset( return SvgPicture.asset(
e.svgPath!, e.svgPath!,
package: defaultItems.contains(e.item) package: defaultItems.contains(e.item) ? 'tencent_cloud_chat_uikit' : null,
? 'tencent_cloud_chat_uikit'
: null,
key: key, key: key,
width: e.size ?? 16, width: e.size ?? 16,
height: e.size ?? 16, height: e.size ?? 16,
@ -561,9 +513,7 @@ class _TIMUIKitTextFieldLayoutWideState
if (TencentUtils.checkString(e.imgPath) != null) { if (TencentUtils.checkString(e.imgPath) != null) {
return Image.asset( return Image.asset(
e.imgPath!, e.imgPath!,
package: defaultItems.contains(e.item) package: defaultItems.contains(e.item) ? 'tencent_cloud_chat_uikit' : null,
? 'tencent_cloud_chat_uikit'
: null,
key: key, key: key,
width: e.size ?? 16, width: e.size ?? 16,
height: e.size ?? 16, height: e.size ?? 16,
@ -592,18 +542,10 @@ class _TIMUIKitTextFieldLayoutWideState
fileContent = imageContent; fileContent = imageContent;
html.Node? inputElem; html.Node? inputElem;
inputElem = html.document inputElem = html.document.getElementById("__image_picker_web-file-input")?.querySelector("input");
.getElementById("__image_picker_web-file-input")
?.querySelector("input");
final convID = widget.conversationID; final convID = widget.conversationID;
final convType = widget.conversationType; final convType = widget.conversationType;
MessageUtils.handleMessageError( MessageUtils.handleMessageError(model.sendImageMessage(inputElement: inputElem, imagePath: tempFile?.path, convID: convID, convType: convType), context);
model.sendImageMessage(
inputElement: inputElem,
imagePath: tempFile?.path,
convID: convID,
convType: convType),
context);
} catch (e) { } catch (e) {
// ignore: avoid_print // ignore: avoid_print
outputLogger.i("_sendFileErr: ${e.toString()}"); outputLogger.i("_sendFileErr: ${e.toString()}");
@ -619,26 +561,15 @@ class _TIMUIKitTextFieldLayoutWideState
fileContent = videoContent; fileContent = videoContent;
if (fileName!.split(".")[fileName!.split(".").length - 1] != "mp4") { if (fileName!.split(".")[fileName!.split(".").length - 1] != "mp4") {
onTIMCallback(TIMCallback( onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("视频消息仅限 mp4 格式"), infoCode: 6660412));
type: TIMCallbackType.INFO,
infoRecommendText: TIM_t("视频消息仅限 mp4 格式"),
infoCode: 6660412));
return; return;
} }
html.Node? inputElem; html.Node? inputElem;
inputElem = html.document inputElem = html.document.getElementById("__image_picker_web-file-input")?.querySelector("input");
.getElementById("__image_picker_web-file-input")
?.querySelector("input");
final convID = widget.conversationID; final convID = widget.conversationID;
final convType = widget.conversationType; final convType = widget.conversationType;
MessageUtils.handleMessageError( MessageUtils.handleMessageError(model.sendVideoMessage(inputElement: inputElem, videoPath: tempFile?.path, convID: convID, convType: convType), context);
model.sendVideoMessage(
inputElement: inputElem,
videoPath: tempFile?.path,
convID: convID,
convType: convType),
context);
} catch (e) { } catch (e) {
// ignore: avoid_print // ignore: avoid_print
outputLogger.i("_sendFileErr: ${e.toString()}"); outputLogger.i("_sendFileErr: ${e.toString()}");
@ -651,10 +582,7 @@ class _TIMUIKitTextFieldLayoutWideState
final originFile = await asset.originFile; final originFile = await asset.originFile;
final size = await originFile!.length(); final size = await originFile!.length();
if (size >= 104857600) { if (size >= 104857600) {
onTIMCallback(TIMCallback( onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("发送失败,视频不能大于100MB"), infoCode: 6660405));
type: TIMCallbackType.INFO,
infoRecommendText: TIM_t("发送失败,视频不能大于100MB"),
infoCode: 6660405));
return; return;
} }
@ -663,9 +591,7 @@ class _TIMUIKitTextFieldLayoutWideState
final convID = widget.conversationID; final convID = widget.conversationID;
final convType = widget.conversationType; final convType = widget.conversationType;
String tempPath = (await getTemporaryDirectory()).path + String tempPath = (await getTemporaryDirectory()).path + p.extension(originFile.path, 3) + ".jpeg";
p.extension(originFile.path, 3) +
".jpeg";
await plugin.getVideoThumbnail( await plugin.getVideoThumbnail(
srcFile: originFile.path, srcFile: originFile.path,
@ -676,24 +602,13 @@ class _TIMUIKitTextFieldLayoutWideState
quality: 100, quality: 100,
height: 128, height: 128,
); );
MessageUtils.handleMessageError( MessageUtils.handleMessageError(model.sendVideoMessage(videoPath: filePath, duration: duration, snapshotPath: tempPath, convID: convID, convType: convType), context);
model.sendVideoMessage(
videoPath: filePath,
duration: duration,
snapshotPath: tempPath,
convID: convID,
convType: convType),
context);
} catch (e) { } catch (e) {
onTIMCallback(TIMCallback( onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("视频文件异常"), infoCode: 6660415));
type: TIMCallbackType.INFO,
infoRecommendText: TIM_t("视频文件异常"),
infoCode: 6660415));
} }
} }
_sendMediaMessage( _sendMediaMessage(TUIChatSeparateViewModel model, TUITheme theme, FileType fileType) async {
TUIChatSeparateViewModel model, TUITheme theme, FileType fileType) async {
try { try {
final convID = widget.conversationID; final convID = widget.conversationID;
final convType = widget.conversationType; final convType = widget.conversationType;
@ -708,12 +623,7 @@ class _TIMUIKitTextFieldLayoutWideState
final type = asset.type; final type = asset.type;
if (filePath != null) { if (filePath != null) {
if (type == AssetType.image) { if (type == AssetType.image) {
MessageUtils.handleMessageError( MessageUtils.handleMessageError(model.sendImageMessage(imagePath: filePath, convID: convID, convType: convType), context);
model.sendImageMessage(
imagePath: filePath,
convID: convID,
convType: convType),
context);
} }
if (type == AssetType.video) { if (type == AssetType.video) {
@ -725,26 +635,17 @@ class _TIMUIKitTextFieldLayoutWideState
} else { } else {
final plugin = FcNativeVideoThumbnail(); final plugin = FcNativeVideoThumbnail();
_addGreyOverlay(); _addGreyOverlay();
FilePickerResult? result = FilePickerResult? result = await FilePicker.platform.pickFiles(type: fileType);
await FilePicker.platform.pickFiles(type: fileType);
_removeOverlay(); _removeOverlay();
if (result != null && result.files.isNotEmpty) { if (result != null && result.files.isNotEmpty) {
File file = File(result.files.single.path!); File file = File(result.files.single.path!);
final String savePath = file.path; final String savePath = file.path;
final String type = TencentUtils.getFileType( final String type = TencentUtils.getFileType((savePath.split(".")[savePath.split(".").length - 1]).toLowerCase()).split("/")[0];
(savePath.split(".")[savePath.split(".").length - 1])
.toLowerCase())
.split("/")[0];
if (type == "image") { if (type == "image") {
MessageUtils.handleMessageError( MessageUtils.handleMessageError(model.sendImageMessage(imagePath: savePath, convID: convID, convType: convType), context);
model.sendImageMessage(
imagePath: savePath, convID: convID, convType: convType),
context);
} else if (type == "video") { } else if (type == "video") {
String tempPath = (await getTemporaryDirectory()).path + String tempPath = (await getTemporaryDirectory()).path + p.basename(savePath) + ".jpeg";
p.basename(savePath) +
".jpeg";
await plugin.getVideoThumbnail( await plugin.getVideoThumbnail(
srcFile: savePath, srcFile: savePath,
keepAspectRatio: true, keepAspectRatio: true,
@ -754,13 +655,7 @@ class _TIMUIKitTextFieldLayoutWideState
quality: 100, quality: 100,
height: 128, height: 128,
); );
MessageUtils.handleMessageError( MessageUtils.handleMessageError(model.sendVideoMessage(videoPath: savePath, convID: convID, convType: convType, snapshotPath: tempPath), context);
model.sendVideoMessage(
videoPath: savePath,
convID: convID,
convType: convType,
snapshotPath: tempPath),
context);
} }
} else { } else {
throw TypeError(); throw TypeError();
@ -769,17 +664,12 @@ class _TIMUIKitTextFieldLayoutWideState
} catch (err) { } catch (err) {
// ignore: avoid_print // ignore: avoid_print
outputLogger.i("send media err: $err"); outputLogger.i("send media err: $err");
onTIMCallback(TIMCallback( onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("视频文件异常"), infoCode: 6660415));
type: TIMCallbackType.INFO,
infoRecommendText: TIM_t("视频文件异常"),
infoCode: 6660415));
} }
} }
_sendImageWithConfirmation( _sendImageWithConfirmation({String? fileName, Size? fileSize, required String filePath}) async {
{String? fileName, Size? fileSize, required String filePath}) async { final option1 = widget.currentConversation.showName ?? (widget.conversationType == ConvType.group ? TIM_t("群聊") : TIM_t("对方"));
final option1 = widget.currentConversation.showName ??
(widget.conversationType == ConvType.group ? TIM_t("群聊") : TIM_t("对方"));
final size = fileSize ?? await ScreenshotHelper.getImageSize(filePath); final size = fileSize ?? await ScreenshotHelper.getImageSize(filePath);
TUIKitWidePopup.showPopupWindow( TUIKitWidePopup.showPopupWindow(
@ -798,9 +688,7 @@ class _TIMUIKitTextFieldLayoutWideState
height: min(360, size.height / 2), height: min(360, size.height / 2),
child: InkWell( child: InkWell(
onTap: () { onTap: () {
launchUrl(PlatformUtils().isWeb launchUrl(PlatformUtils().isWeb ? Uri.parse(filePath) : Uri.file(filePath));
? Uri.parse(filePath)
: Uri.file(filePath));
}, },
child: PlatformUtils().isWeb child: PlatformUtils().isWeb
? Image.network( ? Image.network(
@ -828,12 +716,7 @@ class _TIMUIKitTextFieldLayoutWideState
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
MessageUtils.handleMessageError( MessageUtils.handleMessageError(
widget.model.sendImageMessage( widget.model.sendImageMessage(imagePath: filePath, imageName: fileName, convID: widget.conversationID, convType: widget.conversationType), context);
imagePath: filePath,
imageName: fileName,
convID: widget.conversationID,
convType: widget.conversationType),
context);
closeFunc(); closeFunc();
}, },
child: Text(TIM_t("发送"))) child: Text(TIM_t("发送")))
@ -852,8 +735,7 @@ class _TIMUIKitTextFieldLayoutWideState
} }
generateDefaultControlBarItems() { generateDefaultControlBarItems() {
final DesktopControlBarConfig config = final DesktopControlBarConfig config = widget.chatConfig.desktopControlBarConfig ?? DesktopControlBarConfig();
widget.chatConfig.desktopControlBarConfig ?? DesktopControlBarConfig();
final List<DesktopControlBarItem> itemsList = [ final List<DesktopControlBarItem> itemsList = [
if (config.showStickerPanel) if (config.showStickerPanel)
DesktopControlBarItem( DesktopControlBarItem(
@ -916,15 +798,8 @@ class _TIMUIKitTextFieldLayoutWideState
child: (onClose) => TIMUIKitSearchMsgDetail( child: (onClose) => TIMUIKitSearchMsgDetail(
currentConversation: widget.currentConversation, currentConversation: widget.currentConversation,
keyword: '', keyword: '',
initMessageList: widget.model initMessageList: widget.model.getOriginMessageList().getRange(0, min(widget.model.getOriginMessageList().length, 100)).toList(),
.getOriginMessageList() onTapConversation: (V2TimConversation conversation, V2TimMessage? message) {},
.getRange(
0,
min(widget.model.getOriginMessageList().length,
100))
.toList(),
onTapConversation: (V2TimConversation conversation,
V2TimMessage? message) {},
), ),
theme: widget.theme); theme: widget.theme);
}, },
@ -933,12 +808,8 @@ class _TIMUIKitTextFieldLayoutWideState
defaultControlBarItems = itemsList; defaultControlBarItems = itemsList;
} }
List<Widget> generateControlBar( List<Widget> generateControlBar(TUIChatSeparateViewModel model, TUITheme theme) {
TUIChatSeparateViewModel model, TUITheme theme) { final List<DesktopControlBarItem> itemsList = [...defaultControlBarItems, ...(widget.chatConfig.additionalDesktopControlBarItems ?? [])];
final List<DesktopControlBarItem> itemsList = [
...defaultControlBarItems,
...(widget.chatConfig.additionalDesktopControlBarItems ?? [])
];
return generateBarIcons(itemsList, theme); return generateBarIcons(itemsList, theme);
} }
@ -948,29 +819,22 @@ class _TIMUIKitTextFieldLayoutWideState
final type = mimeType[0]; final type = mimeType[0];
final blobUrl = html.Url.createObjectUrl(file); final blobUrl = html.Url.createObjectUrl(file);
if (type == 'image') { if (type == 'image') {
_sendImageWithConfirmation( _sendImageWithConfirmation(filePath: blobUrl, fileName: file.name, fileSize: const Size(500, 500));
filePath: blobUrl,
fileName: file.name,
fileSize: const Size(500, 500));
} }
} }
Future<void> _handleKeyEvent(RawKeyEvent event) async { Future<void> _handleKeyEvent(RawKeyEvent event) async {
if (PlatformUtils().isDesktop && if (PlatformUtils().isDesktop &&
((event.isKeyPressed(LogicalKeyboardKey.controlLeft) && ((event.isKeyPressed(LogicalKeyboardKey.controlLeft) && event.logicalKey == LogicalKeyboardKey.keyV) ||
event.logicalKey == LogicalKeyboardKey.keyV) || (event.isMetaPressed && event.logicalKey == LogicalKeyboardKey.keyV))) {
(event.isMetaPressed &&
event.logicalKey == LogicalKeyboardKey.keyV))) {
final bytes = await Pasteboard.image; final bytes = await Pasteboard.image;
if (bytes != null) { if (bytes != null) {
String directory; String directory;
if (PlatformUtils().isWindows) { if (PlatformUtils().isWindows) {
final String documentsDirectoryPath = final String documentsDirectoryPath = "${Platform.environment['USERPROFILE']}";
"${Platform.environment['USERPROFILE']}";
PackageInfo packageInfo = await PackageInfo.fromPlatform(); PackageInfo packageInfo = await PackageInfo.fromPlatform();
String pkgName = packageInfo.packageName; String pkgName = packageInfo.packageName;
directory = p.join(documentsDirectoryPath, "Documents", directory = p.join(documentsDirectoryPath, "Documents", ".TencentCloudChat", pkgName, "screenshots");
".TencentCloudChat", pkgName, "screenshots");
} else { } else {
final dic = await getApplicationSupportDirectory(); final dic = await getApplicationSupportDirectory();
directory = dic.path; directory = dic.path;
@ -978,8 +842,7 @@ class _TIMUIKitTextFieldLayoutWideState
const uuid = Uuid(); const uuid = Uuid();
final fileName = 'paste_image_${uuid.v4()}.png'; final fileName = 'paste_image_${uuid.v4()}.png';
final scDirectory = Directory(directory); final scDirectory = Directory(directory);
final filePath = final filePath = '${scDirectory.path}${PlatformUtils().isWindows ? "\\" : "/"}$fileName';
'${scDirectory.path}${PlatformUtils().isWindows ? "\\" : "/"}$fileName';
final file = File(filePath); final file = File(filePath);
if (!await scDirectory.exists()) { if (!await scDirectory.exists()) {
await scDirectory.create(recursive: true); await scDirectory.create(recursive: true);
@ -1020,14 +883,10 @@ class _TIMUIKitTextFieldLayoutWideState
child: Column( child: Column(
children: [ children: [
_buildRepliedMessage(widget.repliedMessage), _buildRepliedMessage(widget.repliedMessage),
SizedBox( SizedBox(height: 1, child: Container(color: theme.weakDividerColor ?? Colors.black12)),
height: 1,
child: Container(
color: theme.weakDividerColor ?? Colors.black12)),
if (widget.forbiddenText == null) if (widget.forbiddenText == null)
Container( Container(
padding: padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 12),
const EdgeInsets.symmetric(vertical: 4, horizontal: 12),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: generateControlBar(widget.model, theme), children: generateControlBar(widget.model, theme),
@ -1042,8 +901,7 @@ class _TIMUIKitTextFieldLayoutWideState
Expanded( Expanded(
child: Container( child: Container(
height: 35, height: 35,
color: widget.backgroundColor ?? color: widget.backgroundColor ?? theme.desktopChatMessageInputBgColor,
theme.desktopChatMessageInputBgColor,
alignment: Alignment.center, alignment: Alignment.center,
child: Text( child: Text(
TIM_t(widget.forbiddenText!), TIM_t(widget.forbiddenText!),
@ -1060,10 +918,8 @@ class _TIMUIKitTextFieldLayoutWideState
child: ExtendedTextField( child: ExtendedTextField(
scrollController: _scrollController, scrollController: _scrollController,
autofocus: true, autofocus: true,
maxLines: maxLines: widget.chatConfig.desktopMessageInputFieldLines,
widget.chatConfig.desktopMessageInputFieldLines, minLines: widget.chatConfig.desktopMessageInputFieldLines,
minLines:
widget.chatConfig.desktopMessageInputFieldLines,
focusNode: widget.focusNode, focusNode: widget.focusNode,
onChanged: debounceFunc, onChanged: debounceFunc,
keyboardType: TextInputType.multiline, keyboardType: TextInputType.multiline,
@ -1078,9 +934,7 @@ class _TIMUIKitTextFieldLayoutWideState
hintStyle: const TextStyle( hintStyle: const TextStyle(
color: Color(0xffAEA4A3), color: Color(0xffAEA4A3),
), ),
fillColor: widget.backgroundColor ?? fillColor: widget.backgroundColor ?? theme.desktopChatMessageInputBgColor ?? hexToColor("fafafa"),
theme.desktopChatMessageInputBgColor ??
hexToColor("fafafa"),
filled: true, filled: true,
isDense: true, isDense: true,
hintText: widget.hintText ?? '', hintText: widget.hintText ?? '',
@ -1089,21 +943,9 @@ class _TIMUIKitTextFieldLayoutWideState
specialTextSpanBuilder: PlatformUtils().isWeb specialTextSpanBuilder: PlatformUtils().isWeb
? null ? null
: DefaultSpecialTextSpanBuilder( : DefaultSpecialTextSpanBuilder(
isUseQQPackage: (widget isUseQQPackage: (widget.model.chatConfig.stickerPanelConfig?.useTencentCloudChatStickerPackage ?? true) || widget.isUseDefaultEmoji,
.model isUseTencentCloudChatPackage: widget.model.chatConfig.stickerPanelConfig?.useTencentCloudChatStickerPackage ?? true,
.chatConfig customEmojiStickerList: widget.customEmojiStickerList,
.stickerPanelConfig
?.useTencentCloudChatStickerPackage ??
true) ||
widget.isUseDefaultEmoji,
isUseTencentCloudChatPackage: widget
.model
.chatConfig
.stickerPanelConfig
?.useTencentCloudChatStickerPackage ??
true,
customEmojiStickerList:
widget.customEmojiStickerList,
showAtBackground: true, showAtBackground: true,
)), )),
), ),

View File

@ -357,18 +357,18 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: extended_image name: extended_image
sha256: d1b122d6f5cf5596ea61d703d116d89e2ece7e324db414cfeed12967b72b7aef sha256: d7f091d068fcac7246c4b22a84b8dac59a62e04d29a5c172710c696e67a22f94
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "8.1.0" version: "8.2.0"
extended_image_library: extended_image_library:
dependency: transitive dependency: transitive
description: description:
name: extended_image_library name: extended_image_library
sha256: "8bf87c0b14dcb59200c923a9a3952304e4732a0901e40811428834ef39018ee1" sha256: "9b55fc5ebc65fad984de66b8f177a1bef2a84d79203c9c213f75ff83c2c29edd"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.6.0" version: "4.0.1"
extended_text: extended_text:
dependency: "direct main" dependency: "direct main"
description: description:

View File

@ -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.4.0 version: 2.4.1
homepage: https://trtc.io/products/chat?utm_source=gfs&utm_medium=link&utm_campaign=%E6%B8%A0%E9%81%93&_channel_track_key=k6WgfCKn homepage: https://trtc.io/products/chat?utm_source=gfs&utm_medium=link&utm_campaign=%E6%B8%A0%E9%81%93&_channel_track_key=k6WgfCKn
repository: https://github.com/TencentCloud/chat-uikit-flutter repository: https://github.com/TencentCloud/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
@ -44,7 +44,7 @@ dependencies:
wechat_assets_picker: ^8.9.0-dev.1 wechat_assets_picker: ^8.9.0-dev.1
wechat_camera_picker: ^4.2.0-dev.2 wechat_camera_picker: ^4.2.0-dev.2
flutter_easyrefresh: ^2.2.1 flutter_easyrefresh: ^2.2.1
extended_image: ^8.1.0 extended_image: ^8.2.0
extended_text_field: ^13.0.0 extended_text_field: ^13.0.0
extended_text: ^12.0.0 extended_text: ^12.0.0
package_info_plus: ^4.0.1 package_info_plus: ^4.0.1