diff --git a/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart b/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart index 20dd7b8f8..8c5aa7b46 100644 --- a/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart +++ b/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart @@ -67,7 +67,7 @@ class InteractiveviewerGallery extends StatefulWidget { this.onClose, }); - final VoidCallback? onClose; + final ValueChanged? onClose; final bool? setStatusBar; @@ -152,6 +152,7 @@ class _InteractiveviewerGalleryState extends State @override void dispose() async { + widget.onClose?.call(true); _player?.dispose(); _pageController?.dispose(); _animationController.removeListener(() {}); @@ -259,7 +260,7 @@ class _InteractiveviewerGalleryState extends State void onClose() { if (widget.onClose != null) { - widget.onClose!(); + widget.onClose!(false); } else { Get.back(); widget.onDismissed?.call(_pageController!.page!.floor()); diff --git a/lib/pages/dynamics/detail/view.dart b/lib/pages/dynamics/detail/view.dart index 0679ee437..ea7466926 100644 --- a/lib/pages/dynamics/detail/view.dart +++ b/lib/pages/dynamics/detail/view.dart @@ -64,6 +64,11 @@ class _DynamicDetailPageState extends State get _getImageCallback => _horizontalPreview ? (imgList, index) { + bool needReverse = + _fabAnimationCtr?.status.isForwardOrCompleted == true; + if (needReverse) { + _fabAnimationCtr?.reverse(); + } final ctr = AnimationController( vsync: this, duration: const Duration(milliseconds: 200), @@ -77,10 +82,20 @@ class _DynamicDetailPageState extends State ctr, imgList, index, - () async { - await ctr.reverse(); - ctr.dispose(); - Get.back(); + (value) async { + if (needReverse) { + needReverse = false; + _fabAnimationCtr?.forward(); + } + if (value == false) { + await ctr.reverse(); + } + try { + ctr.dispose(); + } catch (_) {} + if (value == false) { + Get.back(); + } }, ); } @@ -155,7 +170,9 @@ class _DynamicDetailPageState extends State EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () { int oid = replyItem.oid.toInt(); int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid; - Widget replyReplyPage([bool automaticallyImplyLeading = true]) => + Widget replyReplyPage( + [bool automaticallyImplyLeading = true, + VoidCallback? onDispose]) => Scaffold( resizeToAvoidBottomInset: false, appBar: AppBar( @@ -171,6 +188,7 @@ class _DynamicDetailPageState extends State replyType: ReplyType.values[replyType], firstFloor: replyItem, isTop: isTop ?? false, + onDispose: onDispose, ), ); if (this.context.orientation == Orientation.portrait) { @@ -178,12 +196,24 @@ class _DynamicDetailPageState extends State } else { ScaffoldState? scaffoldState = Scaffold.maybeOf(context); if (scaffoldState != null) { + bool needReverse = + _fabAnimationCtr?.status.isForwardOrCompleted == true; + if (needReverse) { + _fabAnimationCtr?.reverse(); + } scaffoldState.showBottomSheet( backgroundColor: Colors.transparent, (context) => MediaQuery.removePadding( context: context, removeLeft: true, - child: replyReplyPage(false), + child: replyReplyPage( + false, + () { + if (needReverse) { + _fabAnimationCtr?.forward(); + } + }, + ), ), ); } else { diff --git a/lib/pages/html/view.dart b/lib/pages/html/view.dart index 85c538439..b00a4846e 100644 --- a/lib/pages/html/view.dart +++ b/lib/pages/html/view.dart @@ -57,6 +57,11 @@ class _HtmlRenderPageState extends State get _getImageCallback => _horizontalPreview ? (imgList, index) { + bool needReverse = + fabAnimationCtr.status.isForwardOrCompleted == true; + if (needReverse) { + fabAnimationCtr.reverse(); + } final ctr = AnimationController( vsync: this, duration: const Duration(milliseconds: 200), @@ -70,10 +75,20 @@ class _HtmlRenderPageState extends State ctr, imgList, index, - () async { - await ctr.reverse(); - ctr.dispose(); - Get.back(); + (value) async { + if (needReverse) { + needReverse = false; + fabAnimationCtr.forward(); + } + if (value == false) { + await ctr.reverse(); + } + try { + ctr.dispose(); + } catch (_) {} + if (value == false) { + Get.back(); + } }, ); } @@ -144,7 +159,9 @@ class _HtmlRenderPageState extends State EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () { int oid = replyItem.oid.toInt(); int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid; - Widget replyReplyPage([bool automaticallyImplyLeading = true]) => + Widget replyReplyPage( + [bool automaticallyImplyLeading = true, + VoidCallback? onDispose]) => Scaffold( resizeToAvoidBottomInset: false, appBar: AppBar( @@ -160,6 +177,7 @@ class _HtmlRenderPageState extends State replyType: ReplyType.values[type], firstFloor: replyItem, isTop: isTop ?? false, + onDispose: onDispose, ), ); if (this.context.orientation == Orientation.portrait) { @@ -167,12 +185,24 @@ class _HtmlRenderPageState extends State } else { ScaffoldState? scaffoldState = Scaffold.maybeOf(context); if (scaffoldState != null) { + bool needReverse = + fabAnimationCtr.status.isForwardOrCompleted == true; + if (needReverse) { + fabAnimationCtr.reverse(); + } scaffoldState.showBottomSheet( backgroundColor: Colors.transparent, (context) => MediaQuery.removePadding( context: context, removeLeft: true, - child: replyReplyPage(false), + child: replyReplyPage( + false, + () { + if (needReverse) { + fabAnimationCtr.forward(); + } + }, + ), ), ); } else { diff --git a/lib/pages/video/detail/reply_reply/view.dart b/lib/pages/video/detail/reply_reply/view.dart index bc811c610..5a18f3b08 100644 --- a/lib/pages/video/detail/reply_reply/view.dart +++ b/lib/pages/video/detail/reply_reply/view.dart @@ -32,6 +32,7 @@ class VideoReplyReplyPanel extends StatefulWidget { this.isTop = false, this.onViewImage, this.onDismissed, + this.onDispose, }); final int? id; final int oid; @@ -44,13 +45,14 @@ class VideoReplyReplyPanel extends StatefulWidget { final bool isTop; final VoidCallback? onViewImage; final ValueChanged? onDismissed; + final VoidCallback? onDispose; @override State createState() => _VideoReplyReplyPanelState(); } class _VideoReplyReplyPanelState extends State - with SingleTickerProviderStateMixin { + with TickerProviderStateMixin { late VideoReplyReplyController _videoReplyReplyController; late final _savedReplies = {}; late final itemPositionsListener = ItemPositionsListener.create(); @@ -82,6 +84,7 @@ class _VideoReplyReplyPanelState extends State @override void dispose() { + widget.onDispose?.call(); _videoReplyReplyController.controller?.stop(); _videoReplyReplyController.controller?.dispose(); _videoReplyReplyController.controller = null; @@ -305,10 +308,16 @@ class _VideoReplyReplyPanelState extends State ctr, imgList, index, - () async { - await ctr.reverse(); - ctr.dispose(); - Get.back(); + (value) async { + if (value == false) { + await ctr.reverse(); + } + try { + ctr.dispose(); + } catch (_) {} + if (value == false) { + Get.back(); + } }, ); } diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 81504288c..bda919e6d 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -1736,10 +1736,16 @@ class _VideoDetailPageState extends State ctr, imgList, index, - () async { - await ctr.reverse(); - ctr.dispose(); - Get.back(); + (value) async { + if (value == false) { + await ctr.reverse(); + } + try { + ctr.dispose(); + } catch (_) {} + if (value == false) { + Get.back(); + } }, ); }