feat: add bottom navigation shell with study/manage/stats/account tabs

This commit is contained in:
pluv committed 2026-10-24 01:06:49 +08:00
1 parent 500c69bf33
commit 277ead9fe7
8 files changed
+247 -125

No files matched your search

+63
View File
@@ -0,0 +1,63 @@
import 'package:flutter/material.dart';
import 'pages/account_page.dart';
import 'pages/manage_page.dart';
import 'pages/stats_page.dart';
import 'pages/study_page.dart';
/// 应用外壳:底部四个主入口。
///
/// 用 [IndexedStack] 而不是直接切换 widget,是为了在切页时保留各页面的
/// 状态(滚动位置、输入内容、进行中的学习会话)。
class AppShell extends StatefulWidget {
const AppShell({super.key});
@override
State<AppShell> createState() => _AppShellState();
}
class _AppShellState extends State<AppShell> {
int _selectedIndex = 0;
static const List<Widget> _pages = <Widget>[
StudyPage(),
ManagePage(),
StatsPage(),
AccountPage(),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: IndexedStack(index: _selectedIndex, children: _pages),
bottomNavigationBar: NavigationBar(
selectedIndex: _selectedIndex,
onDestinationSelected: (int index) {
setState(() => _selectedIndex = index);
},
destinations: const <NavigationDestination>[
NavigationDestination(
icon: Icon(Icons.school_outlined),
selectedIcon: Icon(Icons.school),
label: '学习',
),
NavigationDestination(
icon: Icon(Icons.library_books_outlined),
selectedIcon: Icon(Icons.library_books),
label: '管理',
),
NavigationDestination(
icon: Icon(Icons.insights_outlined),
selectedIcon: Icon(Icons.insights),
label: '统计',
),
NavigationDestination(
icon: Icon(Icons.person_outline),
selectedIcon: Icon(Icons.person),
label: '账户',
),
],
),
);
}
}