forked from eatvio/eatvio_app
feat(diary): new layouts for diary
This commit is contained in:
@@ -11,7 +11,6 @@ import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart';
|
||||
import 'package:eatvio_app/widgets/custom_edit_drop_down.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/widgets/custom_scale_element.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -91,16 +90,18 @@ class DiaryScreen extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
_buildHeaderRow(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
SizedBox(height: 8.v),
|
||||
_buildWakupRetire(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
SizedBox(height: 8.v),
|
||||
_buildMeal(context, state),
|
||||
SizedBox(height: 20.v),
|
||||
SizedBox(height: 8.v),
|
||||
_buildMood(context, state),
|
||||
SizedBox(height: 20.v),
|
||||
SizedBox(height: 8.v),
|
||||
_buildNutritionChart(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
_buildComment(context, state),
|
||||
SizedBox(height: 8.v),
|
||||
// _buildComment(context, state),
|
||||
// SizedBox(height: 8.v),
|
||||
_buildEndDay(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -111,7 +112,6 @@ class DiaryScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildEndDay(context),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -119,30 +119,24 @@ class DiaryScreen extends StatelessWidget {
|
||||
|
||||
_buildNutritionChart(BuildContext context, DiaryStateLoaded state) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h, vertical: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"График КБЖУ",
|
||||
"Ваш КБЖУ",
|
||||
style: theme.textTheme.titleMedium,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Text(
|
||||
"от дневной суточной нормы",
|
||||
),
|
||||
Transform.rotate(
|
||||
angle: -1.5708,
|
||||
child: ClipRect(
|
||||
@@ -152,7 +146,7 @@ class DiaryScreen extends StatelessWidget {
|
||||
child: SfCircularChart(
|
||||
series: <CircularSeries>[
|
||||
RadialBarSeries<NutritionData, String>(
|
||||
dataSource: state.chartData,
|
||||
dataSource: state.chartDataCounted,
|
||||
xValueMapper: (NutritionData data, _) => data.category,
|
||||
yValueMapper: (NutritionData data, _) => data.nutrition,
|
||||
pointColorMapper: (NutritionData data, _) => data.color,
|
||||
@@ -167,23 +161,26 @@ class DiaryScreen extends StatelessWidget {
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('Углеводы'),
|
||||
Text('Жиры'),
|
||||
Text('Белки'),
|
||||
Text('Калории'),
|
||||
Text(style: theme.textTheme.titleMedium, 'Углеводы'),
|
||||
Text(style: theme.textTheme.titleMedium, 'Жиры'),
|
||||
Text(style: theme.textTheme.titleMedium, 'Белки'),
|
||||
Text(style: theme.textTheme.titleMedium, 'Калории'),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'${state.chartData![3].nutrition.toStringAsFixed(0)}%'), // Калории
|
||||
'${state.chartData['dailyNutritionIntake']['carbohydrates'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['carbohydrates'].toStringAsFixed(1)} грамм'),
|
||||
SizedBox(height: 8.v),
|
||||
Text(
|
||||
'${state.chartData![2].nutrition.toStringAsFixed(0)}%'), // Белки
|
||||
'${state.chartData['dailyNutritionIntake']['fats'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['fats'].toStringAsFixed(1)} грамм'),
|
||||
SizedBox(height: 8.v),
|
||||
Text(
|
||||
'${state.chartData![1].nutrition.toStringAsFixed(0)}%'), // Жиры
|
||||
'${state.chartData['dailyNutritionIntake']['proteins'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['proteins'].toStringAsFixed(1)} грамм'),
|
||||
SizedBox(height: 8.v),
|
||||
Text(
|
||||
'${state.chartData![0].nutrition.toStringAsFixed(0)}% '), // Углеводы
|
||||
'${state.chartData['dailyNutritionIntake']['energy'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['energy'].toStringAsFixed(1)} Ккал'),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -194,18 +191,24 @@ class DiaryScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
_buildEndDay(BuildContext context) {
|
||||
return CustomOutlinedButton(
|
||||
text: "Закончить день",
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 16.h,
|
||||
bottom: 16.v,
|
||||
return Container(
|
||||
height: 48,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
padding: EdgeInsets.only(left: 4, right: 4),
|
||||
child: FloatingActionButton.extended(
|
||||
highlightElevation: 0,
|
||||
elevation: 0,
|
||||
focusElevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
backgroundColor: appTheme.blueA400,
|
||||
onPressed: () => onFinishDayPressed,
|
||||
label: Text(
|
||||
'Закончить день',
|
||||
style: theme.textTheme.titleSmall,
|
||||
),
|
||||
),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
onPressed: onFinishDayPressed(context),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -219,22 +222,13 @@ class DiaryScreen extends StatelessWidget {
|
||||
_buildHeaderRow(BuildContext context, DiaryStateLoaded state) {
|
||||
final day = state.diary.id;
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h, vertical: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -260,11 +254,24 @@ class DiaryScreen extends StatelessWidget {
|
||||
|
||||
/// Section Widget
|
||||
_buildAddProduct(BuildContext context, DiaryState state) {
|
||||
return CustomOutlinedButton(
|
||||
text: "Добавить продукт",
|
||||
margin: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
onPressed: addProduct(context),
|
||||
return Container(
|
||||
height: 48,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
padding: EdgeInsets.only(left: 4, right: 4),
|
||||
child: FloatingActionButton.extended(
|
||||
highlightElevation: 0,
|
||||
elevation: 0,
|
||||
focusElevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
backgroundColor: appTheme.blueA400,
|
||||
onPressed: () => addProduct,
|
||||
label: Text(
|
||||
'Добавить продукт',
|
||||
style: theme.textTheme.titleSmall,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -354,22 +361,13 @@ class DiaryScreen extends StatelessWidget {
|
||||
state.autocompleteList.map((Product item) => item.name).toList();
|
||||
FocusNode focusNodeName = FocusNode();
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -530,17 +528,17 @@ class DiaryScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 30.v),
|
||||
SizedBox(height: 24.v),
|
||||
_buildAddProduct(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
SizedBox(height: 24.v),
|
||||
...state.portions
|
||||
.map((portion) => _buildProduct(context, portion))
|
||||
.toList(),
|
||||
SizedBox(height: 30.v),
|
||||
SizedBox(height: 24.v),
|
||||
_buildCarousel(context, state),
|
||||
SizedBox(height: 20.v),
|
||||
SizedBox(height: 24.v),
|
||||
_buildAddPhoto(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
SizedBox(height: 24.v),
|
||||
Text(
|
||||
"Ваша сытость после приёма пищи",
|
||||
style: CustomTextStyles.bodyMediumBlack900,
|
||||
@@ -736,7 +734,7 @@ class DiaryScreen extends StatelessWidget {
|
||||
return Text("Фото нет");
|
||||
} else {
|
||||
return CarouselSlider(
|
||||
options: CarouselOptions(height: 340.0),
|
||||
options: CarouselOptions(height: 200.0),
|
||||
items: state.currentMeal.photos.map<Widget>((photo) {
|
||||
return _buildPhoto(context, photo);
|
||||
}).toList(),
|
||||
@@ -846,22 +844,13 @@ class DiaryScreen extends StatelessWidget {
|
||||
|
||||
_buildComment(BuildContext context, DiaryStateLoaded state) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -890,22 +879,13 @@ class DiaryScreen extends StatelessWidget {
|
||||
|
||||
_buildWakupRetire(BuildContext context, DiaryStateLoaded state) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -1010,22 +990,13 @@ class DiaryScreen extends StatelessWidget {
|
||||
|
||||
_buildMood(BuildContext context, DiaryStateLoaded state) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user