mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-21 17:46:24 +08:00
feat: audio page (#1518)
* feat: audio page Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * opt ui Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * impl intro, share, fav Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * tweaks Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * load prev/next Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> --------- Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -21,6 +21,7 @@ abstract class CommonPageState<
|
||||
double? _lastScrollPosition; // 记录上次滚动位置
|
||||
final _enableScrollThreshold = Pref.enableScrollThreshold;
|
||||
late final double _scrollThreshold = Pref.scrollThreshold; // 滚动阈值
|
||||
late final scrollController = controller.scrollController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -29,25 +30,38 @@ abstract class CommonPageState<
|
||||
mainStream = Get.find<MainController>().bottomBarStream;
|
||||
searchBarStream = Get.find<HomeController>().searchBarStream;
|
||||
} catch (_) {}
|
||||
if (mainStream != null || searchBarStream != null) {
|
||||
if (_enableScrollThreshold &&
|
||||
(mainStream != null || searchBarStream != null)) {
|
||||
controller.scrollController.addListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
void listener() {
|
||||
final scrollController = controller.scrollController;
|
||||
final direction = scrollController.position.userScrollDirection;
|
||||
|
||||
if (!_enableScrollThreshold) {
|
||||
if (direction == ScrollDirection.forward) {
|
||||
mainStream?.add(true);
|
||||
searchBarStream?.add(true);
|
||||
} else if (direction == ScrollDirection.reverse) {
|
||||
mainStream?.add(false);
|
||||
searchBarStream?.add(false);
|
||||
}
|
||||
return;
|
||||
Widget onBuild(Widget child) {
|
||||
if (!_enableScrollThreshold &&
|
||||
(mainStream != null || searchBarStream != null)) {
|
||||
return NotificationListener<UserScrollNotification>(
|
||||
onNotification: onNotification,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
bool onNotification(UserScrollNotification notification) {
|
||||
if (notification.metrics.axis == Axis.horizontal) return false;
|
||||
final direction = notification.direction;
|
||||
if (direction == ScrollDirection.forward) {
|
||||
mainStream?.add(true);
|
||||
searchBarStream?.add(true);
|
||||
} else if (direction == ScrollDirection.reverse) {
|
||||
mainStream?.add(false);
|
||||
searchBarStream?.add(false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void listener() {
|
||||
final direction = scrollController.position.userScrollDirection;
|
||||
|
||||
final double currentPosition = scrollController.position.pixels;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user