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

@@ -44,22 +44,6 @@ class RankController extends GetxController with GetTickerProviderStateMixin {
length: tabs.length,
vsync: this,
);
// 监听 tabController 切换
// if (enableGradientBg) {
// tabController.animation!.addListener(() {
// if (tabController.indexIsChanging) {
// if (initialIndex.value != tabController.index) {
// initialIndex.value = tabController.index;
// }
// } else {
// final int temp = tabController.animation!.value.round();
// if (initialIndex.value != temp) {
// initialIndex.value = temp;
// tabController.index = initialIndex.value;
// }
// }
// });
// }
}
@override

View File

@@ -36,28 +36,28 @@ class _ZonePageState extends State<ZonePage>
super.initState();
_zoneController =
Get.put(ZoneController(zoneID: widget.rid), tag: widget.rid.toString());
_zoneController.scrollController.addListener(listener);
}
void listener() {
StreamController<bool> mainStream =
Get.find<MainController>().bottomBarStream;
StreamController<bool> searchBarStream =
Get.find<HomeController>().searchBarStream;
_zoneController.scrollController.addListener(
() {
final ScrollDirection direction =
_zoneController.scrollController.position.userScrollDirection;
if (direction == ScrollDirection.forward) {
mainStream.add(true);
searchBarStream.add(true);
} else if (direction == ScrollDirection.reverse) {
mainStream.add(false);
searchBarStream.add(false);
}
},
);
final ScrollDirection direction =
_zoneController.scrollController.position.userScrollDirection;
if (direction == ScrollDirection.forward) {
mainStream.add(true);
searchBarStream.add(true);
} else if (direction == ScrollDirection.reverse) {
mainStream.add(false);
searchBarStream.add(false);
}
}
@override
void dispose() {
_zoneController.scrollController.removeListener(() {});
_zoneController.scrollController.removeListener(listener);
super.dispose();
}