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

@@ -31,7 +31,9 @@ class MainController extends GetxController
List<NavigationBarType> navigationBars = <NavigationBarType>[];
RxDouble? barOffset;
RxBool? showBottomBar;
late final bool hideBottomBar;
late final barHideType = Pref.barHideType;
late double navHeight = 80.0;
bool useBottomNav = false;
late dynamic controller;
@@ -86,8 +88,13 @@ class MainController extends GetxController
hideBottomBar =
!useSideBar && navigationBars.length > 1 && Pref.hideBottomBar;
if (hideBottomBar || homeController.hideTopBar) {
barOffset = RxDouble(0.0);
if (hideBottomBar) {
switch (barHideType) {
case .instant:
showBottomBar = RxBool(true);
case .sync:
barOffset ??= RxDouble(0.0);
}
}
dynamicBadgeMode = Pref.dynamicBadgeMode;
@@ -318,6 +325,12 @@ class MainController extends GetxController
}
}
void setSearchBar() {
if (hasHome) {
homeController.showTopBar?.value = true;
}
}
@override
void onClose() {
barOffset?.close();

View File

@@ -57,7 +57,9 @@ class _MainAppState extends PopScopeState<MainApp>
void didChangeDependencies() {
super.didChangeDependencies();
_padding = MediaQuery.viewPaddingOf(context);
_mainController.navHeight = 80.0 + _padding.bottom;
if (_mainController.hideBottomBar && _mainController.barHideType == .sync) {
_mainController.navHeight = 80.0 + _padding.bottom;
}
final brightness = Theme.brightnessOf(context);
NetworkImgLayer.reduce =
NetworkImgLayer.reduceLuxColor != null && brightness.isDark;
@@ -253,7 +255,9 @@ class _MainAppState extends PopScopeState<MainApp>
if (_mainController.selectedIndex.value != 0) {
_mainController
..setIndex(0)
..barOffset?.value = 0.0;
..barOffset?.value = 0.0
..showBottomBar?.value = true
..setSearchBar();
} else {
_onBack();
}
@@ -300,14 +304,26 @@ class _MainAppState extends PopScopeState<MainApp>
)
: null;
if (bottomNav != null && _mainController.hideBottomBar) {
return Obx(
() => CustomHeightWidget(
height:
_mainController.navHeight *
(1 - _mainController.barOffset!.value / StyleString.topBarHeight),
child: bottomNav,
),
);
if (_mainController.barOffset case final barOffset?) {
return Obx(
() => CustomHeightWidget(
height:
_mainController.navHeight *
(1 - barOffset.value / StyleString.topBarHeight),
child: bottomNav,
),
);
}
if (_mainController.showBottomBar case final showBottomBar?) {
return Obx(
() => AnimatedSlide(
curve: Curves.easeInOutCubicEmphasized,
duration: const Duration(milliseconds: 500),
offset: Offset(0, showBottomBar.value ? 0 : 1),
child: bottomNav,
),
);
}
}
return bottomNav;
}