forked from eatvio/eatvio_app
feat(order info): added order info screen
This commit is contained in:
@@ -54,7 +54,7 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
const Text(
|
||||
'Добавление блюда',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
@@ -75,7 +75,7 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
||||
onChanged: (query) {
|
||||
EasyDebounce.debounce(
|
||||
'glossary-search',
|
||||
Duration(milliseconds: 250),
|
||||
const Duration(milliseconds: 250),
|
||||
() async {
|
||||
selectedGlossary = null;
|
||||
if (query.isEmpty) {
|
||||
@@ -113,7 +113,7 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
||||
),
|
||||
glossariesList.isEmpty ? const SizedBox(height: 16) : const SizedBox.shrink(),
|
||||
Container(
|
||||
constraints: BoxConstraints(
|
||||
constraints: const BoxConstraints(
|
||||
maxHeight: 256,
|
||||
),
|
||||
child: ListView.separated(
|
||||
@@ -135,7 +135,7 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
||||
),
|
||||
title: Text(
|
||||
glossariesList[i].name,
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
@@ -152,12 +152,12 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
||||
Icons.add_rounded,
|
||||
color: Colors.grey.shade400,
|
||||
),
|
||||
contentPadding: EdgeInsets.only(left: 12),
|
||||
contentPadding: const EdgeInsets.only(left: 12),
|
||||
);
|
||||
},
|
||||
itemCount: glossariesList.length,
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return CustomDivider();
|
||||
return const CustomDivider();
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -179,9 +179,9 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
||||
height: 52,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
color: Color(0xFFF6F6F6),
|
||||
color: const Color(0xFFF6F6F6),
|
||||
),
|
||||
child: Icon(
|
||||
child: const Icon(
|
||||
Icons.delete_outline_rounded,
|
||||
color: Colors.red,
|
||||
),
|
||||
@@ -201,7 +201,7 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
||||
child: Center(
|
||||
child: Text(
|
||||
widget.portionIndex == null ? 'Добавить' : 'Сохранить',
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
@@ -220,10 +220,10 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
||||
Future<void> addPortion() async {
|
||||
final portionIndex = widget.portionIndex;
|
||||
var measurementUnits = selectedGlossary?.grInPortion == null
|
||||
? Portion.PCS
|
||||
? Portion.pcs
|
||||
: selectedGlossary?.grInPortion == 0
|
||||
? Portion.GRAMS
|
||||
: Portion.PCS;
|
||||
? Portion.grams
|
||||
: Portion.pcs;
|
||||
final glossary = selectedGlossary;
|
||||
if (glossary != null) {
|
||||
final [calories, carbohydrates, proteins, fats] = _getCPFC(glossary, measurementUnits);
|
||||
@@ -265,7 +265,7 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
||||
),
|
||||
);
|
||||
if (newGlossary != null) {
|
||||
measurementUnits = Portion.GRAMS;
|
||||
measurementUnits = Portion.grams;
|
||||
final [calories, carbohydrates, proteins, fats] = _getCPFC(newGlossary, measurementUnits);
|
||||
final portion = DailySchedule(
|
||||
dailyNutrition: DailyNutrition(energy: calories, proteins: proteins, fats: fats, carbohydrates: carbohydrates),
|
||||
@@ -297,7 +297,7 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
||||
final double carbohydrates;
|
||||
final double proteins;
|
||||
final double fats;
|
||||
if (measurementUnits == Portion.GRAMS) {
|
||||
if (measurementUnits == Portion.grams) {
|
||||
calories = (glossary.energyOn100Gr * int.parse(quantityController.text) / 100);
|
||||
carbohydrates = (glossary.carbohydratesOn100Gr * int.parse(quantityController.text) / 100);
|
||||
proteins = (glossary.proteinsOn100Gr * int.parse(quantityController.text) / 100);
|
||||
@@ -310,5 +310,4 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
||||
}
|
||||
return [calories, carbohydrates, proteins, fats];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
|
||||
class DayWidget extends StatefulWidget {
|
||||
DayWidget({
|
||||
const DayWidget({
|
||||
super.key,
|
||||
required this.index,
|
||||
});
|
||||
@@ -47,10 +47,10 @@ class _DayWidgetState extends State<DayWidget> {
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
s.day + ' ${widget.index + 1}',
|
||||
'${s.day} ${widget.index + 1}',
|
||||
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
||||
),
|
||||
Spacer(),
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
context.read<CreateDietCubit>().copyDay(widget.index);
|
||||
@@ -65,23 +65,23 @@ class _DayWidgetState extends State<DayWidget> {
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
CustomDivider(),
|
||||
SizedBox(
|
||||
const CustomDivider(),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Text(
|
||||
s.meal,
|
||||
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||
fontSize: TextStyles.textMMedium.fontSize,
|
||||
fontWeight: TextStyles.textMMedium.fontWeight,
|
||||
index: 0,
|
||||
@@ -92,10 +92,10 @@ class _DayWidgetState extends State<DayWidget> {
|
||||
});
|
||||
},
|
||||
),
|
||||
Spacer(),
|
||||
const Spacer(),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||
fontSize: TextStyles.textMMedium.fontSize,
|
||||
fontWeight: TextStyles.textMMedium.fontWeight,
|
||||
index: 1,
|
||||
@@ -106,10 +106,10 @@ class _DayWidgetState extends State<DayWidget> {
|
||||
});
|
||||
},
|
||||
),
|
||||
Spacer(),
|
||||
const Spacer(),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||
fontSize: TextStyles.textMMedium.fontSize,
|
||||
fontWeight: TextStyles.textMMedium.fontWeight,
|
||||
index: 2,
|
||||
@@ -120,10 +120,10 @@ class _DayWidgetState extends State<DayWidget> {
|
||||
});
|
||||
},
|
||||
),
|
||||
Spacer(),
|
||||
const Spacer(),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||
fontSize: TextStyles.textMMedium.fontSize,
|
||||
fontWeight: TextStyles.textMMedium.fontWeight,
|
||||
index: 3,
|
||||
@@ -134,10 +134,10 @@ class _DayWidgetState extends State<DayWidget> {
|
||||
});
|
||||
},
|
||||
),
|
||||
Spacer(),
|
||||
const Spacer(),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||
fontSize: TextStyles.textMMedium.fontSize,
|
||||
fontWeight: TextStyles.textMMedium.fontWeight,
|
||||
index: 4,
|
||||
@@ -151,10 +151,10 @@ class _DayWidgetState extends State<DayWidget> {
|
||||
],
|
||||
),
|
||||
ListView.separated(
|
||||
separatorBuilder: (context, index) => SizedBox(
|
||||
separatorBuilder: (context, index) => const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
padding: EdgeInsets.all(0),
|
||||
padding: const EdgeInsets.all(0),
|
||||
itemBuilder: (context, index) {
|
||||
final product = state.dietData.dailySchedule?[widget.index][_selectedMealIndex][index];
|
||||
if (product != null) {
|
||||
@@ -174,9 +174,9 @@ class _DayWidgetState extends State<DayWidget> {
|
||||
},
|
||||
itemCount: state.dietData.dailySchedule?[widget.index][_selectedMealIndex].length ?? 0,
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
@@ -184,8 +184,8 @@ class _DayWidgetState extends State<DayWidget> {
|
||||
context.read<CreateDietCubit>().pasteCopiedDay(widget.index);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 14),
|
||||
decoration: BoxDecoration(color: appTheme.gray50, borderRadius: BorderRadius.all(Radius.circular(12))),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
|
||||
decoration: BoxDecoration(color: appTheme.gray50, borderRadius: const BorderRadius.all(Radius.circular(12))),
|
||||
child: SvgPicture.asset(
|
||||
'assets/icons/paste2.svg',
|
||||
width: 28,
|
||||
@@ -193,7 +193,7 @@ class _DayWidgetState extends State<DayWidget> {
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: CustomOutlinedButton(
|
||||
onPressed: () {
|
||||
@@ -209,7 +209,7 @@ class _DayWidgetState extends State<DayWidget> {
|
||||
color: appTheme.whiteA700,
|
||||
),
|
||||
buttonStyle: ButtonStyle(
|
||||
side: WidgetStatePropertyAll(BorderSide.none),
|
||||
side: const WidgetStatePropertyAll(BorderSide.none),
|
||||
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
|
||||
),
|
||||
),
|
||||
@@ -217,10 +217,10 @@ class _DayWidgetState extends State<DayWidget> {
|
||||
],
|
||||
),
|
||||
if (state.dailyScheduleErrors[widget.index].isNotEmpty) ...[
|
||||
SizedBox(height: 12),
|
||||
const SizedBox(height: 12),
|
||||
CustomErrorWidget(error: state.dailyScheduleErrors[widget.index]),
|
||||
],
|
||||
SizedBox(height: 20),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -274,7 +274,7 @@ class _DayWidgetState extends State<DayWidget> {
|
||||
carbohydrates: carbohydrates,
|
||||
);
|
||||
}
|
||||
return CpfcContainer(
|
||||
return const CpfcContainer(
|
||||
calories: 0,
|
||||
proteins: 0,
|
||||
fats: 0,
|
||||
@@ -302,7 +302,7 @@ class _DayWidgetState extends State<DayWidget> {
|
||||
quantityControllerText: quantity.toString(),
|
||||
);
|
||||
},
|
||||
trailing: Icon(Icons.more_vert_rounded),
|
||||
trailing: const Icon(Icons.more_vert_rounded),
|
||||
title: Text(product),
|
||||
subtitle: Text('$quantity $portion'),
|
||||
shape: RoundedRectangleBorder(
|
||||
@@ -324,7 +324,7 @@ class _DayWidgetState extends State<DayWidget> {
|
||||
return showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
shape: RoundedRectangleBorder(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(12)),
|
||||
),
|
||||
isScrollControlled: true,
|
||||
|
||||
@@ -26,9 +26,9 @@ class _DietDurationDropDownWidgetState extends State<DietDurationDropDownWidget>
|
||||
super.didChangeDependencies();
|
||||
final s = S.of(context);
|
||||
if (durationDropDownTitles.isEmpty) {
|
||||
durationValues.forEach((element) {
|
||||
for (var element in durationValues) {
|
||||
durationDropDownTitles.add('$element ${getDayForm(element, s)}');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,18 +54,18 @@ class _DietDurationDropDownWidgetState extends State<DietDurationDropDownWidget>
|
||||
items: durationDropDownTitles
|
||||
.mapIndexed(
|
||||
(index, value) => DropdownMenuItem(
|
||||
value: durationDropDownTitles[index],
|
||||
child: Text(
|
||||
durationDropDownTitles[index],
|
||||
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||
),
|
||||
value: durationDropDownTitles[index],
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
value: state.durationIndex == null ? null : durationDropDownTitles[state.durationIndex ?? 0],
|
||||
),
|
||||
if (state.dietDurationError != null) ...[
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
CustomErrorWidget(error: state.dietDurationError ?? ''),
|
||||
|
||||
@@ -31,12 +31,13 @@ class _DietImagePickerWidgetState extends State<DietImagePickerWidget> {
|
||||
final picker = ImagePicker();
|
||||
final image = await picker.pickImage(source: ImageSource.camera);
|
||||
cubit.setImage(image);
|
||||
if (!context.mounted) return;
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.photo_camera),
|
||||
SizedBox(width: 8),
|
||||
const Icon(Icons.photo_camera),
|
||||
const SizedBox(width: 8),
|
||||
Text(s.photo),
|
||||
],
|
||||
),
|
||||
@@ -46,12 +47,13 @@ class _DietImagePickerWidgetState extends State<DietImagePickerWidget> {
|
||||
final picker = ImagePicker();
|
||||
final image = await picker.pickImage(source: ImageSource.gallery);
|
||||
cubit.setImage(image);
|
||||
if (!context.mounted) return;
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.photo),
|
||||
SizedBox(width: 8),
|
||||
const Icon(Icons.photo),
|
||||
const SizedBox(width: 8),
|
||||
Text(s.gallery),
|
||||
],
|
||||
),
|
||||
@@ -96,7 +98,7 @@ class _DietImagePickerWidgetState extends State<DietImagePickerWidget> {
|
||||
color: appTheme.gray50,
|
||||
),
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
padding: hasImage ? null : EdgeInsets.all(8),
|
||||
padding: hasImage ? null : const EdgeInsets.all(8),
|
||||
child: hasImage
|
||||
? Padding(
|
||||
padding: const EdgeInsets.only(top: 6, right: 6),
|
||||
@@ -113,7 +115,7 @@ class _DietImagePickerWidgetState extends State<DietImagePickerWidget> {
|
||||
color: appTheme.dividerColor,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
child: const Icon(
|
||||
Icons.close_rounded,
|
||||
color: Colors.grey,
|
||||
size: 16,
|
||||
@@ -126,20 +128,20 @@ class _DietImagePickerWidgetState extends State<DietImagePickerWidget> {
|
||||
children: [
|
||||
DottedBorder(
|
||||
stackFit: StackFit.expand,
|
||||
dashPattern: [14, 14],
|
||||
dashPattern: const [14, 14],
|
||||
color: state.dietImageError != null ? appTheme.red : appTheme.dottedBorder,
|
||||
borderType: BorderType.RRect,
|
||||
radius: Radius.circular(12),
|
||||
child: SizedBox.expand(),
|
||||
radius: const Radius.circular(12),
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
Center(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 48,
|
||||
),
|
||||
SvgPicture.asset('assets/icons/eatvio_logo.svg'),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
Text(
|
||||
@@ -153,7 +155,7 @@ class _DietImagePickerWidgetState extends State<DietImagePickerWidget> {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (state.dietImageError != null) ...[SizedBox(height: 8), CustomErrorWidget(error: state.dietImageError ?? '')],
|
||||
if (state.dietImageError != null) ...[const SizedBox(height: 8), CustomErrorWidget(error: state.dietImageError ?? '')],
|
||||
],
|
||||
);
|
||||
},
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
|
||||
class DietTypeChoiceWidget extends StatefulWidget {
|
||||
DietTypeChoiceWidget({super.key});
|
||||
const DietTypeChoiceWidget({super.key});
|
||||
|
||||
@override
|
||||
State<DietTypeChoiceWidget> createState() => _DietTypeChoiceWidgetState();
|
||||
@@ -76,12 +76,12 @@ class _DietTypeChoiceWidgetState extends State<DietTypeChoiceWidget> {
|
||||
height: 80,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 16),
|
||||
const SizedBox(height: 16),
|
||||
SvgPicture.asset(
|
||||
choiceContent[index].$1,
|
||||
height: 30,
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
choiceContent[index].$2,
|
||||
overflow: TextOverflow.clip,
|
||||
|
||||
@@ -11,7 +11,7 @@ class CustomErrorWidget extends StatelessWidget {
|
||||
return Row(
|
||||
children: [
|
||||
SvgPicture.asset('assets/icons/error_icon.svg', width: 14, height: 14),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
width: 2,
|
||||
),
|
||||
Expanded(
|
||||
|
||||
@@ -26,7 +26,7 @@ class _StatusDropDownWidgetState extends State<StatusDropDownWidget> {
|
||||
super.didChangeDependencies();
|
||||
final s = S.of(context);
|
||||
if (dietStateTitles.isEmpty) {
|
||||
dietStates.forEach((elem) {
|
||||
for (var elem in dietStates) {
|
||||
switch (elem) {
|
||||
case DietState.active:
|
||||
dietStateTitles.add(s.active_diet_state);
|
||||
@@ -35,7 +35,7 @@ class _StatusDropDownWidgetState extends State<StatusDropDownWidget> {
|
||||
case DietState.personal:
|
||||
dietStateTitles.add(s.personal_diet_state);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,18 +62,18 @@ class _StatusDropDownWidgetState extends State<StatusDropDownWidget> {
|
||||
items: dietStateTitles
|
||||
.mapIndexed(
|
||||
(index, value) => DropdownMenuItem(
|
||||
value: dietStates[index],
|
||||
child: Text(
|
||||
dietStateTitles[index],
|
||||
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||
),
|
||||
value: dietStates[index],
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
value: state.dietStateIndex == null ? null : dietStates[state.dietStateIndex ?? 0],
|
||||
),
|
||||
if (state.dietStateError != null) ...[
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
CustomErrorWidget(error: state.dietStateError ?? ''),
|
||||
|
||||
Reference in New Issue
Block a user