feat:重构模块
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter_common/widget/common_widget.dart';
|
||||
import 'package:food_hub_app/models/recipe.dart';
|
||||
import 'package:food_hub_app/provider/food_provider.dart';
|
||||
import 'package:food_hub_app/utils/index.dart';
|
||||
import 'package:food_hub_app/views/record_form.dart';
|
||||
import 'package:food_hub_app/widgets/common/index.dart';
|
||||
import 'package:table_calendar/table_calendar.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -62,19 +63,16 @@ class _RecipeCalendarState extends State<RecipeCalendar> {
|
||||
Text(formatDateTime(provider.selectedDay, 'MM月dd日 EEEE')),
|
||||
SizedBox(height: 4),
|
||||
if (provider.selectRecordList.isEmpty)
|
||||
buildEmptyData()
|
||||
SizedBox(height: 100, child: buildEmptyData())
|
||||
else
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
itemCount: provider.selectRecordList.length,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8),
|
||||
itemBuilder: (context, index) {
|
||||
return _buildRecordItem(
|
||||
context,
|
||||
provider.selectRecordList[index],
|
||||
);
|
||||
},
|
||||
),
|
||||
Column(
|
||||
children:
|
||||
provider.selectRecordList.map((record) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: _buildRecordItem(context, record),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -112,7 +110,15 @@ class _RecipeCalendarState extends State<RecipeCalendar> {
|
||||
|
||||
provider.initRecordForm(record);
|
||||
provider.isEditing = true;
|
||||
Navigator.pushNamed(context, "/recordForm");
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
||||
),
|
||||
builder: (context) => RecordForm(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRecordItem(BuildContext context, FoodRecord record) {
|
||||
@@ -195,12 +201,15 @@ class _RecipeCalendarState extends State<RecipeCalendar> {
|
||||
}
|
||||
|
||||
Widget _buildContent(FoodProvider provider) {
|
||||
return Column(
|
||||
children: [
|
||||
CommonCard(child: _recipeCalendar(provider)),
|
||||
SizedBox(height: 8),
|
||||
Expanded(child: CommonCard(child: _dailyItem(context, provider))),
|
||||
],
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.only(bottom: 80),
|
||||
child: Column(
|
||||
children: [
|
||||
CommonCard(child: _recipeCalendar(provider)),
|
||||
const SizedBox(height: 8),
|
||||
CommonCard(child: _dailyItem(context, provider)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -208,13 +217,10 @@ class _RecipeCalendarState extends State<RecipeCalendar> {
|
||||
Widget build(BuildContext context) {
|
||||
final provider = context.watch<FoodProvider>();
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
if (provider.isLoading)
|
||||
buildLoadingIndicator()
|
||||
else
|
||||
_buildContent(provider),
|
||||
],
|
||||
);
|
||||
if (provider.isLoading) {
|
||||
return buildLoadingIndicator();
|
||||
}
|
||||
|
||||
return _buildContent(provider);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user