opt: horizontal preview

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-02-22 11:53:03 +08:00
parent f94cb2a4b5
commit 61ca7bc1cb
5 changed files with 99 additions and 23 deletions

View File

@@ -67,7 +67,7 @@ class InteractiveviewerGallery<T> extends StatefulWidget {
this.onClose, this.onClose,
}); });
final VoidCallback? onClose; final ValueChanged? onClose;
final bool? setStatusBar; final bool? setStatusBar;
@@ -152,6 +152,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
@override @override
void dispose() async { void dispose() async {
widget.onClose?.call(true);
_player?.dispose(); _player?.dispose();
_pageController?.dispose(); _pageController?.dispose();
_animationController.removeListener(() {}); _animationController.removeListener(() {});
@@ -259,7 +260,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
void onClose() { void onClose() {
if (widget.onClose != null) { if (widget.onClose != null) {
widget.onClose!(); widget.onClose!(false);
} else { } else {
Get.back(); Get.back();
widget.onDismissed?.call(_pageController!.page!.floor()); widget.onDismissed?.call(_pageController!.page!.floor());

View File

@@ -64,6 +64,11 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
get _getImageCallback => _horizontalPreview get _getImageCallback => _horizontalPreview
? (imgList, index) { ? (imgList, index) {
bool needReverse =
_fabAnimationCtr?.status.isForwardOrCompleted == true;
if (needReverse) {
_fabAnimationCtr?.reverse();
}
final ctr = AnimationController( final ctr = AnimationController(
vsync: this, vsync: this,
duration: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 200),
@@ -77,10 +82,20 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
ctr, ctr,
imgList, imgList,
index, index,
() async { (value) async {
await ctr.reverse(); if (needReverse) {
ctr.dispose(); needReverse = false;
Get.back(); _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<DynamicDetailPage>
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () { EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
int oid = replyItem.oid.toInt(); int oid = replyItem.oid.toInt();
int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid; int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid;
Widget replyReplyPage([bool automaticallyImplyLeading = true]) => Widget replyReplyPage(
[bool automaticallyImplyLeading = true,
VoidCallback? onDispose]) =>
Scaffold( Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
@@ -171,6 +188,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
replyType: ReplyType.values[replyType], replyType: ReplyType.values[replyType],
firstFloor: replyItem, firstFloor: replyItem,
isTop: isTop ?? false, isTop: isTop ?? false,
onDispose: onDispose,
), ),
); );
if (this.context.orientation == Orientation.portrait) { if (this.context.orientation == Orientation.portrait) {
@@ -178,12 +196,24 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
} else { } else {
ScaffoldState? scaffoldState = Scaffold.maybeOf(context); ScaffoldState? scaffoldState = Scaffold.maybeOf(context);
if (scaffoldState != null) { if (scaffoldState != null) {
bool needReverse =
_fabAnimationCtr?.status.isForwardOrCompleted == true;
if (needReverse) {
_fabAnimationCtr?.reverse();
}
scaffoldState.showBottomSheet( scaffoldState.showBottomSheet(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
(context) => MediaQuery.removePadding( (context) => MediaQuery.removePadding(
context: context, context: context,
removeLeft: true, removeLeft: true,
child: replyReplyPage(false), child: replyReplyPage(
false,
() {
if (needReverse) {
_fabAnimationCtr?.forward();
}
},
),
), ),
); );
} else { } else {

View File

@@ -57,6 +57,11 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
get _getImageCallback => _horizontalPreview get _getImageCallback => _horizontalPreview
? (imgList, index) { ? (imgList, index) {
bool needReverse =
fabAnimationCtr.status.isForwardOrCompleted == true;
if (needReverse) {
fabAnimationCtr.reverse();
}
final ctr = AnimationController( final ctr = AnimationController(
vsync: this, vsync: this,
duration: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 200),
@@ -70,10 +75,20 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
ctr, ctr,
imgList, imgList,
index, index,
() async { (value) async {
await ctr.reverse(); if (needReverse) {
ctr.dispose(); needReverse = false;
Get.back(); 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<HtmlRenderPage>
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () { EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
int oid = replyItem.oid.toInt(); int oid = replyItem.oid.toInt();
int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid; int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid;
Widget replyReplyPage([bool automaticallyImplyLeading = true]) => Widget replyReplyPage(
[bool automaticallyImplyLeading = true,
VoidCallback? onDispose]) =>
Scaffold( Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
@@ -160,6 +177,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
replyType: ReplyType.values[type], replyType: ReplyType.values[type],
firstFloor: replyItem, firstFloor: replyItem,
isTop: isTop ?? false, isTop: isTop ?? false,
onDispose: onDispose,
), ),
); );
if (this.context.orientation == Orientation.portrait) { if (this.context.orientation == Orientation.portrait) {
@@ -167,12 +185,24 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
} else { } else {
ScaffoldState? scaffoldState = Scaffold.maybeOf(context); ScaffoldState? scaffoldState = Scaffold.maybeOf(context);
if (scaffoldState != null) { if (scaffoldState != null) {
bool needReverse =
fabAnimationCtr.status.isForwardOrCompleted == true;
if (needReverse) {
fabAnimationCtr.reverse();
}
scaffoldState.showBottomSheet( scaffoldState.showBottomSheet(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
(context) => MediaQuery.removePadding( (context) => MediaQuery.removePadding(
context: context, context: context,
removeLeft: true, removeLeft: true,
child: replyReplyPage(false), child: replyReplyPage(
false,
() {
if (needReverse) {
fabAnimationCtr.forward();
}
},
),
), ),
); );
} else { } else {

View File

@@ -32,6 +32,7 @@ class VideoReplyReplyPanel extends StatefulWidget {
this.isTop = false, this.isTop = false,
this.onViewImage, this.onViewImage,
this.onDismissed, this.onDismissed,
this.onDispose,
}); });
final int? id; final int? id;
final int oid; final int oid;
@@ -44,13 +45,14 @@ class VideoReplyReplyPanel extends StatefulWidget {
final bool isTop; final bool isTop;
final VoidCallback? onViewImage; final VoidCallback? onViewImage;
final ValueChanged<int>? onDismissed; final ValueChanged<int>? onDismissed;
final VoidCallback? onDispose;
@override @override
State<VideoReplyReplyPanel> createState() => _VideoReplyReplyPanelState(); State<VideoReplyReplyPanel> createState() => _VideoReplyReplyPanelState();
} }
class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
with SingleTickerProviderStateMixin { with TickerProviderStateMixin {
late VideoReplyReplyController _videoReplyReplyController; late VideoReplyReplyController _videoReplyReplyController;
late final _savedReplies = {}; late final _savedReplies = {};
late final itemPositionsListener = ItemPositionsListener.create(); late final itemPositionsListener = ItemPositionsListener.create();
@@ -82,6 +84,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
@override @override
void dispose() { void dispose() {
widget.onDispose?.call();
_videoReplyReplyController.controller?.stop(); _videoReplyReplyController.controller?.stop();
_videoReplyReplyController.controller?.dispose(); _videoReplyReplyController.controller?.dispose();
_videoReplyReplyController.controller = null; _videoReplyReplyController.controller = null;
@@ -305,10 +308,16 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
ctr, ctr,
imgList, imgList,
index, index,
() async { (value) async {
await ctr.reverse(); if (value == false) {
ctr.dispose(); await ctr.reverse();
Get.back(); }
try {
ctr.dispose();
} catch (_) {}
if (value == false) {
Get.back();
}
}, },
); );
} }

View File

@@ -1736,10 +1736,16 @@ class _VideoDetailPageState extends State<VideoDetailPage>
ctr, ctr,
imgList, imgList,
index, index,
() async { (value) async {
await ctr.reverse(); if (value == false) {
ctr.dispose(); await ctr.reverse();
Get.back(); }
try {
ctr.dispose();
} catch (_) {}
if (value == false) {
Get.back();
}
}, },
); );
} }