mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-14 05:10:13 +08:00
@@ -1,5 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/avatars.dart';
|
||||
import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
|
||||
@@ -55,6 +55,7 @@ class MainController extends GetxController
|
||||
late int lastCheckUnreadAt = 0;
|
||||
|
||||
final enableMYBar = Pref.enableMYBar;
|
||||
final floatingNavBar = Pref.floatingNavBar;
|
||||
final useSideBar = Pref.useSideBar;
|
||||
final mainTabBarView = Pref.mainTabBarView;
|
||||
late final optTabletNav = Pref.optTabletNav;
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:io';
|
||||
import 'package:PiliPlus/common/assets.dart';
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/style.dart';
|
||||
import 'package:PiliPlus/common/widgets/floating_navigation_bar.dart';
|
||||
import 'package:PiliPlus/common/widgets/flutter/pop_scope.dart';
|
||||
import 'package:PiliPlus/common/widgets/flutter/tabs.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
@@ -270,67 +271,88 @@ class _MainAppState extends PopScopeState<MainApp>
|
||||
}
|
||||
|
||||
Widget? get _bottomNav {
|
||||
Widget? bottomNav = _mainController.navigationBars.length > 1
|
||||
? _mainController.enableMYBar
|
||||
? Obx(
|
||||
() => NavigationBar(
|
||||
maintainBottomViewPadding: true,
|
||||
onDestinationSelected: _mainController.setIndex,
|
||||
selectedIndex: _mainController.selectedIndex.value,
|
||||
destinations: _mainController.navigationBars
|
||||
.map(
|
||||
(e) => NavigationDestination(
|
||||
label: e.label,
|
||||
icon: _buildIcon(type: e),
|
||||
selectedIcon: _buildIcon(type: e, selected: true),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
Widget? bottomNav;
|
||||
if (_mainController.navigationBars.length > 1) {
|
||||
if (_mainController.floatingNavBar) {
|
||||
bottomNav = Obx(
|
||||
() => FloatingNavigationBar(
|
||||
onDestinationSelected: _mainController.setIndex,
|
||||
selectedIndex: _mainController.selectedIndex.value,
|
||||
destinations: _mainController.navigationBars
|
||||
.map(
|
||||
(e) => FloatingNavigationDestination(
|
||||
label: e.label,
|
||||
icon: _buildIcon(type: e),
|
||||
selectedIcon: _buildIcon(type: e, selected: true),
|
||||
),
|
||||
)
|
||||
: Obx(
|
||||
() => BottomNavigationBar(
|
||||
currentIndex: _mainController.selectedIndex.value,
|
||||
onTap: _mainController.setIndex,
|
||||
iconSize: 16,
|
||||
selectedFontSize: 12,
|
||||
unselectedFontSize: 12,
|
||||
type: .fixed,
|
||||
items: _mainController.navigationBars
|
||||
.map(
|
||||
(e) => BottomNavigationBarItem(
|
||||
label: e.label,
|
||||
icon: _buildIcon(type: e),
|
||||
activeIcon: _buildIcon(type: e, selected: true),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
} else if (_mainController.enableMYBar) {
|
||||
bottomNav = Obx(
|
||||
() => NavigationBar(
|
||||
maintainBottomViewPadding: true,
|
||||
onDestinationSelected: _mainController.setIndex,
|
||||
selectedIndex: _mainController.selectedIndex.value,
|
||||
destinations: _mainController.navigationBars
|
||||
.map(
|
||||
(e) => NavigationDestination(
|
||||
label: e.label,
|
||||
icon: _buildIcon(type: e),
|
||||
selectedIcon: _buildIcon(type: e, selected: true),
|
||||
),
|
||||
)
|
||||
: null;
|
||||
if (bottomNav != null && _mainController.hideBottomBar) {
|
||||
if (_mainController.barOffset case final barOffset?) {
|
||||
return Obx(
|
||||
() => FractionalTranslation(
|
||||
translation: Offset(
|
||||
0.0,
|
||||
barOffset.value / Style.topBarHeight,
|
||||
),
|
||||
child: bottomNav,
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
bottomNav = Obx(
|
||||
() => BottomNavigationBar(
|
||||
currentIndex: _mainController.selectedIndex.value,
|
||||
onTap: _mainController.setIndex,
|
||||
iconSize: 16,
|
||||
selectedFontSize: 12,
|
||||
unselectedFontSize: 12,
|
||||
type: .fixed,
|
||||
items: _mainController.navigationBars
|
||||
.map(
|
||||
(e) => BottomNavigationBarItem(
|
||||
label: e.label,
|
||||
icon: _buildIcon(type: e),
|
||||
activeIcon: _buildIcon(type: e, selected: true),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
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,
|
||||
),
|
||||
);
|
||||
|
||||
if (_mainController.hideBottomBar) {
|
||||
if (_mainController.barOffset case final barOffset?) {
|
||||
return Obx(
|
||||
() => FractionalTranslation(
|
||||
translation: Offset(
|
||||
0.0,
|
||||
barOffset.value / Style.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;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ List<SettingsModel> get styleSettings => [
|
||||
),
|
||||
const SwitchModel(
|
||||
title: '优化平板导航栏',
|
||||
leading: Icon(MdiIcons.soundbar),
|
||||
leading: Icon(Icons.auto_fix_high),
|
||||
setKey: SettingBoxKey.optTabletNav,
|
||||
defaultVal: true,
|
||||
needReboot: true,
|
||||
@@ -119,6 +119,13 @@ List<SettingsModel> get styleSettings => [
|
||||
defaultVal: true,
|
||||
needReboot: true,
|
||||
),
|
||||
const SwitchModel(
|
||||
title: '悬浮底栏',
|
||||
leading: Icon(MdiIcons.soundbar),
|
||||
setKey: SettingBoxKey.floatingNavBar,
|
||||
defaultVal: false,
|
||||
needReboot: true,
|
||||
),
|
||||
NormalModel(
|
||||
leading: const Icon(Icons.calendar_view_week_outlined),
|
||||
title: '列表宽度(dp)限制',
|
||||
|
||||
Reference in New Issue
Block a user