feat:增加主题色模块
This commit is contained in:
96
lib/layout/app_actions.dart
Normal file
96
lib/layout/app_actions.dart
Normal file
@@ -0,0 +1,96 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:food_hub_app/provider/food_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class AppActions extends StatefulWidget {
|
||||
const AppActions({super.key});
|
||||
|
||||
@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>();
|
||||
|
||||
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: () => _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),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void _handleAddRecipe(FoodProvider provider) {
|
||||
// provider.resetRecordForm();
|
||||
// Navigator.pop(context);
|
||||
// Navigator.pushNamed(context, "/recordForm");
|
||||
}
|
||||
|
||||
void _handleAddRecord(FoodProvider provider) {
|
||||
provider.resetRecordForm();
|
||||
provider.isEditing = false;
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, "/recordForm");
|
||||
}
|
||||
|
||||
void _handleAddMoment(FoodProvider provider) {
|
||||
provider.resetMomentForm();
|
||||
provider.isEditing = false;
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, "/momentForm");
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = context.watch<FoodProvider>();
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.search, color: Colors.white),
|
||||
onPressed: () {
|
||||
// 搜索功能
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.add, color: Colors.white),
|
||||
onPressed: () {
|
||||
_buildBottomSheet(provider);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user