forked from eatvio/eatvio_app
feat(diary): Chart refactor, photo add and delete refactor
This commit is contained in:
@@ -150,6 +150,12 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
xValueMapper: (NutritionData data, _) => data.category,
|
xValueMapper: (NutritionData data, _) => data.category,
|
||||||
yValueMapper: (NutritionData data, _) => data.nutrition,
|
yValueMapper: (NutritionData data, _) => data.nutrition,
|
||||||
pointColorMapper: (NutritionData data, _) => data.color,
|
pointColorMapper: (NutritionData data, _) => data.color,
|
||||||
|
trackColor: Color.fromRGBO(59, 130, 246, 1),
|
||||||
|
trackOpacity: 0.1,
|
||||||
|
gap: "8%",
|
||||||
|
radius: "110%",
|
||||||
|
innerRadius:
|
||||||
|
'20%', // Измените значение по вашему усмотрению
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -332,7 +338,9 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
borderRadius: BorderRadiusStyle.roundedBorder5,
|
borderRadius: BorderRadiusStyle.roundedBorder5,
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: CircularProgressIndicator(color: appTheme.blueGray300), // Замените на свой прелоадер при необходимости
|
child: CircularProgressIndicator(
|
||||||
|
color: appTheme
|
||||||
|
.blueGray300), // Замените на свой прелоадер при необходимости
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -358,7 +366,8 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
|
|
||||||
_buildMeal(BuildContext context, DiaryStateLoaded state) {
|
_buildMeal(BuildContext context, DiaryStateLoaded state) {
|
||||||
final digitsOnly = FilteringTextInputFormatter.digitsOnly;
|
final digitsOnly = FilteringTextInputFormatter.digitsOnly;
|
||||||
List<String> _options = state.autocompleteList.map((Product item) => item.name).toList();
|
List<String> _options =
|
||||||
|
state.autocompleteList.map((Product item) => item.name).toList();
|
||||||
FocusNode focusNodeName = FocusNode();
|
FocusNode focusNodeName = FocusNode();
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
@@ -393,7 +402,9 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
onTap: () => _selectMealTime(context, state),
|
onTap: () => _selectMealTime(context, state),
|
||||||
child: AbsorbPointer(
|
child: AbsorbPointer(
|
||||||
child: CustomTextFormField(
|
child: CustomTextFormField(
|
||||||
hintText: state.mealTimeController?.format(context).toString(),
|
hintText: state.mealTimeController
|
||||||
|
?.format(context)
|
||||||
|
.toString(),
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -529,7 +540,9 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
SizedBox(height: 24.v),
|
SizedBox(height: 24.v),
|
||||||
_buildAddProduct(context, state),
|
_buildAddProduct(context, state),
|
||||||
SizedBox(height: 24.v),
|
SizedBox(height: 24.v),
|
||||||
...state.portions.map((portion) => _buildProduct(context, portion)).toList(),
|
...state.portions
|
||||||
|
.map((portion) => _buildProduct(context, portion))
|
||||||
|
.toList(),
|
||||||
SizedBox(height: 24.v),
|
SizedBox(height: 24.v),
|
||||||
_buildCarousel(context, state),
|
_buildCarousel(context, state),
|
||||||
SizedBox(height: 24.v),
|
SizedBox(height: 24.v),
|
||||||
@@ -678,7 +691,8 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
|
|
||||||
popDialog(BuildContext dialogContext) {
|
popDialog(BuildContext dialogContext) {
|
||||||
return () {
|
return () {
|
||||||
Navigator.of(dialogContext).pop(); // Dismiss the dialog on Cancel button press
|
Navigator.of(dialogContext)
|
||||||
|
.pop(); // Dismiss the dialog on Cancel button press
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -688,7 +702,8 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
selectProduct(AutocompleteOnSelected<String> onSelected, String option, DiaryStateLoaded state) {
|
selectProduct(AutocompleteOnSelected<String> onSelected, String option,
|
||||||
|
DiaryStateLoaded state) {
|
||||||
state.product_nameController.text = option;
|
state.product_nameController.text = option;
|
||||||
return () {
|
return () {
|
||||||
onSelected(option);
|
onSelected(option);
|
||||||
@@ -730,7 +745,7 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
return CarouselSlider(
|
return CarouselSlider(
|
||||||
options: CarouselOptions(height: 200.0),
|
options: CarouselOptions(height: 200.0),
|
||||||
items: state.currentMeal.photos.map<Widget>((photo) {
|
items: state.currentMeal.photos.map<Widget>((photo) {
|
||||||
return _buildPhoto(context, photo);
|
return _buildPhoto(context, photo, state);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -756,7 +771,9 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
top: 5.v,
|
top: 5.v,
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
portion.product_name.length > 8 ? portion.product_name.substring(0, 8) : portion.product_name,
|
portion.product_name.length > 8
|
||||||
|
? portion.product_name.substring(0, 8)
|
||||||
|
: portion.product_name,
|
||||||
style: CustomTextStyles.titleMedium16,
|
style: CustomTextStyles.titleMedium16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -786,7 +803,7 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_buildPhoto(BuildContext context, Photo photo) {
|
_buildPhoto(BuildContext context, Photo photo, DiaryStateLoaded state) {
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
@@ -821,14 +838,12 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.photo_outlined),
|
icon: Icon(Icons.photo_outlined),
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
onPressed: () {
|
onPressed: addImage(context, state.isLoading),
|
||||||
// Ваш код для кнопки фотографии
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.delete_outlined),
|
icon: Icon(Icons.delete_outlined),
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
onPressed: () => removePhoto(context, photo),
|
onPressed: removePhoto(context, photo),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -846,7 +861,9 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
|
|
||||||
removePhoto(BuildContext context, Photo photo) {
|
removePhoto(BuildContext context, Photo photo) {
|
||||||
return () {
|
return () {
|
||||||
context.read<DiaryBloc>().add(RemoveImageEvent(photo.id.toString(), photo.path));
|
context
|
||||||
|
.read<DiaryBloc>()
|
||||||
|
.add(RemoveImageEvent(photo.id.toString(), photo.path));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -906,7 +923,9 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
r"Подъем \ отход ко сну",
|
r"Подъем \ отход ко сну",
|
||||||
style: CustomTextStyles.bodyMediumBlack900,
|
style: CustomTextStyles.bodyMediumBlack900,
|
||||||
),
|
),
|
||||||
Icon(state.wakeupExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down),
|
Icon(state.wakeupExpanded
|
||||||
|
? Icons.arrow_drop_up
|
||||||
|
: Icons.arrow_drop_down),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -920,7 +939,8 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
onTap: () => _selectWakeupTime(context, state),
|
onTap: () => _selectWakeupTime(context, state),
|
||||||
child: AbsorbPointer(
|
child: AbsorbPointer(
|
||||||
child: CustomTextFormField(
|
child: CustomTextFormField(
|
||||||
hintText: state.wakeupController.format(context).toString(),
|
hintText:
|
||||||
|
state.wakeupController.format(context).toString(),
|
||||||
prefix: Icon(Icons.sunny),
|
prefix: Icon(Icons.sunny),
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
),
|
),
|
||||||
@@ -931,7 +951,8 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
onTap: () => _selectRetireTime(context, state),
|
onTap: () => _selectRetireTime(context, state),
|
||||||
child: AbsorbPointer(
|
child: AbsorbPointer(
|
||||||
child: CustomTextFormField(
|
child: CustomTextFormField(
|
||||||
hintText: state.retireController.format(context).toString(),
|
hintText:
|
||||||
|
state.retireController.format(context).toString(),
|
||||||
prefix: Icon(Icons.bed),
|
prefix: Icon(Icons.bed),
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
),
|
),
|
||||||
@@ -978,7 +999,8 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Function() sendFinishDayData(BuildContext dialogContext, BuildContext context) {
|
Function() sendFinishDayData(
|
||||||
|
BuildContext dialogContext, BuildContext context) {
|
||||||
return () {
|
return () {
|
||||||
closeDialog(dialogContext);
|
closeDialog(dialogContext);
|
||||||
context.read<DiaryBloc>().add(FinishDay());
|
context.read<DiaryBloc>().add(FinishDay());
|
||||||
@@ -1012,7 +1034,9 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
"Ваше настроение после приема пищи",
|
"Ваше настроение после приема пищи",
|
||||||
style: CustomTextStyles.bodyMediumBlack900,
|
style: CustomTextStyles.bodyMediumBlack900,
|
||||||
),
|
),
|
||||||
Icon(state.moodExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down),
|
Icon(state.moodExpanded
|
||||||
|
? Icons.arrow_drop_up
|
||||||
|
: Icons.arrow_drop_down),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -1072,7 +1096,8 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _selectWakeupTime(BuildContext context, DiaryStateLoaded state) async {
|
Future<void> _selectWakeupTime(
|
||||||
|
BuildContext context, DiaryStateLoaded state) async {
|
||||||
final TimeOfDay? pickedTime = await showTimePicker(
|
final TimeOfDay? pickedTime = await showTimePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialTime: state.wakeupController,
|
initialTime: state.wakeupController,
|
||||||
@@ -1082,7 +1107,8 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _selectRetireTime(BuildContext context, DiaryStateLoaded state) async {
|
Future<void> _selectRetireTime(
|
||||||
|
BuildContext context, DiaryStateLoaded state) async {
|
||||||
final TimeOfDay? pickedTime = await showTimePicker(
|
final TimeOfDay? pickedTime = await showTimePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialTime: state.retireController,
|
initialTime: state.retireController,
|
||||||
@@ -1092,7 +1118,8 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _selectMealTime(BuildContext context, DiaryStateLoaded state) async {
|
Future<void> _selectMealTime(
|
||||||
|
BuildContext context, DiaryStateLoaded state) async {
|
||||||
final TimeOfDay? pickedTime = await showTimePicker(
|
final TimeOfDay? pickedTime = await showTimePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialTime: state.mealTimeController ?? TimeOfDay.now(),
|
initialTime: state.mealTimeController ?? TimeOfDay.now(),
|
||||||
@@ -1103,7 +1130,8 @@ class DiaryScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkConsumedValues(List<int> recommendedValues, List<int> consumedValues) {
|
bool checkConsumedValues(
|
||||||
|
List<int> recommendedValues, List<int> consumedValues) {
|
||||||
for (int i = 0; i < recommendedValues.length; i++) {
|
for (int i = 0; i < recommendedValues.length; i++) {
|
||||||
if (consumedValues[i] > recommendedValues[i]) {
|
if (consumedValues[i] > recommendedValues[i]) {
|
||||||
// Если хотя бы одно потребленное значение превышает рекомендованное
|
// Если хотя бы одно потребленное значение превышает рекомендованное
|
||||||
|
|||||||
Reference in New Issue
Block a user