Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-27 21:54:45 +08:00
parent ab7b1524b6
commit 54cb1a6fc0
2 changed files with 29 additions and 26 deletions

View File

@@ -21,7 +21,6 @@ class VideoReplyReplyController extends ReplyController
required this.dialog,
required this.replyType,
required this.isDialogue,
required this.getThemeData,
});
final int? dialog;
final bool isDialogue;
@@ -40,7 +39,6 @@ class VideoReplyReplyController extends ReplyController
int? index;
AnimationController? controller;
Animation<Color?>? colorAnimation;
late final horizontalPreview = GStorage.horizontalPreview;
@@ -61,8 +59,6 @@ class VideoReplyReplyController extends ReplyController
return super.onRefresh();
}
final ThemeData Function() getThemeData;
@override
bool customHandleResponse(Success response) {
if (GlobalData().grpcReply) {
@@ -78,15 +74,13 @@ class VideoReplyReplyController extends ReplyController
.map((item) => item.id.toInt())
.toList()
.indexOf(id!);
if (index != null && index != -1) {
if (index == -1) {
index = null;
} else {
controller = AnimationController(
duration: const Duration(milliseconds: 300),
vsync: this,
);
colorAnimation = ColorTween(
begin: getThemeData().colorScheme.onInverseSurface,
end: getThemeData().colorScheme.surface,
).animate(controller!);
WidgetsBinding.instance.addPostFrameCallback((_) async {
if (index != null) {
try {
@@ -202,4 +196,10 @@ class VideoReplyReplyController extends ReplyController
: Mode.MAIN_LIST_HOT;
onReload();
}
@override
void onClose() {
controller?.dispose();
super.dispose();
}
}

View File

@@ -68,6 +68,8 @@ class _VideoReplyReplyPanelState
context.orientation == Orientation.landscape &&
_videoReplyReplyController.horizontalPreview;
Animation<Color?>? colorAnimation;
@override
void initState() {
super.initState();
@@ -80,7 +82,6 @@ class _VideoReplyReplyPanelState
dialog: widget.dialog,
replyType: widget.replyType,
isDialogue: widget.isDialogue,
getThemeData: () => Theme.of(context),
),
tag: '${widget.rpid}${widget.dialog}${widget.isDialogue}',
);
@@ -89,9 +90,6 @@ class _VideoReplyReplyPanelState
@override
void dispose() {
widget.onDispose?.call();
_videoReplyReplyController.controller?.stop();
_videoReplyReplyController.controller?.dispose();
_videoReplyReplyController.controller = null;
Get.delete<VideoReplyReplyController>(
tag: '${widget.rpid}${widget.dialog}${widget.isDialogue}',
);
@@ -471,19 +469,24 @@ class _VideoReplyReplyPanelState
),
);
} else {
return _videoReplyReplyController.index == index
? AnimatedBuilder(
animation: _videoReplyReplyController.colorAnimation!,
if (_videoReplyReplyController.index != null &&
_videoReplyReplyController.index == index) {
colorAnimation ??= ColorTween(
begin: Theme.of(context).colorScheme.onInverseSurface,
end: Theme.of(context).colorScheme.surface,
).animate(_videoReplyReplyController.controller!);
return AnimatedBuilder(
animation: colorAnimation!,
builder: (context, child) {
return ColoredBox(
color:
_videoReplyReplyController.colorAnimation?.value ??
color: colorAnimation!.value ??
Theme.of(context).colorScheme.onInverseSurface,
child: _replyItem(loadingState.response[index], index),
);
},
)
: _replyItem(loadingState.response[index], index);
);
}
return _replyItem(loadingState.response[index], index);
}
}(),
Error() => replyErrorWidget(