forked from eatvio/eatvio_app
feat(diary): Diary ID is passed on calendar click, new layouts for calendar, fixed nutrition chart
This commit is contained in:
@@ -68,10 +68,14 @@ class AppRouter {
|
|||||||
builder: (context, state) => FeedScreenNew(),
|
builder: (context, state) => FeedScreenNew(),
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/diary-screen',
|
path: '/diary-screen',
|
||||||
name: 'diaryScreen',
|
name: 'diaryScreen',
|
||||||
builder: (context, state) => DiaryScreen(),
|
builder: (context, state) {
|
||||||
),
|
if (state.extra != null)
|
||||||
|
return DiaryScreen(diaryID: state.extra as String);
|
||||||
|
else
|
||||||
|
return DiaryScreen(diaryID: '0');
|
||||||
|
}),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/chat-select-screen',
|
path: '/chat-select-screen',
|
||||||
name: 'chatSelectScreen',
|
name: 'chatSelectScreen',
|
||||||
@@ -87,7 +91,8 @@ class AppRouter {
|
|||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/blog-post-screen',
|
path: '/blog-post-screen',
|
||||||
name: 'blogPostScreen',
|
name: 'blogPostScreen',
|
||||||
builder: (context, state) => BlogPostScreen(blogPostID: state.extra as String),
|
builder: (context, state) =>
|
||||||
|
BlogPostScreen(blogPostID: state.extra as String),
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/blog-post-edit-screen',
|
path: '/blog-post-edit-screen',
|
||||||
|
|||||||
20
lib/features/calendar/models/calendar_entry_model.dart
Normal file
20
lib/features/calendar/models/calendar_entry_model.dart
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import 'package:eatvio_app/core/app_export.dart';
|
||||||
|
|
||||||
|
/// This class is used in the [userprofile_item_widget] screen.
|
||||||
|
// ignore_for_file: must_be_immutable
|
||||||
|
|
||||||
|
class CalendarEntryModel {
|
||||||
|
String? date;
|
||||||
|
String? status;
|
||||||
|
String id;
|
||||||
|
|
||||||
|
CalendarEntryModel({
|
||||||
|
this.date,
|
||||||
|
this.status,
|
||||||
|
required this.id,
|
||||||
|
}) {
|
||||||
|
date = date;
|
||||||
|
status = status;
|
||||||
|
id = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
// ignore_for_file: unused_local_variable
|
// ignore_for_file: unused_local_variable
|
||||||
|
|
||||||
import 'package:eatvio_app/features/calendar/models/calendar_model.dart';
|
|
||||||
import 'package:eatvio_app/features/calendar/presentation/bloc/calendar_cubit.dart';
|
import 'package:eatvio_app/features/calendar/presentation/bloc/calendar_cubit.dart';
|
||||||
import 'package:eatvio_app/features/calendar/presentation/bloc/calendar_state.dart';
|
import 'package:eatvio_app/features/calendar/presentation/bloc/calendar_state.dart';
|
||||||
import 'package:eatvio_app/core/app_export.dart';
|
import 'package:eatvio_app/core/app_export.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:table_calendar/table_calendar.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||||
@@ -54,7 +53,7 @@ class CalendarScreen extends StatelessWidget {
|
|||||||
toolbarHeight: 0,
|
toolbarHeight: 0,
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
),
|
),
|
||||||
backgroundColor: Color.fromARGB(255, 240, 242, 245),
|
backgroundColor: Colors.white,
|
||||||
resizeToAvoidBottomInset: true,
|
resizeToAvoidBottomInset: true,
|
||||||
body: SizedBox(
|
body: SizedBox(
|
||||||
width: double.maxFinite,
|
width: double.maxFinite,
|
||||||
@@ -83,82 +82,154 @@ class CalendarScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_buildCalendarBody(BuildContext context, CalendarStateLoaded state) {
|
_buildCalendarBody(BuildContext context, CalendarStateLoaded state) {
|
||||||
return Container(
|
return ListView.separated(
|
||||||
margin: EdgeInsets.symmetric(horizontal: 16.h, vertical: 16.h),
|
padding: EdgeInsets.all(8),
|
||||||
padding: EdgeInsets.symmetric(
|
shrinkWrap: true,
|
||||||
horizontal: 24.h,
|
physics: NeverScrollableScrollPhysics(),
|
||||||
vertical: 12.v,
|
separatorBuilder: (context, index) {
|
||||||
),
|
return SizedBox(
|
||||||
decoration: BoxDecoration(
|
height: 2.v,
|
||||||
color: Colors.white,
|
);
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
},
|
||||||
boxShadow: [
|
itemCount: state.calendarList.length,
|
||||||
BoxShadow(
|
itemBuilder: (context, index) {
|
||||||
color: Colors.grey.withOpacity(0.5),
|
Map<String, dynamic> diary = {};
|
||||||
spreadRadius: 2,
|
if (state.calendarList[index].diary is List<dynamic>) {
|
||||||
blurRadius: 5,
|
diary['status'] = 'Скоро';
|
||||||
offset: Offset(0, 3),
|
} else if (state.calendarList[index].diary is Map<String, dynamic>) {
|
||||||
|
diary = state.calendarList[index].diary as Map<String, dynamic>;
|
||||||
|
}
|
||||||
|
return InkWell(
|
||||||
|
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||||
|
onTap: () => GoRouter.of(context).go(
|
||||||
|
'/diary-screen',
|
||||||
|
extra: diary['id'].toString(),
|
||||||
),
|
),
|
||||||
],
|
child: Ink(
|
||||||
),
|
padding: EdgeInsets.all(8),
|
||||||
child: TableCalendar(
|
decoration: BoxDecoration(
|
||||||
locale: 'ru_RU',
|
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||||
firstDay: DateTime.utc(2010, 10, 16),
|
color: getBackgroundColor(diary['state']),
|
||||||
lastDay: DateTime.utc(2030, 3, 14),
|
),
|
||||||
focusedDay: DateTime.now(),
|
child: Row(
|
||||||
startingDayOfWeek: StartingDayOfWeek.monday,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
calendarBuilders: CalendarBuilders(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
selectedBuilder: (context, day, focusedDay) =>
|
children: [
|
||||||
_buildCellDate(context, day, focusedDay: focusedDay, state),
|
Expanded(
|
||||||
defaultBuilder: (context, day, focusedDay) =>
|
child: Column(
|
||||||
_buildCellDate(context, day, state),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
todayBuilder: (context, day, focusedDay) =>
|
children: [
|
||||||
_buildCellDate(context, day, state),
|
Text(
|
||||||
),
|
formatDate(state.calendarList[index].date),
|
||||||
),
|
style: theme.textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
SizedBox(height: 2.v),
|
||||||
|
if (diary['state'] != null)
|
||||||
|
Row(children: [
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.all(
|
||||||
|
4.0), // Отступы внутри контейнера
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: diary['state'] == 'finished'
|
||||||
|
? Color.fromRGBO(1, 154, 62, 1)
|
||||||
|
: Color.fromRGBO(154, 74, 1, 1),
|
||||||
|
borderRadius: BorderRadius.circular(
|
||||||
|
24.0), // Закругленные углы
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
_getStateText(diary['state'] ?? ''),
|
||||||
|
style: CustomTextStyles
|
||||||
|
.titleSmallBold, // Предполагается, что текст белый
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 4),
|
||||||
|
if (diary['state'] == 'started')
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.all(
|
||||||
|
4.0), // Отступы внутри контейнера
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color.fromRGBO(13, 110, 253, 1),
|
||||||
|
borderRadius: BorderRadius.circular(
|
||||||
|
24.0), // Закругленные углы
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'Заполнить отчет',
|
||||||
|
style: CustomTextStyles
|
||||||
|
.titleSmallBold, // Предполагается, что текст белый
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (diary['state'] == 'finished')
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.all(
|
||||||
|
4.0), // Отступы внутри контейнера
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color.fromRGBO(13, 110, 253, 1),
|
||||||
|
borderRadius: BorderRadius.circular(
|
||||||
|
24.0), // Закругленные углы
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'Изменить отчет',
|
||||||
|
style: CustomTextStyles
|
||||||
|
.titleSmallBold, // Предполагается, что текст белый
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
if (state.calendarList[index].diary is List<dynamic>)
|
||||||
|
Container(
|
||||||
|
padding:
|
||||||
|
EdgeInsets.all(4.0), // Отступы внутри контейнера
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color.fromRGBO(108, 117, 125, 1),
|
||||||
|
borderRadius: BorderRadius.circular(
|
||||||
|
24.0), // Закругленные углы
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'Cкоро',
|
||||||
|
style: CustomTextStyles
|
||||||
|
.titleSmallBold, // Предполагается, что текст белый
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildCellDate(
|
String _getStateText(String state) {
|
||||||
BuildContext context, DateTime day, CalendarStateLoaded state,
|
switch (state) {
|
||||||
{DateTime? focusedDay}) {
|
case 'finished':
|
||||||
final String dayString = day.toIso8601String().split('T').first;
|
return 'Готово';
|
||||||
final List<CalendarModel> calendarModels = state.calendarList;
|
case 'started':
|
||||||
|
return 'В процессе';
|
||||||
// Находим первую модель, соответствующую дате
|
default:
|
||||||
final CalendarModel model = calendarModels.firstWhere(
|
return ''; // Возвращаем пустую строку, если состояние не распознано
|
||||||
(model) => model.date == dayString,
|
}
|
||||||
orElse: () => CalendarModel(date: dayString, diary: {}));
|
}
|
||||||
|
|
||||||
Color? bgclr; // Объявляем переменную bgclr здесь
|
String formatDate(String dateString) {
|
||||||
|
// Преобразуем строку в объект DateTime
|
||||||
final Map<String, dynamic> diary = model.diary as Map<String, dynamic>;
|
DateTime dateTime = DateTime.parse(dateString);
|
||||||
if (model.diary is Map<String, dynamic>) {
|
|
||||||
if (diary['state'] == "started") {
|
// Форматируем дату
|
||||||
bgclr = Colors.grey;
|
String formattedDate = DateFormat('d MMMM', 'ru_RU').format(dateTime);
|
||||||
} else if (diary['state'] == "finished") {
|
|
||||||
bgclr = Colors.green;
|
// Возвращаем результат в нужном формате
|
||||||
} else {
|
return '$formattedDate';
|
||||||
bgclr = Colors.white;
|
}
|
||||||
}
|
|
||||||
} else {
|
Color getBackgroundColor(String? status) {
|
||||||
bgclr = Colors.white; // Значение по умолчанию, если diary не является Map
|
switch (status) {
|
||||||
|
case 'finished':
|
||||||
|
return Color.fromRGBO(1, 154, 62, .1);
|
||||||
|
case 'started':
|
||||||
|
return Color.fromRGBO(154, 74, 1, .1);
|
||||||
|
default:
|
||||||
|
return Color.fromRGBO(126, 136, 151, .1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: () => GoRouter.of(context).pushNamed(
|
|
||||||
'diaryScreen',
|
|
||||||
extra: diary['id'],
|
|
||||||
),
|
|
||||||
child: Container(
|
|
||||||
margin: const EdgeInsets.all(5),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
shape: (day == focusedDay) ? BoxShape.circle : BoxShape.rectangle,
|
|
||||||
color: bgclr,
|
|
||||||
borderRadius: (day == focusedDay) ? null : BorderRadius.circular(4),
|
|
||||||
),
|
|
||||||
child: Text(day.day.toString(), style: TextStyle(color: Colors.black)),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ part 'diary_event.dart';
|
|||||||
class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||||
final DiaryRepository diaryRepository;
|
final DiaryRepository diaryRepository;
|
||||||
|
|
||||||
DiaryBloc({required this.diaryRepository}) : super(const DiaryState.loading()) {
|
DiaryBloc({required this.diaryRepository})
|
||||||
|
: super(const DiaryState.loading()) {
|
||||||
on<LoadDiary>(loadDiary);
|
on<LoadDiary>(loadDiary);
|
||||||
on<ChangeSatiety>(_changeSatiety); // пользователь нажимает на шкалу сытости
|
on<ChangeSatiety>(_changeSatiety); // пользователь нажимает на шкалу сытости
|
||||||
on<ChangeMood>(_changeMood); // пользователь нажимает на шкалу настроения
|
on<ChangeMood>(_changeMood); // пользователь нажимает на шкалу настроения
|
||||||
@@ -53,18 +54,33 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
|||||||
final DiaryModel diary = await diaryRepository.getDiary(diaryID ?? 45);
|
final DiaryModel diary = await diaryRepository.getDiary(diaryID ?? 45);
|
||||||
final Meal currentMeal = diary.meals[0];
|
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> chartData =
|
||||||
final Map<String, dynamic> dailyNutritionIntake = chartData['dailyNutritionIntake']!;
|
await diaryRepository.getChartData(diaryID ?? 45);
|
||||||
final Map<String, dynamic> dailyNutritionRecommendations = chartData['dailyNutritionRecommendation']!;
|
print(chartData);
|
||||||
final double ccal = dailyNutritionIntake['energy']! / dailyNutritionRecommendations['energy']! * 50;
|
final Map<String, dynamic> dailyNutritionIntake =
|
||||||
final double proteins = dailyNutritionIntake['proteins']! / dailyNutritionRecommendations['proteins']! * 50;
|
chartData['dailyNutritionIntake']!;
|
||||||
final double fats = dailyNutritionIntake['fats']! / dailyNutritionRecommendations['fats']! * 50;
|
final Map<String, dynamic> dailyNutritionRecommendations =
|
||||||
final double carbs = dailyNutritionIntake['carbohydrates']! / dailyNutritionRecommendations['carbohydrates']! * 50;
|
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;
|
||||||
|
|
||||||
Color getColor(double value) {
|
Color getColor(double value) {
|
||||||
if (value >= 99.1) {
|
if (value >= 49.1) {
|
||||||
return Colors.red;
|
return Colors.red;
|
||||||
} else {
|
} else {
|
||||||
return Colors.blue;
|
return Colors.blue;
|
||||||
@@ -86,7 +102,6 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
|||||||
SelectionPopupModel(title: "Прием пищи 5", id: 5),
|
SelectionPopupModel(title: "Прием пищи 5", id: 5),
|
||||||
SelectionPopupModel(title: "Прием пищи 6", id: 6),
|
SelectionPopupModel(title: "Прием пищи 6", id: 6),
|
||||||
];
|
];
|
||||||
|
|
||||||
emit(DiaryState.loaded(
|
emit(DiaryState.loaded(
|
||||||
diary: diary,
|
diary: diary,
|
||||||
currentMeal: currentMeal,
|
currentMeal: currentMeal,
|
||||||
@@ -163,9 +178,11 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
|||||||
) async {
|
) async {
|
||||||
if (state is DiaryStateLoaded) {
|
if (state is DiaryStateLoaded) {
|
||||||
var currentState = state as 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 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(
|
await diaryRepository.changeWakeup(
|
||||||
currentState.diary.id,
|
currentState.diary.id,
|
||||||
wakeupString,
|
wakeupString,
|
||||||
@@ -180,9 +197,11 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
|||||||
) async {
|
) async {
|
||||||
if (state is DiaryStateLoaded) {
|
if (state is DiaryStateLoaded) {
|
||||||
var currentState = state as 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 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(
|
await diaryRepository.changeRetire(
|
||||||
currentState.diary.id,
|
currentState.diary.id,
|
||||||
retireString,
|
retireString,
|
||||||
@@ -208,7 +227,8 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
|||||||
) async {
|
) async {
|
||||||
if (state is DiaryStateLoaded) {
|
if (state is DiaryStateLoaded) {
|
||||||
final currentState = state as 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(
|
DiaryStateLoaded updatedState = currentState.copyWith(
|
||||||
currentMeal: meal,
|
currentMeal: meal,
|
||||||
portions: meal.portions,
|
portions: meal.portions,
|
||||||
@@ -227,10 +247,12 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
|||||||
if (state is DiaryStateLoaded) {
|
if (state is DiaryStateLoaded) {
|
||||||
var currentState = state as 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(
|
var updatedState = currentState.copyWith(
|
||||||
product_nameController: TextEditingController(text: event.input),
|
product_nameController: TextEditingController(text: event.input),
|
||||||
autocompleteList: productNutritionalValues['product_nutritional_value'] ?? [],
|
autocompleteList:
|
||||||
|
productNutritionalValues['product_nutritional_value'] ?? [],
|
||||||
);
|
);
|
||||||
if (event.input.length > 3) {
|
if (event.input.length > 3) {
|
||||||
updatedState = updatedState.copyWith(moderationExpanded: true);
|
updatedState = updatedState.copyWith(moderationExpanded: true);
|
||||||
|
|||||||
@@ -23,7 +23,13 @@ import 'package:syncfusion_flutter_charts/charts.dart';
|
|||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class DiaryScreen extends StatelessWidget {
|
class DiaryScreen extends StatelessWidget {
|
||||||
DiaryScreen({Key? key}) : super(key: key);
|
final String? diaryID;
|
||||||
|
|
||||||
|
const DiaryScreen({
|
||||||
|
this.diaryID,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<DiaryBloc, DiaryState>(
|
return BlocBuilder<DiaryBloc, DiaryState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
@@ -141,7 +147,6 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
widthFactor: 0.5,
|
widthFactor: 0.5,
|
||||||
child: SfCircularChart(
|
child: SfCircularChart(
|
||||||
legend: Legend(isVisible: false),
|
|
||||||
series: <CircularSeries>[
|
series: <CircularSeries>[
|
||||||
RadialBarSeries<NutritionData, String>(
|
RadialBarSeries<NutritionData, String>(
|
||||||
dataSource: state.chartData,
|
dataSource: state.chartData,
|
||||||
@@ -153,30 +158,29 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
SizedBox(height: 16.0),
|
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text('Калории'),
|
|
||||||
Text('Белки'),
|
|
||||||
Text('Жиры'),
|
|
||||||
Text('Углеводы'),
|
Text('Углеводы'),
|
||||||
|
Text('Жиры'),
|
||||||
|
Text('Белки'),
|
||||||
|
Text('Калории'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'${state.chartData![0].nutrition.toStringAsFixed(1)}'), // Калории
|
'${state.chartData![3].nutrition.toStringAsFixed(0)}%'), // Калории
|
||||||
Text(
|
Text(
|
||||||
'${state.chartData![1].nutrition.toStringAsFixed(1)}'), // Белки
|
'${state.chartData![2].nutrition.toStringAsFixed(0)}%'), // Белки
|
||||||
Text(
|
Text(
|
||||||
'${state.chartData![2].nutrition.toStringAsFixed(1)}'), // Жиры
|
'${state.chartData![1].nutrition.toStringAsFixed(0)}%'), // Жиры
|
||||||
Text(
|
Text(
|
||||||
'${state.chartData![3].nutrition.toStringAsFixed(1)}'), // Углеводы
|
'${state.chartData![0].nutrition.toStringAsFixed(0)}% '), // Углеводы
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user