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 quantityController = TextEditingController();
|
||||
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
|
||||
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() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(top: 8, bottom: 16),
|
||||
width: double.infinity,
|
||||
child: Icon(
|
||||
_calendarFormat == CalendarFormat.month ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded,
|
||||
color: Colors.grey.shade600,
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onVerticalDragStart: (_) {
|
||||
setState(() {
|
||||
_calendarFormat = CalendarFormat.values[(_calendarFormat.index - 1) % CalendarFormat.values.length];
|
||||
});
|
||||
},
|
||||
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),
|
||||
_divider(context),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'Время приема пищи',
|
||||
style: TextStyle(
|
||||
color: Color(0xFF323F4B),
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Время приема пищи',
|
||||
style: TextStyle(
|
||||
color: Color(0xFF323F4B),
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
_timeOfMeal(time),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_divider(context),
|
||||
@@ -214,22 +306,18 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
||||
ChartData(
|
||||
nutrition.dailyNutritionIntake.carbohydrates,
|
||||
nutrition.dailyNutritionRecommendation.carbohydrates,
|
||||
Color(0xFFFF9500),
|
||||
),
|
||||
ChartData(
|
||||
nutrition.dailyNutritionIntake.fats,
|
||||
nutrition.dailyNutritionRecommendation.fats,
|
||||
Color(0xFFFF3B30),
|
||||
),
|
||||
ChartData(
|
||||
nutrition.dailyNutritionIntake.proteins,
|
||||
nutrition.dailyNutritionRecommendation.proteins,
|
||||
Color(0xFF4CD964),
|
||||
),
|
||||
ChartData(
|
||||
nutrition.dailyNutritionIntake.energy,
|
||||
nutrition.dailyNutritionRecommendation.energy,
|
||||
Color(0xFF007AFF),
|
||||
),
|
||||
];
|
||||
|
||||
@@ -268,46 +356,77 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
||||
showLabels: false,
|
||||
showTicks: false,
|
||||
radiusFactor: 0.7,
|
||||
axisLineStyle: AxisLineStyle(
|
||||
thickness: 0.1,
|
||||
color: Colors.grey[200],
|
||||
thicknessUnit: GaugeSizeUnit.factor,
|
||||
),
|
||||
showAxisLine: false,
|
||||
pointers: <GaugePointer>[
|
||||
// Carbohydrates Arc
|
||||
RangePointer(
|
||||
value: 100,
|
||||
width: 0.16,
|
||||
animationDuration: 2000,
|
||||
color: Color(0xFFF6FAFF),
|
||||
sizeUnit: GaugeSizeUnit.factor,
|
||||
enableAnimation: true,
|
||||
cornerStyle: CornerStyle.bothCurve,
|
||||
),
|
||||
RangePointer(
|
||||
value: (chartData[0].intake / chartData[0].recommendation) * 100,
|
||||
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,
|
||||
enableAnimation: true,
|
||||
cornerStyle: CornerStyle.bothCurve, // Rounded ends
|
||||
cornerStyle: CornerStyle.bothCurve,
|
||||
),
|
||||
// Fats Arc
|
||||
RangePointer(
|
||||
value: (chartData[1].intake / chartData[1].recommendation) * 100,
|
||||
value: 100,
|
||||
width: 0.16,
|
||||
color: chartData[1].intake < chartData[1].recommendation ? chartData[1].color : Colors.red,
|
||||
animationDuration: 2000,
|
||||
color: Color(0xFFF6FAFF),
|
||||
sizeUnit: GaugeSizeUnit.factor,
|
||||
enableAnimation: true,
|
||||
cornerStyle: CornerStyle.bothCurve,
|
||||
pointerOffset: -0.18,
|
||||
),
|
||||
// Proteins Arc
|
||||
RangePointer(
|
||||
value: (chartData[2].intake / chartData[2].recommendation) * 100,
|
||||
value: (chartData[1].intake / chartData[1].recommendation) * 100,
|
||||
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,
|
||||
enableAnimation: true,
|
||||
cornerStyle: CornerStyle.bothCurve,
|
||||
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(
|
||||
value: (chartData[3].intake / chartData[3].recommendation) * 100,
|
||||
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,
|
||||
enableAnimation: true,
|
||||
cornerStyle: CornerStyle.bothCurve,
|
||||
@@ -315,49 +434,57 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
||||
),
|
||||
],
|
||||
annotations: <GaugeAnnotation>[
|
||||
// Label for Carbohydrates
|
||||
GaugeAnnotation(
|
||||
widget: Transform.rotate(
|
||||
angle: 30.1,
|
||||
child: Text(
|
||||
'Углеводы',
|
||||
style: TextStyle(color: Colors.white, fontSize: 12),
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
angle: 198,
|
||||
positionFactor: 0.92,
|
||||
),
|
||||
// Label for Fats
|
||||
GaugeAnnotation(
|
||||
widget: Transform.rotate(
|
||||
angle: 30,
|
||||
child: Text(
|
||||
'Жиры',
|
||||
style: TextStyle(color: Colors.white, fontSize: 12),
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
angle: 190,
|
||||
positionFactor: 1.1,
|
||||
),
|
||||
// Label for Proteins
|
||||
GaugeAnnotation(
|
||||
widget: Transform.rotate(
|
||||
angle: 30,
|
||||
child: Text(
|
||||
'Белки',
|
||||
style: TextStyle(color: Colors.white, fontSize: 12),
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
angle: 190,
|
||||
positionFactor: 1.27,
|
||||
),
|
||||
// Label for Calories
|
||||
GaugeAnnotation(
|
||||
widget: Transform.rotate(
|
||||
angle: 30,
|
||||
child: Text(
|
||||
'Калории',
|
||||
style: TextStyle(color: Colors.white, fontSize: 12),
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
angle: 192,
|
||||
@@ -591,7 +718,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
||||
child: Text(
|
||||
'$mealNumber',
|
||||
style: TextStyle(
|
||||
color: isActive ? Colors.white : Colors.black,
|
||||
color: isActive ? Colors.white : Color(0xFF6D6F71),
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
@@ -892,11 +1019,9 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
||||
class ChartData {
|
||||
final double intake;
|
||||
final double recommendation;
|
||||
final Color color;
|
||||
|
||||
ChartData(
|
||||
this.intake,
|
||||
this.recommendation,
|
||||
this.color,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -51,6 +51,8 @@ dependencies:
|
||||
rive: ^0.13.15
|
||||
mask_text_input_formatter: ^2.9.0
|
||||
lottie: ^3.1.3
|
||||
flutter_portal: ^1.1.4
|
||||
fluttertoast: ^8.2.8
|
||||
flutter_rating_bar: ^4.0.1
|
||||
|
||||
dev_dependencies:
|
||||
|
||||
Reference in New Issue
Block a user