Skip to content

Commit

Permalink
Commit WIP for nutrition page rework
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandgeider committed Oct 17, 2023
1 parent 0bf324f commit 68f0ad4
Show file tree
Hide file tree
Showing 46 changed files with 629 additions and 225 deletions.
8 changes: 8 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@
"@noNutritionalPlans": {
"description": "Message shown when the user has no nutritional plans"
},
"onlyLogging": "Only track calories",
"onlyLoggingHelpText": "Check the box if you only want to log your calories and don't want to setup a detailed nutritional plan with specific meals",
"addGoalsToPlan": "Add goals to this plan",
"addGoalsToPlanHelpText": "This allows you to set general goals for energy, protein, carbohydrates or fat for the plan. Note that if you set-up a detailed meal plan, these values will take precedence.",
"goalEnergy": "Energy goal",
"goalProtein": "Protein goal",
"goalCarbohydrates": "Carbohydrates goal",
"goalFat": "Fat goal",
"anErrorOccurred": "An Error Occurred!",
"@anErrorOccurred": {},
"weight": "Weight",
Expand Down
3 changes: 2 additions & 1 deletion lib/models/body_weight/weight_entry.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 15 additions & 7 deletions lib/models/exercises/base.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/models/exercises/category.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/models/exercises/image.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions lib/models/exercises/translation.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion lib/models/measurements/measurement_category.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/models/measurements/measurement_entry.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/models/nutrition/image.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/models/nutrition/ingredient.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions lib/models/nutrition/ingredient_weight_unit.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion lib/models/nutrition/log.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 23 additions & 1 deletion lib/models/nutrition/nutritional_plan.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ class NutritionalPlan {
@JsonKey(required: true, name: 'creation_date', toJson: toDate)
late DateTime creationDate;

@JsonKey(required: true, name: 'only_logging')
late bool onlyLogging;

@JsonKey(required: true, name: 'goal_energy')
late num? goalEnergy;

@JsonKey(required: true, name: 'goal_protein')
late num? goalProtein;

@JsonKey(required: true, name: 'goal_carbohydrates')
late num? goalCarbohydrates;

@JsonKey(required: true, name: 'goal_fat')
late num? goalFat;

@JsonKey(includeFromJson: false, includeToJson: false, defaultValue: [])
List<Meal> meals = [];

Expand All @@ -47,6 +62,11 @@ class NutritionalPlan {

NutritionalPlan({
this.id,
this.onlyLogging = false,
this.goalEnergy,
this.goalProtein,
this.goalCarbohydrates,
this.goalFat,
required this.description,
required this.creationDate,
List<Meal>? meals,
Expand All @@ -67,7 +87,9 @@ class NutritionalPlan {
Map<String, dynamic> toJson() => _$NutritionalPlanToJson(this);

String getLabel(BuildContext context) {
return description != '' ? description : AppLocalizations.of(context).nutritionalPlan;
return description != '' ? description : AppLocalizations
.of(context)
.nutritionalPlan;
}

/// Calculations
Expand Down
24 changes: 22 additions & 2 deletions lib/models/nutrition/nutritional_plan.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/models/nutrition/weight_unit.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion lib/models/user/profile.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/models/workouts/repetition_unit.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions lib/models/workouts/session.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/models/workouts/weight_unit.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/models/workouts/workout_plan.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 20 additions & 10 deletions lib/screens/home_tabs_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,29 @@ class _HomeTabsScreenState extends State<HomeTabsScreen> with SingleTickerProvid

// Plans, weight and gallery
log('Loading plans, weight, measurements and gallery');
await Future.wait([
galleryProvider.fetchAndSetGallery(),
nutritionPlansProvider.fetchAndSetAllPlansSparse(),
workoutPlansProvider.fetchAndSetAllPlansSparse(),
weightProvider.fetchAndSetEntries(),
measurementProvider.fetchAndSetAllCategoriesAndEntries(),
]);
try {
await Future.wait([
galleryProvider.fetchAndSetGallery(),
nutritionPlansProvider.fetchAndSetAllPlansSparse(),
workoutPlansProvider.fetchAndSetAllPlansSparse(),
weightProvider.fetchAndSetEntries(),
measurementProvider.fetchAndSetAllCategoriesAndEntries(),
]);
} catch (e) {
log('fire! fire!');
log(e.toString());
}

// Current nutritional plan
log('Loading current nutritional plan');
if (nutritionPlansProvider.currentPlan != null) {
final plan = nutritionPlansProvider.currentPlan!;
await nutritionPlansProvider.fetchAndSetPlanFull(plan.id!);
try {
if (nutritionPlansProvider.currentPlan != null) {
final plan = nutritionPlansProvider.currentPlan!;
await nutritionPlansProvider.fetchAndSetPlanFull(plan.id!);
}
} catch (e) {
log('fire! fire!');
log(e.toString());
}

// Current workout plan
Expand Down
8 changes: 7 additions & 1 deletion lib/screens/update_app_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ class UpdateAppScreen extends StatelessWidget {
AppLocalizations.of(context).appUpdateTitle,
style: Theme.of(context).textTheme.headline5,
),
content: Text(AppLocalizations.of(context).appUpdateContent),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(AppLocalizations.of(context).appUpdateContent),
Text(AppLocalizations.of(context).appUpdateContent),
],
),
actions: null,
),
);
Expand Down
Loading

0 comments on commit 68f0ad4

Please sign in to comment.