diff --git a/lib/core/data/data_source/user_data_source.dart b/lib/core/data/data_source/user_data_source.dart index 9cb50d667..b6aa02511 100644 --- a/lib/core/data/data_source/user_data_source.dart +++ b/lib/core/data/data_source/user_data_source.dart @@ -28,6 +28,9 @@ class UserDataSource { weightKG: 80, gender: UserGenderDBO.male, goal: UserWeightGoalDBO.maintainWeight, - pal: UserPALDBO.active); + pal: UserPALDBO.active, + carbsPercentageGoal: 0.6, + fatsPercentageGoal: 0.25, + proteinsPercentageGoal: 0.15); } } diff --git a/lib/core/data/dbo/user_dbo.dart b/lib/core/data/dbo/user_dbo.dart index 019b6d5b1..6ca80f87e 100644 --- a/lib/core/data/dbo/user_dbo.dart +++ b/lib/core/data/dbo/user_dbo.dart @@ -20,6 +20,12 @@ class UserDBO extends HiveObject { UserWeightGoalDBO goal; @HiveField(5) UserPALDBO pal; + @HiveField(6) + double carbsPercentageGoal; + @HiveField(7) + double fatsPercentageGoal; + @HiveField(8) + double proteinsPercentageGoal; UserDBO( {required this.birthday, @@ -27,7 +33,11 @@ class UserDBO extends HiveObject { required this.weightKG, required this.gender, required this.goal, - required this.pal}); + required this.pal, + required this.carbsPercentageGoal, + required this.fatsPercentageGoal, + required this.proteinsPercentageGoal + }); factory UserDBO.fromUserEntity(UserEntity entity) { return UserDBO( @@ -36,6 +46,10 @@ class UserDBO extends HiveObject { weightKG: entity.weightKG, gender: UserGenderDBO.fromUserGenderEntity(entity.gender), goal: UserWeightGoalDBO.fromUserWeightGoalEntity(entity.goal), - pal: UserPALDBO.fromUserPALEntity(entity.pal)); + pal: UserPALDBO.fromUserPALEntity(entity.pal), + carbsPercentageGoal: entity.carbsPercentageGoal, + fatsPercentageGoal: entity.fatsPercentageGoal, + proteinsPercentageGoal: entity.proteinsPercentageGoal + ); } } diff --git a/lib/core/data/dbo/user_dbo.g.dart b/lib/core/data/dbo/user_dbo.g.dart index e28ffe56c..853969336 100644 --- a/lib/core/data/dbo/user_dbo.g.dart +++ b/lib/core/data/dbo/user_dbo.g.dart @@ -23,13 +23,16 @@ class UserDBOAdapter extends TypeAdapter { gender: fields[3] as UserGenderDBO, goal: fields[4] as UserWeightGoalDBO, pal: fields[5] as UserPALDBO, + carbsPercentageGoal: fields[6] as double, + fatsPercentageGoal: fields[7] as double, + proteinsPercentageGoal: fields[8] as double, ); } @override void write(BinaryWriter writer, UserDBO obj) { writer - ..writeByte(6) + ..writeByte(9) ..writeByte(0) ..write(obj.birthday) ..writeByte(1) @@ -41,7 +44,13 @@ class UserDBOAdapter extends TypeAdapter { ..writeByte(4) ..write(obj.goal) ..writeByte(5) - ..write(obj.pal); + ..write(obj.pal) + ..writeByte(6) + ..write(obj.carbsPercentageGoal) + ..writeByte(7) + ..write(obj.fatsPercentageGoal) + ..writeByte(8) + ..write(obj.proteinsPercentageGoal); } @override diff --git a/lib/core/domain/entity/user_entity.dart b/lib/core/domain/entity/user_entity.dart index 9b66d8e5e..05754785a 100644 --- a/lib/core/domain/entity/user_entity.dart +++ b/lib/core/domain/entity/user_entity.dart @@ -10,6 +10,9 @@ class UserEntity { UserGenderEntity gender; UserWeightGoalEntity goal; UserPALEntity pal; + double carbsPercentageGoal; + double fatsPercentageGoal; + double proteinsPercentageGoal; UserEntity( {required this.birthday, @@ -17,7 +20,10 @@ class UserEntity { required this.weightKG, required this.gender, required this.goal, - required this.pal}); + required this.pal, + required this.carbsPercentageGoal, + required this.fatsPercentageGoal, + required this.proteinsPercentageGoal}); factory UserEntity.fromUserDBO(UserDBO userDBO) { return UserEntity( @@ -26,7 +32,10 @@ class UserEntity { weightKG: userDBO.weightKG, gender: UserGenderEntity.fromUserGenderDBO(userDBO.gender), goal: UserWeightGoalEntity.fromUserWeightGoalDBO(userDBO.goal), - pal: UserPALEntity.fromUserPALDBO(userDBO.pal)); + pal: UserPALEntity.fromUserPALDBO(userDBO.pal), + carbsPercentageGoal: userDBO.carbsPercentageGoal, + fatsPercentageGoal: userDBO.fatsPercentageGoal, + proteinsPercentageGoal: userDBO.proteinsPercentageGoal); } int get age => DateTime.now().difference(birthday).inDays~/365; diff --git a/lib/core/utils/calc/macro_calc.dart b/lib/core/utils/calc/macro_calc.dart index 888e2ab63..8400f1997 100644 --- a/lib/core/utils/calc/macro_calc.dart +++ b/lib/core/utils/calc/macro_calc.dart @@ -1,3 +1,5 @@ +import 'package:opennutritracker/core/domain/entity/user_entity.dart'; + class MacroCalc { /// Information provided by /// 'OBESITY: PREVENTING AND MANAGING @@ -8,16 +10,12 @@ class MacroCalc { static const _fatKcalPerGram = 9.0; static const _proteinKcalPerGram = 4.0; - static const _defaultCarbsPercentageGoal = 0.6; - static const _defaultFatsPercentageGoal = 0.25; - static const _defaultProteinsPercentageGoal = 0.15; - - static double getTotalCarbsGoal(double totalCalorieGoal) => - (totalCalorieGoal * _defaultCarbsPercentageGoal) / _carbsKcalPerGram; + static double getTotalCarbsGoal(UserEntity userEntity, double totalCalorieGoal) => + (totalCalorieGoal * userEntity.carbsPercentageGoal) / _carbsKcalPerGram; - static double getTotalFatsGoal(double totalCalorieGoal) => - (totalCalorieGoal * _defaultFatsPercentageGoal) / _fatKcalPerGram; + static double getTotalFatsGoal(UserEntity userEntity, double totalCalorieGoal) => + (totalCalorieGoal * userEntity.fatsPercentageGoal) / _fatKcalPerGram; - static double getTotalProteinsGoal(double totalCalorieGoal) => - (totalCalorieGoal * _defaultProteinsPercentageGoal) / _proteinKcalPerGram; + static double getTotalProteinsGoal(UserEntity userEntity, double totalCalorieGoal) => + (totalCalorieGoal * userEntity.proteinsPercentageGoal) / _proteinKcalPerGram; } diff --git a/lib/features/activity_detail/presentation/bloc/activity_detail_bloc.dart b/lib/features/activity_detail/presentation/bloc/activity_detail_bloc.dart index 355a3bab4..201de7e69 100644 --- a/lib/features/activity_detail/presentation/bloc/activity_detail_bloc.dart +++ b/lib/features/activity_detail/presentation/bloc/activity_detail_bloc.dart @@ -61,9 +61,9 @@ class ActivityDetailBloc final userEntity = await _getUserUsecase.getUserData(); final totalKcalGoal = CalorieGoalCalc.getTotalKcalGoal(userEntity, caloriesBurned); - final totalCarbsGoal = MacroCalc.getTotalCarbsGoal(totalKcalGoal); - final totalFatGoal = MacroCalc.getTotalFatsGoal(totalKcalGoal); - final totalProteinGoal = MacroCalc.getTotalProteinsGoal(totalKcalGoal); + final totalCarbsGoal = MacroCalc.getTotalCarbsGoal(userEntity, totalKcalGoal); + final totalFatGoal = MacroCalc.getTotalFatsGoal(userEntity, totalKcalGoal); + final totalProteinGoal = MacroCalc.getTotalProteinsGoal(userEntity, totalKcalGoal); final hasTrackedDay = await _addTrackedDayUsecase.hasTrackedDay(DateTime.now()); @@ -71,9 +71,9 @@ class ActivityDetailBloc await _addTrackedDayUsecase.addNewTrackedDay(dateTime, totalKcalGoal, totalCarbsGoal, totalFatGoal, totalProteinGoal); } - final carbsIncrease = MacroCalc.getTotalCarbsGoal(caloriesBurned); - final fatIncrease = MacroCalc.getTotalFatsGoal(caloriesBurned); - final proteinIncrease = MacroCalc.getTotalProteinsGoal(caloriesBurned); + final carbsIncrease = MacroCalc.getTotalCarbsGoal(userEntity, caloriesBurned); + final fatIncrease = MacroCalc.getTotalFatsGoal(userEntity, caloriesBurned); + final proteinIncrease = MacroCalc.getTotalProteinsGoal(userEntity, caloriesBurned); _addTrackedDayUsecase.increaseDayCalorieGoal(dateTime, caloriesBurned); _addTrackedDayUsecase.increaseDayMacroGoals(dateTime, diff --git a/lib/features/diary/presentation/bloc/calendar_day_bloc.dart b/lib/features/diary/presentation/bloc/calendar_day_bloc.dart index d6c88da2a..af566b4c8 100644 --- a/lib/features/diary/presentation/bloc/calendar_day_bloc.dart +++ b/lib/features/diary/presentation/bloc/calendar_day_bloc.dart @@ -10,7 +10,6 @@ import 'package:opennutritracker/core/domain/usecase/delete_user_activity_usecas import 'package:opennutritracker/core/domain/usecase/get_intake_usecase.dart'; import 'package:opennutritracker/core/domain/usecase/get_tracked_day_usecase.dart'; import 'package:opennutritracker/core/domain/usecase/get_user_activity_usecase.dart'; -import 'package:opennutritracker/core/utils/calc/macro_calc.dart'; import 'package:opennutritracker/core/utils/locator.dart'; import 'package:opennutritracker/features/diary/presentation/bloc/diary_bloc.dart'; @@ -76,12 +75,13 @@ class CalendarDayBloc extends Bloc { Future deleteUserActivityItem(BuildContext context, UserActivityEntity activityEntity, DateTime day) async { await _deleteUserActivityUsecase.deleteUserActivity(activityEntity); + _addTrackedDayUsecase.reduceDayCalorieGoal(day, activityEntity.burnedKcal); - final carbsAmount = MacroCalc.getTotalCarbsGoal(activityEntity.burnedKcal); - final fatAmount = MacroCalc.getTotalFatsGoal(activityEntity.burnedKcal); - final proteinAmount = - MacroCalc.getTotalProteinsGoal(activityEntity.burnedKcal); + const carbsAmount = 3.3; //MacroCalc.getTotalCarbsGoal(userEntity, activityEntity.burnedKcal); + final fatAmount = 3.3; //MacroCalc.getTotalFatsGoal(userEntity, activityEntity.burnedKcal); + final proteinAmount = 3.3; + //MacroCalc.getTotalProteinsGoal(userEntity, activityEntity.burnedKcal); _addTrackedDayUsecase.reduceDayMacroGoals(day, carbsAmount: carbsAmount, diff --git a/lib/features/home/presentation/bloc/home_bloc.dart b/lib/features/home/presentation/bloc/home_bloc.dart index c2220d66e..a391ce0ef 100644 --- a/lib/features/home/presentation/bloc/home_bloc.dart +++ b/lib/features/home/presentation/bloc/home_bloc.dart @@ -103,9 +103,9 @@ class HomeBloc extends Bloc { final user = await _getUserUsecase.getUserData(); final totalKcalGoal = CalorieGoalCalc.getTotalKcalGoal(user, totalKcalActivities); - final totalCarbsGoal = MacroCalc.getTotalCarbsGoal(totalKcalGoal); - final totalFatsGoal = MacroCalc.getTotalFatsGoal(totalKcalGoal); - final totalProteinsGoal = MacroCalc.getTotalProteinsGoal(totalKcalGoal); + final totalCarbsGoal = MacroCalc.getTotalCarbsGoal(user, totalKcalGoal); + final totalFatsGoal = MacroCalc.getTotalFatsGoal(user, totalKcalGoal); + final totalProteinsGoal = MacroCalc.getTotalProteinsGoal(user, totalKcalGoal); final totalKcalLeft = CalorieGoalCalc.getDailyKcalLeft(totalKcalGoal, totalKcalIntake); @@ -190,14 +190,15 @@ class HomeBloc extends Bloc { Future deleteUserActivityItem(UserActivityEntity activityEntity) async { final dateTime = DateTime.now(); + final user = await _getUserUsecase.getUserData(); await _deleteUserActivityUsecase.deleteUserActivity(activityEntity); _addTrackedDayUseCase.reduceDayCalorieGoal( dateTime, activityEntity.burnedKcal); - final carbsAmount = MacroCalc.getTotalCarbsGoal(activityEntity.burnedKcal); - final fatAmount = MacroCalc.getTotalFatsGoal(activityEntity.burnedKcal); + final carbsAmount = MacroCalc.getTotalCarbsGoal(user, activityEntity.burnedKcal); + final fatAmount = MacroCalc.getTotalFatsGoal(user, activityEntity.burnedKcal); final proteinAmount = - MacroCalc.getTotalProteinsGoal(activityEntity.burnedKcal); + MacroCalc.getTotalProteinsGoal(user, activityEntity.burnedKcal); _addTrackedDayUseCase.reduceDayMacroGoals(dateTime, carbsAmount: carbsAmount, diff --git a/lib/features/meal_detail/presentation/bloc/meal_detail_bloc.dart b/lib/features/meal_detail/presentation/bloc/meal_detail_bloc.dart index adb55aa7f..b01e67adb 100644 --- a/lib/features/meal_detail/presentation/bloc/meal_detail_bloc.dart +++ b/lib/features/meal_detail/presentation/bloc/meal_detail_bloc.dart @@ -38,9 +38,9 @@ class MealDetailBloc { if (!hasTrackedDay) { final userEntity = await _getUserUsecase.getUserData(); final totalKcalGoal = CalorieGoalCalc.getTotalKcalGoal(userEntity, 0); - final totalCarbsGoal = MacroCalc.getTotalCarbsGoal(totalKcalGoal); - final totalFatGoal = MacroCalc.getTotalFatsGoal(totalKcalGoal); - final totalProteinGoal = MacroCalc.getTotalProteinsGoal(totalKcalGoal); + final totalCarbsGoal = MacroCalc.getTotalCarbsGoal(userEntity, totalKcalGoal); + final totalFatGoal = MacroCalc.getTotalFatsGoal(userEntity, totalKcalGoal); + final totalProteinGoal = MacroCalc.getTotalProteinsGoal(userEntity, totalKcalGoal); await _addTrackedDayUsecase.addNewTrackedDay( day, totalKcalGoal, totalCarbsGoal, totalFatGoal, totalProteinGoal); diff --git a/lib/features/onboarding/domain/entity/user_data_mask_entity.dart b/lib/features/onboarding/domain/entity/user_data_mask_entity.dart index 8cf56dbd2..4ae864078 100644 --- a/lib/features/onboarding/domain/entity/user_data_mask_entity.dart +++ b/lib/features/onboarding/domain/entity/user_data_mask_entity.dart @@ -13,6 +13,9 @@ class UserDataMaskEntity { double? weight; UserActivitySelectionEntity? activity; UserGoalSelectionEntity? goal; + double? carbsPercentageGoal; + double? fatsPercentageGoal; + double? proteinsPercentageGoal; bool acceptDataCollection = false; @@ -22,7 +25,10 @@ class UserDataMaskEntity { this.height, this.weight, this.activity, - this.goal}); + this.goal, + this.carbsPercentageGoal, + this.fatsPercentageGoal, + this.proteinsPercentageGoal}); bool checkDataProvided() { if (gender != null && @@ -30,7 +36,7 @@ class UserDataMaskEntity { height != null && weight != null && activity != null && - goal != null) { + goal != null){ return true; } else { return false; @@ -44,6 +50,9 @@ class UserDataMaskEntity { final userBirthday = birthday ?? DateTime.now(); // TODO final userHeight = height ?? 180; final userWeight = weight ?? 70; + final userCarbsPercentageGoal = carbsPercentageGoal ?? 0.6; + final userFatsPercentageGoal = fatsPercentageGoal ?? 0.25; + final userProteinsPercentageGoal = proteinsPercentageGoal ?? 0.15; UserGenderEntity userGender; if (gender == UserGenderSelectionEntity.genderMale) { userGender = UserGenderEntity.male; @@ -88,6 +97,9 @@ class UserDataMaskEntity { weightKG: userWeight, gender: userGender, goal: userGoal, - pal: userPal); + pal: userPal, + carbsPercentageGoal: userCarbsPercentageGoal, + fatsPercentageGoal: userFatsPercentageGoal, + proteinsPercentageGoal: userProteinsPercentageGoal); } } diff --git a/lib/features/onboarding/presentation/bloc/onboarding_bloc.dart b/lib/features/onboarding/presentation/bloc/onboarding_bloc.dart index 830398879..74f9812b7 100644 --- a/lib/features/onboarding/presentation/bloc/onboarding_bloc.dart +++ b/lib/features/onboarding/presentation/bloc/onboarding_bloc.dart @@ -47,7 +47,7 @@ class OnboardingBloc extends Bloc { final calorieGoal = getOverviewCalorieGoal(); double? carbsGoal; if (userEntity != null && calorieGoal != null) { - carbsGoal = MacroCalc.getTotalCarbsGoal(calorieGoal); + carbsGoal = MacroCalc.getTotalCarbsGoal(userEntity, calorieGoal); } return carbsGoal; } @@ -57,7 +57,7 @@ class OnboardingBloc extends Bloc { final calorieGoal = getOverviewCalorieGoal(); double? fatGoal; if (userEntity != null && calorieGoal != null) { - fatGoal = MacroCalc.getTotalFatsGoal(calorieGoal); + fatGoal = MacroCalc.getTotalFatsGoal(userEntity, calorieGoal); } return fatGoal; } @@ -67,7 +67,7 @@ class OnboardingBloc extends Bloc { final calorieGoal = getOverviewCalorieGoal(); double? proteinGoal; if (userEntity != null && calorieGoal != null) { - proteinGoal = MacroCalc.getTotalProteinsGoal(calorieGoal); + proteinGoal = MacroCalc.getTotalProteinsGoal(userEntity, calorieGoal); } return proteinGoal; } diff --git a/lib/features/profile/presentation/widgets/set_percentage_goal_dialog.dart b/lib/features/profile/presentation/widgets/set_percentage_goal_dialog.dart new file mode 100644 index 000000000..aaba99b51 --- /dev/null +++ b/lib/features/profile/presentation/widgets/set_percentage_goal_dialog.dart @@ -0,0 +1,50 @@ +import 'package:flutter/material.dart'; +import 'package:horizontal_picker/horizontal_picker.dart'; +import 'package:opennutritracker/generated/l10n.dart'; + +class SetPercentageDialog extends StatelessWidget { + static const _rangePercent = 100.0; + + final double userPercentage; + + const SetPercentageDialog({super.key, required this.userPercentage}); + + @override + Widget build(BuildContext context) { + double selectedPercentage = userPercentage*100; + return AlertDialog( + title: Text(S.of(context).selectPercentageDialogLabel), + content: Wrap( + children: [ + Column( + children: [ + HorizontalPicker( + height: 100, + backgroundColor: Colors.transparent, + minValue: selectedPercentage - _rangePercent, + maxValue: selectedPercentage + _rangePercent, + divisions: 400, + suffix: ' ${S.of(context).cmLabel}', + onChanged: (value) { + selectedPercentage = value; + }) + ], + ) + ], + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text(S.of(context).dialogCancelLabel)), + TextButton( + onPressed: () { + // TODO validate selected height + Navigator.pop(context, selectedPercentage / 100); + }, + child: Text(S.of(context).dialogOKLabel)) + ], + ); + } +} diff --git a/lib/features/profile/profile_page.dart b/lib/features/profile/profile_page.dart index e4217b9d4..e558589b5 100644 --- a/lib/features/profile/profile_page.dart +++ b/lib/features/profile/profile_page.dart @@ -13,6 +13,7 @@ import 'package:opennutritracker/features/profile/presentation/widgets/set_goal_ import 'package:opennutritracker/features/profile/presentation/widgets/set_height_dialog.dart'; import 'package:opennutritracker/features/profile/presentation/widgets/set_pal_category_dialog.dart'; import 'package:opennutritracker/features/profile/presentation/widgets/set_weight_dialog.dart'; +import 'package:opennutritracker/features/profile/presentation/widgets/set_percentage_goal_dialog.dart'; import 'package:opennutritracker/generated/l10n.dart'; class ProfilePage extends StatefulWidget { @@ -164,6 +165,57 @@ class _ProfilePageState extends State { _showSetGenderDialog(context, user); }, ), + ListTile( + title: Text( + S.of(context).carbGoalLabel, + style: Theme.of(context).textTheme.titleLarge, + ), + subtitle: Text( + '${user.carbsPercentageGoal*100} %', + style: Theme.of(context).textTheme.titleMedium, + ), + leading: const SizedBox( + height: double.infinity, + child: Icon(Icons.percent_outlined), + ), + onTap: () { + _showSetCarbGoalDialog(context, user); + }, + ), + ListTile( + title: Text( + S.of(context).fatsGoalLabel, + style: Theme.of(context).textTheme.titleLarge, + ), + subtitle: Text( + '${user.fatsPercentageGoal*100} %', + style: Theme.of(context).textTheme.titleMedium, + ), + leading: const SizedBox( + height: double.infinity, + child: Icon(Icons.percent_outlined), + ), + onTap: () { + _showSetFatsGoalDialog(context, user); + }, + ), + ListTile( + title: Text( + S.of(context).proteinsGoalLabel, + style: Theme.of(context).textTheme.titleLarge, + ), + subtitle: Text( + '${user.proteinsPercentageGoal*100} %', + style: Theme.of(context).textTheme.titleMedium, + ), + leading: const SizedBox( + height: double.infinity, + child: Icon(Icons.percent_outlined), + ), + onTap: () { + _showSetProteinsGoalDialog(context, user); + }, + ), ], ); } @@ -239,4 +291,44 @@ class _ProfilePageState extends State { _profileBloc.updateUser(userEntity); } } + + Future _showSetCarbGoalDialog( + BuildContext context, UserEntity userEntity) async { + final selectedCarbsGoal = await showDialog( + context: context, + builder: (context) => SetPercentageDialog( + userPercentage: userEntity.carbsPercentageGoal, + )); + if (selectedCarbsGoal != null) { + userEntity.carbsPercentageGoal = selectedCarbsGoal; + + _profileBloc.updateUser(userEntity); + } + } + Future _showSetFatsGoalDialog( + BuildContext context, UserEntity userEntity) async { + final selectedFatsGoal = await showDialog( + context: context, + builder: (context) => SetPercentageDialog( + userPercentage: userEntity.fatsPercentageGoal, + )); + if (selectedFatsGoal != null) { + userEntity.fatsPercentageGoal = selectedFatsGoal; + + _profileBloc.updateUser(userEntity); + } + } + Future _showSetProteinsGoalDialog( + BuildContext context, UserEntity userEntity) async { + final selectedProteinsGoal = await showDialog( + context: context, + builder: (context) => SetPercentageDialog( + userPercentage: userEntity.proteinsPercentageGoal, + )); + if (selectedProteinsGoal != null) { + userEntity.proteinsPercentageGoal = selectedProteinsGoal; + + _profileBloc.updateUser(userEntity); + } + } } diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 12a0372b6..049046739 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -1531,6 +1531,46 @@ class S { ); } + /// `Select Percentage` + String get selectPercentageDialogLabel { + return Intl.message( + 'Select Percentage', + name: 'selectPercentageDialogLabel', + desc: '', + args: [], + ); + } + + /// `Carbohydrates Percentage Goal` + String get carbGoalLabel { + return Intl.message( + 'Carbohydrates Goal', + name: 'carbGoalLabel', + desc: '', + args: [], + ); + } + + /// `Fats Percentage Goal` + String get fatsGoalLabel { + return Intl.message( + 'Fats Percentage Goal', + name: 'fatsGoalLabel', + desc: '', + args: [], + ); + } + + /// `Proteins Percentage Goal` + String get proteinsGoalLabel { + return Intl.message( + 'Proteins Percentage Goal', + name: 'proteinsGoalLabel', + desc: '', + args: [], + ); + } + /// `Height` String get heightLabel { return Intl.message( diff --git a/lib/l10n/intl_de.arb b/lib/l10n/intl_de.arb index ac1bb0597..1d78ced0d 100644 --- a/lib/l10n/intl_de.arb +++ b/lib/l10n/intl_de.arb @@ -160,6 +160,7 @@ "goalGainWeight": "Gewicht zunehmen", "goalLabel": "Ziel", "selectHeightDialogLabel": "Größe auswählen", + "selectPercentageDialogLabel": "Prozent auswählen", "heightLabel": "Größe", "cmLabel": "cm", "selectWeightDialogLabel": "Gewicht auswählen", @@ -169,6 +170,9 @@ "yearsLabel": "{age} Jahre", "selectGenderDialogLabel": "Geschlecht auswählen", "genderLabel": "Geschlecht", + "carbGoalLabel": "Kohlenhydrat Prozent Ziel", + "fatsGoalLabel": "Fett Prozent Ziel", + "proteinsGoalLabel": "Protein Prozent Ziel", "genderMaleLabel": "♂ männlich", "genderFemaleLabel": "♀ weiblich", diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 477e40d01..ae4888d81 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -161,6 +161,7 @@ "goalGainWeight": "Gain Weight", "goalLabel": "Goal", "selectHeightDialogLabel": "Select Height", + "selectPercentageDialogLabel": "Select Percentage", "heightLabel": "Height", "cmLabel": "cm", "selectWeightDialogLabel": "Select Weight", @@ -170,6 +171,9 @@ "yearsLabel": "{age} years", "selectGenderDialogLabel": "Select Gender", "genderLabel": "Gender", + "carbGoalLabel": "Carbohydrate percentage Goal", + "fatsGoalLabel": "Fat ercentage Goal", + "proteinsGoalLabel": "Protein percentage Goal", "genderMaleLabel": "♂ male", "genderFemaleLabel": "♀ female", diff --git a/lib/l10n/intl_tr.arb b/lib/l10n/intl_tr.arb index b89743585..a345c6d3e 100644 --- a/lib/l10n/intl_tr.arb +++ b/lib/l10n/intl_tr.arb @@ -160,6 +160,7 @@ "goalGainWeight": "Kilo Al", "goalLabel": "Hedef", "selectHeightDialogLabel": "Boy Seçin", + "selectPercentageDialogLabel": "Yüzde Seçiniz", "heightLabel": "Boy", "cmLabel": "cm", "selectWeightDialogLabel": "Kilo Seçin", @@ -167,8 +168,11 @@ "kgLabel": "kg", "ageLabel": "Yaş", "yearsLabel": "{age} yaş", - "selectGenderDialogLabel": "Cinsiyet Seçin", + "selectGenderDialogLabel": "v", "genderLabel": "Cinsiyet", + "carbGoalLabel": "Karbonhidrat yüzdesi Hedefi", + "fatsGoalLabel": "Yağ Yüzdesi Hedefi", + "proteinsGoalLabel": "Protein yüzdesi Hedefi", "genderMaleLabel": "♂ erkek", "genderFemaleLabel": "♀ kadın", diff --git a/test/fixture/user_entity_fixtures.dart b/test/fixture/user_entity_fixtures.dart index 69bea8b76..fe73d0ba8 100644 --- a/test/fixture/user_entity_fixtures.dart +++ b/test/fixture/user_entity_fixtures.dart @@ -13,7 +13,11 @@ class UserEntityFixtures { weightKG: 80.0, gender: UserGenderEntity.male, goal: UserWeightGoalEntity.maintainWeight, - pal: UserPALEntity.sedentary); + pal: UserPALEntity.sedentary, + carbsPercentageGoal: 0.4, + fatsPercentageGoal: 0.25, + proteinsPercentageGoal: 0.35 + ); /// Mocked user entity /// 54 years, 160 cm, 75 kg, female, lose weight, active @@ -24,7 +28,11 @@ class UserEntityFixtures { weightKG: 75.0, gender: UserGenderEntity.female, goal: UserWeightGoalEntity.loseWeight, - pal: UserPALEntity.active); + pal: UserPALEntity.active, + carbsPercentageGoal: 0.5, + fatsPercentageGoal: 0.15, + proteinsPercentageGoal: 0.35 + ); /// Mocked user entity /// 76 years, 164 cm, 55 kg, male, gain weight, low active @@ -36,6 +44,9 @@ class UserEntityFixtures { gender: UserGenderEntity.male, goal: UserWeightGoalEntity.gainWeight, pal: UserPALEntity.lowActive, + carbsPercentageGoal: 0.5, + fatsPercentageGoal: 0.15, + proteinsPercentageGoal: 0.35 ); /// Mocked user entity @@ -49,5 +60,8 @@ class UserEntityFixtures { gender: UserGenderEntity.female, goal: UserWeightGoalEntity.loseWeight, pal: UserPALEntity.veryActive, + carbsPercentageGoal: 0.5, + fatsPercentageGoal: 0.15, + proteinsPercentageGoal: 0.35 ); } diff --git a/test/unit_test/tdee_calc_test.dart b/test/unit_test/tdee_calc_test.dart index 25fb67cec..3dc6dc888 100644 --- a/test/unit_test/tdee_calc_test.dart +++ b/test/unit_test/tdee_calc_test.dart @@ -17,7 +17,10 @@ void main() { weightKG: 80.0, gender: UserGenderEntity.male, goal: UserWeightGoalEntity.maintainWeight, - pal: UserPALEntity.sedentary); + pal: UserPALEntity.sedentary, + carbsPercentageGoal: 0.6, + fatsPercentageGoal: 0.25, + proteinsPercentageGoal: 0.15); // Call the TDEE calculation method