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

View File

@@ -64,6 +64,11 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
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<DynamicDetailPage>
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<DynamicDetailPage>
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<DynamicDetailPage>
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<DynamicDetailPage>
} 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 {

View File

@@ -57,6 +57,11 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
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<HtmlRenderPage>
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<HtmlRenderPage>
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<HtmlRenderPage>
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<HtmlRenderPage>
} 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 {

View File

@@ -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<int>? onDismissed;
final VoidCallback? onDispose;
@override
State<VideoReplyReplyPanel> createState() => _VideoReplyReplyPanelState();
}
class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
with SingleTickerProviderStateMixin {
with TickerProviderStateMixin {
late VideoReplyReplyController _videoReplyReplyController;
late final _savedReplies = {};
late final itemPositionsListener = ItemPositionsListener.create();
@@ -82,6 +84,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
@override
void dispose() {
widget.onDispose?.call();
_videoReplyReplyController.controller?.stop();
_videoReplyReplyController.controller?.dispose();
_videoReplyReplyController.controller = null;
@@ -305,10 +308,16 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
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();
}
},
);
}

View File

@@ -1736,10 +1736,16 @@ class _VideoDetailPageState extends State<VideoDetailPage>
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();
}
},
);
}