add bar hide type

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-02-18 21:12:34 +08:00
parent a142b15344
commit 3f3d54fd27
12 changed files with 223 additions and 63 deletions

View File

@@ -1,5 +1,6 @@
import 'package:PiliPlus/common/constants.dart' show StyleString;
import 'package:PiliPlus/pages/common/common_controller.dart';
import 'package:PiliPlus/pages/home/controller.dart';
import 'package:PiliPlus/pages/main/controller.dart';
import 'package:flutter/foundation.dart' show clampDouble;
import 'package:flutter/material.dart';
@@ -11,25 +12,52 @@ abstract class CommonPageState<
>
extends State<T> {
R get controller;
final _mainController = Get.find<MainController>();
RxDouble? _barOffset;
RxBool? _showTopBar;
RxBool? _showBottomBar;
final _mainController = Get.find<MainController>();
@override
void initState() {
super.initState();
_barOffset = _mainController.barOffset;
_showBottomBar = _mainController.showBottomBar;
try {
_showTopBar = Get.find<HomeController>().showTopBar;
} catch (_) {}
}
Widget onBuild(Widget child) {
if (_barOffset != null) {
return NotificationListener<ScrollNotification>(
onNotification: onNotification,
onNotification: onNotificationType2,
child: child,
);
}
if (_showTopBar != null || _showBottomBar != null) {
return NotificationListener<UserScrollNotification>(
onNotification: onNotificationType1,
child: child,
);
}
return child;
}
bool onNotificationType1(UserScrollNotification notification) {
if (!_mainController.useBottomNav) return false;
if (notification.metrics.axis == .horizontal) return false;
switch (notification.direction) {
case .forward:
_showTopBar?.value = true;
_showBottomBar?.value = true;
case .reverse:
_showTopBar?.value = false;
_showBottomBar?.value = false;
case _:
}
return false;
}
void _updateOffset(double scrollDelta) {
_barOffset!.value = clampDouble(
_barOffset!.value + scrollDelta,
@@ -38,7 +66,7 @@ abstract class CommonPageState<
);
}
bool onNotification(ScrollNotification notification) {
bool onNotificationType2(ScrollNotification notification) {
if (!_mainController.useBottomNav) return false;
if (notification.metrics.axis == .horizontal) return false;