This commit is contained in:
2026-09-23 15:33:59 +08:00
parent e4cdfbc42f
commit a83cda63f5
24 changed files with 874 additions and 81 deletions
+165
View File
@@ -0,0 +1,165 @@
import 'package:flutter/material.dart';
/// 助手页(占位)。
///
/// 现在是骨架里预留的位置 —— 先让布局一次到位,阶段 B 接 AI 时只填内容、
/// 不再动导航结构。同时它也是首页那个输入框的落地页。
class AssistantPage extends StatelessWidget {
const AssistantPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
width: double.infinity,
height: double.infinity,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Color(0xFFFFE5CC), Color(0xFFFFD4A8), Color(0xFFFFC08A)],
),
),
child: SafeArea(
child: Column(
children: [
_header(context),
Expanded(
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
padding: const EdgeInsets.fromLTRB(24, 40, 24, 0),
children: [
const Center(child: Text('✨', style: TextStyle(fontSize: 46))),
const SizedBox(height: 16),
const Center(
child: Text(
'AI 助手正在建设中',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w600,
color: Color(0xFF5D4037),
),
),
),
const SizedBox(height: 8),
const Center(
child: Text(
'位置已经预留好,接入后不用再改布局',
style: TextStyle(fontSize: 12.5, color: Color(0xFF8D6E63)),
),
),
const SizedBox(height: 28),
_planCard(),
const SizedBox(height: 90),
],
),
),
],
),
),
),
);
}
/// 用 Tab 打开时没有上一页,就不显示返回箭头
Widget _header(BuildContext context) {
return Padding(
padding: const EdgeInsets.fromLTRB(10, 6, 16, 6),
child: Row(
children: [
if (Navigator.of(context).canPop())
InkWell(
onTap: () => Navigator.of(context).pop(),
borderRadius: BorderRadius.circular(20),
child: const Padding(
padding: EdgeInsets.all(6),
child: Icon(Icons.arrow_back, size: 22, color: Color(0xFF5D4037)),
),
),
const Padding(
padding: EdgeInsets.only(left: 6),
child: Text(
'助手',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color(0xFF5D4037),
),
),
),
],
),
);
}
Widget _planCard() {
const items = [
('一句话记账', '「昨天买咖啡 32」→ 自动填好分类和金额'),
('笔记问答', '从你的知识库里找答案,而不是重读一遍'),
('服务器状态', '查状态、看日志 —— 只走预定义动作,不给任意 shell'),
('跨模块查询', '「上周服务器相关的花费」这类要跨模块的问题'),
];
return Container(
padding: const EdgeInsets.fromLTRB(18, 16, 18, 8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'规划中的能力',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: Color(0xFF5D4037),
),
),
const SizedBox(height: 12),
for (final (title, desc) in items) ...[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding: EdgeInsets.only(top: 5),
child: Icon(Icons.circle, size: 5, color: Color(0xFFC8956E)),
),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontSize: 13.5,
fontWeight: FontWeight.w600,
color: Color(0xFF5D4037),
),
),
const SizedBox(height: 2),
Text(
desc,
style: const TextStyle(fontSize: 12, color: Color(0xFF8D6E63)),
),
],
),
),
],
),
const SizedBox(height: 14),
],
const Divider(height: 1, color: Color(0xFFF0E6D8)),
const SizedBox(height: 10),
const Text(
'隐私:涉及你笔记里的服务器信息时,会在请求发出前先脱敏。',
style: TextStyle(fontSize: 11.5, color: Color(0xFFBCAAA4), height: 1.5),
),
const SizedBox(height: 8),
],
),
);
}
}
@@ -11,14 +11,19 @@ import '../../utils/amount_util.dart';
import '../../utils/bill_grouping.dart';
import '../../utils/date_util.dart';
import '../../widgets/state_views.dart';
import '../bill/bill_edit_page.dart';
import 'bill_edit_page.dart';
import 'bill_statistics_page.dart';
import 'widgets/bill_group_card.dart';
import 'widgets/budget_card.dart';
import 'widgets/month_switcher.dart';
/// 首页:月份切换 + 本月汇总 + 预算环 + 按日期分组的账单列表
class HomePage extends ConsumerWidget {
const HomePage({super.key});
/// 记账模块的首页:月份切换 + 本月汇总 + 预算环 + 按日期分组的账单列表。
///
/// 这个页面同时承担两个入口角色:
/// · 从首页仪表盘的「记账」卡片进来(会被 push,这时有返回箭头)
/// · 直接 push 进来时底部没有导航栏,所以底部留白要按情况给
class BillHomePage extends ConsumerWidget {
const BillHomePage({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
@@ -48,7 +53,7 @@ class HomePage extends ConsumerWidget {
physics: const AlwaysScrollableScrollPhysics(),
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
children: [
_header(anchor),
_header(context),
const SizedBox(height: 14),
_summaryCard(anchor, statsAsync),
const SizedBox(height: 12),
@@ -59,7 +64,8 @@ class HomePage extends ConsumerWidget {
_budgetUnavailableTip(),
const SizedBox(height: 16),
..._billSection(context, ref, billsAsync),
const SizedBox(height: 90), // 底部导航避让
// 被 push 进来时底部没有导航栏,就不用留出避让高度
SizedBox(height: Navigator.of(context).canPop() ? 24 : 90),
],
),
),
@@ -68,24 +74,67 @@ class HomePage extends ConsumerWidget {
);
}
// ---- 顶部标题 + 月份切换 ----
Widget _header(DateTime anchor) {
return Row(
// ---- 顶部:返回 + 标题 + 统计入口 / 月份切换 ----
//
// 为什么要分两行:月份切换条本身就有 ~206px 宽,再并上返回箭头(34)、
// 标题(80)、统计图标(34),一行要约 364px —— 而 393 宽的常规手机只有
// 361px 可用,实测溢出 32px。分两行之后每行都很宽松。
Widget _header(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'我的账单',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color(0xFF5D4037),
),
Row(
children: [
if (Navigator.of(context).canPop()) ...[
_iconButton(
icon: Icons.arrow_back,
tooltip: '返回',
onTap: () => Navigator.of(context).pop(),
),
const SizedBox(width: 6),
],
const Text(
'我的账单',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color(0xFF5D4037),
),
),
const Spacer(),
_iconButton(
icon: Icons.bar_chart,
tooltip: '统计分析',
onTap: () => Navigator.of(context).push(
MaterialPageRoute(builder: (_) => const BillStatisticsPage()),
),
),
],
),
const Spacer(),
const SizedBox(height: 10),
const MonthSwitcher(),
],
);
}
Widget _iconButton({
required IconData icon,
required String tooltip,
required VoidCallback onTap,
}) {
return Tooltip(
message: tooltip,
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(20),
child: Padding(
padding: const EdgeInsets.all(6),
child: Icon(icon, size: 22, color: const Color(0xFF5D4037)),
),
),
);
}
// ---- 本月汇总 ----
Widget _summaryCard(DateTime anchor, AsyncValue<StatisticsResponse> statsAsync) {
final stats = statsAsync.value;
@@ -162,7 +211,7 @@ class HomePage extends ConsumerWidget {
if (bills.isEmpty) {
return const EmptyView(
title: '本月暂无账单记录',
tip: '点击底部「记账」添加,或用 OCR 识别小票',
tip: '点击底部「记录」添加,或用 OCR 识别小票',
);
}
return Column(
@@ -10,8 +10,10 @@ import 'widgets/category_pie_card.dart';
import 'widgets/category_rank_list.dart';
/// 统计页:按日/周/月切换 + 汇总 + 分类占比饼图 + 分类明细
class StatisticsPage extends ConsumerWidget {
const StatisticsPage({super.key});
///
/// 属于记账模块,从账单首页右上角进(不是顶层 Tab)。
class BillStatisticsPage extends ConsumerWidget {
const BillStatisticsPage({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
@@ -34,19 +36,13 @@ class StatisticsPage extends ConsumerWidget {
physics: const AlwaysScrollableScrollPhysics(),
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
children: [
const Text(
'统计分析',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color(0xFF5D4037),
),
),
_titleRow(context),
const SizedBox(height: 14),
_tabBar(tab, ref),
const SizedBox(height: 14),
_content(ref, statsAsync),
const SizedBox(height: 90), // 底部导航避让
// 被 push 进来时底部没有导航栏,就不用留出避让高度
SizedBox(height: Navigator.of(context).canPop() ? 24 : 90),
],
),
),
@@ -54,6 +50,31 @@ class StatisticsPage extends ConsumerWidget {
);
}
// ---- 顶部标题(带返回,因为这个页面是 push 进来的) ----
Widget _titleRow(BuildContext context) {
return Row(
children: [
if (Navigator.of(context).canPop())
InkWell(
onTap: () => Navigator.of(context).pop(),
borderRadius: BorderRadius.circular(20),
child: const Padding(
padding: EdgeInsets.all(6),
child: Icon(Icons.arrow_back, size: 22, color: Color(0xFF5D4037)),
),
),
const Text(
'统计分析',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color(0xFF5D4037),
),
),
],
);
}
// ---- 时间粒度切换 ----
Widget _tabBar(StatisticsTab current, WidgetRef ref) {
return Container(
@@ -0,0 +1,47 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../providers/bill_provider.dart';
import '../../../utils/amount_util.dart';
/// 首页仪表盘上「记账」卡片的摘要:当前查看月份的收入 / 支出 / 结余。
///
/// 故意和账单首页共用 `monthAnchorProvider`,而不是自己取 `DateTime.now()`:
/// · 两边看到的永远是同一个月,不会出现「卡片写 9 月、点进去是 8 月」
/// · provider 已经是现成的,不会多打一次接口
/// 所以标签用「N月」而不是「本月」。
class BillModuleSummary extends ConsumerWidget {
const BillModuleSummary({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final anchor = ref.watch(monthAnchorProvider);
final stats = ref.watch(monthlyStatisticsProvider(anchor)).value;
return Row(
children: [
Expanded(
child: _item('${anchor.month}月支出', stats?.totalExpense, const Color(0xFFFA3534)),
),
Expanded(
child: _item('结余', stats?.balance, const Color(0xFF5D4037)),
),
],
);
}
Widget _item(String label, double? amount, Color color) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label, style: const TextStyle(fontSize: 11, color: Color(0xFF8D6E63))),
const SizedBox(height: 3),
Text(
// 统计还没回来时显示占位,避免卡片高度跳动
amount == null ? '--' : '¥${formatAmount(amount)}',
style: TextStyle(fontSize: 14.5, fontWeight: FontWeight.bold, color: color),
),
],
);
}
}
+214
View File
@@ -0,0 +1,214 @@
import 'package:flutter/material.dart';
import '../../core/module/app_module.dart';
import '../assistant/assistant_page.dart';
/// 首页仪表盘:AI 输入入口 + 模块卡片网格。
///
/// 这个页面是「模块目录」,不是某个模块的主页 —— 卡片全部从 [appModules]
/// 生成,所以将来加模块时**这个文件不需要改**。
///
/// 副作用是:打开 App 第一眼看不到账单了,要点一下「记账」卡片才进账单首页。
/// 这是刻意的 —— 记账不再是主角。
class DashboardPage extends StatelessWidget {
const DashboardPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
width: double.infinity,
height: double.infinity,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Color(0xFFFFE5CC), Color(0xFFFFD4A8), Color(0xFFFFC08A)],
),
),
child: SafeArea(
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
padding: const EdgeInsets.fromLTRB(16, 16, 16, 0),
children: [
_header(),
const SizedBox(height: 16),
_aiEntry(context),
const SizedBox(height: 22),
const Text(
'功能模块',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: Color(0xFF5D4037),
),
),
const SizedBox(height: 10),
_moduleGrid(context),
const SizedBox(height: 90), // 底部导航避让
],
),
),
),
);
}
// ---- 标题 + 问候 ----
Widget _header() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'强宝小助手',
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Color(0xFF5D4037),
letterSpacing: 1,
),
),
const SizedBox(height: 4),
Text(
_greeting(),
style: const TextStyle(fontSize: 13, color: Color(0xFF8D6E63)),
),
],
);
}
String _greeting() {
final hour = DateTime.now().hour;
if (hour < 6) return '夜深了,注意休息';
if (hour < 12) return '早上好,今天想做点什么?';
if (hour < 18) return '下午好,今天想做点什么?';
return '晚上好,今天想做点什么?';
}
// ---- AI 入口(阶段 B 接上,现在点进去是占位页)----
Widget _aiEntry(BuildContext context) {
return GestureDetector(
onTap: () => Navigator.of(context).push(
MaterialPageRoute(builder: (_) => const AssistantPage()),
),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 15),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: const Color(0xFFC8956E), width: 1.2),
boxShadow: [
BoxShadow(
color: const Color(0xFF5D4037).withValues(alpha: 0.08),
blurRadius: 10,
offset: const Offset(0, 3),
),
],
),
child: Row(
children: [
const Text('✨', style: TextStyle(fontSize: 18)),
const SizedBox(width: 10),
const Expanded(
child: Text(
'问点什么,或者说一句…',
style: TextStyle(fontSize: 14, color: Color(0xFFBCAAA4)),
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
decoration: BoxDecoration(
color: const Color(0xFFF5EFE6),
borderRadius: BorderRadius.circular(8),
),
child: const Text(
'建设中',
style: TextStyle(fontSize: 11, color: Color(0xFF8D6E63)),
),
),
],
),
),
);
}
// ---- 模块卡片网格 ----
//
// 两列。不用 GridView + childAspectRatio:卡片高度由内容(摘要可有可无)
// 决定,估错比例就会在开发时刷一屏溢出警告 —— GridView 卡片的经典坑。
// 这里让每张卡片自己撑高,居上对齐。
Widget _moduleGrid(BuildContext context) {
const gap = 12.0;
final rows = <Widget>[];
for (var i = 0; i < appModules.length; i += 2) {
final end = i + 2 <= appModules.length ? i + 2 : appModules.length;
final pair = appModules.sublist(i, end);
if (rows.isNotEmpty) rows.add(const SizedBox(height: gap));
rows.add(
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
for (var j = 0; j < pair.length; j++) ...[
if (j > 0) const SizedBox(width: gap),
Expanded(child: _moduleCard(context, pair[j])),
],
// 模块数是奇数时补一个空位,否则最后一张卡片会被拉成通栏
if (pair.length == 1) ...[
const SizedBox(width: gap),
const Expanded(child: SizedBox()),
],
],
),
);
}
return Column(children: rows);
}
Widget _moduleCard(BuildContext context, AppModule module) {
return GestureDetector(
onTap: () => Navigator.of(context).push(MaterialPageRoute(builder: module.open)),
child: Container(
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: const Color(0xFF5D4037).withValues(alpha: 0.08),
blurRadius: 10,
offset: const Offset(0, 3),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(module.icon, style: const TextStyle(fontSize: 24)),
const SizedBox(height: 8),
Text(
module.name,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Color(0xFF5D4037),
),
),
const SizedBox(height: 3),
Text(
module.blurb,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontSize: 11.5, color: Color(0xFF8D6E63)),
),
if (module.summary != null) ...[
const SizedBox(height: 10),
module.summary!(context),
],
],
),
),
);
}
}
+1 -1
View File
@@ -251,7 +251,7 @@ class _LoginPageState extends ConsumerState<LoginPage>
_decoLine(),
const SizedBox(width: 10),
const Text(
'强宝爱记账',
'强宝小助手',
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
+52 -22
View File
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../core/module/app_module.dart';
import '../../core/network/api_exception.dart';
import '../../core/network/auth_redirect.dart';
import '../../models/account.dart';
@@ -12,7 +13,6 @@ import '../../utils/amount_input_formatter.dart';
import '../../utils/amount_util.dart';
import '../../utils/toast.dart';
import '../../widgets/state_views.dart';
import '../note/note_list_page.dart';
/// 「我的」页面
///
@@ -52,7 +52,7 @@ class MinePage extends ConsumerWidget {
const SizedBox(height: 14),
_budgetCard(context, ref, budgetAsync),
const SizedBox(height: 14),
_notesEntry(context),
_moduleSection(context),
const SizedBox(height: 24),
_logoutButton(context),
const SizedBox(height: 90),
@@ -369,43 +369,73 @@ class MinePage extends ConsumerWidget {
);
}
// ---------------- 笔记入口 ----------------
Widget _notesEntry(BuildContext context) {
return GestureDetector(
onTap: () => Navigator.of(context).push(
MaterialPageRoute(builder: (_) => const NoteListPage()),
),
child: Container(
padding: const EdgeInsets.fromLTRB(18, 16, 14, 16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
// ---------------- 功能模块 ----------------
//
// 和首页仪表盘的卡片共用同一份注册表(core/module/app_module.dart),
// 所以新增模块时这个页面不用改。
Widget _moduleSection(BuildContext context) {
return Material(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
clipBehavior: Clip.antiAlias, // 让水波纹被圆角裁掉
child: Padding(
padding: const EdgeInsets.fromLTRB(18, 16, 8, 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'功能模块',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: Color(0xFF5D4037),
),
),
const SizedBox(height: 2),
for (final module in appModules) _moduleRow(context, module),
],
),
),
);
}
Widget _moduleRow(BuildContext context, AppModule module) {
return InkWell(
onTap: () => Navigator.of(context).push(
MaterialPageRoute(builder: module.open),
),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Row(
children: [
const Text('📝', style: TextStyle(fontSize: 24)),
const SizedBox(width: 14),
const Expanded(
Text(module.icon, style: const TextStyle(fontSize: 20)),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'我的笔记',
style: TextStyle(
module.name,
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
color: Color(0xFF5D4037),
),
),
SizedBox(height: 3),
const SizedBox(height: 2),
Text(
'管理 Markdown 文档,随时查看和记录',
style: TextStyle(fontSize: 12.5, color: Color(0xFF8D6E63)),
module.blurb,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontSize: 12, color: Color(0xFF8D6E63)),
),
],
),
),
const Icon(Icons.chevron_right, color: Color(0xFFBCAAA4)),
const Padding(
padding: EdgeInsets.only(right: 3),
child: Icon(Icons.chevron_right, color: Color(0xFFBCAAA4)),
),
],
),
),
@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../providers/note_provider.dart';
/// 首页仪表盘上「笔记」卡片的摘要:笔记总数 + 最近更新时间。
///
/// 数据来自 [noteOverviewProvider](只取 1 条),不碰列表页那套状态。
class NoteModuleSummary extends ConsumerWidget {
const NoteModuleSummary({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final page = ref.watch(noteOverviewProvider).value;
final latest = (page == null || page.items.isEmpty)
? null
: page.items.first.updateTime;
return Row(
children: [
Expanded(child: _item('共', page == null ? null : '${page.total} 篇')),
Expanded(child: _item('最近更新', latest == null ? null : _shortDate(latest))),
],
);
}
/// 后端给的是 `yyyy-MM-dd HH:mm`,卡片上只要 `MM-dd`
String _shortDate(String value) =>
value.length >= 10 ? value.substring(5, 10) : value;
Widget _item(String label, String? value) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label, style: const TextStyle(fontSize: 11, color: Color(0xFF8D6E63))),
const SizedBox(height: 3),
Text(
value ?? '--',
style: const TextStyle(
fontSize: 14.5,
fontWeight: FontWeight.bold,
color: Color(0xFF5D4037),
),
),
],
);
}
}
+34 -9
View File
@@ -3,11 +3,20 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../providers/auth_provider.dart';
import '../add/add_page.dart';
import '../home/home_page.dart';
import '../assistant/assistant_page.dart';
import '../home/dashboard_page.dart';
import '../login/login_page.dart';
import '../mine/mine_page.dart';
import '../statistics/statistics_page.dart';
/// 底部导航的四个 Tab 是四个「角色」,不是四个功能:
///
/// 首页 = 模块目录(卡片由 core/module/app_module.dart 生成)
/// 记录 = 全局录入入口
/// 助手 = AI(阶段 B 接入,现在是占位页)
/// 我的 = 账号、模块管理、设置
///
/// **具体模块不进 Tab** —— 记账、笔记都从首页卡片进。
/// 代价是打开 App 多一次点击才能看到账单,换来的是「以后加模块不用改这里」。
class MainShell extends ConsumerStatefulWidget {
const MainShell({super.key});
@@ -38,12 +47,12 @@ class _MainShellState extends ConsumerState<MainShell> {
@override
Widget build(BuildContext context) {
// IndexedStack 保证四个页面常驻:写操作后首页/统计的数据失效能立即重取,
// IndexedStack 保证四个页面常驻:写操作后各页的数据失效能立即重取,
// 用户切回时看到的就是最新数据。
const pages = [
HomePage(),
DashboardPage(),
AddPage(),
StatisticsPage(),
AssistantPage(),
MinePage(),
];
return Scaffold(
@@ -54,10 +63,26 @@ class _MainShellState extends ConsumerState<MainShell> {
backgroundColor: Colors.white,
indicatorColor: const Color(0x33C8956E),
destinations: const [
NavigationDestination(icon: Icon(Icons.home_outlined), selectedIcon: Icon(Icons.home), label: '首页'),
NavigationDestination(icon: Icon(Icons.add_circle_outline), selectedIcon: Icon(Icons.add_circle), label: '记账'),
NavigationDestination(icon: Icon(Icons.bar_chart_outlined), selectedIcon: Icon(Icons.bar_chart), label: '统计'),
NavigationDestination(icon: Icon(Icons.person_outline), selectedIcon: Icon(Icons.person), label: '我的'),
NavigationDestination(
icon: Icon(Icons.home_outlined),
selectedIcon: Icon(Icons.home),
label: '首页',
),
NavigationDestination(
icon: Icon(Icons.add_circle_outline),
selectedIcon: Icon(Icons.add_circle),
label: '记录',
),
NavigationDestination(
icon: Icon(Icons.auto_awesome_outlined),
selectedIcon: Icon(Icons.auto_awesome),
label: '助手',
),
NavigationDestination(
icon: Icon(Icons.person_outline),
selectedIcon: Icon(Icons.person),
label: '我的',
),
],
),
);