mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
correct scrollable position when hiding top bar
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -11,6 +11,8 @@ abstract class CommonPageState<T extends StatefulWidget> extends State<T> {
|
|||||||
RxBool? _showBottomBar;
|
RxBool? _showBottomBar;
|
||||||
final _mainController = Get.find<MainController>();
|
final _mainController = Get.find<MainController>();
|
||||||
|
|
||||||
|
bool get needsCorrection => false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -63,11 +65,32 @@ abstract class CommonPageState<T extends StatefulWidget> extends State<T> {
|
|||||||
bool onNotificationType2(ScrollNotification notification) {
|
bool onNotificationType2(ScrollNotification notification) {
|
||||||
if (!_mainController.useBottomNav) return false;
|
if (!_mainController.useBottomNav) return false;
|
||||||
|
|
||||||
if (notification.metrics.axis == .horizontal) return false;
|
final metrics = notification.metrics;
|
||||||
|
if (metrics.axis == .horizontal) return false;
|
||||||
|
|
||||||
if (notification is ScrollUpdateNotification) {
|
if (notification is ScrollUpdateNotification) {
|
||||||
if (notification.dragDetails == null) return false;
|
if (notification.dragDetails == null) return false;
|
||||||
_updateOffset(notification.scrollDelta ?? 0.0);
|
final pixel = metrics.pixels;
|
||||||
|
final scrollDelta = notification.scrollDelta ?? 0;
|
||||||
|
if (pixel < 0.0 && scrollDelta > 0) return false;
|
||||||
|
if (needsCorrection) {
|
||||||
|
final value = _barOffset!.value;
|
||||||
|
final newValue = clampDouble(
|
||||||
|
value + scrollDelta,
|
||||||
|
0.0,
|
||||||
|
StyleString.topBarHeight,
|
||||||
|
);
|
||||||
|
final offset = newValue - value;
|
||||||
|
if (offset != 0) {
|
||||||
|
_barOffset!.value = newValue;
|
||||||
|
if (pixel < 0.0 && scrollDelta < 0.0 && value > 0.0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Scrollable.of(notification.context!).position.correctBy(-offset);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_updateOffset(scrollDelta);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ class _HomePageState extends CommonPageState<HomePage>
|
|||||||
final _homeController = Get.putOrFind(HomeController.new);
|
final _homeController = Get.putOrFind(HomeController.new);
|
||||||
final _mainController = Get.find<MainController>();
|
final _mainController = Get.find<MainController>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get needsCorrection => _homeController.hideTopBar;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get wantKeepAlive => true;
|
bool get wantKeepAlive => true;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import 'package:PiliPlus/utils/extension/size_ext.dart';
|
|||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
import 'package:PiliPlus/utils/storage_key.dart';
|
import 'package:PiliPlus/utils/storage_key.dart';
|
||||||
import 'package:PiliPlus/utils/utils.dart';
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:flutter/material.dart'hide LayoutBuilder;
|
import 'package:flutter/material.dart' hide LayoutBuilder;
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
class SearchPage extends StatefulWidget {
|
class SearchPage extends StatefulWidget {
|
||||||
|
|||||||
Reference in New Issue
Block a user