factor:布局颜色重构
This commit is contained in:
@@ -49,17 +49,9 @@ class _HomePage extends State<HomePage> {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
backgroundColor: Color(0xFFF5F5F5),
|
// backgroundColor: Color(0xFFF5F5F5),
|
||||||
drawer: SettingsDrawer(),
|
drawer: SettingsDrawer(),
|
||||||
body: Padding(padding: EdgeInsets.all(4), child: tabPages[_currentIndex]),
|
body: Padding(padding: EdgeInsets.all(10), child: tabPages[_currentIndex]),
|
||||||
// floatingActionButton: FloatingActionButton(
|
|
||||||
// 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: buildBottomNavBar(
|
bottomNavigationBar: buildBottomNavBar(
|
||||||
currentIndex: _currentIndex,
|
currentIndex: _currentIndex,
|
||||||
onTap: (index) {
|
onTap: (index) {
|
||||||
|
|||||||
@@ -79,9 +79,10 @@ class _MomentPageState extends State<MomentPage> {
|
|||||||
void _scrollToTop() => scrollToTopAnimateTo(_scrollController);
|
void _scrollToTop() => scrollToTopAnimateTo(_scrollController);
|
||||||
|
|
||||||
Widget _buildMomentList(FoodProvider provider) {
|
Widget _buildMomentList(FoodProvider provider) {
|
||||||
return ListView.builder(
|
return ListView.separated(
|
||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
itemCount: provider.momentList.length,
|
itemCount: provider.momentList.length,
|
||||||
|
separatorBuilder: (context, index) => SizedBox(height: 8),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return MomentCard(moment: provider.momentList[index]);
|
return MomentCard(moment: provider.momentList[index]);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class _MomentFormPageState extends State<MomentFormPage> {
|
|||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(5),
|
padding: EdgeInsets.all(5),
|
||||||
child: buildCard(context: context, child: _buildFormBuilder()),
|
child: BuildCard(child: _buildFormBuilder()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -55,9 +55,8 @@ class _RecipeDetailState extends State<RecipeDetailPage> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: Text('菜谱信息')),
|
appBar: AppBar(title: Text('菜谱信息')),
|
||||||
backgroundColor: Color(0xFFF5F5F5),
|
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
child: Padding(padding: EdgeInsets.all(5), child: _buildRecipeDetail()),
|
child: Padding(padding: EdgeInsets.all(10), child: _buildRecipeDetail()),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -67,12 +66,14 @@ class _RecipeDetailState extends State<RecipeDetailPage> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
_buildTitleSection(),
|
_buildTitleSection(),
|
||||||
|
SizedBox(height: 8),
|
||||||
_buildInfoCard(
|
_buildInfoCard(
|
||||||
context,
|
context,
|
||||||
icon: Icons.info,
|
icon: Icons.info,
|
||||||
title: "基础信息",
|
title: "基础信息",
|
||||||
content: buildTag(context, recipe.category),
|
content: buildTag(context, recipe.category),
|
||||||
),
|
),
|
||||||
|
SizedBox(height: 8),
|
||||||
_buildInfoCard(
|
_buildInfoCard(
|
||||||
context,
|
context,
|
||||||
icon: Icons.shopping_cart,
|
icon: Icons.shopping_cart,
|
||||||
@@ -86,6 +87,7 @@ class _RecipeDetailState extends State<RecipeDetailPage> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SizedBox(height: 8),
|
||||||
_buildInfoCard(
|
_buildInfoCard(
|
||||||
context,
|
context,
|
||||||
icon: Icons.list,
|
icon: Icons.list,
|
||||||
@@ -95,6 +97,7 @@ class _RecipeDetailState extends State<RecipeDetailPage> {
|
|||||||
recipe.stepList.map((step) => _buildStepSection(step)).toList(),
|
recipe.stepList.map((step) => _buildStepSection(step)).toList(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SizedBox(height: 8),
|
||||||
_buildInfoCard(
|
_buildInfoCard(
|
||||||
context,
|
context,
|
||||||
icon: Icons.note,
|
icon: Icons.note,
|
||||||
@@ -183,8 +186,7 @@ class _RecipeDetailState extends State<RecipeDetailPage> {
|
|||||||
required String title,
|
required String title,
|
||||||
required Widget content,
|
required Widget content,
|
||||||
}) {
|
}) {
|
||||||
return buildCard(
|
return BuildCard(
|
||||||
context: context,
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -297,11 +297,10 @@ class _RecordFormPageState extends State<RecordFormPage> {
|
|||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () => Navigator.pop(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
backgroundColor: const Color(0xFFF5F5F5),
|
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(5),
|
padding: EdgeInsets.all(10),
|
||||||
child: buildCard(context: context, child: _buildFormBuilder()),
|
child: BuildCard(child: _buildFormBuilder()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ class _StatsPage extends State<StatsPage> {
|
|||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
// 禁用网格自身滚动
|
// 禁用网格自身滚动
|
||||||
crossAxisCount: 2,
|
crossAxisCount: 2,
|
||||||
// crossAxisSpacing: 5,
|
crossAxisSpacing: 8,
|
||||||
// mainAxisSpacing: 5,
|
mainAxisSpacing: 8,
|
||||||
childAspectRatio: 2,
|
childAspectRatio: 2,
|
||||||
children: [
|
children: [
|
||||||
StatisticCard(
|
StatisticCard(
|
||||||
@@ -121,23 +121,20 @@ class _StatsPage extends State<StatsPage> {
|
|||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
_buildSummaryStats(provider),
|
_buildSummaryStats(provider),
|
||||||
|
SizedBox(height: 8),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: chartHeight,
|
height: chartHeight,
|
||||||
child: buildCard(
|
child: BuildCard(child: _buildRecordStats(provider)),
|
||||||
context: context,
|
|
||||||
child: _buildRecordStats(provider),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
SizedBox(height: 8),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: chartHeight,
|
height: chartHeight,
|
||||||
child: buildCard(
|
child: BuildCard(child: _buildCategoryStats(provider)),
|
||||||
context: context,
|
|
||||||
child: _buildCategoryStats(provider),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
SizedBox(height: 8),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: chartHeight,
|
height: chartHeight,
|
||||||
child: buildCard(context: context, child: _buildRankStats(provider)),
|
child: BuildCard(child: _buildRankStats(provider)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -28,21 +28,25 @@ InputDecoration formInputDecoration({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildCard({required BuildContext context, required Widget child}) {
|
class BuildCard extends StatelessWidget {
|
||||||
final colors = Theme.of(context).colorScheme;
|
final Widget? child;
|
||||||
return Card(
|
|
||||||
elevation: 0,
|
const BuildCard({super.key, this.child});
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
|
||||||
child: Container(
|
@override
|
||||||
width: double.infinity,
|
Widget build(BuildContext context) {
|
||||||
|
final colors = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: colors.surfaceContainer,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
// border: Border.all(color: colors.outline.withAlpha(50)),
|
// border: Border.all(color: colors.outline.withAlpha(50), width: 1),
|
||||||
),
|
),
|
||||||
child: Padding(padding: EdgeInsets.all(10), child: child),
|
padding: const EdgeInsets.all(16),
|
||||||
),
|
child: child,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildEmptyData() {
|
Widget buildEmptyData() {
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ class MomentCard extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return buildCard(
|
return BuildCard(
|
||||||
context: context,
|
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -62,16 +62,16 @@ class _RecipeCalendarState extends State<RecipeCalendar> {
|
|||||||
if (provider.selectRecordList.isEmpty)
|
if (provider.selectRecordList.isEmpty)
|
||||||
buildEmptyData()
|
buildEmptyData()
|
||||||
else
|
else
|
||||||
ListView.builder(
|
Expanded(
|
||||||
shrinkWrap: true,
|
child: ListView.builder(
|
||||||
physics: NeverScrollableScrollPhysics(),
|
itemCount: provider.selectRecordList.length,
|
||||||
itemCount: provider.selectRecordList.length,
|
itemBuilder: (context, index) {
|
||||||
itemBuilder: (context, index) {
|
return _buildRecordItem(
|
||||||
return _buildRecordItem(
|
context,
|
||||||
context,
|
provider.selectRecordList[index],
|
||||||
provider.selectRecordList[index],
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -188,13 +188,9 @@ class _RecipeCalendarState extends State<RecipeCalendar> {
|
|||||||
Widget _buildContent(FoodProvider provider) {
|
Widget _buildContent(FoodProvider provider) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
buildCard(context: context, child: _recipeCalendar(provider)),
|
BuildCard(child: _recipeCalendar(provider)),
|
||||||
Expanded(
|
SizedBox(height: 8),
|
||||||
child: buildCard(
|
Expanded(child: BuildCard(child: _dailyItem(context, provider))),
|
||||||
context: context,
|
|
||||||
child: _dailyItem(context, provider),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,8 +81,7 @@ class RecipeCard extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildCard(
|
return BuildCard(
|
||||||
context: context,
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -83,8 +83,9 @@ class _RecipeListState extends State<RecipeList> {
|
|||||||
_buildSelectCategory(provider),
|
_buildSelectCategory(provider),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.separated(
|
||||||
itemCount: provider.recipeSummaryList.length,
|
itemCount: provider.recipeSummaryList.length,
|
||||||
|
separatorBuilder: (context, index) => SizedBox(height: 8),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return RecipeCard(recipe: provider.recipeSummaryList[index]);
|
return RecipeCard(recipe: provider.recipeSummaryList[index]);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ class RecipeTimeline extends StatefulWidget {
|
|||||||
|
|
||||||
class _RecipeTimeline extends State<RecipeTimeline> {
|
class _RecipeTimeline extends State<RecipeTimeline> {
|
||||||
Widget buildTimelineCard(BuildContext context, FoodRecord record) {
|
Widget buildTimelineCard(BuildContext context, FoodRecord record) {
|
||||||
return buildCard(
|
return BuildCard(
|
||||||
context: context,
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -69,7 +68,10 @@ class _RecipeTimeline extends State<RecipeTimeline> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
contentsBuilder: (context, index) {
|
contentsBuilder: (context, index) {
|
||||||
return buildTimelineCard(context, recordList[index]);
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||||
|
child: buildTimelineCard(context, recordList[index]),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ class StatisticCard extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return buildCard(
|
return BuildCard(
|
||||||
context: context,
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
Reference in New Issue
Block a user