forked from eatvio/eatvio_app
Merge remote-tracking branch 'refs/remotes/origin/calendar'
# Conflicts: # lib/app_router.dart # lib/features/calendar/services/calendar_service.dart # lib/features/diary/presentation/bloc/diary_bloc.dart # lib/features/diary/services/diary_service.dart # lib/locator_service.dart # lib/main.dart
This commit is contained in:
@@ -9,8 +9,6 @@ import 'package:flutter/material.dart';
|
||||
import '/core/app_export.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
|
||||
part 'diary_event.dart';
|
||||
|
||||
@@ -18,8 +16,7 @@ part 'diary_event.dart';
|
||||
class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
final DiaryRepository diaryRepository;
|
||||
|
||||
DiaryBloc({required this.diaryRepository})
|
||||
: super(const DiaryState.loading()) {
|
||||
DiaryBloc({required this.diaryRepository}) : super(const DiaryState.loading()) {
|
||||
on<LoadDiary>(loadDiary);
|
||||
on<ChangeSatiety>(_changeSatiety); // пользователь нажимает на шкалу сытости
|
||||
on<ChangeMood>(_changeMood); // пользователь нажимает на шкалу настроения
|
||||
@@ -56,29 +53,15 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
final DiaryModel diary = await diaryRepository.getDiary(diaryID ?? 45);
|
||||
final Meal currentMeal = diary.meals[0];
|
||||
|
||||
List<SelectionPopupModel> portionList = [
|
||||
SelectionPopupModel(title: "gr"),
|
||||
SelectionPopupModel(title: "pcs")
|
||||
];
|
||||
List<SelectionPopupModel> portionList = [SelectionPopupModel(title: "gr"), SelectionPopupModel(title: "pcs")];
|
||||
|
||||
final Map<String, dynamic> chartData =
|
||||
await diaryRepository.getChartData(diaryID ?? 45);
|
||||
final Map<String, dynamic> dailyNutritionIntake =
|
||||
chartData['dailyNutritionIntake']!;
|
||||
final Map<String, dynamic> dailyNutritionRecommendations =
|
||||
chartData['dailyNutritionRecommendation']!;
|
||||
final double ccal = dailyNutritionIntake['energy']! /
|
||||
dailyNutritionRecommendations['energy']! *
|
||||
100;
|
||||
final double proteins = dailyNutritionIntake['proteins']! /
|
||||
dailyNutritionRecommendations['proteins']! *
|
||||
100;
|
||||
final double fats = dailyNutritionIntake['fats']! /
|
||||
dailyNutritionRecommendations['fats']! *
|
||||
100;
|
||||
final double carbs = dailyNutritionIntake['carbohydrates']! /
|
||||
dailyNutritionRecommendations['carbohydrates']! *
|
||||
100;
|
||||
final Map<String, dynamic> chartData = await diaryRepository.getChartData(diaryID ?? 45);
|
||||
final Map<String, dynamic> dailyNutritionIntake = chartData['dailyNutritionIntake']!;
|
||||
final Map<String, dynamic> dailyNutritionRecommendations = chartData['dailyNutritionRecommendation']!;
|
||||
final double ccal = dailyNutritionIntake['energy']! / dailyNutritionRecommendations['energy']! * 50;
|
||||
final double proteins = dailyNutritionIntake['proteins']! / dailyNutritionRecommendations['proteins']! * 50;
|
||||
final double fats = dailyNutritionIntake['fats']! / dailyNutritionRecommendations['fats']! * 50;
|
||||
final double carbs = dailyNutritionIntake['carbohydrates']! / dailyNutritionRecommendations['carbohydrates']! * 50;
|
||||
|
||||
Color getColor(double value) {
|
||||
if (value >= 99.1) {
|
||||
@@ -104,8 +87,6 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
SelectionPopupModel(title: "Прием пищи 6", id: 6),
|
||||
];
|
||||
|
||||
print(dailyNutritionRecommendations);
|
||||
print(dailyNutritionIntake);
|
||||
emit(DiaryState.loaded(
|
||||
diary: diary,
|
||||
currentMeal: currentMeal,
|
||||
@@ -116,6 +97,8 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
chartData: chartDataCounted,
|
||||
selectedMood: currentMeal.mood,
|
||||
selectedSatiety: currentMeal.satiety,
|
||||
wakeupController: TimeOfDay.now(),
|
||||
retireController: TimeOfDay.now(),
|
||||
commentController: TextEditingController(),
|
||||
product_nameController: TextEditingController(),
|
||||
productQuantityController: TextEditingController(),
|
||||
@@ -136,54 +119,6 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
}
|
||||
}
|
||||
|
||||
fetchChartValues(
|
||||
String token,
|
||||
int diaryID,
|
||||
Emitter<DiaryState> emit,
|
||||
) async {
|
||||
final responseChart = await http.get(
|
||||
Uri.parse(
|
||||
baseUrl + '/api/' + '/diary/$diaryID/dailyNutritionData/',
|
||||
),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
);
|
||||
|
||||
if (responseChart.statusCode == 200) {
|
||||
final responseBody = jsonDecode(responseChart.body);
|
||||
print(responseBody);
|
||||
final recommendedChartValues =
|
||||
responseBody['dailyNutritionRecommendation']
|
||||
.values
|
||||
.map<int>((value) => convertToInt(value))
|
||||
.toList();
|
||||
|
||||
final consumedChartValues = responseBody['dailyNutritionIntake']
|
||||
.values
|
||||
.map<int>((value) => convertToInt(value))
|
||||
.toList();
|
||||
|
||||
print([
|
||||
recommendedChartValues,
|
||||
consumedChartValues,
|
||||
]);
|
||||
return [
|
||||
recommendedChartValues,
|
||||
consumedChartValues,
|
||||
];
|
||||
} else {
|
||||
emit(DiaryStateError(
|
||||
errorMessage: 'Ошибка при декодировании данных КБЖУ'));
|
||||
print('fail');
|
||||
return [
|
||||
[],
|
||||
[],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _changeSatiety(
|
||||
ChangeSatiety event,
|
||||
Emitter<DiaryState> emit,
|
||||
@@ -228,11 +163,9 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
) async {
|
||||
if (state is DiaryStateLoaded) {
|
||||
var currentState = state as DiaryStateLoaded;
|
||||
var updatedState =
|
||||
currentState.copyWith(wakeupController: event.selectedTime);
|
||||
var updatedState = currentState.copyWith(wakeupController: event.selectedTime);
|
||||
final DateFormat formatter = DateFormat('HH:mm');
|
||||
final String wakeupString = formatter.format(DateTime(
|
||||
2022, 1, 1, event.selectedTime.hour, event.selectedTime.minute));
|
||||
final String wakeupString = formatter.format(DateTime(2022, 1, 1, event.selectedTime.hour, event.selectedTime.minute));
|
||||
await diaryRepository.changeWakeup(
|
||||
currentState.diary.id,
|
||||
wakeupString,
|
||||
@@ -247,11 +180,9 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
) async {
|
||||
if (state is DiaryStateLoaded) {
|
||||
var currentState = state as DiaryStateLoaded;
|
||||
var updatedState =
|
||||
currentState.copyWith(retireController: event.selectedTime);
|
||||
var updatedState = currentState.copyWith(retireController: event.selectedTime);
|
||||
final DateFormat formatter = DateFormat('HH:mm');
|
||||
final String retireString = formatter.format(DateTime(
|
||||
2022, 1, 1, event.selectedTime.hour, event.selectedTime.minute));
|
||||
final String retireString = formatter.format(DateTime(2022, 1, 1, event.selectedTime.hour, event.selectedTime.minute));
|
||||
await diaryRepository.changeRetire(
|
||||
currentState.diary.id,
|
||||
retireString,
|
||||
@@ -277,8 +208,7 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
) async {
|
||||
if (state is DiaryStateLoaded) {
|
||||
final currentState = state as DiaryStateLoaded;
|
||||
final Meal meal = currentState.diary.meals
|
||||
.firstWhere((meal) => meal.type == event.value.id);
|
||||
final Meal meal = currentState.diary.meals.firstWhere((meal) => meal.type == event.value.id);
|
||||
DiaryStateLoaded updatedState = currentState.copyWith(
|
||||
currentMeal: meal,
|
||||
portions: meal.portions,
|
||||
@@ -297,12 +227,10 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
if (state is DiaryStateLoaded) {
|
||||
var currentState = state as DiaryStateLoaded;
|
||||
|
||||
final Map<String, List<Product>> productNutritionalValues =
|
||||
await diaryRepository.inputProduct(event.input);
|
||||
final Map<String, List<Product>> productNutritionalValues = await diaryRepository.inputProduct(event.input);
|
||||
var updatedState = currentState.copyWith(
|
||||
product_nameController: TextEditingController(text: event.input),
|
||||
autocompleteList:
|
||||
productNutritionalValues['product_nutritional_value'] ?? [],
|
||||
autocompleteList: productNutritionalValues['product_nutritional_value'] ?? [],
|
||||
);
|
||||
if (event.input.length > 3) {
|
||||
updatedState = updatedState.copyWith(moderationExpanded: true);
|
||||
@@ -448,9 +376,9 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
|
||||
await diaryRepository.finishDay(
|
||||
currentState.diary.id,
|
||||
currentState.wakeupController,
|
||||
currentState.retireController,
|
||||
currentState.commentController.text,
|
||||
// currentState.wakeupController,
|
||||
// currentState.retireController,
|
||||
// currentState.commentController.text,
|
||||
);
|
||||
add(LoadDiary());
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ abstract class DiaryState with _$DiaryState {
|
||||
required List<Product> autocompleteList,
|
||||
required Meal currentMeal,
|
||||
required SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
required TimeOfDay wakeupController,
|
||||
required TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
required TextEditingController commentController,
|
||||
required TextEditingController product_nameController,
|
||||
|
||||
@@ -31,8 +31,8 @@ mixin _$DiaryState {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
@@ -68,8 +68,8 @@ mixin _$DiaryState {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
@@ -105,8 +105,8 @@ mixin _$DiaryState {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
@@ -224,8 +224,8 @@ class _$DiaryStateImpl implements _DiaryState {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
@@ -264,8 +264,8 @@ class _$DiaryStateImpl implements _DiaryState {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
@@ -304,8 +304,8 @@ class _$DiaryStateImpl implements _DiaryState {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
@@ -425,8 +425,8 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
@@ -465,8 +465,8 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
@@ -505,8 +505,8 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
@@ -592,8 +592,8 @@ abstract class _$$DiaryStateLoadedImplCopyWith<$Res> {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
@@ -637,8 +637,8 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res>
|
||||
Object? autocompleteList = null,
|
||||
Object? currentMeal = null,
|
||||
Object? portionController = null,
|
||||
Object? wakeupController = freezed,
|
||||
Object? retireController = freezed,
|
||||
Object? wakeupController = null,
|
||||
Object? retireController = null,
|
||||
Object? mealTimeController = freezed,
|
||||
Object? commentController = null,
|
||||
Object? product_nameController = null,
|
||||
@@ -697,14 +697,14 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res>
|
||||
? _value.portionController
|
||||
: portionController // ignore: cast_nullable_to_non_nullable
|
||||
as SelectionPopupModel,
|
||||
wakeupController: freezed == wakeupController
|
||||
wakeupController: null == wakeupController
|
||||
? _value.wakeupController
|
||||
: wakeupController // ignore: cast_nullable_to_non_nullable
|
||||
as TimeOfDay?,
|
||||
retireController: freezed == retireController
|
||||
as TimeOfDay,
|
||||
retireController: null == retireController
|
||||
? _value.retireController
|
||||
: retireController // ignore: cast_nullable_to_non_nullable
|
||||
as TimeOfDay?,
|
||||
as TimeOfDay,
|
||||
mealTimeController: freezed == mealTimeController
|
||||
? _value.mealTimeController
|
||||
: mealTimeController // ignore: cast_nullable_to_non_nullable
|
||||
@@ -812,8 +812,8 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
required final List<Product> autocompleteList,
|
||||
required this.currentMeal,
|
||||
required this.portionController,
|
||||
this.wakeupController,
|
||||
this.retireController,
|
||||
required this.wakeupController,
|
||||
required this.retireController,
|
||||
this.mealTimeController,
|
||||
required this.commentController,
|
||||
required this.product_nameController,
|
||||
@@ -898,9 +898,9 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
@override
|
||||
final SelectionPopupModel portionController;
|
||||
@override
|
||||
final TimeOfDay? wakeupController;
|
||||
final TimeOfDay wakeupController;
|
||||
@override
|
||||
final TimeOfDay? retireController;
|
||||
final TimeOfDay retireController;
|
||||
@override
|
||||
final TimeOfDay? mealTimeController;
|
||||
@override
|
||||
@@ -1062,8 +1062,8 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
@@ -1130,8 +1130,8 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
@@ -1198,8 +1198,8 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
@@ -1304,8 +1304,8 @@ abstract class DiaryStateLoaded implements DiaryState {
|
||||
required final List<Product> autocompleteList,
|
||||
required final Meal currentMeal,
|
||||
required final SelectionPopupModel portionController,
|
||||
final TimeOfDay? wakeupController,
|
||||
final TimeOfDay? retireController,
|
||||
required final TimeOfDay wakeupController,
|
||||
required final TimeOfDay retireController,
|
||||
final TimeOfDay? mealTimeController,
|
||||
required final TextEditingController commentController,
|
||||
required final TextEditingController product_nameController,
|
||||
@@ -1333,8 +1333,8 @@ abstract class DiaryStateLoaded implements DiaryState {
|
||||
List<Product> get autocompleteList;
|
||||
Meal get currentMeal;
|
||||
SelectionPopupModel get portionController;
|
||||
TimeOfDay? get wakeupController;
|
||||
TimeOfDay? get retireController;
|
||||
TimeOfDay get wakeupController;
|
||||
TimeOfDay get retireController;
|
||||
TimeOfDay? get mealTimeController;
|
||||
TextEditingController get commentController;
|
||||
TextEditingController get product_nameController;
|
||||
@@ -1435,8 +1435,8 @@ class _$DiaryStateErrorImpl implements DiaryStateError {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
@@ -1475,8 +1475,8 @@ class _$DiaryStateErrorImpl implements DiaryStateError {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
@@ -1515,8 +1515,8 @@ class _$DiaryStateErrorImpl implements DiaryStateError {
|
||||
List<Product> autocompleteList,
|
||||
Meal currentMeal,
|
||||
SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
TimeOfDay? retireController,
|
||||
TimeOfDay wakeupController,
|
||||
TimeOfDay retireController,
|
||||
TimeOfDay? mealTimeController,
|
||||
TextEditingController commentController,
|
||||
TextEditingController product_nameController,
|
||||
|
||||
@@ -842,228 +842,6 @@ class DiaryScreen extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
/*_buildNutritionChart(BuildContext context, DiaryStateLoaded state) {
|
||||
final List<int> recommendedValues = state
|
||||
.recommendedChartValues; // Рекомендуемые значения: калории, жиры, белки, углеводы
|
||||
final List<int> consumedValues = state.consumedChartValues; //
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 10.h,
|
||||
vertical: 16.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),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: 3.v),
|
||||
Text(
|
||||
"Ваш КБЖУ",
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
SizedBox(height: 8.v),
|
||||
Text(
|
||||
"От дневной суточной нормы",
|
||||
style: CustomTextStyles.bodyMediumBluegray800,
|
||||
),
|
||||
SizedBox(height: 19.v),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 30.h,
|
||||
right: 12.h,
|
||||
),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1.5,
|
||||
child: BarChart(
|
||||
BarChartData(
|
||||
alignment: BarChartAlignment.spaceAround,
|
||||
barTouchData: BarTouchData(enabled: false),
|
||||
titlesData: FlTitlesData(
|
||||
show: true,
|
||||
bottomTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: true,
|
||||
//getTitlesWidget: (value, meta) => newMethod(value),
|
||||
),
|
||||
),
|
||||
),
|
||||
borderData: FlBorderData(show: false),
|
||||
barGroups: [
|
||||
BarChartGroupData(
|
||||
x: 0,
|
||||
barRods: [
|
||||
BarChartRodData(
|
||||
toY: consumedValues[0] / recommendedValues[0] * 100,
|
||||
color: checkConsumedValues(
|
||||
[recommendedValues[0]], [consumedValues[1]])
|
||||
? Colors.red
|
||||
: Colors.blue,
|
||||
),
|
||||
],
|
||||
),
|
||||
BarChartGroupData(
|
||||
x: 1,
|
||||
barRods: [
|
||||
BarChartRodData(
|
||||
toY: consumedValues[1] / recommendedValues[1] * 100,
|
||||
color: checkConsumedValues(
|
||||
[recommendedValues[1]], [consumedValues[1]])
|
||||
? Colors.red
|
||||
: Colors.blue,
|
||||
),
|
||||
],
|
||||
),
|
||||
BarChartGroupData(
|
||||
x: 2,
|
||||
barRods: [
|
||||
BarChartRodData(
|
||||
toY: consumedValues[2] / recommendedValues[2] * 100,
|
||||
color: checkConsumedValues(
|
||||
[recommendedValues[2]], [consumedValues[2]])
|
||||
? Colors.red
|
||||
: Colors.blue,
|
||||
),
|
||||
],
|
||||
),
|
||||
BarChartGroupData(
|
||||
x: 3,
|
||||
barRods: [
|
||||
BarChartRodData(
|
||||
toY: consumedValues[3] / recommendedValues[3] * 100,
|
||||
color: checkConsumedValues(
|
||||
[recommendedValues[3]], [consumedValues[3]])
|
||||
? Colors.red
|
||||
: Colors.blue,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8.v),
|
||||
SizedBox(height: 2.v),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 10.h,
|
||||
right: 2.h,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Калорий",
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 25.h,
|
||||
bottom: 11.v,
|
||||
),
|
||||
child: Text(
|
||||
"Белков",
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 19.h,
|
||||
bottom: 11.v,
|
||||
),
|
||||
child: Text(
|
||||
"Жиров",
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 14.h,
|
||||
bottom: 11.v,
|
||||
),
|
||||
child: Text(
|
||||
"Углеводов",
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 2.v),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 10.h,
|
||||
right: 2.h,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"${consumedValues[0].toInt()} из ${recommendedValues[0].toInt()}",
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 25.h,
|
||||
bottom: 11.v,
|
||||
),
|
||||
child: Text(
|
||||
"${consumedValues[1].toInt()} из ${recommendedValues[1].toInt()}",
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 19.h,
|
||||
bottom: 11.v,
|
||||
),
|
||||
child: Text(
|
||||
"${consumedValues[2].toInt()} из ${recommendedValues[2].toInt()}",
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 14.h,
|
||||
bottom: 11.v,
|
||||
),
|
||||
child: Text(
|
||||
"${consumedValues[3].toInt()} из ${recommendedValues[3].toInt()}",
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 19.v),
|
||||
if (checkConsumedValues(recommendedValues, consumedValues))
|
||||
Text(
|
||||
"*Превышенная суточная норма",
|
||||
style: theme.textTheme.labelLarge,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}*/
|
||||
|
||||
/// Section Widget
|
||||
_buildComment(BuildContext context, DiaryStateLoaded state) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
@@ -1155,7 +933,7 @@ class DiaryScreen extends StatelessWidget {
|
||||
child: AbsorbPointer(
|
||||
child: CustomTextFormField(
|
||||
hintText:
|
||||
state.wakeupController?.format(context).toString(),
|
||||
state.wakeupController.format(context).toString(),
|
||||
prefix: Icon(Icons.sunny),
|
||||
autofocus: false,
|
||||
),
|
||||
@@ -1167,7 +945,7 @@ class DiaryScreen extends StatelessWidget {
|
||||
child: AbsorbPointer(
|
||||
child: CustomTextFormField(
|
||||
hintText:
|
||||
state.retireController?.format(context).toString(),
|
||||
state.retireController.format(context).toString(),
|
||||
prefix: Icon(Icons.bed),
|
||||
autofocus: false,
|
||||
),
|
||||
@@ -1324,7 +1102,7 @@ class DiaryScreen extends StatelessWidget {
|
||||
BuildContext context, DiaryStateLoaded state) async {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: state.wakeupController ?? TimeOfDay.now(),
|
||||
initialTime: state.wakeupController,
|
||||
);
|
||||
if (pickedTime != null && pickedTime != state.wakeupController) {
|
||||
context.read<DiaryBloc>().add(WakeupEvent(pickedTime));
|
||||
@@ -1335,7 +1113,7 @@ class DiaryScreen extends StatelessWidget {
|
||||
BuildContext context, DiaryStateLoaded state) async {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: state.retireController ?? TimeOfDay.now(),
|
||||
initialTime: state.retireController,
|
||||
);
|
||||
if (pickedTime != null && pickedTime != state.retireController) {
|
||||
context.read<DiaryBloc>().add(RetireEvent(pickedTime));
|
||||
|
||||
Reference in New Issue
Block a user