feat:更新菜谱显示模块

This commit is contained in:
2025-11-18 15:57:00 +08:00
parent df26790389
commit 9a8e1a7419
9 changed files with 244 additions and 221 deletions

View File

@@ -14,79 +14,6 @@ class _HomePage extends State<HomePage> {
List<Widget> get tabPages => pageInfos.map((item) => item.page).toList();
// 显示底部弹窗
void _showBottomSheet() {
showModalBottomSheet(
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
builder:
(context) => Container(
padding: const EdgeInsets.all(10),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
'请选择操作',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 10),
ListTile(
leading: Icon(
Icons.book,
color: Theme.of(context).primaryColor,
),
title: const Text('新增菜谱'),
onTap: () {
Navigator.pop(context);
_handleAddRecipe();
},
),
ListTile(
leading: Icon(
Icons.note_add,
color: Theme.of(context).primaryColor,
),
title: const Text('新增记录'),
onTap: () {
Navigator.pop(context);
Navigator.pushNamed(context, "/recordForm");
},
),
ListTile(
leading: Icon(
Icons.group,
color: Theme.of(context).primaryColor,
),
title: const Text('发布朋友圈'),
onTap: () {
Navigator.pop(context);
_handleAddRecord();
},
),
],
),
),
);
}
// 处理添加菜谱
void _handleAddRecipe() {
// 这里添加跳转或处理添加菜谱的逻辑
ScaffoldMessenger.of(
context,
).showSnackBar(const SnackBar(content: Text('添加菜谱功能')));
}
// 处理添加记录
void _handleAddRecord() {
// 这里添加跳转或处理添加记录的逻辑
ScaffoldMessenger.of(
context,
).showSnackBar(const SnackBar(content: Text('添加记录功能')));
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -103,23 +30,27 @@ class _HomePage extends State<HomePage> {
);
},
),
actions: homeActions(context),
actions: [
IconButton(
icon: Icon(Icons.search, color: Colors.white),
onPressed: () {
// 搜索功能
},
),
],
),
backgroundColor: Color(0xFFF5F5F5),
drawer: SettingsDrawer(),
body: Padding(
padding: EdgeInsets.all(4),
child: tabPages[_currentIndex],
),
body: Padding(padding: EdgeInsets.all(4), child: tabPages[_currentIndex]),
floatingActionButton: FloatingActionButton(
backgroundColor: Theme.of(context).primaryColor,
onPressed: _showBottomSheet,
backgroundColor: Theme.of(context).colorScheme.primary,
onPressed: () => buildBottomSheet(context),
shape: const CircleBorder(),
mini: true,
child: const Icon(Icons.add, color: Colors.white, size: 30),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: NavBar(
bottomNavigationBar: buildBottomNavBar(
currentIndex: _currentIndex,
onTap: (index) {
setState(() {