From 6ac036aae369b43feb68befa7c64e05ebecb05cd Mon Sep 17 00:00:00 2001 From: vinsonswang Date: Mon, 23 Dec 2024 10:01:00 +0800 Subject: [PATCH] Modify ImageGallerySaver to ImageGallerySaverPlus in video_screen.dart --- lib/ui/widgets/group_member_list.dart | 98 +++----- lib/ui/widgets/message_read_receipt.dart | 293 +++++++++++------------ lib/ui/widgets/video_screen.dart | 99 +++----- 3 files changed, 203 insertions(+), 287 deletions(-) diff --git a/lib/ui/widgets/group_member_list.dart b/lib/ui/widgets/group_member_list.dart index 5130db5..5ffbb60 100644 --- a/lib/ui/widgets/group_member_list.dart +++ b/lib/ui/widgets/group_member_list.dart @@ -24,12 +24,9 @@ class GroupProfileMemberList extends StatefulWidget { // when the @ need filter some group types final String? groupType; - final Function(List selectedMember)? - onSelectedMemberChange; + final Function(List selectedMember)? onSelectedMemberChange; // notice: onTapMemberItem and onSelectedMemberChange use together will triger together - final Function( - V2TimGroupMemberFullInfo memberInfo, TapDownDetails? tapDetails)? - onTapMemberItem; + final Function(V2TimGroupMemberFullInfo memberInfo, TapDownDetails? tapDetails)? onTapMemberItem; // When sliding to the bottom bar callBack final Function()? touchBottomCallBack; @@ -56,8 +53,7 @@ class GroupProfileMemberList extends StatefulWidget { State createState() => _GroupProfileMemberListState(); } -class _GroupProfileMemberListState - extends TIMUIKitState { +class _GroupProfileMemberListState extends TIMUIKitState { List selectedMemberList = []; _getShowName(V2TimGroupMemberFullInfo? item) { @@ -74,8 +70,7 @@ class _GroupProfileMemberListState : userID; } - List _getShowList( - List memberList) { + List _getShowList(List memberList) { final List showList = List.empty(growable: true); for (var i = 0; i < memberList.length; i++) { final item = memberList[i]; @@ -103,9 +98,8 @@ class _GroupProfileMemberListState showList.insert( 0, ISuspensionBeanImpl( - memberInfo: V2TimGroupMemberFullInfo( - userID: GroupProfileMemberList.AT_ALL_USER_ID, - nickName: TIM_t("所有人")), + memberInfo: + V2TimGroupMemberFullInfo(userID: GroupProfileMemberList.AT_ALL_USER_ID, nickName: TIM_t("所有人")), tagIndex: "")); } } @@ -113,13 +107,10 @@ class _GroupProfileMemberListState return showList; } - Widget _buildListItem( - BuildContext context, V2TimGroupMemberFullInfo memberInfo) { + Widget _buildListItem(BuildContext context, V2TimGroupMemberFullInfo memberInfo) { final theme = Provider.of(context).theme; - final isDesktopScreen = - TUIKitScreenUtils.getFormFactor() == DeviceType.Desktop; - final isGroupMember = - memberInfo.role == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_MEMBER; + final isDesktopScreen = TUIKitScreenUtils.getFormFactor() == DeviceType.Desktop; + final isGroupMember = memberInfo.role == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_MEMBER; return Container( color: Colors.white, child: Slidable( @@ -132,8 +123,7 @@ class _GroupProfileMemberListState } }, flex: 1, - backgroundColor: - theme.cautionColor ?? CommonColor.cautionColor, + backgroundColor: theme.cautionColor ?? CommonColor.cautionColor, autoClose: true, label: TIM_t("删除"), ) @@ -150,26 +140,21 @@ class _GroupProfileMemberListState child: CheckBoxButton( onChanged: (isChecked) { if (isChecked) { - if (widget.maxSelectNum != null && - selectedMemberList.length >= - widget.maxSelectNum!) { + if (widget.maxSelectNum != null && selectedMemberList.length >= widget.maxSelectNum!) { return; } selectedMemberList.add(memberInfo); } else { - selectedMemberList.removeWhere((element) => - element.userID == memberInfo.userID); + selectedMemberList.removeWhere((element) => element.userID == memberInfo.userID); } if (widget.onSelectedMemberChange != null) { - widget.onSelectedMemberChange!( - selectedMemberList); + widget.onSelectedMemberChange!(selectedMemberList); } setState(() {}); }, isChecked: selectedMemberList - .where((element) => - element.userID == memberInfo.userID) + .where((element) => element.userID == memberInfo.userID) .toList() .isNotEmpty), ), @@ -183,10 +168,8 @@ class _GroupProfileMemberListState type: 1, ), ), - Text(_getShowName(memberInfo), - style: TextStyle(fontSize: isDesktopScreen ? 14 : 16)), - memberInfo.role == - GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_OWNER + Text(_getShowName(memberInfo), style: TextStyle(fontSize: isDesktopScreen ? 14 : 16)), + memberInfo.role == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_OWNER ? Container( margin: const EdgeInsets.only(left: 5), child: Text(TIM_t("群主"), @@ -196,17 +179,11 @@ class _GroupProfileMemberListState )), padding: const EdgeInsets.fromLTRB(5, 0, 5, 0), decoration: BoxDecoration( - border: Border.all( - color: theme.ownerColor ?? - CommonColor.ownerColor, - width: 1), - borderRadius: - const BorderRadius.all(Radius.circular(4.0)), + border: Border.all(color: theme.ownerColor ?? CommonColor.ownerColor, width: 1), + borderRadius: const BorderRadius.all(Radius.circular(4.0)), ), ) - : memberInfo.role == - GroupMemberRoleType - .V2TIM_GROUP_MEMBER_ROLE_ADMIN + : memberInfo.role == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_ADMIN ? Container( margin: const EdgeInsets.only(left: 5), child: Text(TIM_t("管理员"), @@ -216,12 +193,8 @@ class _GroupProfileMemberListState )), padding: const EdgeInsets.fromLTRB(5, 0, 5, 0), decoration: BoxDecoration( - border: Border.all( - color: theme.adminColor ?? - CommonColor.adminColor, - width: 1), - borderRadius: const BorderRadius.all( - Radius.circular(4.0)), + border: Border.all(color: theme.adminColor ?? CommonColor.adminColor, width: 1), + borderRadius: const BorderRadius.all(Radius.circular(4.0)), ), ) : Container() @@ -236,8 +209,7 @@ class _GroupProfileMemberListState if (isChecked) { selectedMemberList.remove(memberInfo); } else { - if (widget.maxSelectNum != null && - selectedMemberList.length >= widget.maxSelectNum!) { + if (widget.maxSelectNum != null && selectedMemberList.length >= widget.maxSelectNum!) { return; } selectedMemberList.add(memberInfo); @@ -249,17 +221,11 @@ class _GroupProfileMemberListState } }, ), - Divider( - thickness: 1, - indent: 74, - endIndent: 0, - color: theme.weakBackgroundColor, - height: 0) + Divider(thickness: 1, indent: 74, endIndent: 0, color: theme.weakBackgroundColor, height: 0) ]))); } - static Widget getSusItem(BuildContext context, TUITheme theme, String tag, - {double susHeight = 40}) { + static Widget getSusItem(BuildContext context, TUITheme theme, String tag, {double susHeight = 40}) { if (tag == '@') { tag = TIM_t("群主、管理员"); } @@ -284,11 +250,9 @@ class _GroupProfileMemberListState Widget tuiBuild(BuildContext context, TUIKitBuildValue value) { final TUITheme theme = value.theme; - final isDesktopScreen = - TUIKitScreenUtils.getFormFactor() == DeviceType.Desktop; + final isDesktopScreen = TUIKitScreenUtils.getFormFactor() == DeviceType.Desktop; - final throteFunction = - OptimizeUtils.throttle((ScrollNotification notification) { + final throteFunction = OptimizeUtils.throttle((ScrollNotification notification) { final pixels = notification.metrics.pixels; // 总像素高度 final maxScrollExtent = notification.metrics.maxScrollExtent; @@ -316,19 +280,15 @@ class _GroupProfileMemberListState child: Text(TIM_t("暂无群成员")), ) : Container( - padding: isDesktopScreen - ? const EdgeInsets.symmetric(horizontal: 16) - : null, + padding: isDesktopScreen ? const EdgeInsets.symmetric(horizontal: 16) : null, child: AZListViewContainer( memberList: showList, susItemBuilder: (context, index) { final model = showList[index]; - return getSusItem( - context, theme, model.getSuspensionTag()); + return getSusItem(context, theme, model.getSuspensionTag()); }, itemBuilder: (context, index) { - final memberInfo = showList[index].memberInfo - as V2TimGroupMemberFullInfo; + final memberInfo = showList[index].memberInfo as V2TimGroupMemberFullInfo; return _buildListItem(context, memberInfo); }), diff --git a/lib/ui/widgets/message_read_receipt.dart b/lib/ui/widgets/message_read_receipt.dart index be96585..11286b8 100644 --- a/lib/ui/widgets/message_read_receipt.dart +++ b/lib/ui/widgets/message_read_receipt.dart @@ -1,9 +1,11 @@ +import 'package:extended_text/extended_text.dart'; import 'package:flutter/material.dart'; // ignore: unused_import import 'package:provider/provider.dart'; import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart'; import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart'; +import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/special_text/DefaultSpecialTextSpanBuilder.dart'; import 'package:tencent_im_base/tencent_im_base.dart'; import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart'; @@ -49,11 +51,8 @@ class _MessageReadReceiptState extends TIMUIKitState { int currentIndex = 0; _getUnreadMemberList() async { - final unReadMemberRes = await widget.model.getGroupMessageReadMemberList( - widget.messageItem.msgID!, - GetGroupMessageReadMemberListFilter - .V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_UNREAD, - unreadMemberListNextSeq); + final unReadMemberRes = await widget.model.getGroupMessageReadMemberList(widget.messageItem.msgID!, + GetGroupMessageReadMemberListFilter.V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_UNREAD, unreadMemberListNextSeq); if (unReadMemberRes.code == 0) { final res = unReadMemberRes.data; if (res != null) { @@ -68,8 +67,7 @@ class _MessageReadReceiptState extends TIMUIKitState { _getReadMemberList() async { final readMemberRes = await widget.model.getGroupMessageReadMemberList( widget.messageItem.msgID!, - GetGroupMessageReadMemberListFilter - .V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_READ, + GetGroupMessageReadMemberListFilter.V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_READ, readMemberListNextSeq, ); if (readMemberRes.code == 0) { @@ -107,11 +105,18 @@ class _MessageReadReceiptState extends TIMUIKitState { isFromSelf: isFromSelf, localCustomInt: message.localCustomInt); case MessageElemType.V2TIM_ELEM_TYPE_TEXT: - return Text( - message.textElem!.text!, - softWrap: true, - style: const TextStyle(fontSize: 16), - ); + return ExtendedText(message.textElem!.text!, + softWrap: true, + style: const TextStyle(fontSize: 16), + specialTextSpanBuilder: DefaultSpecialTextSpanBuilder( + isUseQQPackage: widget.model.chatConfig.stickerPanelConfig?.useQQStickerPackage ?? true, + isUseTencentCloudChatPackage: + widget.model.chatConfig.stickerPanelConfig?.useTencentCloudChatStickerPackage ?? true, + isUseTencentCloudChatPackageOldKeys: + widget.model.chatConfig.stickerPanelConfig?.useTencentCloudChatStickerPackageOldKeys ?? false, + showAtBackground: true, + checkHttpLink: true, + )); // return Text(message.textElem!.text!); case MessageElemType.V2TIM_ELEM_TYPE_FACE: return TIMUIKitFaceElem( @@ -139,10 +144,7 @@ class _MessageReadReceiptState extends TIMUIKitState { key: Key("${message.seq}_${message.timestamp}"), ); case MessageElemType.V2TIM_ELEM_TYPE_VIDEO: - return TIMUIKitVideoElem(message, - chatModel: widget.model, - isShowMessageReaction: false, - isFrom: "merger"); + return TIMUIKitVideoElem(message, chatModel: widget.model, isShowMessageReaction: false, isFrom: "merger"); case MessageElemType.V2TIM_ELEM_TYPE_LOCATION: return Text(TIM_t("[位置]")); case MessageElemType.V2TIM_ELEM_TYPE_MERGER: @@ -170,8 +172,7 @@ class _MessageReadReceiptState extends TIMUIKitState { Widget _memberItemBuilder(V2TimGroupMemberInfo item, TUITheme theme) { final faceUrl = item.faceUrl ?? ''; final showName = _getShowName(item); - final isDesktopScreen = - TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop; + final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop; return InkWell( onTapDown: (details) { @@ -194,10 +195,7 @@ class _MessageReadReceiptState extends TIMUIKitState { alignment: Alignment.centerLeft, padding: EdgeInsets.only(top: 10, bottom: isDesktopScreen ? 14 : 19, right: 28), decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: theme.weakDividerColor ?? - CommonColor.weakDividerColor))), + border: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))), child: Text( showName, style: TextStyle(color: Colors.black, fontSize: isDesktopScreen ? 14 : 18), @@ -214,148 +212,146 @@ class _MessageReadReceiptState extends TIMUIKitState { final TUITheme theme = value.theme; final option1 = widget.readCount; final option2 = widget.unreadCount; - final isDesktopScreen = - TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop; + final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop; Widget pageBody() { return Container( color: isDesktopScreen ? null : Colors.white, child: Column( children: [ - Padding( - padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( + // The top part of the message content + ConstrainedBox( + constraints: BoxConstraints( + maxHeight: MediaQuery.of(context).size.height / 2, + ), + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(MessageUtils.getDisplayName(widget.messageItem)), - const SizedBox( - width: 8, + Row( + children: [ + Text(MessageUtils.getDisplayName(widget.messageItem)), + const SizedBox(width: 8), + Text( + TimeAgo().getTimeForMessage(widget.messageItem.timestamp ?? 0), + softWrap: true, + style: TextStyle(fontSize: 12, color: theme.weakTextColor), + ) + ], ), - Text( - TimeAgo().getTimeForMessage( - widget.messageItem.timestamp ?? 0), - softWrap: true, - style: - TextStyle(fontSize: 12, color: theme.weakTextColor), - ) + const SizedBox(height: 6), + // message content + _getMsgItem(widget.messageItem), ], ), - const SizedBox( - height: 6, - ), - _getMsgItem(widget.messageItem) - ], + ), ), ), + // divider Container( height: 8, color: theme.weakBackgroundColor, ), - Row( - // direction: Axis.horizontal, - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - currentIndex = 0; - setState(() {}); - }, - child: Container( - height: isDesktopScreen ? 40 : 50.0, - alignment: Alignment.bottomCenter, - padding: EdgeInsets.only(bottom: isDesktopScreen ? 8 : 12), - decoration: BoxDecoration( - color: Colors.white, - border: Border( - bottom: BorderSide( - width: 2, - color: currentIndex == 0 - ? theme.primaryColor! - : Colors.white))), - child: Text( - TIM_t_para("{{option1}}人已读", "$option1人已读")( - option1: option1), - style: TextStyle( - color: currentIndex != 0 - ? theme.weakTextColor - : Colors.black, - fontSize: isDesktopScreen ? 14 : 18, - ), - ), - ), - ), - ), - Expanded( - flex: 1, - child: InkWell( - onTap: () { - currentIndex = 1; - setState(() {}); - }, - child: Container( - alignment: Alignment.bottomCenter, - height: isDesktopScreen ? 40 : 50.0, - padding: EdgeInsets.only(bottom: isDesktopScreen ? 8 : 12), - decoration: BoxDecoration( - color: Colors.white, - border: Border( - bottom: BorderSide( - width: 2, - color: currentIndex == 1 - ? theme.primaryColor! - : Colors.white))), - child: Text( - TIM_t_para("{{option2}}人未读", "$option2人未读")( - option2: option2), - style: TextStyle( - color: currentIndex != 1 - ? theme.weakTextColor - : Colors.black, - fontSize: isDesktopScreen ? 14 : 18, - ), - ), - ), - ), - ), - ], - ), - Container( - height: 1, - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: theme.weakDividerColor ?? - CommonColor.weakDividerColor))), - ), + // The bottom part shows the read/unread list Expanded( - child: IndexedStack( - index: currentIndex, - children: [ - ListView.builder( - shrinkWrap: true, - itemCount: readMemberList.length, - itemBuilder: (context, index) { - if (!readMemberIsFinished && - index == readMemberList.length - 5) { - _getReadMemberList(); - } - return _memberItemBuilder(readMemberList[index], theme); - }), - ListView.builder( - shrinkWrap: true, - itemCount: unreadMemberList.length, - itemBuilder: (context, index) { - if (!unreadMemberIsFinished && - index == unreadMemberList.length - 5) { - _getUnreadMemberList(); - } - return _memberItemBuilder(unreadMemberList[index], theme); - }), - ], - )), + child: Column( + children: [ + // read/unread switch button + Row( + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () { + currentIndex = 0; + setState(() {}); + }, + child: Container( + height: isDesktopScreen ? 40 : 50.0, + alignment: Alignment.bottomCenter, + padding: EdgeInsets.only(bottom: isDesktopScreen ? 8 : 12), + decoration: BoxDecoration( + color: Colors.white, + border: Border( + bottom: BorderSide( + width: 2, color: currentIndex == 0 ? theme.primaryColor! : Colors.white))), + child: Text( + TIM_t_para("{{option1}}人已读", "$option1人已读")(option1: option1), + style: TextStyle( + color: currentIndex != 0 ? theme.weakTextColor : Colors.black, + fontSize: isDesktopScreen ? 14 : 18, + ), + ), + ), + ), + ), + Expanded( + flex: 1, + child: InkWell( + onTap: () { + currentIndex = 1; + setState(() {}); + }, + child: Container( + alignment: Alignment.bottomCenter, + height: isDesktopScreen ? 40 : 50.0, + padding: EdgeInsets.only(bottom: isDesktopScreen ? 8 : 12), + decoration: BoxDecoration( + color: Colors.white, + border: Border( + bottom: BorderSide( + width: 2, color: currentIndex == 1 ? theme.primaryColor! : Colors.white))), + child: Text( + TIM_t_para("{{option2}}人未读", "$option2人未读")(option2: option2), + style: TextStyle( + color: currentIndex != 1 ? theme.weakTextColor : Colors.black, + fontSize: isDesktopScreen ? 14 : 18, + ), + ), + ), + ), + ), + ], + ), + Container( + height: 1, + decoration: BoxDecoration( + border: + Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))), + ), + // member list + Expanded( + child: IndexedStack( + index: currentIndex, + children: [ + ListView.builder( + shrinkWrap: false, + itemCount: readMemberList.length, + itemBuilder: (context, index) { + if (!readMemberIsFinished && index == readMemberList.length - 5) { + _getReadMemberList(); + } + return _memberItemBuilder(readMemberList[index], theme); + }, + ), + ListView.builder( + shrinkWrap: false, + itemCount: unreadMemberList.length, + itemBuilder: (context, index) { + if (!unreadMemberIsFinished && index == unreadMemberList.length - 5) { + _getUnreadMemberList(); + } + return _memberItemBuilder(unreadMemberList[index], theme); + }, + ), + ], + ), + ), + ], + ), + ), ], ), ); @@ -373,8 +369,7 @@ class _MessageReadReceiptState extends TIMUIKitState { style: TextStyle(color: theme.appbarTextColor, fontSize: 17), ), shadowColor: theme.weakDividerColor, - backgroundColor: theme.appbarBgColor ?? - theme.primaryColor, + backgroundColor: theme.appbarBgColor ?? theme.primaryColor, iconTheme: IconThemeData( color: theme.appbarTextColor, )), diff --git a/lib/ui/widgets/video_screen.dart b/lib/ui/widgets/video_screen.dart index b2e069d..6aa39ce 100644 --- a/lib/ui/widgets/video_screen.dart +++ b/lib/ui/widgets/video_screen.dart @@ -21,11 +21,7 @@ import 'package:universal_html/html.dart' as html; import 'package:video_player/video_player.dart'; class VideoScreen extends StatefulWidget { - const VideoScreen( - {required this.message, - required this.heroTag, - required this.videoElement, - Key? key}) + const VideoScreen({required this.message, required this.heroTag, required this.videoElement, Key? key}) : super(key: key); final V2TimMessage message; @@ -39,8 +35,7 @@ class VideoScreen extends StatefulWidget { class _VideoScreenState extends TIMUIKitState { late VideoPlayerController videoPlayerController; late ChewieController chewieController; - GlobalKey slidePagekey = - GlobalKey(); + GlobalKey slidePagekey = GlobalKey(); final TUIChatGlobalModel model = serviceLocator(); bool isInit = false; @@ -70,8 +65,7 @@ class _VideoScreenState extends TIMUIKitState { xhr.open('get', videoUrl); xhr.responseType = 'arraybuffer'; xhr.onLoad.listen((event) { - final a = html.AnchorElement( - href: html.Url.createObjectUrl(html.Blob([xhr.response]))); + final a = html.AnchorElement(href: html.Url.createObjectUrl(html.Blob([xhr.response]))); a.download = '${md5.convert(utf8.encode(videoUrl)).toString()}$suffix'; a.click(); a.remove(); @@ -117,73 +111,50 @@ class _VideoScreenState extends TIMUIKitState { } if (model.getMessageProgress(widget.message.msgID) == 100) { String savePath; - if (widget.message.videoElem!.localVideoUrl != null && - widget.message.videoElem!.localVideoUrl != '') { + if (widget.message.videoElem!.localVideoUrl != null && widget.message.videoElem!.localVideoUrl != '') { savePath = widget.message.videoElem!.localVideoUrl!; } else { savePath = model.getFileMessageLocation(widget.message.msgID); } File f = File(savePath); if (f.existsSync()) { - var result = await ImageGallerySaver.saveFile(savePath); + var result = await ImageGallerySaverPlus.saveFile(savePath); if (PlatformUtils().isIOS) { if (result['isSuccess']) { - onTIMCallback(TIMCallback( - type: TIMCallbackType.INFO, - infoRecommendText: TIM_t("视频保存成功"), - infoCode: 6660402)); + onTIMCallback( + TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("视频保存成功"), infoCode: 6660402)); } else { - onTIMCallback(TIMCallback( - type: TIMCallbackType.INFO, - infoRecommendText: TIM_t("视频保存失败"), - infoCode: 6660403)); + onTIMCallback( + TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("视频保存失败"), infoCode: 6660403)); } } else { if (result != null) { - onTIMCallback(TIMCallback( - type: TIMCallbackType.INFO, - infoRecommendText: TIM_t("视频保存成功"), - infoCode: 6660402)); + onTIMCallback( + TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("视频保存成功"), infoCode: 6660402)); } else { - onTIMCallback(TIMCallback( - type: TIMCallbackType.INFO, - infoRecommendText: TIM_t("视频保存失败"), - infoCode: 6660403)); + onTIMCallback( + TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("视频保存失败"), infoCode: 6660403)); } } } } else { onTIMCallback(TIMCallback( - type: TIMCallbackType.INFO, - infoRecommendText: TIM_t("the message is downloading"), - infoCode: -1)); + type: TIMCallbackType.INFO, infoRecommendText: TIM_t("the message is downloading"), infoCode: -1)); } return; } - var result = await ImageGallerySaver.saveFile(savePath); + var result = await ImageGallerySaverPlus.saveFile(savePath); if (PlatformUtils().isIOS) { if (result['isSuccess']) { - onTIMCallback(TIMCallback( - type: TIMCallbackType.INFO, - infoRecommendText: TIM_t("视频保存成功"), - infoCode: 6660402)); + onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("视频保存成功"), infoCode: 6660402)); } else { - onTIMCallback(TIMCallback( - type: TIMCallbackType.INFO, - infoRecommendText: TIM_t("视频保存失败"), - infoCode: 6660403)); + onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("视频保存失败"), infoCode: 6660403)); } } else { if (result != null) { - onTIMCallback(TIMCallback( - type: TIMCallbackType.INFO, - infoRecommendText: TIM_t("视频保存成功"), - infoCode: 6660402)); + onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("视频保存成功"), infoCode: 6660402)); } else { - onTIMCallback(TIMCallback( - type: TIMCallbackType.INFO, - infoRecommendText: TIM_t("视频保存失败"), - infoCode: 6660403)); + onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("视频保存失败"), infoCode: 6660403)); } } return; @@ -209,8 +180,7 @@ class _VideoScreenState extends TIMUIKitState { ); } } - if (widget.videoElement.localVideoUrl != '' && - widget.videoElement.localVideoUrl != null) { + if (widget.videoElement.localVideoUrl != '' && widget.videoElement.localVideoUrl != null) { File f = File(widget.videoElement.localVideoUrl!); if (f.existsSync()) { return await _saveNetworkVideo( @@ -249,8 +219,7 @@ class _VideoScreenState extends TIMUIKitState { setVideoPlayerController() async { if (!PlatformUtils().isWeb) { - if (TencentUtils.checkString(widget.message.msgID) != null && - widget.videoElement.localVideoUrl == null) { + if (TencentUtils.checkString(widget.message.msgID) != null && widget.videoElement.localVideoUrl == null) { String savePath = model.getFileMessageLocation(widget.message.msgID); File f = File(savePath); if (f.existsSync()) { @@ -265,8 +234,7 @@ class _VideoScreenState extends TIMUIKitState { ? VideoPlayerController.networkUrl( Uri.parse(widget.videoElement.videoPath!), ) - : (TencentUtils.checkString(widget.videoElement.localVideoUrl) == - null) + : (TencentUtils.checkString(widget.videoElement.localVideoUrl) == null) ? VideoPlayerController.networkUrl( Uri.parse(widget.videoElement.videoUrl!), ) @@ -274,12 +242,10 @@ class _VideoScreenState extends TIMUIKitState { Uri.parse(widget.videoElement.localVideoUrl!), )) : ((TencentUtils.checkString(widget.videoElement.videoPath) != null || - widget.message.status == - MessageStatus.V2TIM_MSG_STATUS_SENDING) && + widget.message.status == MessageStatus.V2TIM_MSG_STATUS_SENDING) && File(widget.videoElement.videoPath!).existsSync()) ? VideoPlayerController.file(File(widget.videoElement.videoPath!)) - : (TencentUtils.checkString(widget.videoElement.localVideoUrl) == - null) + : (TencentUtils.checkString(widget.videoElement.localVideoUrl) == null) ? VideoPlayerController.networkUrl( Uri.parse(widget.videoElement.videoUrl!), ) @@ -345,10 +311,8 @@ class _VideoScreenState extends TIMUIKitState { return Colors.black; } double opacity = 0.0; - opacity = offset.distance / - (Offset(size.width, size.height).distance / 2.0); - return Colors.black - .withOpacity(min(1.0, max(1.0 - opacity, 0.0))); + opacity = offset.distance / (Offset(size.width, size.height).distance / 2.0); + return Colors.black.withOpacity(min(1.0, max(1.0 - opacity, 0.0))); }, slideType: SlideType.onlyImage, slideEndHandler: ( @@ -370,9 +334,7 @@ class _VideoScreenState extends TIMUIKitState { ? Chewie( controller: chewieController, ) - : const Center( - child: CircularProgressIndicator( - color: Colors.white))), + : const Center(child: CircularProgressIndicator(color: Colors.white))), heroBuilderForSlidingPage: (Widget result) { return Hero( tag: widget.heroTag, @@ -382,10 +344,9 @@ class _VideoScreenState extends TIMUIKitState { HeroFlightDirection flightDirection, BuildContext fromHeroContext, BuildContext toHeroContext) { - final Hero hero = - (flightDirection == HeroFlightDirection.pop - ? fromHeroContext.widget - : toHeroContext.widget) as Hero; + final Hero hero = (flightDirection == HeroFlightDirection.pop + ? fromHeroContext.widget + : toHeroContext.widget) as Hero; return hero.child; },