feat:更新菜谱显示模块
This commit is contained in:
@@ -32,14 +32,11 @@ final List<PageInfo> pageInfos = [
|
||||
),
|
||||
];
|
||||
|
||||
class NavBar extends StatelessWidget {
|
||||
final int currentIndex;
|
||||
|
||||
final Function(int) onTap;
|
||||
|
||||
const NavBar({super.key, required this.currentIndex, required this.onTap});
|
||||
|
||||
List<BottomNavigationBarItem> get items =>
|
||||
Widget buildBottomNavBar({
|
||||
required int currentIndex,
|
||||
required Function(int) onTap,
|
||||
}) {
|
||||
final List<BottomNavigationBarItem> items =
|
||||
pageInfos
|
||||
.map(
|
||||
(item) => BottomNavigationBarItem(
|
||||
@@ -50,37 +47,78 @@ class NavBar extends StatelessWidget {
|
||||
)
|
||||
.toList();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(top: BorderSide(color: Theme.of(context).primaryColor)),
|
||||
),
|
||||
child: BottomNavigationBar(
|
||||
currentIndex: currentIndex,
|
||||
iconSize: 25,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
backgroundColor: Colors.white,
|
||||
items: items,
|
||||
onTap: onTap,
|
||||
),
|
||||
);
|
||||
}
|
||||
return BottomNavigationBar(
|
||||
currentIndex: currentIndex,
|
||||
iconSize: 25,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
backgroundColor: Colors.white,
|
||||
items: items,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
|
||||
List<StatelessWidget> homeActions(BuildContext context) {
|
||||
return [
|
||||
IconButton(
|
||||
icon: Icon(Icons.search, color: Colors.white),
|
||||
onPressed: () {
|
||||
// 搜索功能
|
||||
},
|
||||
void buildBottomSheet(BuildContext context) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
||||
),
|
||||
// IconButton(
|
||||
// icon: Icon(Icons.add, color: Colors.white),
|
||||
// onPressed: () {
|
||||
// Navigator.pushNamed(context, '/recordForm');
|
||||
// },
|
||||
// ),
|
||||
];
|
||||
builder: (context) => buildBottomSheetBody(context),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildBottomSheetBody(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'请选择操作',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
ListTile(
|
||||
leading: Icon(Icons.book, color: colors.primary),
|
||||
title: const Text('新增菜谱'),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
_handleAddRecipe(context);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.note_add, color: colors.primary),
|
||||
title: const Text('新增记录'),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, "/recordForm");
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.group, color: colors.primary),
|
||||
title: const Text('发布朋友圈'),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
_handleAddRecord(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 处理添加菜谱
|
||||
void _handleAddRecipe(BuildContext context) {
|
||||
// 这里添加跳转或处理添加菜谱的逻辑
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('添加菜谱功能')));
|
||||
}
|
||||
|
||||
// 处理添加记录
|
||||
void _handleAddRecord(BuildContext context) {
|
||||
// 这里添加跳转或处理添加记录的逻辑
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('添加记录功能')));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user