diff --git a/lib/ui/widgets/video_screen.dart b/lib/ui/widgets/video_screen.dart index 75e9891..9b1c879 100644 --- a/lib/ui/widgets/video_screen.dart +++ b/lib/ui/widgets/video_screen.dart @@ -26,7 +26,11 @@ import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKITMessageIt import 'package:universal_html/html.dart' as html; 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; @@ -38,7 +42,8 @@ class VideoScreen extends StatefulWidget { } class _VideoScreenState extends TIMUIKitState { - GlobalKey slidePagekey = GlobalKey(); + GlobalKey slidePagekey = + GlobalKey(); final TUIChatGlobalModel model = serviceLocator(); @override @@ -66,7 +71,8 @@ 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(); @@ -112,7 +118,8 @@ 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); @@ -122,40 +129,62 @@ class _VideoScreenState extends TIMUIKitState { 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 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; @@ -181,7 +210,8 @@ 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( @@ -245,8 +275,10 @@ 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: ( @@ -264,34 +296,45 @@ class _VideoScreenState extends TIMUIKitState { child: TIMUIKitVideoPlayer( message: widget.message, controller: true, - isSending: widget.message.status == MessageStatus.V2TIM_MSG_STATUS_SENDING, + isSending: widget.message.status == + MessageStatus.V2TIM_MSG_STATUS_SENDING, ), ), ), Positioned( - bottom: 20, - left: 20, - child: IconButton( - icon: Image.asset( - 'images/close.png', - package: 'tencent_cloud_chat_uikit', + left: 10, + bottom: 50, + child: SizedBox( + width: 48, + height: 48, + child: IconButton( + icon: Image.asset( + 'images/close.png', + package: 'tencent_cloud_chat_uikit', + ), + iconSize: 30, + onPressed: () { + Navigator.of(context).pop(); + }, ), - onPressed: () { - Navigator.of(context).pop(); - }, ), ), Positioned( - bottom: 20, - right: 20, - child: IconButton( - icon: Image.asset( - 'images/download.png', - package: 'tencent_cloud_chat_uikit', + right: 10, + bottom: 50, + child: SizedBox( + width: 48, + height: 48, + child: IconButton( + icon: Image.asset( + 'images/download.png', + package: 'tencent_cloud_chat_uikit', + ), + iconSize: 30, + onPressed: () async { + await _saveVideo(); + }, ), - onPressed: () async { - await _saveVideo(); - }, ), ), ], diff --git a/scripts/sync_from_upstream.sh b/scripts/sync_from_upstream.sh index 92a38b6..4b94a66 100755 --- a/scripts/sync_from_upstream.sh +++ b/scripts/sync_from_upstream.sh @@ -31,6 +31,15 @@ if ! git remote | grep -q "upstream"; then git remote add upstream "$UPSTREAM_URL" fi +# 2.1 Stash local changes to prevent data loss during branch switching +echo -e "${BLUE}Stashing local changes...${NC}" +STASH_NEEDED=false +if ! git diff-index --quiet HEAD --; then + git stash push -m "Stash before upstream sync" + STASH_NEEDED=true +fi + + # 3. Fetch upstream echo -e "${BLUE}Fetching latest upstream changes...${NC}" git fetch upstream @@ -88,3 +97,13 @@ else fi echo -e "${GREEN}=== Synchronization Complete ===${NC}" + +if [ "$STASH_NEEDED" = true ]; then + echo -e "${BLUE}Restoring stashed changes...${NC}" + if git stash pop; then + echo -e "${GREEN}Local changes restored successfully.${NC}" + else + echo -e "${RED}Conflict detected while restoring stashed changes. Please resolve manually.${NC}" + fi +fi +