forked from eatvio/eatvio_app
Merge pull request 'diary updates' (#147) from mso7nueh/eatvio_app:main into main
Reviewed-on: eatvio/eatvio_app#147
This commit is contained in:
@@ -37,6 +37,59 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
|||||||
final productNameController = TextEditingController();
|
final productNameController = TextEditingController();
|
||||||
final quantityController = TextEditingController();
|
final quantityController = TextEditingController();
|
||||||
int currentSelectedPhotoIndex = 0;
|
int currentSelectedPhotoIndex = 0;
|
||||||
|
String time = "${DateTime.now().hour.toString().padLeft(2, '0')} : ${DateTime.now().minute.toString().padLeft(2, '0')}";
|
||||||
|
DateTime _time = DateTime.now();
|
||||||
|
|
||||||
|
_showDatePicker() {
|
||||||
|
showModalBottomSheet<void>(
|
||||||
|
context: context,
|
||||||
|
useRootNavigator: true,
|
||||||
|
builder: (context) => SizedBox(
|
||||||
|
height: MediaQuery.of(context).copyWith().size.height / 3,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: CupertinoDatePicker(
|
||||||
|
mode: CupertinoDatePickerMode.time,
|
||||||
|
use24hFormat: true,
|
||||||
|
initialDateTime: DateTime.now(),
|
||||||
|
onDateTimeChanged: (newTime) {
|
||||||
|
setState(() {
|
||||||
|
_time = newTime;
|
||||||
|
time = "${_time.hour.toString().padLeft(2, '0')} : ${_time.minute.toString().padLeft(2, '0')}";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
child: Ink(
|
||||||
|
width: MediaQuery.of(context).size.width - 16,
|
||||||
|
height: 52,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
color: appTheme.blueA400,
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'Сохранить',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -78,13 +131,46 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_timeOfMeal(String time) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () => _showDatePicker(),
|
||||||
|
borderRadius: BorderRadius.circular(100),
|
||||||
|
child: Ink(
|
||||||
|
width: MediaQuery.of(context).size.width / 5,
|
||||||
|
height: 32,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(100),
|
||||||
|
color: Color(0xFFF1F2F6),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
time,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Color(0xFF6D6F71),
|
||||||
|
fontSize: 17,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
_arrowDown() {
|
_arrowDown() {
|
||||||
return Container(
|
return GestureDetector(
|
||||||
padding: const EdgeInsets.only(top: 8, bottom: 16),
|
behavior: HitTestBehavior.translucent,
|
||||||
width: double.infinity,
|
onVerticalDragStart: (_) {
|
||||||
child: Icon(
|
setState(() {
|
||||||
_calendarFormat == CalendarFormat.month ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded,
|
_calendarFormat = CalendarFormat.values[(_calendarFormat.index - 1) % CalendarFormat.values.length];
|
||||||
color: Colors.grey.shade600,
|
});
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.only(top: 8, bottom: 16),
|
||||||
|
child: Icon(
|
||||||
|
_calendarFormat == CalendarFormat.month ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded,
|
||||||
|
color: Colors.grey.shade600,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -172,13 +258,19 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
|||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
_divider(context),
|
_divider(context),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
Text(
|
Row(
|
||||||
'Время приема пищи',
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
style: TextStyle(
|
children: [
|
||||||
color: Color(0xFF323F4B),
|
Text(
|
||||||
fontSize: 16,
|
'Время приема пищи',
|
||||||
fontWeight: FontWeight.w500,
|
style: TextStyle(
|
||||||
),
|
color: Color(0xFF323F4B),
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_timeOfMeal(time),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
_divider(context),
|
_divider(context),
|
||||||
@@ -214,22 +306,18 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
|||||||
ChartData(
|
ChartData(
|
||||||
nutrition.dailyNutritionIntake.carbohydrates,
|
nutrition.dailyNutritionIntake.carbohydrates,
|
||||||
nutrition.dailyNutritionRecommendation.carbohydrates,
|
nutrition.dailyNutritionRecommendation.carbohydrates,
|
||||||
Color(0xFFFF9500),
|
|
||||||
),
|
),
|
||||||
ChartData(
|
ChartData(
|
||||||
nutrition.dailyNutritionIntake.fats,
|
nutrition.dailyNutritionIntake.fats,
|
||||||
nutrition.dailyNutritionRecommendation.fats,
|
nutrition.dailyNutritionRecommendation.fats,
|
||||||
Color(0xFFFF3B30),
|
|
||||||
),
|
),
|
||||||
ChartData(
|
ChartData(
|
||||||
nutrition.dailyNutritionIntake.proteins,
|
nutrition.dailyNutritionIntake.proteins,
|
||||||
nutrition.dailyNutritionRecommendation.proteins,
|
nutrition.dailyNutritionRecommendation.proteins,
|
||||||
Color(0xFF4CD964),
|
|
||||||
),
|
),
|
||||||
ChartData(
|
ChartData(
|
||||||
nutrition.dailyNutritionIntake.energy,
|
nutrition.dailyNutritionIntake.energy,
|
||||||
nutrition.dailyNutritionRecommendation.energy,
|
nutrition.dailyNutritionRecommendation.energy,
|
||||||
Color(0xFF007AFF),
|
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -268,46 +356,77 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
|||||||
showLabels: false,
|
showLabels: false,
|
||||||
showTicks: false,
|
showTicks: false,
|
||||||
radiusFactor: 0.7,
|
radiusFactor: 0.7,
|
||||||
axisLineStyle: AxisLineStyle(
|
showAxisLine: false,
|
||||||
thickness: 0.1,
|
|
||||||
color: Colors.grey[200],
|
|
||||||
thicknessUnit: GaugeSizeUnit.factor,
|
|
||||||
),
|
|
||||||
pointers: <GaugePointer>[
|
pointers: <GaugePointer>[
|
||||||
// Carbohydrates Arc
|
RangePointer(
|
||||||
|
value: 100,
|
||||||
|
width: 0.16,
|
||||||
|
animationDuration: 2000,
|
||||||
|
color: Color(0xFFF6FAFF),
|
||||||
|
sizeUnit: GaugeSizeUnit.factor,
|
||||||
|
enableAnimation: true,
|
||||||
|
cornerStyle: CornerStyle.bothCurve,
|
||||||
|
),
|
||||||
RangePointer(
|
RangePointer(
|
||||||
value: (chartData[0].intake / chartData[0].recommendation) * 100,
|
value: (chartData[0].intake / chartData[0].recommendation) * 100,
|
||||||
width: 0.16,
|
width: 0.16,
|
||||||
color: chartData[0].intake < chartData[0].recommendation ? chartData[0].color : Colors.red,
|
color: chartData[0].intake < chartData[0].recommendation ? appTheme.blueA400 : Colors.red,
|
||||||
sizeUnit: GaugeSizeUnit.factor,
|
sizeUnit: GaugeSizeUnit.factor,
|
||||||
enableAnimation: true,
|
enableAnimation: true,
|
||||||
cornerStyle: CornerStyle.bothCurve, // Rounded ends
|
cornerStyle: CornerStyle.bothCurve,
|
||||||
),
|
),
|
||||||
// Fats Arc
|
|
||||||
RangePointer(
|
RangePointer(
|
||||||
value: (chartData[1].intake / chartData[1].recommendation) * 100,
|
value: 100,
|
||||||
width: 0.16,
|
width: 0.16,
|
||||||
color: chartData[1].intake < chartData[1].recommendation ? chartData[1].color : Colors.red,
|
animationDuration: 2000,
|
||||||
|
color: Color(0xFFF6FAFF),
|
||||||
sizeUnit: GaugeSizeUnit.factor,
|
sizeUnit: GaugeSizeUnit.factor,
|
||||||
enableAnimation: true,
|
enableAnimation: true,
|
||||||
cornerStyle: CornerStyle.bothCurve,
|
cornerStyle: CornerStyle.bothCurve,
|
||||||
pointerOffset: -0.18,
|
pointerOffset: -0.18,
|
||||||
),
|
),
|
||||||
// Proteins Arc
|
|
||||||
RangePointer(
|
RangePointer(
|
||||||
value: (chartData[2].intake / chartData[2].recommendation) * 100,
|
value: (chartData[1].intake / chartData[1].recommendation) * 100,
|
||||||
width: 0.16,
|
width: 0.16,
|
||||||
color: chartData[2].intake < chartData[2].recommendation ? chartData[2].color : Colors.red,
|
color: chartData[1].intake < chartData[1].recommendation ? appTheme.blueA400 : Colors.red,
|
||||||
|
sizeUnit: GaugeSizeUnit.factor,
|
||||||
|
enableAnimation: true,
|
||||||
|
cornerStyle: CornerStyle.bothCurve,
|
||||||
|
pointerOffset: -0.18,
|
||||||
|
),
|
||||||
|
RangePointer(
|
||||||
|
value: 100,
|
||||||
|
width: 0.16,
|
||||||
|
animationDuration: 2000,
|
||||||
|
color: Color(0xFFF6FAFF),
|
||||||
sizeUnit: GaugeSizeUnit.factor,
|
sizeUnit: GaugeSizeUnit.factor,
|
||||||
enableAnimation: true,
|
enableAnimation: true,
|
||||||
cornerStyle: CornerStyle.bothCurve,
|
cornerStyle: CornerStyle.bothCurve,
|
||||||
pointerOffset: -0.36,
|
pointerOffset: -0.36,
|
||||||
),
|
),
|
||||||
// Calories Arc
|
RangePointer(
|
||||||
|
value: (chartData[2].intake / chartData[2].recommendation) * 100,
|
||||||
|
width: 0.16,
|
||||||
|
color: chartData[2].intake < chartData[2].recommendation ? appTheme.blueA400 : Colors.red,
|
||||||
|
sizeUnit: GaugeSizeUnit.factor,
|
||||||
|
enableAnimation: true,
|
||||||
|
cornerStyle: CornerStyle.bothCurve,
|
||||||
|
pointerOffset: -0.36,
|
||||||
|
),
|
||||||
|
RangePointer(
|
||||||
|
value: 100,
|
||||||
|
width: 0.16,
|
||||||
|
animationDuration: 2000,
|
||||||
|
color: Color(0xFFF6FAFF),
|
||||||
|
sizeUnit: GaugeSizeUnit.factor,
|
||||||
|
enableAnimation: true,
|
||||||
|
cornerStyle: CornerStyle.bothCurve,
|
||||||
|
pointerOffset: -0.54,
|
||||||
|
),
|
||||||
RangePointer(
|
RangePointer(
|
||||||
value: (chartData[3].intake / chartData[3].recommendation) * 100,
|
value: (chartData[3].intake / chartData[3].recommendation) * 100,
|
||||||
width: 0.16,
|
width: 0.16,
|
||||||
color: chartData[3].intake < chartData[3].recommendation ? chartData[3].color : Colors.red,
|
color: chartData[3].intake < chartData[3].recommendation ? appTheme.blueA400 : Colors.red,
|
||||||
sizeUnit: GaugeSizeUnit.factor,
|
sizeUnit: GaugeSizeUnit.factor,
|
||||||
enableAnimation: true,
|
enableAnimation: true,
|
||||||
cornerStyle: CornerStyle.bothCurve,
|
cornerStyle: CornerStyle.bothCurve,
|
||||||
@@ -315,49 +434,57 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
annotations: <GaugeAnnotation>[
|
annotations: <GaugeAnnotation>[
|
||||||
// Label for Carbohydrates
|
|
||||||
GaugeAnnotation(
|
GaugeAnnotation(
|
||||||
widget: Transform.rotate(
|
widget: Transform.rotate(
|
||||||
angle: 30.1,
|
angle: 30.1,
|
||||||
child: Text(
|
child: Text(
|
||||||
'Углеводы',
|
'Углеводы',
|
||||||
style: TextStyle(color: Colors.white, fontSize: 12),
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
angle: 198,
|
angle: 198,
|
||||||
positionFactor: 0.92,
|
positionFactor: 0.92,
|
||||||
),
|
),
|
||||||
// Label for Fats
|
|
||||||
GaugeAnnotation(
|
GaugeAnnotation(
|
||||||
widget: Transform.rotate(
|
widget: Transform.rotate(
|
||||||
angle: 30,
|
angle: 30,
|
||||||
child: Text(
|
child: Text(
|
||||||
'Жиры',
|
'Жиры',
|
||||||
style: TextStyle(color: Colors.white, fontSize: 12),
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
angle: 190,
|
angle: 190,
|
||||||
positionFactor: 1.1,
|
positionFactor: 1.1,
|
||||||
),
|
),
|
||||||
// Label for Proteins
|
|
||||||
GaugeAnnotation(
|
GaugeAnnotation(
|
||||||
widget: Transform.rotate(
|
widget: Transform.rotate(
|
||||||
angle: 30,
|
angle: 30,
|
||||||
child: Text(
|
child: Text(
|
||||||
'Белки',
|
'Белки',
|
||||||
style: TextStyle(color: Colors.white, fontSize: 12),
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
angle: 190,
|
angle: 190,
|
||||||
positionFactor: 1.27,
|
positionFactor: 1.27,
|
||||||
),
|
),
|
||||||
// Label for Calories
|
|
||||||
GaugeAnnotation(
|
GaugeAnnotation(
|
||||||
widget: Transform.rotate(
|
widget: Transform.rotate(
|
||||||
angle: 30,
|
angle: 30,
|
||||||
child: Text(
|
child: Text(
|
||||||
'Калории',
|
'Калории',
|
||||||
style: TextStyle(color: Colors.white, fontSize: 12),
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
angle: 192,
|
angle: 192,
|
||||||
@@ -591,7 +718,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
'$mealNumber',
|
'$mealNumber',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: isActive ? Colors.white : Colors.black,
|
color: isActive ? Colors.white : Color(0xFF6D6F71),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
@@ -892,11 +1019,9 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
|||||||
class ChartData {
|
class ChartData {
|
||||||
final double intake;
|
final double intake;
|
||||||
final double recommendation;
|
final double recommendation;
|
||||||
final Color color;
|
|
||||||
|
|
||||||
ChartData(
|
ChartData(
|
||||||
this.intake,
|
this.intake,
|
||||||
this.recommendation,
|
this.recommendation,
|
||||||
this.color,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ dependencies:
|
|||||||
rive: ^0.13.15
|
rive: ^0.13.15
|
||||||
mask_text_input_formatter: ^2.9.0
|
mask_text_input_formatter: ^2.9.0
|
||||||
lottie: ^3.1.3
|
lottie: ^3.1.3
|
||||||
|
flutter_portal: ^1.1.4
|
||||||
|
fluttertoast: ^8.2.8
|
||||||
flutter_rating_bar: ^4.0.1
|
flutter_rating_bar: ^4.0.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|||||||
Reference in New Issue
Block a user