mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: nav bar
Closes #138 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -36,11 +36,14 @@ class _HomePageState extends State<HomePage>
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(toolbarHeight: 0),
|
appBar: AppBar(toolbarHeight: 0),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
if (!_homeController.useSideBar) customAppBar,
|
if (!_homeController.useSideBar &&
|
||||||
|
context.orientation == Orientation.portrait)
|
||||||
|
customAppBar,
|
||||||
if (_homeController.tabs.length > 1) ...[
|
if (_homeController.tabs.length > 1) ...[
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Material(
|
Material(
|
||||||
|
|||||||
@@ -165,67 +165,21 @@ class _MainAppState extends State<MainApp>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: LayoutBuilder(
|
child: Scaffold(
|
||||||
builder: (context, constriants) {
|
|
||||||
bool isPortait = constriants.maxHeight > constriants.maxWidth;
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
extendBody: true,
|
extendBody: true,
|
||||||
body: Row(
|
body: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
if (useSideBar) ...[
|
if (useSideBar || context.orientation == Orientation.landscape)
|
||||||
SizedBox(
|
|
||||||
width: context.width * 0.04 +
|
|
||||||
40 +
|
|
||||||
MediaQuery.of(context).padding.left,
|
|
||||||
child: Obx(
|
|
||||||
() => _mainController.navigationBars.length > 1
|
|
||||||
? NavigationRail(
|
|
||||||
groupAlignment: 1,
|
|
||||||
minWidth: context.width * 0.0286 + 28.56,
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
selectedIndex:
|
|
||||||
_mainController.selectedIndex.value,
|
|
||||||
onDestinationSelected: setIndex,
|
|
||||||
labelType: NavigationRailLabelType.none,
|
|
||||||
leading: userAndSearchVertical,
|
|
||||||
destinations: _mainController.navigationBars
|
|
||||||
.map((e) => NavigationRailDestination(
|
|
||||||
icon: _buildIcon(
|
|
||||||
id: e['id'],
|
|
||||||
count: e['count'],
|
|
||||||
icon: e['icon'],
|
|
||||||
),
|
|
||||||
selectedIcon: _buildIcon(
|
|
||||||
id: e['id'],
|
|
||||||
count: e['count'],
|
|
||||||
icon: e['selectIcon'],
|
|
||||||
),
|
|
||||||
label: Text(e['label']),
|
|
||||||
padding: EdgeInsets.symmetric(
|
|
||||||
vertical: 0.01 * context.height),
|
|
||||||
))
|
|
||||||
.toList(),
|
|
||||||
trailing: SizedBox(height: 0.1 * context.height),
|
|
||||||
)
|
|
||||||
: Container(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
top: MediaQuery.paddingOf(context).top + 10),
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
minWidth: context.width * 0.0286 + 28.56,
|
|
||||||
),
|
|
||||||
child: userAndSearchVertical,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
] else if (!isPortait)
|
|
||||||
Obx(
|
Obx(
|
||||||
() => _mainController.navigationBars.length > 1
|
() => _mainController.navigationBars.length > 1
|
||||||
? NavigationRail(
|
? NavigationRail(
|
||||||
onDestinationSelected: setIndex,
|
groupAlignment: 0.5,
|
||||||
selectedIndex: _mainController.selectedIndex.value,
|
selectedIndex: _mainController.selectedIndex.value,
|
||||||
|
onDestinationSelected: setIndex,
|
||||||
|
labelType: NavigationRailLabelType.selected,
|
||||||
|
leading: userAndSearchVertical,
|
||||||
destinations: _mainController.navigationBars
|
destinations: _mainController.navigationBars
|
||||||
.map(
|
.map(
|
||||||
(e) => NavigationRailDestination(
|
(e) => NavigationRailDestination(
|
||||||
@@ -244,14 +198,19 @@ class _MainAppState extends State<MainApp>
|
|||||||
)
|
)
|
||||||
.toList(),
|
.toList(),
|
||||||
)
|
)
|
||||||
: const SizedBox.shrink(),
|
: Container(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
top: MediaQuery.paddingOf(context).top + 10,
|
||||||
|
),
|
||||||
|
width: 56,
|
||||||
|
child: userAndSearchVertical,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
VerticalDivider(
|
VerticalDivider(
|
||||||
width: 1,
|
width: 1,
|
||||||
indent: MediaQuery.of(context).padding.top,
|
indent: MediaQuery.of(context).padding.top,
|
||||||
endIndent: MediaQuery.of(context).padding.bottom,
|
endIndent: MediaQuery.of(context).padding.bottom,
|
||||||
color:
|
color: Theme.of(context).colorScheme.outline.withOpacity(0.06),
|
||||||
Theme.of(context).colorScheme.outline.withOpacity(0.06),
|
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: PageView(
|
child: PageView(
|
||||||
@@ -260,10 +219,10 @@ class _MainAppState extends State<MainApp>
|
|||||||
children: _mainController.pages,
|
children: _mainController.pages,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (useSideBar) SizedBox(width: context.width * 0.004),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
bottomNavigationBar: useSideBar || !isPortait
|
bottomNavigationBar:
|
||||||
|
useSideBar || context.orientation == Orientation.landscape
|
||||||
? null
|
? null
|
||||||
: StreamBuilder(
|
: StreamBuilder(
|
||||||
stream: _mainController.hideTabBar
|
stream: _mainController.hideTabBar
|
||||||
@@ -313,10 +272,6 @@ class _MainAppState extends State<MainApp>
|
|||||||
selectedFontSize: 12,
|
selectedFontSize: 12,
|
||||||
unselectedFontSize: 12,
|
unselectedFontSize: 12,
|
||||||
type: BottomNavigationBarType.fixed,
|
type: BottomNavigationBarType.fixed,
|
||||||
// selectedItemColor:
|
|
||||||
// Theme.of(context).colorScheme.primary, // 选中项的颜色
|
|
||||||
// unselectedItemColor:
|
|
||||||
// Theme.of(context).colorScheme.onSurface,
|
|
||||||
items: _mainController.navigationBars
|
items: _mainController.navigationBars
|
||||||
.map(
|
.map(
|
||||||
(e) => BottomNavigationBarItem(
|
(e) => BottomNavigationBarItem(
|
||||||
@@ -340,8 +295,6 @@ class _MainAppState extends State<MainApp>
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user