mirror of
https://github.com/wger-project/flutter.git
synced 2026-12-03 10:33:54 +01:00
Merge PR #1260 (health sync) for 2.7 integration testing
# Conflicts: # lib/core/consts.dart # lib/core/network/auth_notifier.g.dart # lib/l10n/app_en.arb # pubspec.yaml # test/core/validators_test.mocks.dart # test/features/routines/providers/routines_repository_test.mocks.dart # test/screenshots/screenshots_03_gym_mode.dart
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 wger Team
|
||||
* Copyright (C) 2020 - 2026 wger Team
|
||||
*
|
||||
* wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
@@ -16,39 +16,54 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:wger/features/weight/models/weight_entry.dart';
|
||||
import 'package:wger/features/measurements/models/measurement_category.dart';
|
||||
import 'package:wger/features/measurements/models/measurement_entry.dart';
|
||||
|
||||
final testWeightEntry1 = WeightEntry(
|
||||
/// Body weight entries are measurements in the user's official body weight
|
||||
/// category (metric_type=body_weight, is_official=true), created by the server.
|
||||
const testBodyWeightCategoryId = 'bw';
|
||||
|
||||
final testWeightEntry1 = MeasurementEntry(
|
||||
id: '1',
|
||||
weight: 80.0,
|
||||
categoryId: testBodyWeightCategoryId,
|
||||
value: 80.0,
|
||||
date: DateTime.utc(2021, 01, 01, 15, 30),
|
||||
notes: '',
|
||||
);
|
||||
final testWeightEntry2 = WeightEntry(
|
||||
final testWeightEntry2 = MeasurementEntry(
|
||||
id: '2',
|
||||
weight: 81.0,
|
||||
categoryId: testBodyWeightCategoryId,
|
||||
value: 81.0,
|
||||
date: DateTime.utc(2021, 01, 10, 10, 0),
|
||||
notes: '',
|
||||
);
|
||||
|
||||
List<WeightEntry> getWeightEntries() {
|
||||
return [testWeightEntry1, testWeightEntry2];
|
||||
/// Entry recorded in pounds (extra_data.unit); 176.4 lb are 80.01 kg
|
||||
final testWeightEntryLb = MeasurementEntry(
|
||||
id: '3',
|
||||
categoryId: testBodyWeightCategoryId,
|
||||
value: 176.4,
|
||||
date: DateTime.utc(2021, 01, 20, 8, 0),
|
||||
notes: '',
|
||||
extraData: const {'unit': 'lb'},
|
||||
);
|
||||
|
||||
/// The official category. Its entries are seeded apart from it, see
|
||||
/// [bodyWeightEntries].
|
||||
MeasurementCategory getBodyWeightCategory() {
|
||||
return MeasurementCategory(
|
||||
id: testBodyWeightCategoryId,
|
||||
name: 'Weight',
|
||||
unit: 'kg',
|
||||
metricType: MetricType.bodyWeight,
|
||||
isOfficial: true,
|
||||
);
|
||||
}
|
||||
|
||||
List<WeightEntry> getScreenshotWeightEntries() {
|
||||
return [
|
||||
WeightEntry(id: '1', weight: 86, date: DateTime.utc(2021, 01, 01)),
|
||||
WeightEntry(id: '2', weight: 81, date: DateTime.utc(2021, 01, 10)),
|
||||
WeightEntry(id: '3', weight: 82, date: DateTime.utc(2021, 01, 20)),
|
||||
WeightEntry(id: '4', weight: 83, date: DateTime.utc(2021, 01, 30)),
|
||||
WeightEntry(id: '5', weight: 86, date: DateTime.utc(2021, 02, 20)),
|
||||
WeightEntry(id: '6', weight: 90, date: DateTime.utc(2021, 02, 28)),
|
||||
WeightEntry(id: '7', weight: 91, date: DateTime.utc(2021, 03, 20)),
|
||||
WeightEntry(id: '8', weight: 91.1, date: DateTime.utc(2021, 03, 30)),
|
||||
WeightEntry(id: '9', weight: 90, date: DateTime.utc(2021, 05, 1)),
|
||||
WeightEntry(id: '10', weight: 91, date: DateTime.utc(2021, 6, 5)),
|
||||
WeightEntry(id: '11', weight: 89, date: DateTime.utc(2021, 6, 20)),
|
||||
WeightEntry(id: '12', weight: 88, date: DateTime.utc(2021, 7, 15)),
|
||||
WeightEntry(id: '13', weight: 86, date: DateTime.utc(2021, 7, 20)),
|
||||
WeightEntry(id: '14', weight: 83, date: DateTime.utc(2021, 7, 30)),
|
||||
WeightEntry(id: '15', weight: 80, date: DateTime.utc(2021, 8, 10)),
|
||||
];
|
||||
/// [entries] keyed for the official category, as the seeding helpers take
|
||||
/// them. Defaults to the two test entries, newest first.
|
||||
Map<String, List<MeasurementEntry>> bodyWeightEntries([List<MeasurementEntry>? entries]) {
|
||||
return {
|
||||
testBodyWeightCategoryId: entries ?? [testWeightEntry2, testWeightEntry1],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ import 'package:wger/features/exercises/models/exercise.dart';
|
||||
import 'package:wger/features/exercises/models/muscle.dart';
|
||||
import 'package:wger/features/exercises/models/translation.dart';
|
||||
|
||||
import 'screenshots_exercises.dart';
|
||||
|
||||
const testGerman = Language(id: 1, shortName: 'de', fullName: 'Deutsch');
|
||||
const testEnglish = Language(id: 2, shortName: 'en', fullName: 'English');
|
||||
const testFrench = Language(id: 3, shortName: 'fr', fullName: 'Français');
|
||||
@@ -230,14 +228,3 @@ final sideRaisesEn = Translation(
|
||||
List<Exercise> getTestExercises() {
|
||||
return [testBenchPress, testCrunches, testDeadLift, testCurls, testSquats, testSideRaises];
|
||||
}
|
||||
|
||||
List<Exercise> getScreenshotExercises() {
|
||||
return [
|
||||
testBenchPress.copyWith(translations: benchPressTranslations),
|
||||
testCrunches.copyWith(translations: crunchesTranslations),
|
||||
testDeadLift.copyWith(translations: deadLiftTranslations),
|
||||
testCurls.copyWith(translations: curlsTranslations),
|
||||
testSquats.copyWith(translations: squatsTranslations),
|
||||
testSideRaises.copyWith(translations: raisesTranslations),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -78,29 +78,87 @@ final testMeasurementEntry8 = MeasurementEntry(
|
||||
notes: '',
|
||||
);
|
||||
|
||||
List<MeasurementCategory> getMeasurementCategories() {
|
||||
final testNeasurementEntry9 = MeasurementEntry(
|
||||
id: 'e1',
|
||||
categoryId: 'sys',
|
||||
date: DateTime(2026, 1, 1),
|
||||
value: 120,
|
||||
notes: '',
|
||||
);
|
||||
|
||||
final testNeasurementEntry10 = MeasurementEntry(
|
||||
id: 'e2',
|
||||
categoryId: 'dia',
|
||||
date: DateTime(2026, 1, 1),
|
||||
value: 80,
|
||||
notes: '',
|
||||
);
|
||||
|
||||
/// Multi-value group: blood pressure with systolic/diastolic components.
|
||||
final testMeasurementCategoryBloodPressure = MeasurementCategory(
|
||||
id: 'bp',
|
||||
name: 'Blood pressure',
|
||||
unit: 'mmHg',
|
||||
metricType: MetricType.bloodPressure,
|
||||
children: [testMeasurementCategorySystolic, testMeasurementCategoryDiastolic],
|
||||
);
|
||||
|
||||
final testMeasurementCategorySystolic = MeasurementCategory(
|
||||
id: 'sys',
|
||||
name: 'Systolic',
|
||||
unit: 'mmHg',
|
||||
parentId: 'bp',
|
||||
order: 0,
|
||||
);
|
||||
|
||||
final testMeasurementCategoryDiastolic = MeasurementCategory(
|
||||
id: 'dia',
|
||||
name: 'Diastolic',
|
||||
unit: 'mmHg',
|
||||
parentId: 'bp',
|
||||
order: 1,
|
||||
);
|
||||
|
||||
/// The blood pressure group as a flat list (parent first) with the children
|
||||
/// attached to the parent, matching the shape the repository's watchAll()
|
||||
/// returns. Not included in [getMeasurementCategories].
|
||||
List<MeasurementCategory> getBloodPressureGroup() {
|
||||
return [
|
||||
MeasurementCategory(
|
||||
id: '1',
|
||||
name: 'Body fat',
|
||||
unit: '%',
|
||||
entries: [
|
||||
testMeasurementEntry1,
|
||||
testMeasurementEntry2,
|
||||
testMeasurementEntry3,
|
||||
testMeasurementEntry4,
|
||||
testMeasurementEntry5,
|
||||
testMeasurementEntry6,
|
||||
],
|
||||
),
|
||||
MeasurementCategory(
|
||||
id: '2',
|
||||
name: 'Biceps',
|
||||
unit: 'cm',
|
||||
entries: [
|
||||
testMeasurementEntry7,
|
||||
testMeasurementEntry8,
|
||||
],
|
||||
),
|
||||
testMeasurementCategoryBloodPressure,
|
||||
testMeasurementCategorySystolic,
|
||||
testMeasurementCategoryDiastolic,
|
||||
];
|
||||
}
|
||||
|
||||
List<MeasurementCategory> getMeasurementCategories() {
|
||||
return [
|
||||
MeasurementCategory(id: '1', name: 'Body fat', unit: '%'),
|
||||
MeasurementCategory(id: '2', name: 'Biceps', unit: 'cm'),
|
||||
];
|
||||
}
|
||||
|
||||
/// The entries of [getMeasurementCategories], keyed by category id.
|
||||
///
|
||||
/// Apart from the categories, which no longer carry them: what a screen shows
|
||||
/// is read through its own query, so a test seeds the two independently.
|
||||
Map<String, List<MeasurementEntry>> getMeasurementEntries() {
|
||||
return {
|
||||
'1': [
|
||||
testMeasurementEntry1,
|
||||
testMeasurementEntry2,
|
||||
testMeasurementEntry3,
|
||||
testMeasurementEntry4,
|
||||
testMeasurementEntry5,
|
||||
testMeasurementEntry6,
|
||||
],
|
||||
'2': [testMeasurementEntry7, testMeasurementEntry8],
|
||||
};
|
||||
}
|
||||
|
||||
/// The entries of [getBloodPressureGroup], keyed by component id.
|
||||
Map<String, List<MeasurementEntry>> getBloodPressureEntries() {
|
||||
return {
|
||||
'sys': [testNeasurementEntry9],
|
||||
'dia': [testNeasurementEntry10],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wger/features/nutrition/models/ingredient.dart';
|
||||
import 'package:wger/features/nutrition/models/log.dart';
|
||||
@@ -230,64 +228,3 @@ NutritionalPlan getNutritionalPlan() {
|
||||
|
||||
return plan;
|
||||
}
|
||||
|
||||
NutritionalPlan getNutritionalPlanScreenshot() {
|
||||
final random = Random();
|
||||
|
||||
final mealItem1 = MealItem(ingredientId: 1, amount: 100, ingredient: muesli);
|
||||
final mealItem2 = MealItem(ingredientId: 2, amount: 75, ingredient: milk);
|
||||
final mealItem3 = MealItem(ingredientId: 3, amount: 100, ingredient: apple);
|
||||
|
||||
final meal1 = Meal(
|
||||
id: testMealUuid1,
|
||||
plan: testPlanUuid1,
|
||||
time: const TimeOfDay(hour: 8, minute: 30),
|
||||
name: 'Breakfast',
|
||||
mealItems: [mealItem1, mealItem2],
|
||||
);
|
||||
|
||||
final meal2 = Meal(
|
||||
id: testMealUuid2,
|
||||
plan: testPlanUuid1,
|
||||
time: const TimeOfDay(hour: 11, minute: 0),
|
||||
name: 'Snack 1',
|
||||
mealItems: [mealItem3],
|
||||
);
|
||||
|
||||
final NutritionalPlan plan = NutritionalPlan(
|
||||
id: testPlanUuid1,
|
||||
description: 'Diet',
|
||||
creationDate: DateTime(2021, 5, 23),
|
||||
startDate: DateTime(2021, 5, 23),
|
||||
meals: [meal1, meal2],
|
||||
);
|
||||
|
||||
// Add logs
|
||||
plan.diaryEntries.add(
|
||||
LogItem.fromMealItem(mealItem1, testPlanUuid1, testMealUuid1, DateTime.now()),
|
||||
);
|
||||
plan.diaryEntries.add(
|
||||
LogItem.fromMealItem(mealItem2, testPlanUuid1, testMealUuid1, DateTime.now()),
|
||||
);
|
||||
plan.diaryEntries.add(
|
||||
LogItem.fromMealItem(mealItem3, testPlanUuid1, testMealUuid1, DateTime.now()),
|
||||
);
|
||||
|
||||
for (final i in plan.diaryEntries) {
|
||||
i.datetime = DateTime.now();
|
||||
i.amount = i.amount / (1.0 + random.nextDouble() * (4.0 - 1.0));
|
||||
}
|
||||
|
||||
final log = LogItem(
|
||||
mealId: meal1.id,
|
||||
ingredientId: 1,
|
||||
weightUnitId: 1,
|
||||
amount: 40,
|
||||
planId: plan.id!,
|
||||
datetime: DateTime.now(),
|
||||
);
|
||||
log.ingredient = cake;
|
||||
plan.diaryEntries.add(log);
|
||||
|
||||
return plan;
|
||||
}
|
||||
|
||||
73
test_data/screenshots/exercises.dart
Normal file
73
test_data/screenshots/exercises.dart
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (c) 2026 wger Team
|
||||
*
|
||||
* wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:wger/features/exercises/models/exercise.dart';
|
||||
import 'package:wger/features/exercises/models/muscle.dart';
|
||||
|
||||
import '../exercises.dart';
|
||||
import '../screenshots_exercises.dart';
|
||||
|
||||
// Real muscles instead of the joke names of the unit-test fixtures; the gym
|
||||
// mode summary prints them as 'name (nameEn)' in the muscle distribution.
|
||||
const _chest = Muscle(id: 101, name: 'Pectoralis major', nameEn: 'Chest', isFront: true);
|
||||
const _delts = Muscle(id: 102, name: 'Deltoideus', nameEn: 'Shoulders', isFront: true);
|
||||
const _triceps = Muscle(id: 103, name: 'Triceps brachii', nameEn: 'Triceps', isFront: false);
|
||||
const _biceps = Muscle(id: 104, name: 'Biceps brachii', nameEn: 'Biceps', isFront: true);
|
||||
const _glutes = Muscle(id: 105, name: 'Gluteus maximus', nameEn: 'Glutes', isFront: false);
|
||||
const _quads = Muscle(id: 106, name: 'Quadriceps femoris', nameEn: 'Quads', isFront: true);
|
||||
const _hamstrings = Muscle(id: 107, name: 'Biceps femoris', nameEn: 'Hamstrings', isFront: false);
|
||||
const _abs = Muscle(id: 108, name: 'Rectus abdominis', nameEn: 'Abs', isFront: true);
|
||||
const _lowerBack = Muscle(id: 109, name: 'Erector spinae', nameEn: 'Lower back', isFront: false);
|
||||
|
||||
/// The test exercises with their full translation sets and realistic muscle
|
||||
/// assignments attached, so the screenshots show localized exercise names and
|
||||
/// a plausible muscle distribution.
|
||||
List<Exercise> getScreenshotExercises() {
|
||||
return [
|
||||
testBenchPress.copyWith(
|
||||
translations: benchPressTranslations,
|
||||
muscles: const [_chest],
|
||||
musclesSecondary: const [_delts, _triceps],
|
||||
),
|
||||
testCrunches.copyWith(
|
||||
translations: crunchesTranslations,
|
||||
muscles: const [_abs],
|
||||
musclesSecondary: const [],
|
||||
),
|
||||
testDeadLift.copyWith(
|
||||
translations: deadLiftTranslations,
|
||||
muscles: const [_glutes, _lowerBack],
|
||||
musclesSecondary: const [_hamstrings],
|
||||
),
|
||||
testCurls.copyWith(
|
||||
translations: curlsTranslations,
|
||||
muscles: const [_biceps],
|
||||
musclesSecondary: const [],
|
||||
),
|
||||
testSquats.copyWith(
|
||||
translations: squatsTranslations,
|
||||
muscles: const [_quads],
|
||||
musclesSecondary: const [_glutes, _abs],
|
||||
),
|
||||
testSideRaises.copyWith(
|
||||
translations: raisesTranslations,
|
||||
muscles: const [_delts],
|
||||
musclesSecondary: const [],
|
||||
),
|
||||
];
|
||||
}
|
||||
297
test_data/screenshots/measurements.dart
Normal file
297
test_data/screenshots/measurements.dart
Normal file
@@ -0,0 +1,297 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (c) 2026 wger Team
|
||||
*
|
||||
* wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:wger/features/measurements/models/measurement_category.dart';
|
||||
import 'package:wger/features/measurements/models/measurement_entry.dart';
|
||||
|
||||
/// Measurement categories for the store screenshots: the account of someone
|
||||
/// syncing daily, shaped like a health import, plus a hand-kept tape measure.
|
||||
/// Three months of data ending today, so every tile of the overview grid has
|
||||
/// something to show: the weight card on top, each spark form (line, dots,
|
||||
/// bars, floating, stack, heatmap) and both footer kinds exactly once.
|
||||
/// Deterministic (fixed random seed); only the dates move with today.
|
||||
///
|
||||
/// The categories come as the flat parent-first list the repository emits,
|
||||
/// with the group's children attached to their parent; the entries alongside
|
||||
/// them, keyed by the category holding them, since a category carries none.
|
||||
({List<MeasurementCategory> categories, Map<String, List<MeasurementEntry>> entries})
|
||||
getScreenshotMeasurements() {
|
||||
final random = Random(7);
|
||||
final today = DateTime.now();
|
||||
DateTime day(int daysAgo, {int hour = 0, int minute = 0}) =>
|
||||
DateTime(today.year, today.month, today.day - daysAgo, hour, minute);
|
||||
|
||||
MeasurementEntry entry(
|
||||
String categoryId,
|
||||
Object key,
|
||||
num value,
|
||||
DateTime date, {
|
||||
String source = 'apple_health',
|
||||
}) => MeasurementEntry(
|
||||
id: '$categoryId-$key',
|
||||
categoryId: categoryId,
|
||||
value: value,
|
||||
date: date,
|
||||
notes: '',
|
||||
source: source,
|
||||
);
|
||||
|
||||
// Body weight: the morning weigh-in, slowly losing. Feeds the full-width
|
||||
// card on top of the grid, not a tile.
|
||||
final weightEntries = <MeasurementEntry>[];
|
||||
for (var daysAgo = 90; daysAgo >= 0; daysAgo--) {
|
||||
final value = 84.2 - 0.02 * (90 - daysAgo) + (random.nextDouble() - 0.5) * 0.5;
|
||||
weightEntries.add(
|
||||
entry(
|
||||
'screenshot-weight',
|
||||
daysAgo,
|
||||
(value * 10).round() / 10,
|
||||
day(daysAgo, hour: 7, minute: 2),
|
||||
source: 'user',
|
||||
),
|
||||
);
|
||||
}
|
||||
final weight = MeasurementCategory(
|
||||
id: 'screenshot-weight',
|
||||
name: 'Weight',
|
||||
unit: 'kg',
|
||||
metricType: MetricType.bodyWeight,
|
||||
isOfficial: true,
|
||||
);
|
||||
|
||||
// Steps: quiet office days, active days, and the occasional long hike
|
||||
final stepEntries = <MeasurementEntry>[];
|
||||
for (var daysAgo = 90; daysAgo >= 0; daysAgo--) {
|
||||
final roll = random.nextDouble();
|
||||
final int steps;
|
||||
if (roll < 0.1) {
|
||||
steps = 15000 + random.nextInt(4000);
|
||||
} else if (roll < 0.5) {
|
||||
steps = 8500 + random.nextInt(3500);
|
||||
} else {
|
||||
steps = 4500 + random.nextInt(3000);
|
||||
}
|
||||
stepEntries.add(entry('screenshot-steps', daysAgo, steps, day(daysAgo, hour: 22)));
|
||||
}
|
||||
final steps = MeasurementCategory(
|
||||
id: 'screenshot-steps',
|
||||
name: 'Steps',
|
||||
unit: 'count',
|
||||
metricType: MetricType.steps,
|
||||
isOfficial: true,
|
||||
);
|
||||
|
||||
// Blood pressure: a morning reading every two to three days, slowly
|
||||
// improving. Systolic and diastolic share their timestamp, which is how
|
||||
// the components of a reading are paired.
|
||||
final systolicEntries = <MeasurementEntry>[];
|
||||
final diastolicEntries = <MeasurementEntry>[];
|
||||
for (var daysAgo = 90; daysAgo >= 0; daysAgo -= 2 + random.nextInt(2)) {
|
||||
final date = day(daysAgo, hour: 8, minute: 5);
|
||||
final systolic = (123 + 11 * daysAgo / 90 + (random.nextDouble() - 0.5) * 8).roundToDouble();
|
||||
final diastolic = (systolic - 46 + (random.nextDouble() - 0.5) * 6).roundToDouble();
|
||||
systolicEntries.add(entry('screenshot-sys', daysAgo, systolic, date));
|
||||
diastolicEntries.add(entry('screenshot-dia', daysAgo, diastolic, date));
|
||||
}
|
||||
final systolic = MeasurementCategory(
|
||||
id: 'screenshot-sys',
|
||||
name: 'Systolic',
|
||||
unit: 'mmHg',
|
||||
metricType: MetricType.bloodPressureSystolic,
|
||||
parentId: 'screenshot-bp',
|
||||
order: 0,
|
||||
);
|
||||
final diastolic = MeasurementCategory(
|
||||
id: 'screenshot-dia',
|
||||
name: 'Diastolic',
|
||||
unit: 'mmHg',
|
||||
metricType: MetricType.bloodPressureDiastolic,
|
||||
parentId: 'screenshot-bp',
|
||||
order: 1,
|
||||
);
|
||||
final bloodPressure = MeasurementCategory(
|
||||
id: 'screenshot-bp',
|
||||
name: 'Blood pressure',
|
||||
unit: 'mmHg',
|
||||
metricType: MetricType.bloodPressure,
|
||||
isOfficial: true,
|
||||
children: [systolic, diastolic],
|
||||
);
|
||||
|
||||
// Body fat: measured with the weigh-in, falling steadily. The line tile
|
||||
// with a downward weekly-rate chip.
|
||||
final bodyFatEntries = <MeasurementEntry>[];
|
||||
for (var daysAgo = 90; daysAgo >= 0; daysAgo--) {
|
||||
final value = 21.8 - 0.03 * (90 - daysAgo) + (random.nextDouble() - 0.5) * 0.3;
|
||||
bodyFatEntries.add(
|
||||
entry('screenshot-fat', daysAgo, (value * 10).round() / 10, day(daysAgo, hour: 7, minute: 3)),
|
||||
);
|
||||
}
|
||||
final bodyFat = MeasurementCategory(
|
||||
id: 'screenshot-fat',
|
||||
name: 'Body fat',
|
||||
unit: '%',
|
||||
metricType: MetricType.bodyFat,
|
||||
);
|
||||
|
||||
// Resting heart rate: barely moves. The line tile with the "stable" chip.
|
||||
final restingEntries = <MeasurementEntry>[];
|
||||
for (var daysAgo = 90; daysAgo >= 0; daysAgo--) {
|
||||
restingEntries.add(
|
||||
entry(
|
||||
'screenshot-rhr',
|
||||
daysAgo,
|
||||
(58 + (random.nextDouble() - 0.5) * 2).roundToDouble(),
|
||||
day(daysAgo, hour: 6, minute: 45),
|
||||
),
|
||||
);
|
||||
}
|
||||
final restingHeartRate = MeasurementCategory(
|
||||
id: 'screenshot-rhr',
|
||||
name: 'Resting heart rate',
|
||||
unit: 'bpm',
|
||||
metricType: MetricType.restingHeartRate,
|
||||
);
|
||||
|
||||
// Sleep: a night per day, split into stages; the total leads the tile
|
||||
// ("7:12" for the last night) over the stacked stage bars
|
||||
final sleepTotalEntries = <MeasurementEntry>[];
|
||||
final sleepLightEntries = <MeasurementEntry>[];
|
||||
final sleepDeepEntries = <MeasurementEntry>[];
|
||||
final sleepRemEntries = <MeasurementEntry>[];
|
||||
for (var daysAgo = 90; daysAgo >= 0; daysAgo--) {
|
||||
final light = daysAgo == 0 ? 240 : 220 + random.nextInt(60) - 30;
|
||||
final deep = daysAgo == 0 ? 90 : 95 + random.nextInt(30) - 15;
|
||||
final rem = daysAgo == 0 ? 102 : 105 + random.nextInt(30) - 15;
|
||||
final date = day(daysAgo, hour: 7);
|
||||
|
||||
sleepTotalEntries.add(entry('screenshot-sleep-total', daysAgo, light + deep + rem, date));
|
||||
sleepLightEntries.add(entry('screenshot-sleep-light', daysAgo, light, date));
|
||||
sleepDeepEntries.add(entry('screenshot-sleep-deep', daysAgo, deep, date));
|
||||
sleepRemEntries.add(entry('screenshot-sleep-rem', daysAgo, rem, date));
|
||||
}
|
||||
final sleepChildren = [
|
||||
MeasurementCategory(
|
||||
id: 'screenshot-sleep-total',
|
||||
name: 'Total sleep',
|
||||
unit: 'min',
|
||||
metricType: MetricType.sleepTotal,
|
||||
parentId: 'screenshot-sleep',
|
||||
order: 0,
|
||||
),
|
||||
MeasurementCategory(
|
||||
id: 'screenshot-sleep-light',
|
||||
name: 'Light sleep',
|
||||
unit: 'min',
|
||||
metricType: MetricType.sleepLight,
|
||||
parentId: 'screenshot-sleep',
|
||||
order: 1,
|
||||
),
|
||||
MeasurementCategory(
|
||||
id: 'screenshot-sleep-deep',
|
||||
name: 'Deep sleep',
|
||||
unit: 'min',
|
||||
metricType: MetricType.sleepDeep,
|
||||
parentId: 'screenshot-sleep',
|
||||
order: 2,
|
||||
),
|
||||
MeasurementCategory(
|
||||
id: 'screenshot-sleep-rem',
|
||||
name: 'REM sleep',
|
||||
unit: 'min',
|
||||
metricType: MetricType.sleepRem,
|
||||
parentId: 'screenshot-sleep',
|
||||
order: 3,
|
||||
),
|
||||
];
|
||||
final sleep = MeasurementCategory(
|
||||
id: 'screenshot-sleep',
|
||||
name: 'Sleep',
|
||||
unit: 'min',
|
||||
metricType: MetricType.sleep,
|
||||
isOfficial: true,
|
||||
children: sleepChildren,
|
||||
);
|
||||
|
||||
// Distance: configured as a heatmap, so the tile answers how regularly
|
||||
// rather than how much; the rest days stay visible as gaps
|
||||
final distanceEntries = <MeasurementEntry>[];
|
||||
for (var daysAgo = 90; daysAgo >= 0; daysAgo--) {
|
||||
if (random.nextDouble() < 0.3) {
|
||||
continue;
|
||||
}
|
||||
distanceEntries.add(
|
||||
entry(
|
||||
'screenshot-distance',
|
||||
daysAgo,
|
||||
((2 + random.nextDouble() * 9) * 100).round() / 100,
|
||||
day(daysAgo, hour: 21),
|
||||
),
|
||||
);
|
||||
}
|
||||
final distance = MeasurementCategory(
|
||||
id: 'screenshot-distance',
|
||||
name: 'Distance',
|
||||
unit: 'km',
|
||||
metricType: MetricType.distance,
|
||||
chartType: ChartType.heatmap,
|
||||
);
|
||||
|
||||
// Biceps: the hand-kept tape measure, taken every few weeks. The sparse
|
||||
// tile (dots, last-measured date) and the one entry of the quick-add menu.
|
||||
final bicepsEntries = <MeasurementEntry>[];
|
||||
final bicepsReadings = [(88, 37.6), (67, 37.9), (46, 38.1), (28, 38.3), (21, 38.5)];
|
||||
for (final (daysAgo, value) in bicepsReadings) {
|
||||
bicepsEntries.add(
|
||||
entry('screenshot-biceps', daysAgo, value, day(daysAgo, hour: 9), source: 'user'),
|
||||
);
|
||||
}
|
||||
final biceps = MeasurementCategory(id: 'screenshot-biceps', name: 'Biceps', unit: 'cm');
|
||||
|
||||
return (
|
||||
categories: [
|
||||
weight,
|
||||
bloodPressure,
|
||||
systolic,
|
||||
diastolic,
|
||||
bodyFat,
|
||||
restingHeartRate,
|
||||
sleep,
|
||||
...sleepChildren,
|
||||
steps,
|
||||
distance,
|
||||
biceps,
|
||||
],
|
||||
entries: {
|
||||
weight.id!: weightEntries,
|
||||
systolic.id!: systolicEntries,
|
||||
diastolic.id!: diastolicEntries,
|
||||
bodyFat.id!: bodyFatEntries,
|
||||
restingHeartRate.id!: restingEntries,
|
||||
'screenshot-sleep-total': sleepTotalEntries,
|
||||
'screenshot-sleep-light': sleepLightEntries,
|
||||
'screenshot-sleep-deep': sleepDeepEntries,
|
||||
'screenshot-sleep-rem': sleepRemEntries,
|
||||
steps.id!: stepEntries,
|
||||
distance.id!: distanceEntries,
|
||||
biceps.id!: bicepsEntries,
|
||||
},
|
||||
);
|
||||
}
|
||||
282
test_data/screenshots/nutrition.dart
Normal file
282
test_data/screenshots/nutrition.dart
Normal file
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (c) 2026 wger Team
|
||||
*
|
||||
* wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wger/features/nutrition/models/ingredient.dart';
|
||||
import 'package:wger/features/nutrition/models/log.dart';
|
||||
import 'package:wger/features/nutrition/models/meal.dart';
|
||||
import 'package:wger/features/nutrition/models/meal_item.dart';
|
||||
import 'package:wger/features/nutrition/models/nutritional_plan.dart';
|
||||
|
||||
const _planUuid = 'cc000000-0000-4000-8000-000000000010';
|
||||
const _mealUuids = [
|
||||
'cc000000-0000-4000-8000-000000000001',
|
||||
'cc000000-0000-4000-8000-000000000002',
|
||||
'cc000000-0000-4000-8000-000000000003',
|
||||
'cc000000-0000-4000-8000-000000000004',
|
||||
];
|
||||
|
||||
/// Nutrition values are per 100 g, roughly matching the real foods.
|
||||
Ingredient _ingredient(
|
||||
int id,
|
||||
String name, {
|
||||
required int energy,
|
||||
required num carbs,
|
||||
required num sugar,
|
||||
required num protein,
|
||||
required num fat,
|
||||
required num fatSaturated,
|
||||
required num fiber,
|
||||
bool isVegan = false,
|
||||
NutriScore? nutriscore,
|
||||
}) => Ingredient(
|
||||
remoteId: '$id',
|
||||
sourceName: 'Built-in testdata',
|
||||
sourceUrl: 'https://example.com/ingredient/$id',
|
||||
id: id,
|
||||
code: '20000000$id',
|
||||
name: name,
|
||||
created: DateTime(2026, 1, 1),
|
||||
energy: energy,
|
||||
carbohydrates: carbs,
|
||||
carbohydratesSugar: sugar,
|
||||
protein: protein,
|
||||
fat: fat,
|
||||
fatSaturated: fatSaturated,
|
||||
fiber: fiber,
|
||||
sodium: 0.05,
|
||||
isVegan: isVegan,
|
||||
isVegetarian: true,
|
||||
nutriscore: nutriscore,
|
||||
);
|
||||
|
||||
final _oats = _ingredient(
|
||||
201,
|
||||
'Rolled oats',
|
||||
energy: 372,
|
||||
carbs: 58.7,
|
||||
sugar: 0.7,
|
||||
protein: 13.5,
|
||||
fat: 7,
|
||||
fatSaturated: 1.2,
|
||||
fiber: 10,
|
||||
isVegan: true,
|
||||
nutriscore: NutriScore.a,
|
||||
);
|
||||
final _milk = _ingredient(
|
||||
202,
|
||||
'Whole milk',
|
||||
energy: 64,
|
||||
carbs: 4.7,
|
||||
sugar: 4.7,
|
||||
protein: 3.4,
|
||||
fat: 3.6,
|
||||
fatSaturated: 2.3,
|
||||
fiber: 0,
|
||||
nutriscore: NutriScore.b,
|
||||
);
|
||||
final _banana = _ingredient(
|
||||
203,
|
||||
'Banana',
|
||||
energy: 89,
|
||||
carbs: 22.8,
|
||||
sugar: 12.2,
|
||||
protein: 1.1,
|
||||
fat: 0.3,
|
||||
fatSaturated: 0.1,
|
||||
fiber: 2.6,
|
||||
isVegan: true,
|
||||
nutriscore: NutriScore.a,
|
||||
);
|
||||
final _chicken = _ingredient(
|
||||
204,
|
||||
'Chicken breast',
|
||||
energy: 107,
|
||||
carbs: 0,
|
||||
sugar: 0,
|
||||
protein: 23.1,
|
||||
fat: 1.8,
|
||||
fatSaturated: 0.5,
|
||||
fiber: 0,
|
||||
nutriscore: NutriScore.a,
|
||||
);
|
||||
final _rice = _ingredient(
|
||||
205,
|
||||
'Basmati rice, cooked',
|
||||
energy: 130,
|
||||
carbs: 28.2,
|
||||
sugar: 0.1,
|
||||
protein: 2.7,
|
||||
fat: 0.3,
|
||||
fatSaturated: 0.1,
|
||||
fiber: 0.4,
|
||||
isVegan: true,
|
||||
nutriscore: NutriScore.a,
|
||||
);
|
||||
final _broccoli = _ingredient(
|
||||
206,
|
||||
'Broccoli',
|
||||
energy: 34,
|
||||
carbs: 6.6,
|
||||
sugar: 1.7,
|
||||
protein: 2.8,
|
||||
fat: 0.4,
|
||||
fatSaturated: 0.1,
|
||||
fiber: 2.6,
|
||||
isVegan: true,
|
||||
nutriscore: NutriScore.a,
|
||||
);
|
||||
final _skyr = _ingredient(
|
||||
207,
|
||||
'Skyr',
|
||||
energy: 63,
|
||||
carbs: 4,
|
||||
sugar: 4,
|
||||
protein: 10.6,
|
||||
fat: 0.2,
|
||||
fatSaturated: 0.1,
|
||||
fiber: 0,
|
||||
nutriscore: NutriScore.a,
|
||||
);
|
||||
final _apple = _ingredient(
|
||||
208,
|
||||
'Apple',
|
||||
energy: 52,
|
||||
carbs: 13.8,
|
||||
sugar: 10.4,
|
||||
protein: 0.3,
|
||||
fat: 0.2,
|
||||
fatSaturated: 0,
|
||||
fiber: 2.4,
|
||||
isVegan: true,
|
||||
nutriscore: NutriScore.a,
|
||||
);
|
||||
final _salmon = _ingredient(
|
||||
209,
|
||||
'Salmon fillet',
|
||||
energy: 208,
|
||||
carbs: 0,
|
||||
sugar: 0,
|
||||
protein: 20.4,
|
||||
fat: 13.4,
|
||||
fatSaturated: 3.1,
|
||||
fiber: 0,
|
||||
nutriscore: NutriScore.b,
|
||||
);
|
||||
final _potatoes = _ingredient(
|
||||
210,
|
||||
'Potatoes, boiled',
|
||||
energy: 77,
|
||||
carbs: 17,
|
||||
sugar: 0.8,
|
||||
protein: 2,
|
||||
fat: 0.1,
|
||||
fatSaturated: 0,
|
||||
fiber: 2.2,
|
||||
isVegan: true,
|
||||
nutriscore: NutriScore.a,
|
||||
);
|
||||
|
||||
/// A lean bulk plan running relative to today: four meals with real foods,
|
||||
/// explicit macro goals, breakfast, lunch and the snack already logged today,
|
||||
/// and two weeks of diary history for the logged chart.
|
||||
NutritionalPlan getNutritionalPlanScreenshot() {
|
||||
final today = DateTime.now();
|
||||
|
||||
MealItem item(Ingredient ingredient, num amount) =>
|
||||
MealItem(ingredientId: ingredient.id, amount: amount, ingredient: ingredient);
|
||||
|
||||
final meals = [
|
||||
Meal(
|
||||
id: _mealUuids[0],
|
||||
plan: _planUuid,
|
||||
time: const TimeOfDay(hour: 7, minute: 0),
|
||||
name: 'Breakfast',
|
||||
mealItems: [item(_oats, 80), item(_milk, 300), item(_banana, 120)],
|
||||
),
|
||||
Meal(
|
||||
id: _mealUuids[1],
|
||||
plan: _planUuid,
|
||||
time: const TimeOfDay(hour: 12, minute: 30),
|
||||
name: 'Lunch',
|
||||
mealItems: [item(_chicken, 180), item(_rice, 250), item(_broccoli, 150)],
|
||||
),
|
||||
Meal(
|
||||
id: _mealUuids[2],
|
||||
plan: _planUuid,
|
||||
time: const TimeOfDay(hour: 16, minute: 0),
|
||||
name: 'Snack',
|
||||
mealItems: [item(_skyr, 300), item(_apple, 180)],
|
||||
),
|
||||
Meal(
|
||||
id: _mealUuids[3],
|
||||
plan: _planUuid,
|
||||
time: const TimeOfDay(hour: 19, minute: 0),
|
||||
name: 'Dinner',
|
||||
mealItems: [item(_salmon, 200), item(_potatoes, 300), item(_broccoli, 150)],
|
||||
),
|
||||
];
|
||||
|
||||
final plan = NutritionalPlan(
|
||||
id: _planUuid,
|
||||
description: 'Lean bulk',
|
||||
creationDate: today.subtract(const Duration(days: 45)),
|
||||
startDate: today.subtract(const Duration(days: 45)),
|
||||
onlyLogging: false,
|
||||
hasGoalCalories: true,
|
||||
goalEnergy: 2400,
|
||||
goalProtein: 150,
|
||||
goalCarbohydrates: 250,
|
||||
goalFat: 80,
|
||||
goalFiber: 30,
|
||||
meals: meals,
|
||||
);
|
||||
|
||||
// A meal logged on [date]: one diary entry per planned item, attached to
|
||||
// the plan and, for today, to the meal so its card shows the progress
|
||||
void logMeal(Meal meal, DateTime date) {
|
||||
for (final mealItem in meal.mealItems) {
|
||||
final log = LogItem.fromMealItem(mealItem, _planUuid, meal.id, date);
|
||||
plan.diaryEntries.add(log);
|
||||
if (date.day == today.day && date.month == today.month && date.year == today.year) {
|
||||
meal.diaryEntries.add(log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DateTime at(int daysAgo, TimeOfDay time) => DateTime(
|
||||
today.year,
|
||||
today.month,
|
||||
today.day - daysAgo,
|
||||
time.hour,
|
||||
time.minute,
|
||||
);
|
||||
|
||||
// Today: everything up to the afternoon snack is logged, dinner is not
|
||||
for (final meal in meals.take(3)) {
|
||||
logMeal(meal, at(0, meal.time!));
|
||||
}
|
||||
// Two weeks of full days for the diary chart and table
|
||||
for (var daysAgo = 1; daysAgo <= 14; daysAgo++) {
|
||||
for (final meal in meals) {
|
||||
logMeal(meal, at(daysAgo, meal.time!));
|
||||
}
|
||||
}
|
||||
|
||||
return plan;
|
||||
}
|
||||
299
test_data/screenshots/routines.dart
Normal file
299
test_data/screenshots/routines.dart
Normal file
@@ -0,0 +1,299 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (c) 2026 wger Team
|
||||
*
|
||||
* wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:wger/features/exercises/models/exercise.dart';
|
||||
import 'package:wger/features/routines/models/base_config.dart';
|
||||
import 'package:wger/features/routines/models/day.dart';
|
||||
import 'package:wger/features/routines/models/day_data.dart';
|
||||
import 'package:wger/features/routines/models/log.dart';
|
||||
import 'package:wger/features/routines/models/routine.dart';
|
||||
import 'package:wger/features/routines/models/session.dart';
|
||||
import 'package:wger/features/routines/models/set_config_data.dart';
|
||||
import 'package:wger/features/routines/models/slot.dart';
|
||||
import 'package:wger/features/routines/models/slot_data.dart';
|
||||
import 'package:wger/features/routines/models/slot_entry.dart';
|
||||
|
||||
import '../routines.dart';
|
||||
import 'exercises.dart';
|
||||
|
||||
/// A three day push/pull/legs routine, running relative to today, with a
|
||||
/// completed push session for the gym mode summary. Built from the screenshot
|
||||
/// exercises so names are localized and the muscle distribution is real.
|
||||
Routine getScreenshotRoutine() {
|
||||
final exercises = getScreenshotExercises();
|
||||
final benchPress = exercises[0];
|
||||
final crunches = exercises[1];
|
||||
final deadLift = exercises[2];
|
||||
final curls = exercises[3];
|
||||
final squats = exercises[4];
|
||||
final raises = exercises[5];
|
||||
|
||||
final today = DateTime.now();
|
||||
|
||||
SlotEntry entry(
|
||||
int slotId,
|
||||
Exercise exercise, {
|
||||
required int sets,
|
||||
required int reps,
|
||||
required num weight,
|
||||
}) => SlotEntry(
|
||||
slotId: slotId,
|
||||
type: SlotEntryType.normal,
|
||||
order: 1,
|
||||
exerciseId: exercise.id,
|
||||
repetitionUnitId: 1,
|
||||
repetitionRounding: 1,
|
||||
weightUnitId: 1,
|
||||
weightRounding: 1.25,
|
||||
comment: '',
|
||||
repetitionUnit: testRepetitionUnit1,
|
||||
weightUnit: testWeightUnit1,
|
||||
exercise: exercise,
|
||||
nrOfSetsConfigs: [BaseConfig.firstIteration(sets, 1)],
|
||||
repetitionsConfigs: [BaseConfig.firstIteration(reps, 1)],
|
||||
weightConfigs: [BaseConfig.firstIteration(weight, 1)],
|
||||
);
|
||||
|
||||
Slot slot(
|
||||
int id,
|
||||
int dayId,
|
||||
int order,
|
||||
Exercise exercise, {
|
||||
required int sets,
|
||||
required int reps,
|
||||
required num weight,
|
||||
String comment = '',
|
||||
}) {
|
||||
final slot = Slot.withData(id: id, day: dayId, order: order, comment: comment);
|
||||
slot.addExerciseBase(exercise);
|
||||
slot.entries.add(entry(id, exercise, sets: sets, reps: reps, weight: weight));
|
||||
return slot;
|
||||
}
|
||||
|
||||
final dayPush = Day(
|
||||
id: 1,
|
||||
routineId: 1,
|
||||
name: 'Push day',
|
||||
description: 'Chest, shoulders and triceps',
|
||||
slots: [
|
||||
slot(1, 1, 1, benchPress, sets: 4, reps: 8, weight: 80, comment: 'Warm up properly first'),
|
||||
slot(2, 1, 2, raises, sets: 3, reps: 12, weight: 10),
|
||||
],
|
||||
);
|
||||
final dayPull = Day(
|
||||
id: 2,
|
||||
routineId: 1,
|
||||
name: 'Pull day',
|
||||
description: 'Back and biceps',
|
||||
slots: [
|
||||
slot(3, 2, 1, deadLift, sets: 3, reps: 5, weight: 120),
|
||||
slot(4, 2, 2, curls, sets: 3, reps: 12, weight: 14),
|
||||
],
|
||||
);
|
||||
final dayLegs = Day(
|
||||
id: 3,
|
||||
routineId: 1,
|
||||
name: 'Legs and core',
|
||||
description: 'Legs and abs',
|
||||
slots: [
|
||||
slot(5, 3, 1, squats, sets: 4, reps: 15, weight: 0),
|
||||
slot(6, 3, 2, crunches, sets: 3, reps: 20, weight: 0),
|
||||
],
|
||||
);
|
||||
|
||||
// One collapsed entry per exercise, the way the routine detail screen
|
||||
// shows a day
|
||||
SetConfigData displaySet(
|
||||
Exercise exercise, {
|
||||
required int sets,
|
||||
required int reps,
|
||||
num? weight,
|
||||
int? restTime,
|
||||
double? rir,
|
||||
}) => SetConfigData(
|
||||
exerciseId: exercise.id,
|
||||
exercise: exercise,
|
||||
slotEntryId: 1,
|
||||
nrOfSets: sets,
|
||||
repetitions: reps,
|
||||
repetitionsUnit: testRepetitionUnit1,
|
||||
weight: weight ?? 0,
|
||||
weightUnit: testWeightUnit1,
|
||||
restTime: restTime,
|
||||
rir: rir,
|
||||
rpe: null,
|
||||
textRepr: weight == null ? '$sets sets $reps reps' : '$sets sets ${reps}x${weight}kg',
|
||||
);
|
||||
|
||||
// One entry per set, the way gym mode steps through a day
|
||||
SetConfigData gymSet(Exercise exercise, {required int reps, required num weight}) =>
|
||||
SetConfigData(
|
||||
exerciseId: exercise.id,
|
||||
exercise: exercise,
|
||||
slotEntryId: 1,
|
||||
nrOfSets: 1,
|
||||
repetitions: reps,
|
||||
repetitionsUnit: testRepetitionUnit1,
|
||||
weight: weight,
|
||||
weightUnit: testWeightUnit1,
|
||||
restTime: 120,
|
||||
rir: 2,
|
||||
rpe: null,
|
||||
textRepr: '${reps}x${weight}kg',
|
||||
);
|
||||
|
||||
final dayData = [
|
||||
DayData(
|
||||
iteration: 1,
|
||||
date: today,
|
||||
label: '',
|
||||
day: dayPush,
|
||||
slots: [
|
||||
SlotData(
|
||||
comment: 'Warm up properly first',
|
||||
isSuperset: false,
|
||||
exerciseIds: [benchPress.id],
|
||||
setConfigs: [displaySet(benchPress, sets: 4, reps: 8, weight: 80, restTime: 120, rir: 2)],
|
||||
),
|
||||
SlotData(
|
||||
comment: '',
|
||||
isSuperset: false,
|
||||
exerciseIds: [raises.id],
|
||||
setConfigs: [displaySet(raises, sets: 3, reps: 12, weight: 10, restTime: 60)],
|
||||
),
|
||||
],
|
||||
),
|
||||
DayData(
|
||||
iteration: 1,
|
||||
date: today.add(const Duration(days: 2)),
|
||||
label: '',
|
||||
day: dayPull,
|
||||
slots: [
|
||||
SlotData(
|
||||
comment: 'Reset your form between the reps',
|
||||
isSuperset: false,
|
||||
exerciseIds: [deadLift.id],
|
||||
setConfigs: [displaySet(deadLift, sets: 3, reps: 5, weight: 120, restTime: 180, rir: 1)],
|
||||
),
|
||||
SlotData(
|
||||
comment: '',
|
||||
isSuperset: false,
|
||||
exerciseIds: [curls.id],
|
||||
setConfigs: [displaySet(curls, sets: 3, reps: 12, weight: 14, restTime: 60)],
|
||||
),
|
||||
],
|
||||
),
|
||||
DayData(
|
||||
iteration: 1,
|
||||
date: today.add(const Duration(days: 4)),
|
||||
label: '',
|
||||
day: dayLegs,
|
||||
slots: [
|
||||
SlotData(
|
||||
comment: 'Keep a steady pace and brace your core',
|
||||
isSuperset: false,
|
||||
exerciseIds: [squats.id],
|
||||
setConfigs: [displaySet(squats, sets: 4, reps: 15)],
|
||||
),
|
||||
SlotData(
|
||||
comment: '',
|
||||
isSuperset: false,
|
||||
exerciseIds: [crunches.id],
|
||||
setConfigs: [displaySet(crunches, sets: 3, reps: 20)],
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
final dayDataGym = [
|
||||
DayData(
|
||||
iteration: 1,
|
||||
date: today,
|
||||
label: '',
|
||||
day: dayPush,
|
||||
slots: [
|
||||
SlotData(
|
||||
comment: 'Warm up properly first',
|
||||
isSuperset: false,
|
||||
exerciseIds: [benchPress.id],
|
||||
setConfigs: [for (var i = 0; i < 4; i++) gymSet(benchPress, reps: 8, weight: 80)],
|
||||
),
|
||||
SlotData(
|
||||
comment: '',
|
||||
isSuperset: false,
|
||||
exerciseIds: [raises.id],
|
||||
setConfigs: [for (var i = 0; i < 3; i++) gymSet(raises, reps: 12, weight: 10)],
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
// The push session behind the gym mode summary: every planned set logged
|
||||
var logId = 0;
|
||||
Log log(Exercise exercise, {required num weight, required int reps, double? rir}) {
|
||||
final log = Log(
|
||||
id: 'screenshot-log-${logId++}',
|
||||
exerciseId: exercise.id,
|
||||
iteration: 1,
|
||||
slotEntryId: 1,
|
||||
weight: weight,
|
||||
rir: rir,
|
||||
date: today,
|
||||
repetitions: reps,
|
||||
routineId: 1,
|
||||
);
|
||||
log.exercise = exercise;
|
||||
log.weightUnit = testWeightUnit1;
|
||||
log.repetitionUnit = testRepetitionUnit1;
|
||||
return log;
|
||||
}
|
||||
|
||||
final session = WorkoutSession(
|
||||
id: 'screenshot-session-1',
|
||||
routineId: 1,
|
||||
impression: WorkoutImpression.good,
|
||||
notes: 'Bench felt strong today',
|
||||
datetimeStart: DateTime(today.year, today.month, today.day, 17, 30),
|
||||
datetimeEnd: DateTime(today.year, today.month, today.day, 18, 42),
|
||||
logs: [
|
||||
log(benchPress, weight: 80, reps: 8, rir: 2),
|
||||
log(benchPress, weight: 80, reps: 8, rir: 2),
|
||||
log(benchPress, weight: 80, reps: 8, rir: 1.5),
|
||||
log(benchPress, weight: 80, reps: 8, rir: 1),
|
||||
log(raises, weight: 10, reps: 12, rir: 2),
|
||||
log(raises, weight: 10, reps: 12, rir: 2),
|
||||
log(raises, weight: 10, reps: 12, rir: 1),
|
||||
],
|
||||
);
|
||||
|
||||
return Routine(
|
||||
id: 1,
|
||||
created: today.subtract(const Duration(days: 42)),
|
||||
name: '3 day split',
|
||||
description:
|
||||
'Push, pull and legs across the week. Add weight as soon as you hit '
|
||||
'the top of the rep range on every set.',
|
||||
start: today.subtract(const Duration(days: 42)),
|
||||
end: today.add(const Duration(days: 42)),
|
||||
days: [dayPush, dayPull, dayLegs],
|
||||
sessions: [session],
|
||||
dayData: dayData,
|
||||
dayDataGym: dayDataGym,
|
||||
isHydrated: true,
|
||||
);
|
||||
}
|
||||
98
test_data/screenshots/weight.dart
Normal file
98
test_data/screenshots/weight.dart
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (c) 2026 wger Team
|
||||
*
|
||||
* wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:wger/features/measurements/models/measurement_entry.dart';
|
||||
import 'package:wger/features/nutrition/models/nutritional_plan.dart';
|
||||
|
||||
import '../body_weight.dart';
|
||||
|
||||
/// A year of body weight ending today, shaped like a real log: a slow drift
|
||||
/// up, a successful cut over the period of [getScreenshotWeightPlans]' first
|
||||
/// plan, a short maintenance phase, and a fresh cut under the active plan.
|
||||
/// The cut and the active plan fall inside the last three months, so the
|
||||
/// story is visible in every chart range.
|
||||
///
|
||||
/// Deterministic (fixed random seed); only the dates move with today.
|
||||
Map<String, List<MeasurementEntry>> getScreenshotBodyWeightEntries() {
|
||||
final random = Random(42);
|
||||
final today = DateTime.now();
|
||||
|
||||
// Piecewise linear phases over the last year, oldest first
|
||||
double weightAt(int daysAgo) {
|
||||
double phase(int from, int to, double start, double end) =>
|
||||
start + (end - start) * (from - daysAgo) / (from - to);
|
||||
|
||||
if (daysAgo > 100) {
|
||||
return phase(365, 100, 85.8, 87.5);
|
||||
}
|
||||
if (daysAgo > 75) {
|
||||
return phase(100, 75, 87.5, 87.6);
|
||||
}
|
||||
if (daysAgo > 25) {
|
||||
return phase(75, 25, 87.6, 82.5);
|
||||
}
|
||||
if (daysAgo > 10) {
|
||||
return phase(25, 10, 82.5, 82.9);
|
||||
}
|
||||
return phase(10, 0, 82.9, 82.3);
|
||||
}
|
||||
|
||||
final entries = <MeasurementEntry>[];
|
||||
// Weigh-ins every two to three days, in the morning, with scale-level noise
|
||||
for (var daysAgo = 365; daysAgo >= 0; daysAgo -= 2 + random.nextInt(2)) {
|
||||
final value = weightAt(daysAgo) + (random.nextDouble() - 0.5) * 0.7;
|
||||
entries.add(
|
||||
MeasurementEntry(
|
||||
id: 'screenshot-weight-${entries.length}',
|
||||
categoryId: testBodyWeightCategoryId,
|
||||
value: double.parse(value.toStringAsFixed(1)),
|
||||
date: DateTime(today.year, today.month, today.day - daysAgo, 7, 30),
|
||||
notes: '',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// newest first, matching the order the paged list reads them in
|
||||
return bodyWeightEntries(entries.reversed.toList());
|
||||
}
|
||||
|
||||
/// The nutrition plans behind the weight phases of
|
||||
/// [getScreenshotBodyWeightEntries]: a finished cut covering the big drop
|
||||
/// and a currently active plan. Shown as period bands in the weight chart.
|
||||
List<NutritionalPlan> getScreenshotWeightPlans() {
|
||||
final today = DateTime.now();
|
||||
DateTime daysAgo(int days) => DateTime(today.year, today.month, today.day - days);
|
||||
|
||||
return [
|
||||
NutritionalPlan(
|
||||
id: 'bb000000-0000-4000-8000-000000000001',
|
||||
description: 'Summer cut',
|
||||
startDate: daysAgo(75),
|
||||
endDate: daysAgo(25),
|
||||
onlyLogging: true,
|
||||
),
|
||||
NutritionalPlan(
|
||||
id: 'bb000000-0000-4000-8000-000000000002',
|
||||
description: 'Mini cut',
|
||||
startDate: daysAgo(10),
|
||||
onlyLogging: true,
|
||||
),
|
||||
];
|
||||
}
|
||||
@@ -58,7 +58,7 @@ List<UserTrophy> getScreenshotUserTrophies() {
|
||||
trophy: trophy(
|
||||
2,
|
||||
'5000 kg lifted',
|
||||
'Lifted a whole elefant',
|
||||
'Lifted a whole elephant',
|
||||
TrophyType.volume,
|
||||
'volume/5353989b-adc0-481b-a9bc-64365a9179e8.png',
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user