Files
2026-09-28 16:40:32 +08:00

89 lines
2.9 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
import '../../pages/bill/bill_home_page.dart';
import '../../pages/bill/widgets/bill_module_summary.dart';
import '../../pages/health/health_home_page.dart';
import '../../pages/health/widgets/health_module_summary.dart';
import '../../pages/note/note_list_page.dart';
import '../../pages/note/widgets/note_module_summary.dart';
import '../../pages/watermark/watermark_camera_page.dart';
import '../../pages/watermark/widgets/watermark_module_summary.dart';
/// 一个功能模块要对外暴露的东西:它是谁、怎么打开自己。
///
/// 首页仪表盘的卡片网格、「我的」里的模块列表都从 [appModules] 生成 ——
/// 新增一个模块 = 往列表里加一条 + 写这个模块的页面,
/// 布局层(导航栏、首页、设置页)一行都不用改。
@immutable
class AppModule {
const AppModule({
required this.id,
required this.name,
required this.blurb,
required this.icon,
required this.open,
this.summary,
});
/// 稳定标识。将来做「模块排序 / 开关 / AI 可读范围」时要靠它持久化。
final String id;
/// 模块名,显示在卡片和列表上
final String name;
/// 一句话说明,让用户在首页就能看懂这个模块是干什么的
final String blurb;
/// 图标名,对应 `assets/icons/<name>.svg`(见 [cuteIconNames])
final String icon;
/// 打开模块入口页
final WidgetBuilder open;
/// 首页卡片上的摘要。
///
/// 由模块自己提供,因为只有模块知道该摘要什么;返回 null 表示这个模块
/// 暂时没有可显示的数据(卡片就只显示名字和说明)。
final Widget Function(BuildContext context)? summary;
}
/// 全部模块。**顺序 = 首页卡片顺序 = 「我的」里的列表顺序。**
///
/// 现在只有两个真模块。加「投资」「运动」「服务器」时照抄一条即可 ——
/// 注意「记录」Tab 目前直接就是记账录入,等第二种记录类型出现时,
/// 才需要在它上面加一层「选类型」。
final List<AppModule> appModules = [
AppModule(
id: 'bill',
name: '记账',
blurb: '收支记录、统计与预算',
icon: 'bill',
open: (_) => const BillHomePage(),
summary: (_) => const BillModuleSummary(),
),
AppModule(
id: 'note',
name: '笔记',
blurb: 'Markdown 知识库,随时查看和记录',
icon: 'note',
open: (_) => const NoteListPage(),
summary: (_) => const NoteModuleSummary(),
),
AppModule(
id: 'watermark',
name: '水印相机',
blurb: '拍照自动加时间地点水印',
icon: 'camera',
open: (_) => const WatermarkCameraPage(),
summary: (_) => const WatermarkModuleSummary(),
),
AppModule(
id: 'health',
name: '强宝健康',
blurb: '减重进度、体重与每日饮食',
icon: 'health',
open: (_) => const HealthHomePage(),
summary: (_) => const HealthModuleSummary(),
),
];