Modify ImageGallerySaver to ImageGallerySaverPlus in video_screen.dart

This commit is contained in:
vinsonswang 2024-12-23 10:01:00 +08:00
parent eb2dd69ac9
commit 6ac036aae3
3 changed files with 203 additions and 287 deletions

View File

@ -24,12 +24,9 @@ class GroupProfileMemberList extends StatefulWidget {
// when the @ need filter some group types
final String? groupType;
final Function(List<V2TimGroupMemberFullInfo> selectedMember)?
onSelectedMemberChange;
final Function(List<V2TimGroupMemberFullInfo> 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<StatefulWidget> createState() => _GroupProfileMemberListState();
}
class _GroupProfileMemberListState
extends TIMUIKitState<GroupProfileMemberList> {
class _GroupProfileMemberListState extends TIMUIKitState<GroupProfileMemberList> {
List<V2TimGroupMemberFullInfo> selectedMemberList = [];
_getShowName(V2TimGroupMemberFullInfo? item) {
@ -74,8 +70,7 @@ class _GroupProfileMemberListState
: userID;
}
List<ISuspensionBeanImpl> _getShowList(
List<V2TimGroupMemberFullInfo?> memberList) {
List<ISuspensionBeanImpl> _getShowList(List<V2TimGroupMemberFullInfo?> memberList) {
final List<ISuspensionBeanImpl> 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<TUIThemeViewModel>(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);
}),

View File

@ -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<MessageReadReceipt> {
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<MessageReadReceipt> {
_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<MessageReadReceipt> {
isFromSelf: isFromSelf,
localCustomInt: message.localCustomInt);
case MessageElemType.V2TIM_ELEM_TYPE_TEXT:
return Text(
message.textElem!.text!,
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<MessageReadReceipt> {
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<MessageReadReceipt> {
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<MessageReadReceipt> {
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,15 +212,20 @@ class _MessageReadReceiptState extends TIMUIKitState<MessageReadReceipt> {
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(
// 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,
@ -230,31 +233,33 @@ class _MessageReadReceiptState extends TIMUIKitState<MessageReadReceipt> {
Row(
children: [
Text(MessageUtils.getDisplayName(widget.messageItem)),
const SizedBox(
width: 8,
),
const SizedBox(width: 8),
Text(
TimeAgo().getTimeForMessage(
widget.messageItem.timestamp ?? 0),
TimeAgo().getTimeForMessage(widget.messageItem.timestamp ?? 0),
softWrap: true,
style:
TextStyle(fontSize: 12, color: theme.weakTextColor),
style: TextStyle(fontSize: 12, color: theme.weakTextColor),
)
],
),
const SizedBox(
height: 6,
),
_getMsgItem(widget.messageItem)
const SizedBox(height: 6),
// message content
_getMsgItem(widget.messageItem),
],
),
),
),
),
// divider
Container(
height: 8,
color: theme.weakBackgroundColor,
),
// The bottom part shows the read/unread list
Expanded(
child: Column(
children: [
// read/unread switch button
Row(
// direction: Axis.horizontal,
children: <Widget>[
Expanded(
flex: 1,
@ -271,17 +276,11 @@ class _MessageReadReceiptState extends TIMUIKitState<MessageReadReceipt> {
color: Colors.white,
border: Border(
bottom: BorderSide(
width: 2,
color: currentIndex == 0
? theme.primaryColor!
: Colors.white))),
width: 2, color: currentIndex == 0 ? theme.primaryColor! : Colors.white))),
child: Text(
TIM_t_para("{{option1}}人已读", "$option1人已读")(
option1: option1),
TIM_t_para("{{option1}}人已读", "$option1人已读")(option1: option1),
style: TextStyle(
color: currentIndex != 0
? theme.weakTextColor
: Colors.black,
color: currentIndex != 0 ? theme.weakTextColor : Colors.black,
fontSize: isDesktopScreen ? 14 : 18,
),
),
@ -303,17 +302,11 @@ class _MessageReadReceiptState extends TIMUIKitState<MessageReadReceipt> {
color: Colors.white,
border: Border(
bottom: BorderSide(
width: 2,
color: currentIndex == 1
? theme.primaryColor!
: Colors.white))),
width: 2, color: currentIndex == 1 ? theme.primaryColor! : Colors.white))),
child: Text(
TIM_t_para("{{option2}}人未读", "$option2人未读")(
option2: option2),
TIM_t_para("{{option2}}人未读", "$option2人未读")(option2: option2),
style: TextStyle(
color: currentIndex != 1
? theme.weakTextColor
: Colors.black,
color: currentIndex != 1 ? theme.weakTextColor : Colors.black,
fontSize: isDesktopScreen ? 14 : 18,
),
),
@ -325,37 +318,40 @@ class _MessageReadReceiptState extends TIMUIKitState<MessageReadReceipt> {
Container(
height: 1,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: theme.weakDividerColor ??
CommonColor.weakDividerColor))),
border:
Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
),
// member list
Expanded(
child: IndexedStack(
index: currentIndex,
children: [
ListView.builder(
shrinkWrap: true,
shrinkWrap: false,
itemCount: readMemberList.length,
itemBuilder: (context, index) {
if (!readMemberIsFinished &&
index == readMemberList.length - 5) {
if (!readMemberIsFinished && index == readMemberList.length - 5) {
_getReadMemberList();
}
return _memberItemBuilder(readMemberList[index], theme);
}),
},
),
ListView.builder(
shrinkWrap: true,
shrinkWrap: false,
itemCount: unreadMemberList.length,
itemBuilder: (context, index) {
if (!unreadMemberIsFinished &&
index == unreadMemberList.length - 5) {
if (!unreadMemberIsFinished && index == unreadMemberList.length - 5) {
_getUnreadMemberList();
}
return _memberItemBuilder(unreadMemberList[index], theme);
}),
},
),
],
)),
),
),
],
),
),
],
),
);
@ -373,8 +369,7 @@ class _MessageReadReceiptState extends TIMUIKitState<MessageReadReceipt> {
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,
)),

View File

@ -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<VideoScreen> {
late VideoPlayerController videoPlayerController;
late ChewieController chewieController;
GlobalKey<ExtendedImageSlidePageState> slidePagekey =
GlobalKey<ExtendedImageSlidePageState>();
GlobalKey<ExtendedImageSlidePageState> slidePagekey = GlobalKey<ExtendedImageSlidePageState>();
final TUIChatGlobalModel model = serviceLocator<TUIChatGlobalModel>();
bool isInit = false;
@ -70,8 +65,7 @@ class _VideoScreenState extends TIMUIKitState<VideoScreen> {
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<VideoScreen> {
}
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<VideoScreen> {
);
}
}
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<VideoScreen> {
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<VideoScreen> {
? 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<VideoScreen> {
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<VideoScreen> {
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<VideoScreen> {
? 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,8 +344,7 @@ class _VideoScreenState extends TIMUIKitState<VideoScreen> {
HeroFlightDirection flightDirection,
BuildContext fromHeroContext,
BuildContext toHeroContext) {
final Hero hero =
(flightDirection == HeroFlightDirection.pop
final Hero hero = (flightDirection == HeroFlightDirection.pop
? fromHeroContext.widget
: toHeroContext.widget) as Hero;