mod: listener

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-02-25 12:38:20 +08:00
parent 0e69e23606
commit e236485bc7
29 changed files with 348 additions and 334 deletions

View File

@@ -31,13 +31,17 @@ class AnimatedDialogState extends State<AnimatedDialog>
opacityAnimation = Tween<double>(begin: 0.0, end: 0.6)
.animate(CurvedAnimation(parent: controller, curve: Curves.linear));
scaleAnimation = CurvedAnimation(parent: controller, curve: Curves.linear);
controller.addListener(() => setState(() {}));
controller.addListener(listener);
controller.forward();
}
void listener() {
setState(() {});
}
@override
void dispose() {
controller.removeListener(() {});
controller.removeListener(listener);
controller.dispose();
super.dispose();
}

View File

@@ -127,10 +127,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
_animationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 300),
)..addListener(() {
_transformationController!.value =
_animation?.value ?? Matrix4.identity();
});
)..addListener(listener);
if (widget.setStatusBar != false) {
setStatusBar();
@@ -141,6 +138,10 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
}
}
void listener() {
_transformationController!.value = _animation?.value ?? Matrix4.identity();
}
setStatusBar() async {
if (Platform.isIOS || Platform.isAndroid) {
await StatusBarControl.setHidden(
@@ -155,7 +156,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
widget.onClose?.call(true);
_player?.dispose();
_pageController?.dispose();
_animationController.removeListener(() {});
_animationController.removeListener(listener);
_animationController.dispose();
if (widget.setStatusBar != false) {
if (Platform.isIOS || Platform.isAndroid) {

View File

@@ -105,6 +105,10 @@ class _ListSheetContentState extends State<ListSheetContent>
.indexWhere((e) => e.cid == widget.currentCid)
: episodes.indexWhere((e) => e.cid == widget.currentCid));
void listener() {
_indexStream?.add(_ctr?.index);
}
@override
void initState() {
super.initState();
@@ -114,9 +118,7 @@ class _ListSheetContentState extends State<ListSheetContent>
vsync: this,
length: widget.season.sections.length,
initialIndex: _index,
)..addListener(() {
_indexStream?.add(_ctr?.index);
});
)..addListener(listener);
}
itemScrollController = _isList
? List.generate(
@@ -148,7 +150,7 @@ class _ListSheetContentState extends State<ListSheetContent>
_favStream = null;
_indexStream?.close();
_indexStream = null;
_ctr?.removeListener(() {});
_ctr?.removeListener(listener);
_ctr?.dispose();
super.dispose();
}