feat:更新个人主页模块

This commit is contained in:
2025-11-24 19:56:13 +08:00
parent 97e7a6f44b
commit 8cff5228ae
18 changed files with 443 additions and 197 deletions

View File

@@ -3,23 +3,15 @@ import 'package:food_hub_app/provider/food_provider.dart';
import 'package:provider/provider.dart';
class AppActions extends StatefulWidget {
const AppActions({super.key});
final int pageIndex;
const AppActions({super.key, required this.pageIndex});
@override
State<StatefulWidget> createState() => AppActionsState();
}
class AppActionsState extends State<AppActions> {
void _buildBottomSheet(FoodProvider provider) {
showModalBottomSheet(
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
builder: (context) => _buildBottomSheetBody(provider),
);
}
Widget _buildBottomSheetBody(FoodProvider provider) {
final colors = Theme.of(context).colorScheme;
final provider = context.watch<FoodProvider>();
@@ -33,25 +25,44 @@ class AppActionsState extends State<AppActions> {
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 10),
ListTile(
leading: Icon(Icons.book, color: colors.primary),
title: const Text('新增菜谱'),
onTap: () => _handleAddRecipe(provider),
),
ListTile(
leading: Icon(Icons.note_add, color: colors.primary),
title: const Text('新增记录'),
onTap: () => _handleAddRecord(provider),
),
ListTile(
leading: Icon(Icons.group, color: colors.primary),
title: const Text('发布朋友圈'),
onTap: () => _handleAddMoment(provider),
),
if (widget.pageIndex == 0)
ListTile(
leading: Icon(Icons.book, color: colors.primary),
title: const Text('新增菜谱'),
onTap: () => _handleAddRecipe(provider),
),
if (widget.pageIndex == 0)
ListTile(
leading: Icon(Icons.note_add, color: colors.primary),
title: const Text('新增记录'),
onTap: () => _handleAddRecord(provider),
),
if (widget.pageIndex == 2)
ListTile(
leading: Icon(Icons.group, color: colors.primary),
title: const Text('发布朋友圈'),
onTap: () => _handleAddMoment(provider),
),
],
);
}
void _onPressAdd(FoodProvider provider) {
if (widget.pageIndex == 0) {
showModalBottomSheet(
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
builder: (context) => _buildBottomSheetBody(provider),
);
}
if (widget.pageIndex == 2) {
_handleAddMoment(provider);
}
}
void _handleAddRecipe(FoodProvider provider) {
// provider.resetRecordForm();
// Navigator.pop(context);
@@ -68,7 +79,6 @@ class AppActionsState extends State<AppActions> {
void _handleAddMoment(FoodProvider provider) {
provider.resetMomentForm();
provider.isEditing = false;
Navigator.pop(context);
Navigator.pushNamed(context, "/momentForm");
}
@@ -84,12 +94,11 @@ class AppActionsState extends State<AppActions> {
// 搜索功能
},
),
IconButton(
icon: Icon(Icons.add, color: Colors.white),
onPressed: () {
_buildBottomSheet(provider);
},
),
if (widget.pageIndex == 0 || widget.pageIndex == 2)
IconButton(
icon: Icon(Icons.add, color: Colors.white),
onPressed: () => _onPressAdd(provider),
),
],
);
}