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

View File

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