mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-08-03 01:00:14 +08:00
@@ -5,8 +5,8 @@ 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';
|
||||
import 'package:PiliPlus/common/widgets/main_layout.dart';
|
||||
import 'package:PiliPlus/common/widgets/route_aware_mixin.dart';
|
||||
import 'package:PiliPlus/models/common/nav_bar_config.dart';
|
||||
import 'package:PiliPlus/pages/home/view.dart';
|
||||
@@ -46,7 +46,7 @@ class _MainAppState extends PopScopeState<MainApp>
|
||||
final _mainController = Get.put(MainController());
|
||||
late final _setting = GStorage.setting;
|
||||
late EdgeInsets _padding;
|
||||
late ThemeData theme;
|
||||
late ColorScheme _colorScheme;
|
||||
Brightness? _brightness;
|
||||
|
||||
@override
|
||||
@@ -74,8 +74,8 @@ class _MainAppState extends PopScopeState<MainApp>
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_padding = MediaQuery.viewPaddingOf(context);
|
||||
theme = Theme.of(context);
|
||||
final brightness = theme.brightness;
|
||||
_colorScheme = ColorScheme.of(context);
|
||||
final brightness = _colorScheme.brightness;
|
||||
NetworkImgLayer.reduce =
|
||||
NetworkImgLayer.reduceLuxColor != null && brightness.isDark;
|
||||
if (PlatformUtils.isDesktop) {
|
||||
@@ -368,128 +368,141 @@ class _MainAppState extends PopScopeState<MainApp>
|
||||
return bottomNav;
|
||||
}
|
||||
|
||||
Widget _sideBar(ThemeData theme) {
|
||||
return _mainController.navigationBars.length > 1
|
||||
? context.isTablet && _mainController.optTabletNav
|
||||
? Column(
|
||||
children: [
|
||||
const SizedBox(height: 25),
|
||||
userAndSearchVertical(theme),
|
||||
const Spacer(flex: 2),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: SizedBox(
|
||||
width: 130,
|
||||
child: Obx(
|
||||
() => NavigationDrawer(
|
||||
backgroundColor: Colors.transparent,
|
||||
tilePadding: const .symmetric(
|
||||
vertical: 5,
|
||||
horizontal: 12,
|
||||
),
|
||||
indicatorShape: const RoundedRectangleBorder(
|
||||
borderRadius: .all(.circular(16)),
|
||||
),
|
||||
onDestinationSelected: _mainController.setIndex,
|
||||
selectedIndex: _mainController.selectedIndex.value,
|
||||
children: _mainController.navigationBars
|
||||
.map(
|
||||
(e) => NavigationDrawerDestination(
|
||||
label: Text(e.label),
|
||||
icon: _buildIcon(type: e),
|
||||
selectedIcon: _buildIcon(
|
||||
type: e,
|
||||
selected: true,
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
Widget _sideBar() {
|
||||
if (_mainController.navigationBars.length > 1) {
|
||||
if (context.isTablet && _mainController.optTabletNav) {
|
||||
return Padding(
|
||||
padding: const .only(top: 25),
|
||||
child: MediaQuery.removePadding(
|
||||
context: context,
|
||||
removeRight: true,
|
||||
child: DrawerTheme(
|
||||
data: DrawerThemeData(width: 130 + _padding.left),
|
||||
child: Obx(
|
||||
() => NavigationDrawer(
|
||||
/// apply `lib/scripts/navigation_drawer.patch`
|
||||
flex: 5,
|
||||
backgroundColor: Colors.transparent,
|
||||
onDestinationSelected: _mainController.setIndex,
|
||||
selectedIndex: _mainController.selectedIndex.value,
|
||||
header: Expanded(flex: 4, child: userAndSearchVertical()),
|
||||
tilePadding: const .symmetric(vertical: 5, horizontal: 12),
|
||||
indicatorShape: const RoundedRectangleBorder(
|
||||
borderRadius: .all(.circular(16)),
|
||||
),
|
||||
children: _mainController.navigationBars
|
||||
.map(
|
||||
(e) => NavigationDrawerDestination(
|
||||
label: Text(e.label),
|
||||
icon: _buildIcon(type: e),
|
||||
selectedIcon: _buildIcon(
|
||||
type: e,
|
||||
selected: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Obx(
|
||||
() => NavigationRail(
|
||||
groupAlignment: 0.5,
|
||||
selectedIndex: _mainController.selectedIndex.value,
|
||||
onDestinationSelected: _mainController.setIndex,
|
||||
labelType: .selected,
|
||||
leading: userAndSearchVertical(theme),
|
||||
destinations: _mainController.navigationBars
|
||||
.map(
|
||||
(e) => NavigationRailDestination(
|
||||
label: Text(e.label),
|
||||
icon: _buildIcon(type: e),
|
||||
selectedIcon: _buildIcon(type: e, selected: true),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
width: 80,
|
||||
padding: const .only(top: 10),
|
||||
child: userAndSearchVertical(theme),
|
||||
);
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Obx(
|
||||
() => NavigationRail(
|
||||
groupAlignment: 0.5,
|
||||
labelType: .selected,
|
||||
leading: userAndSearchVertical(),
|
||||
backgroundColor: Colors.transparent,
|
||||
onDestinationSelected: _mainController.setIndex,
|
||||
selectedIndex: _mainController.selectedIndex.value,
|
||||
destinations: _mainController.navigationBars
|
||||
.map(
|
||||
(e) => NavigationRailDestination(
|
||||
label: Text(e.label),
|
||||
icon: _buildIcon(type: e),
|
||||
selectedIcon: _buildIcon(type: e, selected: true),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Container(
|
||||
width: 80,
|
||||
margin: .only(top: 12 + _padding.top, left: _padding.left),
|
||||
child: userAndSearchVertical(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget child;
|
||||
if (_mainController.mainTabBarView) {
|
||||
child = CustomTabBarView(
|
||||
scrollDirection: _mainController.useBottomNav ? .horizontal : .vertical,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
child = TabBarView(
|
||||
controller: _mainController.controller,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
|
||||
/// apply `lib/scripts/tabs.patch`
|
||||
scrollDirection: _mainController.useBottomNav ? .horizontal : .vertical,
|
||||
children: _mainController.navigationBars.map((i) => i.page).toList(),
|
||||
);
|
||||
} else {
|
||||
child = PageView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
controller: _mainController.controller,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: _mainController.navigationBars.map((i) => i.page).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget? sideBar;
|
||||
Widget? bottomNav;
|
||||
final EdgeInsets padding;
|
||||
if (_mainController.useBottomNav) {
|
||||
bottomNav = _bottomNav;
|
||||
child = Row(children: [Expanded(child: child)]);
|
||||
} else {
|
||||
child = Row(
|
||||
children: [
|
||||
_sideBar(theme),
|
||||
VerticalDivider(
|
||||
width: 1,
|
||||
endIndent: _padding.bottom,
|
||||
color: theme.colorScheme.outline.withValues(alpha: 0.06),
|
||||
),
|
||||
Expanded(child: child),
|
||||
],
|
||||
if (bottomNav != null) {
|
||||
bottomNav = MediaQuery.removePadding(
|
||||
context: context,
|
||||
removeTop: true,
|
||||
child: bottomNav,
|
||||
);
|
||||
}
|
||||
padding = .only(
|
||||
top: _padding.top,
|
||||
left: _padding.left,
|
||||
right: _padding.right,
|
||||
);
|
||||
} else {
|
||||
sideBar = DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
right: BorderSide(
|
||||
color: _colorScheme.outline.withValues(alpha: 0.06),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: _sideBar(),
|
||||
);
|
||||
padding = .only(top: _padding.top, right: _padding.right);
|
||||
}
|
||||
|
||||
child = Scaffold(
|
||||
extendBody: true,
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: AppBar(toolbarHeight: 0),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: _mainController.useBottomNav ? _padding.left : 0.0,
|
||||
right: _padding.right,
|
||||
),
|
||||
child: child,
|
||||
child = Material(
|
||||
child: MainLayout(
|
||||
sideBar: sideBar,
|
||||
bottomNav: bottomNav,
|
||||
body: Padding(padding: padding, child: child),
|
||||
),
|
||||
bottomNavigationBar: bottomNav,
|
||||
);
|
||||
|
||||
if (PlatformUtils.isMobile) {
|
||||
child = AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
statusBarBrightness: _colorScheme.brightness,
|
||||
statusBarIconBrightness: _colorScheme.brightness.reverse,
|
||||
systemStatusBarContrastEnforced: false,
|
||||
systemNavigationBarColor: Colors.transparent,
|
||||
systemNavigationBarIconBrightness: theme.brightness.reverse,
|
||||
systemNavigationBarIconBrightness: _colorScheme.brightness.reverse,
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
@@ -517,10 +530,10 @@ class _MainAppState extends PopScopeState<MainApp>
|
||||
: icon;
|
||||
}
|
||||
|
||||
Widget userAndSearchVertical(ThemeData theme) {
|
||||
Widget userAndSearchVertical() {
|
||||
return Column(
|
||||
children: [
|
||||
userAvatar(theme: theme, mainController: _mainController),
|
||||
userAvatar(colorScheme: _colorScheme, mainController: _mainController),
|
||||
const SizedBox(height: 8),
|
||||
msgBadge(_mainController),
|
||||
IconButton(
|
||||
|
||||
Reference in New Issue
Block a user