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