mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Merge branch 'fix/terminology'
# Conflicts: # lib/widgets/routines/day.dart # lib/widgets/routines/forms.dart # lib/widgets/routines/log.dart # lib/widgets/routines/routines_list.dart # lib/widgets/routines/workout_logs.dart # test/routine/gym_mode_screen_test.mocks.dart # test/routine/repetition_unit_form_widget_test.mocks.dart # test/routine/weight_unit_form_widget_test.mocks.dart # test/routine/workout_day_form_test.mocks.dart # test/routine/workout_form_test.mocks.dart # test/routine/workout_plan_screen_test.mocks.dart # test/routine/workout_plans_screen_test.mocks.dart # test/routine/workout_provider_test.mocks.dart # test/routine/workout_set_form_test.mocks.dart
This commit is contained in:
@@ -5,22 +5,22 @@ import 'package:provider/provider.dart';
|
||||
import 'package:wger/providers/body_weight.dart';
|
||||
import 'package:wger/providers/measurement.dart';
|
||||
import 'package:wger/providers/nutrition.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/screens/dashboard.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
|
||||
import '../test/measurements/measurement_categories_screen_test.mocks.dart';
|
||||
import '../test/nutrition/nutritional_plan_form_test.mocks.dart';
|
||||
import '../test/workout/weight_unit_form_widget_test.mocks.dart';
|
||||
import '../test/workout/workout_form_test.mocks.dart';
|
||||
import '../test/routine/weight_unit_form_widget_test.mocks.dart';
|
||||
import '../test/routine/workout_form_test.mocks.dart';
|
||||
import '../test_data/body_weight.dart';
|
||||
import '../test_data/measurements.dart';
|
||||
import '../test_data/nutritional_plans.dart';
|
||||
import '../test_data/workouts.dart';
|
||||
import '../test_data/routines.dart';
|
||||
|
||||
Widget createDashboardScreen({locale = 'en'}) {
|
||||
final mockWorkoutProvider = MockWorkoutPlansProvider();
|
||||
when(mockWorkoutProvider.activePlan).thenReturn(getWorkout());
|
||||
final mockRoutineProvider = MockRoutineProvider();
|
||||
when(mockRoutineProvider.activeRoutine).thenReturn(getRoutine());
|
||||
|
||||
final Map<String, dynamic> logs = {
|
||||
'results': [
|
||||
@@ -34,7 +34,7 @@ Widget createDashboardScreen({locale = 'en'}) {
|
||||
}
|
||||
]
|
||||
};
|
||||
when(mockWorkoutProvider.fetchSessionData()).thenAnswer((a) => Future.value(logs));
|
||||
when(mockRoutineProvider.fetchSessionData()).thenAnswer((a) => Future.value(logs));
|
||||
|
||||
final mockNutritionProvider = MockNutritionPlansProvider();
|
||||
when(mockNutritionProvider.currentPlan).thenAnswer((realInvocation) => getNutritionalPlan());
|
||||
@@ -48,8 +48,8 @@ Widget createDashboardScreen({locale = 'en'}) {
|
||||
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<WorkoutPlansProvider>(
|
||||
create: (context) => mockWorkoutProvider,
|
||||
ChangeNotifierProvider<RoutineProvider>(
|
||||
create: (context) => mockRoutineProvider,
|
||||
),
|
||||
ChangeNotifierProvider<NutritionPlansProvider>(
|
||||
create: (context) => mockNutritionProvider,
|
||||
|
||||
@@ -2,25 +2,25 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/screens/workout_plan_screen.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
|
||||
import '../test/workout/workout_form_test.mocks.dart';
|
||||
import '../test_data/workouts.dart';
|
||||
import '../test/routine/workout_form_test.mocks.dart';
|
||||
import '../test_data/routines.dart';
|
||||
|
||||
Widget createWorkoutDetailScreen({locale = 'en'}) {
|
||||
Widget createRoutineDetailScreen({locale = 'en'}) {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
|
||||
final mockWorkoutProvider = MockWorkoutPlansProvider();
|
||||
final workout = getWorkout();
|
||||
when(mockWorkoutProvider.activePlan).thenReturn(workout);
|
||||
when(mockWorkoutProvider.fetchAndSetWorkoutPlanFull(1)).thenAnswer((_) => Future.value(workout));
|
||||
final mockRoutineProvider = MockRoutineProvider();
|
||||
final routine = getRoutine();
|
||||
when(mockRoutineProvider.activeRoutine).thenReturn(routine);
|
||||
when(mockRoutineProvider.fetchAndSetRoutineFull(1)).thenAnswer((_) => Future.value(routine));
|
||||
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<WorkoutPlansProvider>(
|
||||
create: (context) => mockWorkoutProvider,
|
||||
ChangeNotifierProvider<RoutineProvider>(
|
||||
create: (context) => mockRoutineProvider,
|
||||
),
|
||||
],
|
||||
child: MaterialApp(
|
||||
@@ -33,8 +33,8 @@ Widget createWorkoutDetailScreen({locale = 'en'}) {
|
||||
home: TextButton(
|
||||
onPressed: () => key.currentState!.push(
|
||||
MaterialPageRoute<void>(
|
||||
settings: RouteSettings(arguments: getWorkout()),
|
||||
builder: (_) => WorkoutPlanScreen(),
|
||||
settings: RouteSettings(arguments: getRoutine()),
|
||||
builder: (_) => RoutineScreen(),
|
||||
),
|
||||
),
|
||||
child: const SizedBox(),
|
||||
@@ -3,20 +3,20 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/screens/gym_mode.dart';
|
||||
import 'package:wger/screens/workout_plan_screen.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
|
||||
import '../test/routine/gym_mode_screen_test.mocks.dart';
|
||||
import '../test/utils.dart';
|
||||
import '../test/workout/gym_mode_screen_test.mocks.dart';
|
||||
import '../test_data/exercises.dart';
|
||||
import '../test_data/workouts.dart';
|
||||
import '../test_data/routines.dart';
|
||||
|
||||
Widget createGymModeScreen({locale = 'en'}) {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
final bases = getTestExerciseBases();
|
||||
final workout = getWorkout();
|
||||
final routine = getRoutine();
|
||||
|
||||
final mockExerciseProvider = MockExercisesProvider();
|
||||
|
||||
@@ -25,11 +25,11 @@ Widget createGymModeScreen({locale = 'en'}) {
|
||||
//when(mockExerciseProvider.findExerciseBaseById(2)).thenReturn(bases[1]); // crunches
|
||||
//when(mockExerciseProvider.findExerciseBaseById(3)).thenReturn(bases[2]); // dead lift
|
||||
|
||||
return ChangeNotifierProvider<WorkoutPlansProvider>(
|
||||
create: (context) => WorkoutPlansProvider(
|
||||
return ChangeNotifierProvider<RoutineProvider>(
|
||||
create: (context) => RoutineProvider(
|
||||
mockBaseProvider,
|
||||
mockExerciseProvider,
|
||||
[workout],
|
||||
[routine],
|
||||
),
|
||||
child: ChangeNotifierProvider<ExercisesProvider>(
|
||||
create: (context) => mockExerciseProvider,
|
||||
@@ -43,14 +43,14 @@ Widget createGymModeScreen({locale = 'en'}) {
|
||||
home: TextButton(
|
||||
onPressed: () => key.currentState!.push(
|
||||
MaterialPageRoute<void>(
|
||||
settings: RouteSettings(arguments: workout.days.first),
|
||||
settings: RouteSettings(arguments: routine.days.first),
|
||||
builder: (_) => GymModeScreen(),
|
||||
),
|
||||
),
|
||||
child: const SizedBox(),
|
||||
),
|
||||
routes: {
|
||||
WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
|
||||
RoutineScreen.routeName: (ctx) => RoutineScreen(),
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
|
||||
import '1_dashboard.dart';
|
||||
import '2_workout.dart';
|
||||
import '2_routine.dart';
|
||||
import '3_gym_mode.dart';
|
||||
import '4_measurements.dart';
|
||||
import '5_nutritional_plan.dart';
|
||||
@@ -61,7 +61,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('workout detail screen - $language', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createWorkoutDetailScreen(locale: languageCode));
|
||||
await tester.pumpWidget(createRoutineDetailScreen(locale: languageCode));
|
||||
await tester.tap(find.byType(TextButton));
|
||||
await tester.pumpAndSettle();
|
||||
await takeScreenshot(tester, binding, language, '02 - workout detail');
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/models/workouts/repetition_unit.dart';
|
||||
import 'package:wger/models/workouts/weight_unit.dart';
|
||||
import 'package:wger/models/routines/repetition_unit.dart';
|
||||
import 'package:wger/models/routines/weight_unit.dart';
|
||||
|
||||
/// Returns the text representation for a single setting, used in the gym mode
|
||||
String repText(
|
||||
|
||||
@@ -24,8 +24,8 @@ import 'package:provider/provider.dart';
|
||||
import 'package:wger/exceptions/http_exception.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/exercises/translation.dart';
|
||||
import 'package:wger/models/workouts/log.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/models/routines/log.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
|
||||
void showErrorDialog(dynamic exception, BuildContext context) {
|
||||
log('showErrorDialog: ');
|
||||
@@ -129,7 +129,7 @@ dynamic showDeleteDialog(
|
||||
),
|
||||
onPressed: () {
|
||||
exerciseData[exercise]!.removeWhere((el) => el.id == log.id);
|
||||
Provider.of<WorkoutPlansProvider>(context, listen: false).deleteLog(
|
||||
Provider.of<RoutineProvider>(context, listen: false).deleteLog(
|
||||
log,
|
||||
);
|
||||
|
||||
|
||||
@@ -69,11 +69,11 @@
|
||||
"@registerInstead": {},
|
||||
"loginInstead": "Already have an account? Login",
|
||||
"@loginInstead": {},
|
||||
"labelWorkoutPlans": "Workout plans",
|
||||
"labelWorkoutPlans": "Routines",
|
||||
"@labelWorkoutPlans": {
|
||||
"description": "Title for screen workout plans"
|
||||
"description": "Title for screen routine list"
|
||||
},
|
||||
"labelBottomNavWorkout": "Workout",
|
||||
"labelBottomNavWorkout": "Routine",
|
||||
"@labelBottomNavWorkout": {
|
||||
"description": "Label used in bottom navigation, use a short word"
|
||||
},
|
||||
@@ -108,11 +108,11 @@
|
||||
"exerciseList": "Exercise list",
|
||||
"exercise": "Exercise",
|
||||
"@exercise": {
|
||||
"description": "An exercise for a workout"
|
||||
"description": "An exercise for a workout or routine"
|
||||
},
|
||||
"exercises": "Exercises",
|
||||
"@exercises": {
|
||||
"description": "Multiple exercises for a workout"
|
||||
"description": "Multiple exercises for a workout or routine"
|
||||
},
|
||||
"exerciseName": "Exercise Name",
|
||||
"@exerciseName": {
|
||||
@@ -143,13 +143,13 @@
|
||||
"@category": {
|
||||
"description": "Category for an exercise, ingredient, etc."
|
||||
},
|
||||
"newWorkout": "New workout plan",
|
||||
"newWorkout": "New routine",
|
||||
"@newWorkout": {
|
||||
"description": "Header when adding a new workout"
|
||||
"description": "Header when adding a new routine"
|
||||
},
|
||||
"noWorkoutPlans": "You have no workout plans",
|
||||
"noWorkoutPlans": "You have no routines",
|
||||
"@noWorkoutPlans": {
|
||||
"description": "Message shown when the user has no workout plans"
|
||||
"description": "Message shown when the user has no routines"
|
||||
},
|
||||
"reps": "Reps",
|
||||
"@reps": {
|
||||
@@ -169,7 +169,7 @@
|
||||
"@repetitionUnit": {},
|
||||
"set": "Set",
|
||||
"@set": {
|
||||
"description": "A set in a workout plan"
|
||||
"description": "A set in a routine"
|
||||
},
|
||||
"dayDescriptionHelp": "A description of what is done on this day (e.g. 'pull day') or what body parts are trained (e.g. 'chest and shoulders')",
|
||||
"@dayDescriptionHelp": {},
|
||||
@@ -237,7 +237,7 @@
|
||||
"@description": {},
|
||||
"name": "Name",
|
||||
"@name": {
|
||||
"description": "Name for a workout or nutritional plan"
|
||||
"description": "Name for a routine or nutritional plan"
|
||||
},
|
||||
"save": "Save",
|
||||
"@save": {},
|
||||
@@ -404,7 +404,7 @@
|
||||
"description": "Message shown when the user has no logged weight entries"
|
||||
},
|
||||
"noMeasurementEntries": "You have no measurement entries",
|
||||
"@noMeasurementntries": {
|
||||
"@noMeasurementEntries": {
|
||||
"description": "Message shown when the user has no logged measurement entries"
|
||||
},
|
||||
"moreMeasurementEntries": "Add new measurement",
|
||||
|
||||
@@ -28,8 +28,8 @@ import 'package:wger/providers/exercises.dart';
|
||||
import 'package:wger/providers/gallery.dart';
|
||||
import 'package:wger/providers/measurement.dart';
|
||||
import 'package:wger/providers/nutrition.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/providers/user.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/screens/add_exercise_screen.dart';
|
||||
import 'package:wger/screens/auth_screen.dart';
|
||||
import 'package:wger/screens/dashboard.dart';
|
||||
@@ -44,10 +44,10 @@ import 'package:wger/screens/measurement_entries_screen.dart';
|
||||
import 'package:wger/screens/nutritional_diary_screen.dart';
|
||||
import 'package:wger/screens/nutritional_plan_screen.dart';
|
||||
import 'package:wger/screens/nutritional_plans_screen.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/screens/routines_screen.dart';
|
||||
import 'package:wger/screens/splash_screen.dart';
|
||||
import 'package:wger/screens/weight_screen.dart';
|
||||
import 'package:wger/screens/workout_plan_screen.dart';
|
||||
import 'package:wger/screens/workout_plans_screen.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
import 'package:wger/widgets/core/about.dart';
|
||||
|
||||
@@ -77,14 +77,14 @@ class MyApp extends StatelessWidget {
|
||||
update: (context, base, previous) =>
|
||||
previous ?? ExercisesProvider(WgerBaseProvider(base)),
|
||||
),
|
||||
ChangeNotifierProxyProvider2<AuthProvider, ExercisesProvider, WorkoutPlansProvider>(
|
||||
create: (context) => WorkoutPlansProvider(
|
||||
ChangeNotifierProxyProvider2<AuthProvider, ExercisesProvider, RoutineProvider>(
|
||||
create: (context) => RoutineProvider(
|
||||
WgerBaseProvider(Provider.of<AuthProvider>(context, listen: false)),
|
||||
Provider.of<ExercisesProvider>(context, listen: false),
|
||||
[],
|
||||
),
|
||||
update: (context, auth, exercises, previous) =>
|
||||
previous ?? WorkoutPlansProvider(WgerBaseProvider(auth), exercises, []),
|
||||
previous ?? RoutineProvider(WgerBaseProvider(auth), exercises, []),
|
||||
),
|
||||
ChangeNotifierProxyProvider<AuthProvider, NutritionPlansProvider>(
|
||||
create: (context) => NutritionPlansProvider(
|
||||
@@ -152,8 +152,8 @@ class MyApp extends StatelessWidget {
|
||||
NutritionalDiaryScreen.routeName: (ctx) => NutritionalDiaryScreen(),
|
||||
NutritionalPlanScreen.routeName: (ctx) => NutritionalPlanScreen(),
|
||||
WeightScreen.routeName: (ctx) => WeightScreen(),
|
||||
WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
|
||||
WorkoutPlansScreen.routeName: (ctx) => WorkoutPlansScreen(),
|
||||
RoutineScreen.routeName: (ctx) => RoutineScreen(),
|
||||
RoutinesScreen.routeName: (ctx) => RoutinesScreen(),
|
||||
ExercisesScreen.routeName: (ctx) => const ExercisesScreen(),
|
||||
ExerciseDetailScreen.routeName: (ctx) => const ExerciseDetailScreen(),
|
||||
AddExerciseScreen.routeName: (ctx) => const AddExerciseScreen(),
|
||||
|
||||
@@ -18,7 +18,8 @@ NutritionalPlan _$NutritionalPlanFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$NutritionalPlanToJson(NutritionalPlan instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$NutritionalPlanToJson(NutritionalPlan instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'description': instance.description,
|
||||
'creation_date': toDate(instance.creationDate),
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:wger/models/workouts/set.dart';
|
||||
import 'package:wger/models/routines/set.dart';
|
||||
|
||||
part 'day.g.dart';
|
||||
|
||||
@@ -38,7 +38,7 @@ class Day {
|
||||
int? id;
|
||||
|
||||
@JsonKey(required: true, name: 'training')
|
||||
late int workoutId;
|
||||
late int routineId;
|
||||
|
||||
@JsonKey(required: true)
|
||||
late String description;
|
||||
@@ -13,14 +13,14 @@ Day _$DayFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
return Day()
|
||||
..id = json['id'] as int?
|
||||
..workoutId = json['training'] as int
|
||||
..routineId = json['training'] as int
|
||||
..description = json['description'] as String
|
||||
..daysOfWeek = (json['day'] as List<dynamic>).map((e) => e as int).toList();
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$DayToJson(Day instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'training': instance.workoutId,
|
||||
'training': instance.routineId,
|
||||
'description': instance.description,
|
||||
'day': instance.daysOfWeek,
|
||||
};
|
||||
@@ -20,8 +20,8 @@ import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:wger/helpers/json.dart';
|
||||
import 'package:wger/helpers/misc.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/workouts/repetition_unit.dart';
|
||||
import 'package:wger/models/workouts/weight_unit.dart';
|
||||
import 'package:wger/models/routines/repetition_unit.dart';
|
||||
import 'package:wger/models/routines/weight_unit.dart';
|
||||
|
||||
part 'log.g.dart';
|
||||
|
||||
@@ -37,7 +37,7 @@ class Log {
|
||||
late ExerciseBase exerciseBaseObj;
|
||||
|
||||
@JsonKey(required: true, name: 'workout')
|
||||
late int workoutPlan;
|
||||
late int routineId;
|
||||
|
||||
@JsonKey(required: true)
|
||||
late int reps;
|
||||
@@ -69,7 +69,7 @@ class Log {
|
||||
Log({
|
||||
this.id,
|
||||
required this.exerciseBaseId,
|
||||
required this.workoutPlan,
|
||||
required this.routineId,
|
||||
required this.reps,
|
||||
required this.rir,
|
||||
required this.repetitionUnitId,
|
||||
@@ -23,7 +23,7 @@ Log _$LogFromJson(Map<String, dynamic> json) {
|
||||
return Log(
|
||||
id: json['id'] as int?,
|
||||
exerciseBaseId: json['exercise_base'] as int,
|
||||
workoutPlan: json['workout'] as int,
|
||||
routineId: json['workout'] as int,
|
||||
reps: json['reps'] as int,
|
||||
rir: json['rir'] as String?,
|
||||
repetitionUnitId: json['repetition_unit'] as int,
|
||||
@@ -36,7 +36,7 @@ Log _$LogFromJson(Map<String, dynamic> json) {
|
||||
Map<String, dynamic> _$LogToJson(Log instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'exercise_base': instance.exerciseBaseId,
|
||||
'workout': instance.workoutPlan,
|
||||
'workout': instance.routineId,
|
||||
'reps': instance.reps,
|
||||
'rir': instance.rir,
|
||||
'repetition_unit': instance.repetitionUnitId,
|
||||
@@ -17,7 +17,8 @@ RepetitionUnit _$RepetitionUnitFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$RepetitionUnitToJson(RepetitionUnit instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$RepetitionUnitToJson(RepetitionUnit instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
};
|
||||
@@ -18,13 +18,13 @@
|
||||
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
import 'package:wger/models/workouts/log.dart';
|
||||
import 'package:wger/models/routines/day.dart';
|
||||
import 'package:wger/models/routines/log.dart';
|
||||
|
||||
part 'workout_plan.g.dart';
|
||||
part 'routine.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class WorkoutPlan {
|
||||
class Routine {
|
||||
@JsonKey(required: true)
|
||||
int? id;
|
||||
|
||||
@@ -43,7 +43,7 @@ class WorkoutPlan {
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
List<Log> logs = [];
|
||||
|
||||
WorkoutPlan({
|
||||
Routine({
|
||||
this.id,
|
||||
required this.creationDate,
|
||||
required this.name,
|
||||
@@ -56,16 +56,16 @@ class WorkoutPlan {
|
||||
this.description = description ?? '';
|
||||
}
|
||||
|
||||
WorkoutPlan.empty() {
|
||||
Routine.empty() {
|
||||
creationDate = DateTime.now();
|
||||
name = '';
|
||||
description = '';
|
||||
}
|
||||
|
||||
// Boilerplate
|
||||
factory WorkoutPlan.fromJson(Map<String, dynamic> json) => _$WorkoutPlanFromJson(json);
|
||||
factory Routine.fromJson(Map<String, dynamic> json) => _$RoutineFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$WorkoutPlanToJson(this);
|
||||
Map<String, dynamic> toJson() => _$RoutineToJson(this);
|
||||
|
||||
/// Filters the workout logs by exercise and sorts them by date
|
||||
///
|
||||
@@ -1,17 +1,17 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'workout_plan.dart';
|
||||
part of 'routine.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
WorkoutPlan _$WorkoutPlanFromJson(Map<String, dynamic> json) {
|
||||
Routine _$RoutineFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(
|
||||
json,
|
||||
requiredKeys: const ['id', 'creation_date', 'name', 'description'],
|
||||
);
|
||||
return WorkoutPlan(
|
||||
return Routine(
|
||||
id: json['id'] as int?,
|
||||
creationDate: DateTime.parse(json['creation_date'] as String),
|
||||
name: json['name'] as String,
|
||||
@@ -19,7 +19,7 @@ WorkoutPlan _$WorkoutPlanFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$WorkoutPlanToJson(WorkoutPlan instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$RoutineToJson(Routine instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'creation_date': instance.creationDate.toIso8601String(),
|
||||
'name': instance.name,
|
||||
@@ -30,7 +30,7 @@ class WorkoutSession {
|
||||
int? id;
|
||||
|
||||
@JsonKey(required: true, name: 'workout')
|
||||
late int workoutId;
|
||||
late int routineId;
|
||||
|
||||
@JsonKey(required: true, toJson: toDate)
|
||||
late DateTime date;
|
||||
@@ -51,7 +51,7 @@ class WorkoutSession {
|
||||
|
||||
WorkoutSession.withData({
|
||||
required this.id,
|
||||
required this.workoutId,
|
||||
required this.routineId,
|
||||
required this.date,
|
||||
required this.impression,
|
||||
required this.notes,
|
||||
@@ -66,6 +66,7 @@ class WorkoutSession {
|
||||
|
||||
// Boilerplate
|
||||
factory WorkoutSession.fromJson(Map<String, dynamic> json) => _$WorkoutSessionFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$WorkoutSessionToJson(this);
|
||||
|
||||
String? get impressionAsString {
|
||||
@@ -9,11 +9,18 @@ part of 'session.dart';
|
||||
WorkoutSession _$WorkoutSessionFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(
|
||||
json,
|
||||
requiredKeys: const ['id', 'workout', 'date', 'impression', 'time_start', 'time_end'],
|
||||
requiredKeys: const [
|
||||
'id',
|
||||
'workout',
|
||||
'date',
|
||||
'impression',
|
||||
'time_start',
|
||||
'time_end'
|
||||
],
|
||||
);
|
||||
return WorkoutSession()
|
||||
..id = json['id'] as int?
|
||||
..workoutId = json['workout'] as int
|
||||
..routineId = json['workout'] as int
|
||||
..date = DateTime.parse(json['date'] as String)
|
||||
..impression = stringToNum(json['impression'] as String?)
|
||||
..notes = json['notes'] as String? ?? ''
|
||||
@@ -21,9 +28,10 @@ WorkoutSession _$WorkoutSessionFromJson(Map<String, dynamic> json) {
|
||||
..timeEnd = stringToTime(json['time_end'] as String?);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$WorkoutSessionToJson(WorkoutSession instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$WorkoutSessionToJson(WorkoutSession instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'workout': instance.workoutId,
|
||||
'workout': instance.routineId,
|
||||
'date': toDate(instance.date),
|
||||
'impression': numToString(instance.impression),
|
||||
'notes': instance.notes,
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/workouts/setting.dart';
|
||||
import 'package:wger/models/routines/setting.dart';
|
||||
|
||||
part 'set.g.dart';
|
||||
|
||||
@@ -20,8 +20,8 @@ import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:wger/helpers/json.dart';
|
||||
import 'package:wger/helpers/misc.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/workouts/repetition_unit.dart';
|
||||
import 'package:wger/models/workouts/weight_unit.dart';
|
||||
import 'package:wger/models/routines/repetition_unit.dart';
|
||||
import 'package:wger/models/routines/weight_unit.dart';
|
||||
|
||||
part 'setting.g.dart';
|
||||
|
||||
@@ -17,7 +17,8 @@ WeightUnit _$WeightUnitFromJson(Map<String, dynamic> json) {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$WeightUnitToJson(WeightUnit instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$WeightUnitToJson(WeightUnit instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
};
|
||||
@@ -25,19 +25,19 @@ import 'package:wger/exceptions/http_exception.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/exercises/translation.dart';
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
import 'package:wger/models/workouts/log.dart';
|
||||
import 'package:wger/models/workouts/repetition_unit.dart';
|
||||
import 'package:wger/models/workouts/session.dart';
|
||||
import 'package:wger/models/workouts/set.dart';
|
||||
import 'package:wger/models/workouts/setting.dart';
|
||||
import 'package:wger/models/workouts/weight_unit.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
import 'package:wger/models/routines/day.dart';
|
||||
import 'package:wger/models/routines/log.dart';
|
||||
import 'package:wger/models/routines/repetition_unit.dart';
|
||||
import 'package:wger/models/routines/routine.dart';
|
||||
import 'package:wger/models/routines/session.dart';
|
||||
import 'package:wger/models/routines/set.dart';
|
||||
import 'package:wger/models/routines/setting.dart';
|
||||
import 'package:wger/models/routines/weight_unit.dart';
|
||||
import 'package:wger/providers/base_provider.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
|
||||
class WorkoutPlansProvider with ChangeNotifier {
|
||||
static const _workoutPlansUrlPath = 'workout';
|
||||
class RoutineProvider with ChangeNotifier {
|
||||
static const _routinesUrlPath = 'workout';
|
||||
static const _daysUrlPath = 'day';
|
||||
static const _setsUrlPath = 'set';
|
||||
static const _settingsUrlPath = 'setting';
|
||||
@@ -46,19 +46,19 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
static const _weightUnitUrlPath = 'setting-weightunit';
|
||||
static const _repetitionUnitUrlPath = 'setting-repetitionunit';
|
||||
|
||||
WorkoutPlan? _currentPlan;
|
||||
Routine? _currentRoutine;
|
||||
final ExercisesProvider _exercises;
|
||||
final WgerBaseProvider baseProvider;
|
||||
List<WorkoutPlan> _workoutPlans = [];
|
||||
List<Routine> _routines = [];
|
||||
List<WeightUnit> _weightUnits = [];
|
||||
List<RepetitionUnit> _repetitionUnit = [];
|
||||
|
||||
WorkoutPlansProvider(this.baseProvider, ExercisesProvider exercises, List<WorkoutPlan> entries)
|
||||
RoutineProvider(this.baseProvider, ExercisesProvider exercises, List<Routine> entries)
|
||||
: _exercises = exercises,
|
||||
_workoutPlans = entries;
|
||||
_routines = entries;
|
||||
|
||||
List<WorkoutPlan> get items {
|
||||
return [..._workoutPlans];
|
||||
List<Routine> get items {
|
||||
return [..._routines];
|
||||
}
|
||||
|
||||
List<WeightUnit> get weightUnits {
|
||||
@@ -67,8 +67,8 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
|
||||
/// Clears all lists
|
||||
void clear() {
|
||||
_currentPlan = null;
|
||||
_workoutPlans = [];
|
||||
_currentRoutine = null;
|
||||
_routines = [];
|
||||
_weightUnits = [];
|
||||
_repetitionUnit = [];
|
||||
}
|
||||
@@ -87,93 +87,94 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
return _repetitionUnit.firstWhere((element) => element.id == REP_UNIT_REPETITIONS);
|
||||
}
|
||||
|
||||
List<WorkoutPlan> getPlans() {
|
||||
return _workoutPlans;
|
||||
List<Routine> getPlans() {
|
||||
return _routines;
|
||||
}
|
||||
|
||||
WorkoutPlan findById(int id) {
|
||||
return _workoutPlans.firstWhere((workoutPlan) => workoutPlan.id == id);
|
||||
Routine findById(int id) {
|
||||
return _routines.firstWhere((workoutPlan) => workoutPlan.id == id);
|
||||
}
|
||||
|
||||
int findIndexById(int id) {
|
||||
return _workoutPlans.indexWhere((workoutPlan) => workoutPlan.id == id);
|
||||
return _routines.indexWhere((workoutPlan) => workoutPlan.id == id);
|
||||
}
|
||||
|
||||
/// Set the currently "active" workout plan
|
||||
/// Set the currently "active" routine
|
||||
void setCurrentPlan(int id) {
|
||||
_currentPlan = findById(id);
|
||||
_currentRoutine = findById(id);
|
||||
}
|
||||
|
||||
/// Returns the currently "active" workout plan
|
||||
WorkoutPlan? get currentPlan {
|
||||
return _currentPlan;
|
||||
/// Returns the currently "active" routine
|
||||
Routine? get currentRoutine {
|
||||
return _currentRoutine;
|
||||
}
|
||||
|
||||
/// Reset the currently "active" workout plan to null
|
||||
void resetCurrentPlan() {
|
||||
_currentPlan = null;
|
||||
/// Reset the currently "active" routine to null
|
||||
void resetCurrentRoutine() {
|
||||
_currentRoutine = null;
|
||||
}
|
||||
|
||||
/// Returns the current active workout plan. At the moment this is just
|
||||
/// Returns the current active routine. At the moment this is just
|
||||
/// the latest, but this might change in the future.
|
||||
WorkoutPlan? get activePlan {
|
||||
if (_workoutPlans.isNotEmpty) {
|
||||
return _workoutPlans.first;
|
||||
Routine? get activeRoutine {
|
||||
if (_routines.isNotEmpty) {
|
||||
return _routines.first;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Workouts
|
||||
* Routines
|
||||
*/
|
||||
|
||||
/// Fetches and sets all workout plans fully, i.e. with all corresponding child
|
||||
/// Fetches and sets all routines fully, i.e. with all corresponding child
|
||||
/// attributes
|
||||
Future<void> fetchAndSetAllPlansFull() async {
|
||||
Future<void> fetchAndSetAllRoutinesFull() async {
|
||||
final data = await baseProvider.fetch(
|
||||
baseProvider.makeUrl(
|
||||
_workoutPlansUrlPath,
|
||||
_routinesUrlPath,
|
||||
query: {'ordering': '-creation_date', 'limit': '1000'},
|
||||
),
|
||||
);
|
||||
for (final entry in data['results']) {
|
||||
await fetchAndSetWorkoutPlanFull(entry['id']);
|
||||
await fetchAndSetRoutineFull(entry['id']);
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Fetches all workout plan sparsely, i.e. only with the data on the plan
|
||||
/// Fetches all routines sparsely, i.e. only with the data on the routine
|
||||
/// object itself and no child attributes
|
||||
Future<void> fetchAndSetAllPlansSparse() async {
|
||||
Future<void> fetchAndSetAllRoutinesSparse() async {
|
||||
final data = await baseProvider.fetch(
|
||||
baseProvider.makeUrl(_workoutPlansUrlPath, query: {'limit': '1000'}),
|
||||
baseProvider.makeUrl(_routinesUrlPath, query: {'limit': '1000'}),
|
||||
);
|
||||
_workoutPlans = [];
|
||||
_routines = [];
|
||||
for (final workoutPlanData in data['results']) {
|
||||
final plan = WorkoutPlan.fromJson(workoutPlanData);
|
||||
_workoutPlans.add(plan);
|
||||
final plan = Routine.fromJson(workoutPlanData);
|
||||
_routines.add(plan);
|
||||
}
|
||||
|
||||
_workoutPlans.sort((a, b) => b.creationDate.compareTo(a.creationDate));
|
||||
_routines.sort((a, b) => b.creationDate.compareTo(a.creationDate));
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Fetches a workout plan sparsely, i.e. only with the data on the plan
|
||||
/// Fetches a routine sparsely, i.e. only with the data on the plan
|
||||
/// object itself and no child attributes
|
||||
Future<WorkoutPlan> fetchAndSetPlanSparse(int planId) async {
|
||||
Future<Routine> fetchAndSetRoutineSparse(int planId) async {
|
||||
final fullPlanData = await baseProvider.fetch(
|
||||
baseProvider.makeUrl(_workoutPlansUrlPath, id: planId),
|
||||
baseProvider.makeUrl(_routinesUrlPath, id: planId),
|
||||
);
|
||||
final plan = WorkoutPlan.fromJson(fullPlanData);
|
||||
_workoutPlans.add(plan);
|
||||
_workoutPlans.sort((a, b) => b.creationDate.compareTo(a.creationDate));
|
||||
final plan = Routine.fromJson(fullPlanData);
|
||||
_routines.add(plan);
|
||||
_routines.sort((a, b) => b.creationDate.compareTo(a.creationDate));
|
||||
|
||||
notifyListeners();
|
||||
return plan;
|
||||
}
|
||||
|
||||
/// Fetches a workout plan fully, i.e. with all corresponding child attributes
|
||||
Future<WorkoutPlan> fetchAndSetWorkoutPlanFull(int workoutId) async {
|
||||
/// Fetches a routine fully, i.e. with all corresponding child attributes
|
||||
Future<Routine> fetchAndSetRoutineFull(int routineId) async {
|
||||
// Load a list of all settings so that we can search through it
|
||||
//
|
||||
// This is a bit ugly, but saves us sending lots of requests later on
|
||||
@@ -181,17 +182,17 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
baseProvider.makeUrl(_settingsUrlPath, query: {'limit': '1000'}),
|
||||
);
|
||||
|
||||
WorkoutPlan plan;
|
||||
Routine routine;
|
||||
try {
|
||||
plan = findById(workoutId);
|
||||
routine = findById(routineId);
|
||||
} on StateError {
|
||||
plan = await fetchAndSetPlanSparse(workoutId);
|
||||
routine = await fetchAndSetRoutineSparse(routineId);
|
||||
}
|
||||
|
||||
// Days
|
||||
final List<Day> days = [];
|
||||
final daysData = await baseProvider.fetch(
|
||||
baseProvider.makeUrl(_daysUrlPath, query: {'training': plan.id.toString()}),
|
||||
baseProvider.makeUrl(_daysUrlPath, query: {'training': routine.id.toString()}),
|
||||
);
|
||||
for (final dayEntry in daysData['results']) {
|
||||
final day = Day.fromJson(dayEntry);
|
||||
@@ -233,14 +234,14 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
day.sets = sets;
|
||||
days.add(day);
|
||||
}
|
||||
plan.days = days;
|
||||
routine.days = days;
|
||||
|
||||
// Logs
|
||||
plan.logs = [];
|
||||
routine.logs = [];
|
||||
|
||||
final logData = await baseProvider.fetchPaginated(baseProvider.makeUrl(
|
||||
_logsUrlPath,
|
||||
query: {'workout': workoutId.toString(), 'limit': '100'},
|
||||
query: {'workout': routineId.toString(), 'limit': '100'},
|
||||
));
|
||||
for (final logEntry in logData) {
|
||||
try {
|
||||
@@ -248,7 +249,7 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
log.weightUnit = _weightUnits.firstWhere((e) => e.id == log.weightUnitId);
|
||||
log.repetitionUnit = _repetitionUnit.firstWhere((e) => e.id == log.weightUnitId);
|
||||
log.exerciseBase = await _exercises.fetchAndSetExerciseBase(log.exerciseBaseId);
|
||||
plan.logs.add(log);
|
||||
routine.logs.add(log);
|
||||
} catch (e) {
|
||||
dev.log('fire! fire!');
|
||||
dev.log(e.toString());
|
||||
@@ -257,44 +258,43 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
|
||||
// ... and done
|
||||
notifyListeners();
|
||||
return plan;
|
||||
return routine;
|
||||
}
|
||||
|
||||
Future<WorkoutPlan> addWorkout(WorkoutPlan workout) async {
|
||||
final data =
|
||||
await baseProvider.post(workout.toJson(), baseProvider.makeUrl(_workoutPlansUrlPath));
|
||||
final plan = WorkoutPlan.fromJson(data);
|
||||
_workoutPlans.insert(0, plan);
|
||||
Future<Routine> addRoutine(Routine routine) async {
|
||||
final data = await baseProvider.post(routine.toJson(), baseProvider.makeUrl(_routinesUrlPath));
|
||||
final plan = Routine.fromJson(data);
|
||||
_routines.insert(0, plan);
|
||||
notifyListeners();
|
||||
return plan;
|
||||
}
|
||||
|
||||
Future<void> editWorkout(WorkoutPlan workout) async {
|
||||
Future<void> editRoutine(Routine routine) async {
|
||||
await baseProvider.patch(
|
||||
workout.toJson(), baseProvider.makeUrl(_workoutPlansUrlPath, id: workout.id));
|
||||
routine.toJson(), baseProvider.makeUrl(_routinesUrlPath, id: routine.id));
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> deleteWorkout(int id) async {
|
||||
final existingWorkoutIndex = _workoutPlans.indexWhere((element) => element.id == id);
|
||||
final existingWorkout = _workoutPlans[existingWorkoutIndex];
|
||||
_workoutPlans.removeAt(existingWorkoutIndex);
|
||||
Future<void> deleteRoutine(int id) async {
|
||||
final existingRoutineIndex = _routines.indexWhere((element) => element.id == id);
|
||||
final existingRoutine = _routines[existingRoutineIndex];
|
||||
_routines.removeAt(existingRoutineIndex);
|
||||
notifyListeners();
|
||||
|
||||
final response = await baseProvider.deleteRequest(_workoutPlansUrlPath, id);
|
||||
final response = await baseProvider.deleteRequest(_routinesUrlPath, id);
|
||||
|
||||
if (response.statusCode >= 400) {
|
||||
_workoutPlans.insert(existingWorkoutIndex, existingWorkout);
|
||||
_routines.insert(existingRoutineIndex, existingRoutine);
|
||||
notifyListeners();
|
||||
throw WgerHttpException(response.body);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> fetchLogData(WorkoutPlan workout, ExerciseBase base) async {
|
||||
Future<Map<String, dynamic>> fetchLogData(Routine routine, ExerciseBase base) async {
|
||||
final data = await baseProvider.fetch(
|
||||
baseProvider.makeUrl(
|
||||
_workoutPlansUrlPath,
|
||||
id: workout.id,
|
||||
_routinesUrlPath,
|
||||
id: routine.id,
|
||||
objectMethod: 'log_data',
|
||||
query: {'id': base.id.toString()},
|
||||
),
|
||||
@@ -354,15 +354,15 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
/*
|
||||
* Days
|
||||
*/
|
||||
Future<Day> addDay(Day day, WorkoutPlan workout) async {
|
||||
Future<Day> addDay(Day day, Routine routine) async {
|
||||
/*
|
||||
* Saves a new day instance to the DB and adds it to the given workout
|
||||
*/
|
||||
day.workoutId = workout.id!;
|
||||
day.routineId = routine.id!;
|
||||
final data = await baseProvider.post(day.toJson(), baseProvider.makeUrl(_daysUrlPath));
|
||||
day = Day.fromJson(data);
|
||||
day.sets = [];
|
||||
workout.days.insert(0, day);
|
||||
routine.days.insert(0, day);
|
||||
notifyListeners();
|
||||
return day;
|
||||
}
|
||||
@@ -374,7 +374,7 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
|
||||
Future<void> deleteDay(Day day) async {
|
||||
await baseProvider.deleteRequest(_daysUrlPath, day.id!);
|
||||
for (final workout in _workoutPlans) {
|
||||
for (final workout in _routines) {
|
||||
workout.days.removeWhere((element) => element.id == day.id);
|
||||
}
|
||||
notifyListeners();
|
||||
@@ -455,7 +455,7 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
Future<void> deleteSet(Set workoutSet) async {
|
||||
await baseProvider.deleteRequest(_setsUrlPath, workoutSet.id!);
|
||||
|
||||
for (final workout in _workoutPlans) {
|
||||
for (final workout in _routines) {
|
||||
for (final day in workout.days) {
|
||||
day.sets.removeWhere((element) => element.id == workoutSet.id);
|
||||
}
|
||||
@@ -505,7 +505,7 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
log.repetitionUnit = _repetitionUnit.firstWhere((e) => e.id == log.weightUnitId);
|
||||
log.exerciseBase = await _exercises.fetchAndSetExerciseBase(log.exerciseBaseId);
|
||||
|
||||
final plan = findById(log.workoutPlan);
|
||||
final plan = findById(log.routineId);
|
||||
plan.logs.add(log);
|
||||
notifyListeners();
|
||||
return newLog;
|
||||
@@ -518,7 +518,7 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
|
||||
Future<void> deleteLog(Log log) async {
|
||||
await baseProvider.deleteRequest(_logsUrlPath, log.id!);
|
||||
for (final workout in _workoutPlans) {
|
||||
for (final workout in _routines) {
|
||||
workout.logs.removeWhere((element) => element.id == log.id);
|
||||
}
|
||||
notifyListeners();
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/widgets/workouts/gym_mode.dart';
|
||||
import 'package:wger/models/routines/day.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/widgets/routines/gym_mode.dart';
|
||||
|
||||
class GymModeScreen extends StatelessWidget {
|
||||
static const routeName = '/gym-mode';
|
||||
@@ -32,7 +32,7 @@ class GymModeScreen extends StatelessWidget {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
body: SafeArea(
|
||||
child: Consumer<WorkoutPlansProvider>(
|
||||
child: Consumer<RoutineProvider>(
|
||||
builder: (context, value, child) => GymMode(_day),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -29,13 +29,13 @@ import 'package:wger/providers/exercises.dart';
|
||||
import 'package:wger/providers/gallery.dart';
|
||||
import 'package:wger/providers/measurement.dart';
|
||||
import 'package:wger/providers/nutrition.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/providers/user.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/screens/dashboard.dart';
|
||||
import 'package:wger/screens/gallery_screen.dart';
|
||||
import 'package:wger/screens/nutritional_plans_screen.dart';
|
||||
import 'package:wger/screens/routines_screen.dart';
|
||||
import 'package:wger/screens/weight_screen.dart';
|
||||
import 'package:wger/screens/workout_plans_screen.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
|
||||
class HomeTabsScreen extends StatefulWidget {
|
||||
@@ -64,7 +64,7 @@ class _HomeTabsScreenState extends State<HomeTabsScreen> with SingleTickerProvid
|
||||
|
||||
final _screenList = [
|
||||
DashboardScreen(),
|
||||
WorkoutPlansScreen(),
|
||||
RoutinesScreen(),
|
||||
NutritionScreen(),
|
||||
WeightScreen(),
|
||||
const GalleryScreen(),
|
||||
@@ -75,7 +75,7 @@ class _HomeTabsScreenState extends State<HomeTabsScreen> with SingleTickerProvid
|
||||
final authProvider = context.read<AuthProvider>();
|
||||
|
||||
if (!authProvider.dataInit) {
|
||||
final workoutPlansProvider = context.read<WorkoutPlansProvider>();
|
||||
final workoutPlansProvider = context.read<RoutineProvider>();
|
||||
final nutritionPlansProvider = context.read<NutritionPlansProvider>();
|
||||
final exercisesProvider = context.read<ExercisesProvider>();
|
||||
final galleryProvider = context.read<GalleryProvider>();
|
||||
@@ -103,7 +103,7 @@ class _HomeTabsScreenState extends State<HomeTabsScreen> with SingleTickerProvid
|
||||
await Future.wait([
|
||||
galleryProvider.fetchAndSetGallery(),
|
||||
nutritionPlansProvider.fetchAndSetAllPlansSparse(),
|
||||
workoutPlansProvider.fetchAndSetAllPlansSparse(),
|
||||
workoutPlansProvider.fetchAndSetAllRoutinesSparse(),
|
||||
weightProvider.fetchAndSetEntries(),
|
||||
measurementProvider.fetchAndSetAllCategoriesAndEntries(),
|
||||
]);
|
||||
@@ -117,9 +117,9 @@ class _HomeTabsScreenState extends State<HomeTabsScreen> with SingleTickerProvid
|
||||
|
||||
// Current workout plan
|
||||
log('Loading current workout plan');
|
||||
if (workoutPlansProvider.activePlan != null) {
|
||||
final planId = workoutPlansProvider.activePlan!.id!;
|
||||
await workoutPlansProvider.fetchAndSetWorkoutPlanFull(planId);
|
||||
if (workoutPlansProvider.activeRoutine != null) {
|
||||
final planId = workoutPlansProvider.activeRoutine!.id!;
|
||||
await workoutPlansProvider.fetchAndSetRoutineFull(planId);
|
||||
workoutPlansProvider.setCurrentPlan(planId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,57 +19,56 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/models/routines/routine.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/widgets/workouts/forms.dart';
|
||||
import 'package:wger/widgets/workouts/workout_logs.dart';
|
||||
import 'package:wger/widgets/workouts/workout_plan_detail.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
import 'package:wger/widgets/routines/routine_detail.dart';
|
||||
import 'package:wger/widgets/routines/workout_logs.dart';
|
||||
|
||||
enum WorkoutScreenMode {
|
||||
workout,
|
||||
enum RoutineScreenMode {
|
||||
routine,
|
||||
log,
|
||||
}
|
||||
|
||||
enum WorkoutOptions {
|
||||
enum RoutineOptions {
|
||||
edit,
|
||||
delete,
|
||||
}
|
||||
|
||||
class WorkoutPlanScreen extends StatefulWidget {
|
||||
static const routeName = '/workout-plan-detail';
|
||||
class RoutineScreen extends StatefulWidget {
|
||||
static const routeName = '/routine-detail';
|
||||
|
||||
@override
|
||||
_WorkoutPlanScreenState createState() => _WorkoutPlanScreenState();
|
||||
_RoutineScreenState createState() => _RoutineScreenState();
|
||||
}
|
||||
|
||||
class _WorkoutPlanScreenState extends State<WorkoutPlanScreen> {
|
||||
WorkoutScreenMode _mode = WorkoutScreenMode.workout;
|
||||
class _RoutineScreenState extends State<RoutineScreen> {
|
||||
RoutineScreenMode _mode = RoutineScreenMode.routine;
|
||||
|
||||
void _changeMode(WorkoutScreenMode newMode) {
|
||||
void _changeMode(RoutineScreenMode newMode) {
|
||||
setState(() {
|
||||
_mode = newMode;
|
||||
});
|
||||
}
|
||||
|
||||
Future<WorkoutPlan> _loadFullWorkout(BuildContext context, int planId) {
|
||||
return Provider.of<WorkoutPlansProvider>(context, listen: false)
|
||||
.fetchAndSetWorkoutPlanFull(planId);
|
||||
Future<Routine> _loadFullRoutine(BuildContext context, int planId) {
|
||||
return Provider.of<RoutineProvider>(context, listen: false).fetchAndSetRoutineFull(planId);
|
||||
}
|
||||
|
||||
Widget getBody(WorkoutPlan plan) {
|
||||
Widget getBody(Routine plan) {
|
||||
switch (_mode) {
|
||||
case WorkoutScreenMode.workout:
|
||||
return WorkoutPlanDetail(plan, _changeMode);
|
||||
case RoutineScreenMode.routine:
|
||||
return RoutineDetail(plan, _changeMode);
|
||||
|
||||
case WorkoutScreenMode.log:
|
||||
case RoutineScreenMode.log:
|
||||
return WorkoutLogs(plan, _changeMode);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final workoutPlan = ModalRoute.of(context)!.settings.arguments as WorkoutPlan;
|
||||
final workoutPlan = ModalRoute.of(context)!.settings.arguments as Routine;
|
||||
|
||||
return Scaffold(
|
||||
body: CustomScrollView(
|
||||
@@ -85,24 +84,24 @@ class _WorkoutPlanScreenState extends State<WorkoutPlanScreen> {
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
PopupMenuButton<WorkoutOptions>(
|
||||
PopupMenuButton<RoutineOptions>(
|
||||
icon: const Icon(Icons.more_vert),
|
||||
onSelected: (value) {
|
||||
// Edit
|
||||
if (value == WorkoutOptions.edit) {
|
||||
if (value == RoutineOptions.edit) {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).edit,
|
||||
WorkoutForm(workoutPlan),
|
||||
RoutineForm(workoutPlan),
|
||||
),
|
||||
);
|
||||
|
||||
// Delete
|
||||
} else if (value == WorkoutOptions.delete) {
|
||||
Provider.of<WorkoutPlansProvider>(context, listen: false)
|
||||
.deleteWorkout(workoutPlan.id!);
|
||||
} else if (value == RoutineOptions.delete) {
|
||||
Provider.of<RoutineProvider>(context, listen: false)
|
||||
.deleteRoutine(workoutPlan.id!);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
// Toggle Mode
|
||||
@@ -110,13 +109,13 @@ class _WorkoutPlanScreenState extends State<WorkoutPlanScreen> {
|
||||
},
|
||||
itemBuilder: (BuildContext context) {
|
||||
return [
|
||||
PopupMenuItem<WorkoutOptions>(
|
||||
value: WorkoutOptions.edit,
|
||||
PopupMenuItem<RoutineOptions>(
|
||||
value: RoutineOptions.edit,
|
||||
child: Text(AppLocalizations.of(context).edit),
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem<WorkoutOptions>(
|
||||
value: WorkoutOptions.delete,
|
||||
PopupMenuItem<RoutineOptions>(
|
||||
value: RoutineOptions.delete,
|
||||
child: Text(AppLocalizations.of(context).delete),
|
||||
),
|
||||
];
|
||||
@@ -125,8 +124,8 @@ class _WorkoutPlanScreenState extends State<WorkoutPlanScreen> {
|
||||
],
|
||||
),
|
||||
FutureBuilder(
|
||||
future: _loadFullWorkout(context, workoutPlan.id!),
|
||||
builder: (context, AsyncSnapshot<WorkoutPlan> snapshot) => SliverList(
|
||||
future: _loadFullRoutine(context, workoutPlan.id!),
|
||||
builder: (context, AsyncSnapshot<Routine> snapshot) => SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
if (snapshot.connectionState == ConnectionState.waiting)
|
||||
@@ -137,7 +136,7 @@ class _WorkoutPlanScreenState extends State<WorkoutPlanScreen> {
|
||||
),
|
||||
)
|
||||
else
|
||||
Consumer<WorkoutPlansProvider>(
|
||||
Consumer<RoutineProvider>(
|
||||
builder: (context, value, child) => getBody(workoutPlan),
|
||||
),
|
||||
],
|
||||
@@ -19,15 +19,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/models/routines/routine.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/widgets/workouts/app_bar.dart';
|
||||
import 'package:wger/widgets/workouts/forms.dart';
|
||||
import 'package:wger/widgets/workouts/workout_plans_list.dart';
|
||||
import 'package:wger/widgets/routines/app_bar.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
import 'package:wger/widgets/routines/routines_list.dart';
|
||||
|
||||
class WorkoutPlansScreen extends StatelessWidget {
|
||||
static const routeName = '/workout-plans-list';
|
||||
class RoutinesScreen extends StatelessWidget {
|
||||
static const routeName = '/routine-list';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -41,13 +41,13 @@ class WorkoutPlansScreen extends StatelessWidget {
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).newWorkout,
|
||||
WorkoutForm(WorkoutPlan.empty()),
|
||||
RoutineForm(Routine.empty()),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
body: Consumer<WorkoutPlansProvider>(
|
||||
builder: (context, workoutProvider, child) => WorkoutPlansList(workoutProvider),
|
||||
body: Consumer<RoutineProvider>(
|
||||
builder: (context, workoutProvider, child) => RoutinesList(workoutProvider),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -23,8 +23,8 @@ import 'package:wger/providers/auth.dart';
|
||||
import 'package:wger/providers/body_weight.dart';
|
||||
import 'package:wger/providers/gallery.dart';
|
||||
import 'package:wger/providers/nutrition.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/providers/user.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/widgets/core/about.dart';
|
||||
import 'package:wger/widgets/user/forms.dart';
|
||||
@@ -88,7 +88,7 @@ class MainAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
title: Text(AppLocalizations.of(context).logout),
|
||||
onTap: () {
|
||||
context.read<AuthProvider>().logout();
|
||||
context.read<WorkoutPlansProvider>().clear();
|
||||
context.read<RoutineProvider>().clear();
|
||||
context.read<NutritionPlansProvider>().clear();
|
||||
context.read<BodyWeightProvider>().clear();
|
||||
context.read<GalleryProvider>().clear();
|
||||
|
||||
@@ -23,11 +23,11 @@ import 'package:table_calendar/table_calendar.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/helpers/json.dart';
|
||||
import 'package:wger/helpers/misc.dart';
|
||||
import 'package:wger/models/workouts/session.dart';
|
||||
import 'package:wger/models/routines/session.dart';
|
||||
import 'package:wger/providers/body_weight.dart';
|
||||
import 'package:wger/providers/measurement.dart';
|
||||
import 'package:wger/providers/nutrition.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
|
||||
/// Types of events
|
||||
@@ -114,7 +114,7 @@ class _DashboardCalendarWidgetState extends State<DashboardCalendarWidget>
|
||||
}
|
||||
|
||||
// Process workout sessions
|
||||
final WorkoutPlansProvider plans = Provider.of<WorkoutPlansProvider>(context, listen: false);
|
||||
final RoutineProvider plans = Provider.of<RoutineProvider>(context, listen: false);
|
||||
await plans.fetchSessionData().then((entries) {
|
||||
for (final entry in entries['results']) {
|
||||
final session = WorkoutSession.fromJson(entry);
|
||||
|
||||
@@ -23,17 +23,17 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/models/nutrition/nutritional_plan.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
import 'package:wger/models/routines/routine.dart';
|
||||
import 'package:wger/providers/body_weight.dart';
|
||||
import 'package:wger/providers/measurement.dart';
|
||||
import 'package:wger/providers/nutrition.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/screens/gym_mode.dart';
|
||||
import 'package:wger/screens/measurement_categories_screen.dart';
|
||||
import 'package:wger/screens/nutritional_plan_screen.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/screens/weight_screen.dart';
|
||||
import 'package:wger/screens/workout_plan_screen.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
import 'package:wger/widgets/measurements/charts.dart';
|
||||
import 'package:wger/widgets/core/core.dart';
|
||||
@@ -41,8 +41,8 @@ import 'package:wger/widgets/measurements/categories_card.dart';
|
||||
import 'package:wger/widgets/measurements/forms.dart';
|
||||
import 'package:wger/widgets/nutrition/charts.dart';
|
||||
import 'package:wger/widgets/nutrition/forms.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
import 'package:wger/widgets/weight/forms.dart';
|
||||
import 'package:wger/widgets/workouts/forms.dart';
|
||||
|
||||
class DashboardNutritionWidget extends StatefulWidget {
|
||||
@override
|
||||
@@ -428,13 +428,13 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
|
||||
var _showDetail = false;
|
||||
bool _hasContent = false;
|
||||
|
||||
WorkoutPlan? _workoutPlan;
|
||||
Routine? _routine;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_workoutPlan = context.read<WorkoutPlansProvider>().activePlan;
|
||||
_hasContent = _workoutPlan != null;
|
||||
_routine = context.read<RoutineProvider>().activeRoutine;
|
||||
_hasContent = _routine != null;
|
||||
}
|
||||
|
||||
Widget getTrailing() {
|
||||
@@ -452,7 +452,7 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
|
||||
return out;
|
||||
}
|
||||
|
||||
for (final day in _workoutPlan!.days) {
|
||||
for (final day in _routine!.days) {
|
||||
out.add(SizedBox(
|
||||
width: double.infinity,
|
||||
child: Row(
|
||||
@@ -523,13 +523,13 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
_hasContent ? _workoutPlan!.name : AppLocalizations.of(context).labelWorkoutPlan,
|
||||
_hasContent ? _routine!.name : AppLocalizations.of(context).labelWorkoutPlan,
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
),
|
||||
subtitle: Text(
|
||||
_hasContent
|
||||
? DateFormat.yMd(Localizations.localeOf(context).languageCode)
|
||||
.format(_workoutPlan!.creationDate)
|
||||
.format(_routine!.creationDate)
|
||||
: '',
|
||||
),
|
||||
leading: const Icon(
|
||||
@@ -556,7 +556,7 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
|
||||
NothingFound(
|
||||
AppLocalizations.of(context).noWorkoutPlans,
|
||||
AppLocalizations.of(context).newWorkout,
|
||||
WorkoutForm(WorkoutPlan.empty()),
|
||||
RoutineForm(Routine.empty()),
|
||||
),
|
||||
if (_hasContent)
|
||||
Row(
|
||||
@@ -565,8 +565,7 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
|
||||
TextButton(
|
||||
child: Text(AppLocalizations.of(context).goToDetailPage),
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.pushNamed(WorkoutPlanScreen.routeName, arguments: _workoutPlan);
|
||||
Navigator.of(context).pushNamed(RoutineScreen.routeName, arguments: _routine);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -20,17 +20,17 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
import 'package:wger/models/workouts/set.dart';
|
||||
import 'package:wger/models/workouts/setting.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/models/routines/day.dart';
|
||||
import 'package:wger/models/routines/set.dart';
|
||||
import 'package:wger/models/routines/setting.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/screens/gym_mode.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
import 'package:wger/widgets/core/core.dart';
|
||||
import 'package:wger/widgets/exercises/exercises.dart';
|
||||
import 'package:wger/widgets/exercises/images.dart';
|
||||
import 'package:wger/widgets/workouts/forms.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
|
||||
class SettingWidget extends StatelessWidget {
|
||||
final Set set;
|
||||
@@ -87,16 +87,16 @@ class SettingWidget extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class WorkoutDayWidget extends StatefulWidget {
|
||||
class RoutineDayWidget extends StatefulWidget {
|
||||
final Day _day;
|
||||
|
||||
const WorkoutDayWidget(this._day);
|
||||
const RoutineDayWidget(this._day);
|
||||
|
||||
@override
|
||||
_WorkoutDayWidgetState createState() => _WorkoutDayWidgetState();
|
||||
_RoutineDayWidgetState createState() => _RoutineDayWidgetState();
|
||||
}
|
||||
|
||||
class _WorkoutDayWidgetState extends State<WorkoutDayWidget> {
|
||||
class _RoutineDayWidgetState extends State<RoutineDayWidget> {
|
||||
bool _expanded = false;
|
||||
late List<Set> _sets;
|
||||
|
||||
@@ -124,7 +124,7 @@ class _WorkoutDayWidgetState extends State<WorkoutDayWidget> {
|
||||
icon: const Icon(Icons.delete),
|
||||
iconSize: ICON_SIZE_SMALL,
|
||||
onPressed: () {
|
||||
Provider.of<WorkoutPlansProvider>(context, listen: false).deleteSet(set);
|
||||
Provider.of<RoutineProvider>(context, listen: false).deleteSet(set);
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
@@ -177,7 +177,7 @@ class _WorkoutDayWidgetState extends State<WorkoutDayWidget> {
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Provider.of<WorkoutPlansProvider>(context, listen: false).deleteDay(
|
||||
Provider.of<RoutineProvider>(context, listen: false).deleteDay(
|
||||
widget._day,
|
||||
);
|
||||
},
|
||||
@@ -208,8 +208,8 @@ class _WorkoutDayWidgetState extends State<WorkoutDayWidget> {
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).edit,
|
||||
DayFormWidget(
|
||||
Provider.of<WorkoutPlansProvider>(context, listen: false)
|
||||
.findById(widget._day.workoutId),
|
||||
Provider.of<RoutineProvider>(context, listen: false)
|
||||
.findById(widget._day.routineId),
|
||||
widget._day),
|
||||
hasListView: true,
|
||||
),
|
||||
@@ -235,7 +235,7 @@ class _WorkoutDayWidgetState extends State<WorkoutDayWidget> {
|
||||
setState(() {
|
||||
_sets.insert(newIndex, _sets.removeAt(oldIndex));
|
||||
});
|
||||
_sets = await Provider.of<WorkoutPlansProvider>(context, listen: false)
|
||||
_sets = await Provider.of<RoutineProvider>(context, listen: false)
|
||||
.reorderSets(_sets, startIndex);
|
||||
},
|
||||
children: [
|
||||
@@ -22,32 +22,32 @@ import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
import 'package:wger/models/workouts/repetition_unit.dart';
|
||||
import 'package:wger/models/workouts/set.dart';
|
||||
import 'package:wger/models/workouts/setting.dart';
|
||||
import 'package:wger/models/workouts/weight_unit.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
import 'package:wger/models/routines/day.dart';
|
||||
import 'package:wger/models/routines/repetition_unit.dart';
|
||||
import 'package:wger/models/routines/routine.dart';
|
||||
import 'package:wger/models/routines/set.dart';
|
||||
import 'package:wger/models/routines/setting.dart';
|
||||
import 'package:wger/models/routines/weight_unit.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/screens/workout_plan_screen.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
import 'package:wger/widgets/exercises/images.dart';
|
||||
|
||||
class WorkoutForm extends StatelessWidget {
|
||||
final WorkoutPlan _plan;
|
||||
class RoutineForm extends StatelessWidget {
|
||||
final Routine _routine;
|
||||
final _form = GlobalKey<FormState>();
|
||||
|
||||
WorkoutForm(this._plan);
|
||||
RoutineForm(this._routine);
|
||||
|
||||
final TextEditingController workoutNameController = TextEditingController();
|
||||
final TextEditingController workoutDescriptionController = TextEditingController();
|
||||
final TextEditingController routineNameController = TextEditingController();
|
||||
final TextEditingController routineDescriptionController = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_plan.id != null) {
|
||||
workoutNameController.text = _plan.name;
|
||||
workoutDescriptionController.text = _plan.description;
|
||||
if (_routine.id != null) {
|
||||
routineNameController.text = _routine.name;
|
||||
routineDescriptionController.text = _routine.description;
|
||||
}
|
||||
|
||||
return Form(
|
||||
@@ -57,7 +57,7 @@ class WorkoutForm extends StatelessWidget {
|
||||
TextFormField(
|
||||
key: const Key('field-name'),
|
||||
decoration: InputDecoration(labelText: AppLocalizations.of(context).name),
|
||||
controller: workoutNameController,
|
||||
controller: routineNameController,
|
||||
validator: (value) {
|
||||
const minLength = 1;
|
||||
const maxLength = 100;
|
||||
@@ -68,7 +68,7 @@ class WorkoutForm extends StatelessWidget {
|
||||
},
|
||||
onFieldSubmitted: (_) {},
|
||||
onSaved: (newValue) {
|
||||
_plan.name = newValue!;
|
||||
_routine.name = newValue!;
|
||||
},
|
||||
),
|
||||
TextFormField(
|
||||
@@ -76,7 +76,7 @@ class WorkoutForm extends StatelessWidget {
|
||||
decoration: InputDecoration(labelText: AppLocalizations.of(context).description),
|
||||
minLines: 3,
|
||||
maxLines: 10,
|
||||
controller: workoutDescriptionController,
|
||||
controller: routineDescriptionController,
|
||||
validator: (value) {
|
||||
const minLength = 0;
|
||||
const maxLength = 1000;
|
||||
@@ -87,7 +87,7 @@ class WorkoutForm extends StatelessWidget {
|
||||
},
|
||||
onFieldSubmitted: (_) {},
|
||||
onSaved: (newValue) {
|
||||
_plan.description = newValue!;
|
||||
_routine.description = newValue!;
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
@@ -102,18 +102,17 @@ class WorkoutForm extends StatelessWidget {
|
||||
_form.currentState!.save();
|
||||
|
||||
// Save to DB
|
||||
if (_plan.id != null) {
|
||||
await Provider.of<WorkoutPlansProvider>(context, listen: false).editWorkout(_plan);
|
||||
if (_routine.id != null) {
|
||||
await Provider.of<RoutineProvider>(context, listen: false).editRoutine(_routine);
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
} else {
|
||||
final WorkoutPlan newPlan =
|
||||
await Provider.of<WorkoutPlansProvider>(context, listen: false)
|
||||
.addWorkout(_plan);
|
||||
final Routine newPlan =
|
||||
await Provider.of<RoutineProvider>(context, listen: false).addRoutine(_routine);
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pushReplacementNamed(
|
||||
WorkoutPlanScreen.routeName,
|
||||
RoutineScreen.routeName,
|
||||
arguments: newPlan,
|
||||
);
|
||||
}
|
||||
@@ -160,13 +159,13 @@ class _DayCheckboxState extends State<DayCheckbox> {
|
||||
}
|
||||
|
||||
class DayFormWidget extends StatefulWidget {
|
||||
final WorkoutPlan workout;
|
||||
final Routine routine;
|
||||
final dayController = TextEditingController();
|
||||
late final Day _day;
|
||||
|
||||
DayFormWidget(this.workout, [Day? day]) {
|
||||
DayFormWidget(this.routine, [Day? day]) {
|
||||
_day = day ?? Day();
|
||||
_day.workoutId = workout.id!;
|
||||
_day.routineId = routine.id!;
|
||||
if (_day.id != null) {
|
||||
dayController.text = day!.description;
|
||||
}
|
||||
@@ -222,12 +221,12 @@ class _DayFormWidgetState extends State<DayFormWidget> {
|
||||
|
||||
try {
|
||||
if (widget._day.id == null) {
|
||||
Provider.of<WorkoutPlansProvider>(context, listen: false).addDay(
|
||||
Provider.of<RoutineProvider>(context, listen: false).addDay(
|
||||
widget._day,
|
||||
widget.workout,
|
||||
widget.routine,
|
||||
);
|
||||
} else {
|
||||
Provider.of<WorkoutPlansProvider>(context, listen: false).editDay(
|
||||
Provider.of<RoutineProvider>(context, listen: false).editDay(
|
||||
widget._day,
|
||||
);
|
||||
}
|
||||
@@ -297,7 +296,7 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
|
||||
/// Adds settings to the set
|
||||
void addSettings() {
|
||||
final workoutProvider = context.read<WorkoutPlansProvider>();
|
||||
final workoutProvider = context.read<RoutineProvider>();
|
||||
|
||||
widget._set.settings = [];
|
||||
int order = 0;
|
||||
@@ -521,8 +520,7 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
}
|
||||
_formKey.currentState!.save();
|
||||
|
||||
final workoutProvider =
|
||||
Provider.of<WorkoutPlansProvider>(context, listen: false);
|
||||
final workoutProvider = Provider.of<RoutineProvider>(context, listen: false);
|
||||
|
||||
// Save set
|
||||
final Set setDb = await workoutProvider.addSet(widget._set);
|
||||
@@ -868,7 +866,7 @@ class _WeightUnitInputWidgetState extends State<WeightUnitInputWidget> {
|
||||
widget._setting.weightUnit = newValue;
|
||||
});
|
||||
},
|
||||
items: Provider.of<WorkoutPlansProvider>(context, listen: false)
|
||||
items: Provider.of<RoutineProvider>(context, listen: false)
|
||||
.weightUnits
|
||||
.map<DropdownMenuItem<WeightUnit>>((WeightUnit value) {
|
||||
return DropdownMenuItem<WeightUnit>(
|
||||
@@ -908,7 +906,7 @@ class _RepetitionUnitInputWidgetState extends State<RepetitionUnitInputWidget> {
|
||||
widget._setting.repetitionUnit = newValue;
|
||||
});
|
||||
},
|
||||
items: Provider.of<WorkoutPlansProvider>(context, listen: false)
|
||||
items: Provider.of<RoutineProvider>(context, listen: false)
|
||||
.repetitionUnits
|
||||
.map<DropdownMenuItem<RepetitionUnit>>((RepetitionUnit value) {
|
||||
return DropdownMenuItem<RepetitionUnit>(
|
||||
@@ -30,24 +30,24 @@ import 'package:wger/helpers/json.dart';
|
||||
import 'package:wger/helpers/misc.dart';
|
||||
import 'package:wger/helpers/ui.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
import 'package:wger/models/workouts/log.dart';
|
||||
import 'package:wger/models/workouts/session.dart';
|
||||
import 'package:wger/models/workouts/set.dart';
|
||||
import 'package:wger/models/workouts/setting.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
import 'package:wger/models/routines/day.dart';
|
||||
import 'package:wger/models/routines/log.dart';
|
||||
import 'package:wger/models/routines/routine.dart';
|
||||
import 'package:wger/models/routines/session.dart';
|
||||
import 'package:wger/models/routines/set.dart';
|
||||
import 'package:wger/models/routines/setting.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
import 'package:wger/widgets/core/core.dart';
|
||||
import 'package:wger/widgets/exercises/images.dart';
|
||||
import 'package:wger/widgets/workouts/forms.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
|
||||
class GymMode extends StatefulWidget {
|
||||
final Day _workoutDay;
|
||||
final Day _routineDay;
|
||||
late final TimeOfDay _start;
|
||||
|
||||
GymMode(this._workoutDay) {
|
||||
GymMode(this._routineDay) {
|
||||
_start = TimeOfDay.now();
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class _GymModeState extends State<GymMode> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Calculate amount of elements for progress indicator
|
||||
for (final set in widget._workoutDay.sets) {
|
||||
for (final set in widget._routineDay.sets) {
|
||||
_totalElements = _totalElements + set.settingsComputed.length;
|
||||
}
|
||||
// Calculate the pages for the navigation
|
||||
@@ -82,7 +82,7 @@ class _GymModeState extends State<GymMode> {
|
||||
// This duplicates the code below in the getContent method, but it seems to
|
||||
// be the easiest way
|
||||
var currentPage = 1;
|
||||
for (final set in widget._workoutDay.sets) {
|
||||
for (final set in widget._routineDay.sets) {
|
||||
var firstPage = true;
|
||||
for (final setting in set.settingsComputed) {
|
||||
final exerciseBase = Provider.of<ExercisesProvider>(context, listen: false)
|
||||
@@ -106,11 +106,11 @@ class _GymModeState extends State<GymMode> {
|
||||
// Returns the list of exercise overview, sets and pause pages
|
||||
List<Widget> getContent() {
|
||||
final exerciseProvider = Provider.of<ExercisesProvider>(context, listen: false);
|
||||
final workoutProvider = Provider.of<WorkoutPlansProvider>(context, listen: false);
|
||||
final workoutProvider = Provider.of<RoutineProvider>(context, listen: false);
|
||||
var currentElement = 1;
|
||||
final List<Widget> out = [];
|
||||
|
||||
for (final set in widget._workoutDay.sets) {
|
||||
for (final set in widget._routineDay.sets) {
|
||||
var firstPage = true;
|
||||
for (final setting in set.settingsComputed) {
|
||||
final ratioCompleted = currentElement / _totalElements;
|
||||
@@ -131,7 +131,7 @@ class _GymModeState extends State<GymMode> {
|
||||
setting,
|
||||
set,
|
||||
exerciseBase,
|
||||
workoutProvider.findById(widget._workoutDay.workoutId),
|
||||
workoutProvider.findById(widget._routineDay.routineId),
|
||||
ratioCompleted,
|
||||
_exercisePages,
|
||||
));
|
||||
@@ -150,13 +150,13 @@ class _GymModeState extends State<GymMode> {
|
||||
children: [
|
||||
StartPage(
|
||||
_controller,
|
||||
widget._workoutDay,
|
||||
widget._routineDay,
|
||||
_exercisePages,
|
||||
),
|
||||
...getContent(),
|
||||
SessionPage(
|
||||
Provider.of<WorkoutPlansProvider>(context, listen: false)
|
||||
.findById(widget._workoutDay.workoutId),
|
||||
Provider.of<RoutineProvider>(context, listen: false)
|
||||
.findById(widget._routineDay.routineId),
|
||||
_controller,
|
||||
widget._start,
|
||||
_exercisePages,
|
||||
@@ -233,7 +233,7 @@ class LogPage extends StatefulWidget {
|
||||
final Setting _setting;
|
||||
final Set _set;
|
||||
final ExerciseBase _exerciseBase;
|
||||
final WorkoutPlan _workoutPlan;
|
||||
final Routine _routine;
|
||||
final double _ratioCompleted;
|
||||
final Map<String, int> _exercisePages;
|
||||
final Log _log = Log.empty();
|
||||
@@ -243,12 +243,12 @@ class LogPage extends StatefulWidget {
|
||||
this._setting,
|
||||
this._set,
|
||||
this._exerciseBase,
|
||||
this._workoutPlan,
|
||||
this._routine,
|
||||
this._ratioCompleted,
|
||||
this._exercisePages,
|
||||
) {
|
||||
_log.date = DateTime.now();
|
||||
_log.workoutPlan = _workoutPlan.id!;
|
||||
_log.routineId = _routine.id!;
|
||||
_log.exerciseBase = _exerciseBase;
|
||||
_log.weightUnit = _setting.weightUnitObj;
|
||||
_log.repetitionUnit = _setting.repetitionUnitObj;
|
||||
@@ -479,7 +479,7 @@ class _LogPageState extends State<LogPage> {
|
||||
|
||||
// Save the entry on the server
|
||||
try {
|
||||
await Provider.of<WorkoutPlansProvider>(context, listen: false)
|
||||
await Provider.of<RoutineProvider>(context, listen: false)
|
||||
.addLog(widget._log);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
@@ -530,9 +530,7 @@ class _LogPageState extends State<LogPage> {
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
...widget._workoutPlan
|
||||
.filterLogsByExerciseBase(widget._exerciseBase, unique: true)
|
||||
.map((log) {
|
||||
...widget._routine.filterLogsByExerciseBase(widget._exerciseBase, unique: true).map((log) {
|
||||
return ListTile(
|
||||
title: Text(log.singleLogRepTextNoNl),
|
||||
subtitle:
|
||||
@@ -644,7 +642,7 @@ class _LogPageState extends State<LogPage> {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Expanded(
|
||||
child: (widget._workoutPlan.filterLogsByExerciseBase(widget._exerciseBase).isNotEmpty)
|
||||
child: (widget._routine.filterLogsByExerciseBase(widget._exerciseBase).isNotEmpty)
|
||||
? getPastLogs()
|
||||
: Container()),
|
||||
// Only show calculator for barbell
|
||||
@@ -727,13 +725,13 @@ class ExerciseOverview extends StatelessWidget {
|
||||
}
|
||||
|
||||
class SessionPage extends StatefulWidget {
|
||||
final WorkoutPlan _workoutPlan;
|
||||
final Routine _routine;
|
||||
final PageController _controller;
|
||||
final TimeOfDay _start;
|
||||
final Map<String, int> _exercisePages;
|
||||
|
||||
const SessionPage(
|
||||
this._workoutPlan,
|
||||
this._routine,
|
||||
this._controller,
|
||||
this._start,
|
||||
this._exercisePages,
|
||||
@@ -761,7 +759,7 @@ class _SessionPageState extends State<SessionPage> {
|
||||
|
||||
timeStartController.text = timeToString(widget._start)!;
|
||||
timeEndController.text = timeToString(TimeOfDay.now())!;
|
||||
_session.workoutId = widget._workoutPlan.id!;
|
||||
_session.routineId = widget._routine.id!;
|
||||
_session.impression = DEFAULT_IMPRESSION;
|
||||
_session.date = DateTime.now();
|
||||
}
|
||||
@@ -904,7 +902,7 @@ class _SessionPageState extends State<SessionPage> {
|
||||
|
||||
// Save the entry on the server
|
||||
try {
|
||||
await Provider.of<WorkoutPlansProvider>(context, listen: false)
|
||||
await Provider.of<RoutineProvider>(context, listen: false)
|
||||
.addSession(_session);
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
@@ -22,11 +22,11 @@ import 'package:provider/provider.dart';
|
||||
import 'package:wger/helpers/colors.dart';
|
||||
import 'package:wger/helpers/ui.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/workouts/log.dart';
|
||||
import 'package:wger/models/workouts/session.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/models/routines/log.dart';
|
||||
import 'package:wger/models/routines/session.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/widgets/routines/charts.dart';
|
||||
import 'package:wger/widgets/measurements/charts.dart';
|
||||
import 'package:wger/widgets/workouts/charts.dart';
|
||||
|
||||
class ExerciseLogChart extends StatelessWidget {
|
||||
final ExerciseBase _base;
|
||||
@@ -36,8 +36,8 @@ class ExerciseLogChart extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final workoutPlansData = Provider.of<WorkoutPlansProvider>(context, listen: false);
|
||||
final workout = workoutPlansData.currentPlan;
|
||||
final workoutPlansData = Provider.of<RoutineProvider>(context, listen: false);
|
||||
final workout = workoutPlansData.currentRoutine;
|
||||
var colors = generateChartColors(1).iterator;
|
||||
|
||||
Future<Map<String, dynamic>> getChartEntries(BuildContext context) async {
|
||||
@@ -18,32 +18,33 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
import 'package:wger/models/routines/routine.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/screens/workout_plan_screen.dart';
|
||||
import 'package:wger/widgets/workouts/day.dart';
|
||||
import 'package:wger/widgets/workouts/forms.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/widgets/routines/day.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
|
||||
class WorkoutPlanDetail extends StatefulWidget {
|
||||
final WorkoutPlan _workoutPlan;
|
||||
class RoutineDetail extends StatefulWidget {
|
||||
final Routine _routine;
|
||||
final Function _changeMode;
|
||||
const WorkoutPlanDetail(this._workoutPlan, this._changeMode);
|
||||
|
||||
const RoutineDetail(this._routine, this._changeMode);
|
||||
|
||||
@override
|
||||
_WorkoutPlanDetailState createState() => _WorkoutPlanDetailState();
|
||||
_RoutineDetailState createState() => _RoutineDetailState();
|
||||
}
|
||||
|
||||
class _WorkoutPlanDetailState extends State<WorkoutPlanDetail> {
|
||||
class _RoutineDetailState extends State<RoutineDetail> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
if (widget._workoutPlan.days.isNotEmpty)
|
||||
if (widget._routine.days.isNotEmpty)
|
||||
ToggleButtons(
|
||||
renderBorder: false,
|
||||
onPressed: (int index) {
|
||||
if (index == 1) {
|
||||
widget._changeMode(WorkoutScreenMode.log);
|
||||
widget._changeMode(RoutineScreenMode.log);
|
||||
}
|
||||
},
|
||||
isSelected: const [true, false],
|
||||
@@ -52,12 +53,12 @@ class _WorkoutPlanDetailState extends State<WorkoutPlanDetail> {
|
||||
Icon(Icons.show_chart),
|
||||
],
|
||||
),
|
||||
if (widget._workoutPlan.description != '')
|
||||
if (widget._routine.description != '')
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(15),
|
||||
child: Text(widget._workoutPlan.description),
|
||||
child: Text(widget._routine.description),
|
||||
),
|
||||
...widget._workoutPlan.days.map((workoutDay) => WorkoutDayWidget(workoutDay)).toList(),
|
||||
...widget._routine.days.map((workoutDay) => RoutineDayWidget(workoutDay)).toList(),
|
||||
Column(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
@@ -68,7 +69,7 @@ class _WorkoutPlanDetailState extends State<WorkoutPlanDetail> {
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).newDay,
|
||||
DayFormWidget(widget._workoutPlan),
|
||||
DayFormWidget(widget._routine),
|
||||
hasListView: true,
|
||||
),
|
||||
);
|
||||
@@ -20,26 +20,26 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/screens/workout_plan_screen.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/widgets/core/text_prompt.dart';
|
||||
|
||||
class WorkoutPlansList extends StatelessWidget {
|
||||
final WorkoutPlansProvider _workoutProvider;
|
||||
class RoutinesList extends StatelessWidget {
|
||||
final RoutineProvider _routineProvider;
|
||||
|
||||
const WorkoutPlansList(this._workoutProvider);
|
||||
const RoutinesList(this._routineProvider);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RefreshIndicator(
|
||||
onRefresh: () => _workoutProvider.fetchAndSetAllPlansSparse(),
|
||||
child: _workoutProvider.items.isEmpty
|
||||
onRefresh: () => _routineProvider.fetchAndSetAllRoutinesSparse(),
|
||||
child: _routineProvider.items.isEmpty
|
||||
? TextPrompt()
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
itemCount: _workoutProvider.items.length,
|
||||
itemCount: _routineProvider.items.length,
|
||||
itemBuilder: (context, index) {
|
||||
final currentWorkout = _workoutProvider.items[index];
|
||||
final currentWorkout = _routineProvider.items[index];
|
||||
return Dismissible(
|
||||
key: Key(currentWorkout.id.toString()),
|
||||
confirmDismiss: (direction) async {
|
||||
@@ -63,8 +63,8 @@ class WorkoutPlansList extends StatelessWidget {
|
||||
),
|
||||
onPressed: () {
|
||||
// Confirmed, delete the workout
|
||||
Provider.of<WorkoutPlansProvider>(context, listen: false)
|
||||
.deleteWorkout(currentWorkout.id!);
|
||||
Provider.of<RoutineProvider>(context, listen: false)
|
||||
.deleteRoutine(currentWorkout.id!);
|
||||
|
||||
// Close the popup
|
||||
Navigator.of(contextDialog).pop();
|
||||
@@ -102,10 +102,10 @@ class WorkoutPlansList extends StatelessWidget {
|
||||
child: Card(
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
_workoutProvider.setCurrentPlan(currentWorkout.id!);
|
||||
_routineProvider.setCurrentPlan(currentWorkout.id!);
|
||||
|
||||
Navigator.of(context)
|
||||
.pushNamed(WorkoutPlanScreen.routeName, arguments: currentWorkout);
|
||||
.pushNamed(RoutineScreen.routeName, arguments: currentWorkout);
|
||||
},
|
||||
title: Text(currentWorkout.name),
|
||||
subtitle: Text(
|
||||
@@ -21,17 +21,18 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:table_calendar/table_calendar.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/workouts/log.dart';
|
||||
import 'package:wger/models/workouts/session.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
import 'package:wger/screens/workout_plan_screen.dart';
|
||||
import 'package:wger/models/routines/log.dart';
|
||||
import 'package:wger/models/routines/routine.dart';
|
||||
import 'package:wger/models/routines/session.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
import 'package:wger/widgets/workouts/log.dart';
|
||||
import 'package:wger/widgets/routines/log.dart';
|
||||
|
||||
class WorkoutLogs extends StatefulWidget {
|
||||
final WorkoutPlan _workoutPlan;
|
||||
final Routine _routine;
|
||||
final Function _changeMode;
|
||||
const WorkoutLogs(this._workoutPlan, this._changeMode);
|
||||
|
||||
const WorkoutLogs(this._routine, this._changeMode);
|
||||
|
||||
@override
|
||||
_WorkoutLogsState createState() => _WorkoutLogsState();
|
||||
@@ -48,7 +49,7 @@ class _WorkoutLogsState extends State<WorkoutLogs> {
|
||||
renderBorder: false,
|
||||
onPressed: (int index) {
|
||||
if (index == 0) {
|
||||
widget._changeMode(WorkoutScreenMode.workout);
|
||||
widget._changeMode(RoutineScreenMode.routine);
|
||||
}
|
||||
},
|
||||
isSelected: const [false, true],
|
||||
@@ -84,7 +85,7 @@ class _WorkoutLogsState extends State<WorkoutLogs> {
|
||||
),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: WorkoutLogCalendar(widget._workoutPlan),
|
||||
child: WorkoutLogCalendar(widget._routine),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -101,9 +102,9 @@ class WorkoutLogEvent {
|
||||
}
|
||||
|
||||
class WorkoutLogCalendar extends StatefulWidget {
|
||||
final WorkoutPlan _workoutPlan;
|
||||
final Routine _routine;
|
||||
|
||||
const WorkoutLogCalendar(this._workoutPlan);
|
||||
const WorkoutLogCalendar(this._routine);
|
||||
|
||||
@override
|
||||
_WorkoutLogCalendarState createState() => _WorkoutLogCalendarState();
|
||||
@@ -132,8 +133,8 @@ class _WorkoutLogCalendarState extends State<WorkoutLogCalendar> {
|
||||
}
|
||||
|
||||
void loadEvents() {
|
||||
for (final date in widget._workoutPlan.logData.keys) {
|
||||
final entry = widget._workoutPlan.logData[date]!;
|
||||
for (final date in widget._routine.logData.keys) {
|
||||
final entry = widget._routine.logData[date]!;
|
||||
_events[DateFormatLists.format(date)] = [
|
||||
WorkoutLogEvent(
|
||||
date,
|
||||
@@ -29,7 +29,7 @@ import 'package:wger/screens/add_exercise_screen.dart';
|
||||
|
||||
import '../../test_data/exercises.dart';
|
||||
import '../../test_data/profile.dart';
|
||||
import '../workout/gym_mode_screen_test.mocks.dart';
|
||||
import '../routine/gym_mode_screen_test.mocks.dart';
|
||||
import 'contribute_exercise_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([AddExerciseProvider, UserProvider])
|
||||
|
||||
@@ -32,7 +32,8 @@ import 'package:wger/providers/user.dart' as _i15;
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake
|
||||
implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
@@ -85,7 +86,8 @@ class _FakeAlias_4 extends _i1.SmartFake implements _i6.Alias {
|
||||
/// A class which mocks [AddExerciseProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockAddExerciseProvider extends _i1.Mock implements _i7.AddExerciseProvider {
|
||||
class MockAddExerciseProvider extends _i1.Mock
|
||||
implements _i7.AddExerciseProvider {
|
||||
MockAddExerciseProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
@@ -374,7 +376,8 @@ class MockAddExerciseProvider extends _i1.Mock implements _i7.AddExerciseProvide
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i4.Translation> addExerciseTranslation(_i4.Translation? exercise) =>
|
||||
_i13.Future<_i4.Translation> addExerciseTranslation(
|
||||
_i4.Translation? exercise) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addExerciseTranslation,
|
||||
|
||||
@@ -24,7 +24,7 @@ import 'package:wger/providers/exercises.dart';
|
||||
import 'package:wger/widgets/exercises/exercises.dart';
|
||||
|
||||
import '../../test_data/exercises.dart';
|
||||
import '../workout/gym_mode_screen_test.mocks.dart';
|
||||
import '../routine/gym_mode_screen_test.mocks.dart';
|
||||
|
||||
void main() {
|
||||
final mockProvider = MockExercisesProvider();
|
||||
|
||||
@@ -193,7 +193,8 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
|
||||
) as _i6.Future<void>);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) => (super.noSuchMethod(
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getDefaultHeaders,
|
||||
[],
|
||||
@@ -239,7 +240,8 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i6.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i6.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i6.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -264,7 +266,8 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i6.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i6.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i6.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -280,7 +283,8 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i6.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i6.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i6.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
|
||||
@@ -193,7 +193,8 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
|
||||
) as _i6.Future<void>);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) => (super.noSuchMethod(
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getDefaultHeaders,
|
||||
[],
|
||||
@@ -239,7 +240,8 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i6.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i6.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i6.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -264,7 +266,8 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i6.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i6.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i6.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -280,7 +283,8 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i6.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i6.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i6.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
|
||||
@@ -23,7 +23,8 @@ import 'package:wger/providers/measurement.dart' as _i4;
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake
|
||||
implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
@@ -33,7 +34,8 @@ class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvi
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeMeasurementCategory_1 extends _i1.SmartFake implements _i3.MeasurementCategory {
|
||||
class _FakeMeasurementCategory_1 extends _i1.SmartFake
|
||||
implements _i3.MeasurementCategory {
|
||||
_FakeMeasurementCategory_1(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
@@ -46,7 +48,8 @@ class _FakeMeasurementCategory_1 extends _i1.SmartFake implements _i3.Measuremen
|
||||
/// A class which mocks [MeasurementProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockMeasurementProvider extends _i1.Mock implements _i4.MeasurementProvider {
|
||||
class MockMeasurementProvider extends _i1.Mock
|
||||
implements _i4.MeasurementProvider {
|
||||
MockMeasurementProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
@@ -127,7 +130,8 @@ class MockMeasurementProvider extends _i1.Mock implements _i4.MeasurementProvide
|
||||
) as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> addCategory(_i3.MeasurementCategory? category) => (super.noSuchMethod(
|
||||
_i5.Future<void> addCategory(_i3.MeasurementCategory? category) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addCategory,
|
||||
[category],
|
||||
|
||||
@@ -106,7 +106,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) => (super.noSuchMethod(
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getDefaultHeaders,
|
||||
[],
|
||||
@@ -152,7 +153,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -177,7 +179,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -193,7 +196,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
|
||||
@@ -25,7 +25,8 @@ import 'package:wger/providers/nutrition.dart' as _i7;
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake
|
||||
implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
@@ -35,7 +36,8 @@ class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvi
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeNutritionalPlan_1 extends _i1.SmartFake implements _i3.NutritionalPlan {
|
||||
class _FakeNutritionalPlan_1 extends _i1.SmartFake
|
||||
implements _i3.NutritionalPlan {
|
||||
_FakeNutritionalPlan_1(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
@@ -78,7 +80,8 @@ class _FakeIngredient_4 extends _i1.SmartFake implements _i6.Ingredient {
|
||||
/// A class which mocks [NutritionPlansProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansProvider {
|
||||
class MockNutritionPlansProvider extends _i1.Mock
|
||||
implements _i7.NutritionPlansProvider {
|
||||
MockNutritionPlansProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
@@ -164,12 +167,14 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansP
|
||||
) as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<_i3.NutritionalPlan> fetchAndSetPlanSparse(int? planId) => (super.noSuchMethod(
|
||||
_i8.Future<_i3.NutritionalPlan> fetchAndSetPlanSparse(int? planId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanSparse,
|
||||
[planId],
|
||||
),
|
||||
returnValue: _i8.Future<_i3.NutritionalPlan>.value(_FakeNutritionalPlan_1(
|
||||
returnValue:
|
||||
_i8.Future<_i3.NutritionalPlan>.value(_FakeNutritionalPlan_1(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanSparse,
|
||||
@@ -179,12 +184,14 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansP
|
||||
) as _i8.Future<_i3.NutritionalPlan>);
|
||||
|
||||
@override
|
||||
_i8.Future<_i3.NutritionalPlan> fetchAndSetPlanFull(int? planId) => (super.noSuchMethod(
|
||||
_i8.Future<_i3.NutritionalPlan> fetchAndSetPlanFull(int? planId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanFull,
|
||||
[planId],
|
||||
),
|
||||
returnValue: _i8.Future<_i3.NutritionalPlan>.value(_FakeNutritionalPlan_1(
|
||||
returnValue:
|
||||
_i8.Future<_i3.NutritionalPlan>.value(_FakeNutritionalPlan_1(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanFull,
|
||||
@@ -194,12 +201,14 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansP
|
||||
) as _i8.Future<_i3.NutritionalPlan>);
|
||||
|
||||
@override
|
||||
_i8.Future<_i3.NutritionalPlan> addPlan(_i3.NutritionalPlan? planData) => (super.noSuchMethod(
|
||||
_i8.Future<_i3.NutritionalPlan> addPlan(_i3.NutritionalPlan? planData) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addPlan,
|
||||
[planData],
|
||||
),
|
||||
returnValue: _i8.Future<_i3.NutritionalPlan>.value(_FakeNutritionalPlan_1(
|
||||
returnValue:
|
||||
_i8.Future<_i3.NutritionalPlan>.value(_FakeNutritionalPlan_1(
|
||||
this,
|
||||
Invocation.method(
|
||||
#addPlan,
|
||||
@@ -304,7 +313,8 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansP
|
||||
) as _i8.Future<_i5.MealItem>);
|
||||
|
||||
@override
|
||||
_i8.Future<void> deleteMealItem(_i5.MealItem? mealItem) => (super.noSuchMethod(
|
||||
_i8.Future<void> deleteMealItem(_i5.MealItem? mealItem) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteMealItem,
|
||||
[mealItem],
|
||||
@@ -314,7 +324,8 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansP
|
||||
) as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<_i6.Ingredient> fetchIngredient(int? ingredientId) => (super.noSuchMethod(
|
||||
_i8.Future<_i6.Ingredient> fetchIngredient(int? ingredientId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchIngredient,
|
||||
[ingredientId],
|
||||
@@ -357,7 +368,8 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansP
|
||||
) as _i8.Future<List<dynamic>>);
|
||||
|
||||
@override
|
||||
_i8.Future<_i6.Ingredient?> searchIngredientWithCode(String? code) => (super.noSuchMethod(
|
||||
_i8.Future<_i6.Ingredient?> searchIngredientWithCode(String? code) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#searchIngredientWithCode,
|
||||
[code],
|
||||
@@ -412,7 +424,8 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansP
|
||||
) as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<void> fetchAndSetLogs(_i3.NutritionalPlan? plan) => (super.noSuchMethod(
|
||||
_i8.Future<void> fetchAndSetLogs(_i3.NutritionalPlan? plan) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetLogs,
|
||||
[plan],
|
||||
|
||||
@@ -25,7 +25,8 @@ import 'package:wger/providers/nutrition.dart' as _i7;
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake
|
||||
implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
@@ -35,7 +36,8 @@ class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvi
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeNutritionalPlan_1 extends _i1.SmartFake implements _i3.NutritionalPlan {
|
||||
class _FakeNutritionalPlan_1 extends _i1.SmartFake
|
||||
implements _i3.NutritionalPlan {
|
||||
_FakeNutritionalPlan_1(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
@@ -78,7 +80,8 @@ class _FakeIngredient_4 extends _i1.SmartFake implements _i6.Ingredient {
|
||||
/// A class which mocks [NutritionPlansProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansProvider {
|
||||
class MockNutritionPlansProvider extends _i1.Mock
|
||||
implements _i7.NutritionPlansProvider {
|
||||
MockNutritionPlansProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
@@ -164,12 +167,14 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansP
|
||||
) as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<_i3.NutritionalPlan> fetchAndSetPlanSparse(int? planId) => (super.noSuchMethod(
|
||||
_i8.Future<_i3.NutritionalPlan> fetchAndSetPlanSparse(int? planId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanSparse,
|
||||
[planId],
|
||||
),
|
||||
returnValue: _i8.Future<_i3.NutritionalPlan>.value(_FakeNutritionalPlan_1(
|
||||
returnValue:
|
||||
_i8.Future<_i3.NutritionalPlan>.value(_FakeNutritionalPlan_1(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanSparse,
|
||||
@@ -179,12 +184,14 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansP
|
||||
) as _i8.Future<_i3.NutritionalPlan>);
|
||||
|
||||
@override
|
||||
_i8.Future<_i3.NutritionalPlan> fetchAndSetPlanFull(int? planId) => (super.noSuchMethod(
|
||||
_i8.Future<_i3.NutritionalPlan> fetchAndSetPlanFull(int? planId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanFull,
|
||||
[planId],
|
||||
),
|
||||
returnValue: _i8.Future<_i3.NutritionalPlan>.value(_FakeNutritionalPlan_1(
|
||||
returnValue:
|
||||
_i8.Future<_i3.NutritionalPlan>.value(_FakeNutritionalPlan_1(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanFull,
|
||||
@@ -194,12 +201,14 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansP
|
||||
) as _i8.Future<_i3.NutritionalPlan>);
|
||||
|
||||
@override
|
||||
_i8.Future<_i3.NutritionalPlan> addPlan(_i3.NutritionalPlan? planData) => (super.noSuchMethod(
|
||||
_i8.Future<_i3.NutritionalPlan> addPlan(_i3.NutritionalPlan? planData) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addPlan,
|
||||
[planData],
|
||||
),
|
||||
returnValue: _i8.Future<_i3.NutritionalPlan>.value(_FakeNutritionalPlan_1(
|
||||
returnValue:
|
||||
_i8.Future<_i3.NutritionalPlan>.value(_FakeNutritionalPlan_1(
|
||||
this,
|
||||
Invocation.method(
|
||||
#addPlan,
|
||||
@@ -304,7 +313,8 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansP
|
||||
) as _i8.Future<_i5.MealItem>);
|
||||
|
||||
@override
|
||||
_i8.Future<void> deleteMealItem(_i5.MealItem? mealItem) => (super.noSuchMethod(
|
||||
_i8.Future<void> deleteMealItem(_i5.MealItem? mealItem) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteMealItem,
|
||||
[mealItem],
|
||||
@@ -314,7 +324,8 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansP
|
||||
) as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<_i6.Ingredient> fetchIngredient(int? ingredientId) => (super.noSuchMethod(
|
||||
_i8.Future<_i6.Ingredient> fetchIngredient(int? ingredientId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchIngredient,
|
||||
[ingredientId],
|
||||
@@ -357,7 +368,8 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansP
|
||||
) as _i8.Future<List<dynamic>>);
|
||||
|
||||
@override
|
||||
_i8.Future<_i6.Ingredient?> searchIngredientWithCode(String? code) => (super.noSuchMethod(
|
||||
_i8.Future<_i6.Ingredient?> searchIngredientWithCode(String? code) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#searchIngredientWithCode,
|
||||
[code],
|
||||
@@ -412,7 +424,8 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i7.NutritionPlansP
|
||||
) as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<void> fetchAndSetLogs(_i3.NutritionalPlan? plan) => (super.noSuchMethod(
|
||||
_i8.Future<void> fetchAndSetLogs(_i3.NutritionalPlan? plan) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetLogs,
|
||||
[plan],
|
||||
|
||||
@@ -65,7 +65,8 @@ class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response {
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeStreamedResponse_4 extends _i1.SmartFake implements _i3.StreamedResponse {
|
||||
class _FakeStreamedResponse_4 extends _i1.SmartFake
|
||||
implements _i3.StreamedResponse {
|
||||
_FakeStreamedResponse_4(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
@@ -120,7 +121,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) => (super.noSuchMethod(
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getDefaultHeaders,
|
||||
[],
|
||||
@@ -166,7 +168,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -191,7 +194,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -207,7 +211,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -272,7 +277,8 @@ class MockAuthProvider extends _i1.Mock implements _i2.AuthProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
set applicationVersion(_i6.PackageInfo? _applicationVersion) => super.noSuchMethod(
|
||||
set applicationVersion(_i6.PackageInfo? _applicationVersion) =>
|
||||
super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#applicationVersion,
|
||||
_applicationVersion,
|
||||
@@ -404,7 +410,8 @@ class MockAuthProvider extends _i1.Mock implements _i2.AuthProvider {
|
||||
#serverUrl: serverUrl,
|
||||
},
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, _i2.LoginActions>>.value(<String, _i2.LoginActions>{}),
|
||||
returnValue: _i5.Future<Map<String, _i2.LoginActions>>.value(
|
||||
<String, _i2.LoginActions>{}),
|
||||
) as _i5.Future<Map<String, _i2.LoginActions>>);
|
||||
|
||||
@override
|
||||
@@ -422,7 +429,8 @@ class MockAuthProvider extends _i1.Mock implements _i2.AuthProvider {
|
||||
serverUrl,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, _i2.LoginActions>>.value(<String, _i2.LoginActions>{}),
|
||||
returnValue: _i5.Future<Map<String, _i2.LoginActions>>.value(
|
||||
<String, _i2.LoginActions>{}),
|
||||
) as _i5.Future<Map<String, _i2.LoginActions>>);
|
||||
|
||||
@override
|
||||
@@ -703,12 +711,14 @@ class MockClient extends _i1.Mock implements _i3.Client {
|
||||
) as _i5.Future<_i9.Uint8List>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i3.StreamedResponse> send(_i3.BaseRequest? request) => (super.noSuchMethod(
|
||||
_i5.Future<_i3.StreamedResponse> send(_i3.BaseRequest? request) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#send,
|
||||
[request],
|
||||
),
|
||||
returnValue: _i5.Future<_i3.StreamedResponse>.value(_FakeStreamedResponse_4(
|
||||
returnValue:
|
||||
_i5.Future<_i3.StreamedResponse>.value(_FakeStreamedResponse_4(
|
||||
this,
|
||||
Invocation.method(
|
||||
#send,
|
||||
|
||||
@@ -65,7 +65,8 @@ class _FakeResponse_3 extends _i1.SmartFake implements _i2.Response {
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeStreamedResponse_4 extends _i1.SmartFake implements _i2.StreamedResponse {
|
||||
class _FakeStreamedResponse_4 extends _i1.SmartFake
|
||||
implements _i2.StreamedResponse {
|
||||
_FakeStreamedResponse_4(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
@@ -111,7 +112,8 @@ class MockAuthProvider extends _i1.Mock implements _i3.AuthProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
set applicationVersion(_i4.PackageInfo? _applicationVersion) => super.noSuchMethod(
|
||||
set applicationVersion(_i4.PackageInfo? _applicationVersion) =>
|
||||
super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#applicationVersion,
|
||||
_applicationVersion,
|
||||
@@ -243,7 +245,8 @@ class MockAuthProvider extends _i1.Mock implements _i3.AuthProvider {
|
||||
#serverUrl: serverUrl,
|
||||
},
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, _i3.LoginActions>>.value(<String, _i3.LoginActions>{}),
|
||||
returnValue: _i5.Future<Map<String, _i3.LoginActions>>.value(
|
||||
<String, _i3.LoginActions>{}),
|
||||
) as _i5.Future<Map<String, _i3.LoginActions>>);
|
||||
|
||||
@override
|
||||
@@ -261,7 +264,8 @@ class MockAuthProvider extends _i1.Mock implements _i3.AuthProvider {
|
||||
serverUrl,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, _i3.LoginActions>>.value(<String, _i3.LoginActions>{}),
|
||||
returnValue: _i5.Future<Map<String, _i3.LoginActions>>.value(
|
||||
<String, _i3.LoginActions>{}),
|
||||
) as _i5.Future<Map<String, _i3.LoginActions>>);
|
||||
|
||||
@override
|
||||
@@ -384,7 +388,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i7.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) => (super.noSuchMethod(
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getDefaultHeaders,
|
||||
[],
|
||||
@@ -430,7 +435,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i7.WgerBaseProvider {
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -455,7 +461,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i7.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -471,7 +478,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i7.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -703,12 +711,14 @@ class MockClient extends _i1.Mock implements _i2.Client {
|
||||
) as _i5.Future<_i9.Uint8List>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) => (super.noSuchMethod(
|
||||
_i5.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#send,
|
||||
[request],
|
||||
),
|
||||
returnValue: _i5.Future<_i2.StreamedResponse>.value(_FakeStreamedResponse_4(
|
||||
returnValue:
|
||||
_i5.Future<_i2.StreamedResponse>.value(_FakeStreamedResponse_4(
|
||||
this,
|
||||
Invocation.method(
|
||||
#send,
|
||||
|
||||
@@ -31,7 +31,8 @@ class _FakeResponse_0 extends _i1.SmartFake implements _i2.Response {
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeStreamedResponse_1 extends _i1.SmartFake implements _i2.StreamedResponse {
|
||||
class _FakeStreamedResponse_1 extends _i1.SmartFake
|
||||
implements _i2.StreamedResponse {
|
||||
_FakeStreamedResponse_1(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
@@ -244,12 +245,14 @@ class MockClient extends _i1.Mock implements _i2.Client {
|
||||
) as _i3.Future<_i5.Uint8List>);
|
||||
|
||||
@override
|
||||
_i3.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) => (super.noSuchMethod(
|
||||
_i3.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#send,
|
||||
[request],
|
||||
),
|
||||
returnValue: _i3.Future<_i2.StreamedResponse>.value(_FakeStreamedResponse_1(
|
||||
returnValue:
|
||||
_i3.Future<_i2.StreamedResponse>.value(_FakeStreamedResponse_1(
|
||||
this,
|
||||
Invocation.method(
|
||||
#send,
|
||||
|
||||
@@ -24,14 +24,14 @@ import 'package:mockito/mockito.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/providers/base_provider.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/screens/gym_mode.dart';
|
||||
import 'package:wger/screens/workout_plan_screen.dart';
|
||||
import 'package:wger/widgets/workouts/forms.dart';
|
||||
import 'package:wger/widgets/workouts/gym_mode.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
import 'package:wger/widgets/routines/gym_mode.dart';
|
||||
|
||||
import '../../test_data/exercises.dart';
|
||||
import '../../test_data/workouts.dart';
|
||||
import '../../test_data/routines.dart';
|
||||
import 'gym_mode_screen_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([WgerBaseProvider, ExercisesProvider])
|
||||
@@ -40,15 +40,15 @@ void main() {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
|
||||
final mockExerciseProvider = MockExercisesProvider();
|
||||
final workoutPlan = getWorkout();
|
||||
final routine = getRoutine();
|
||||
final bases = getTestExerciseBases();
|
||||
|
||||
Widget createHomeScreen({locale = 'en'}) {
|
||||
return ChangeNotifierProvider<WorkoutPlansProvider>(
|
||||
create: (context) => WorkoutPlansProvider(
|
||||
return ChangeNotifierProvider<RoutineProvider>(
|
||||
create: (context) => RoutineProvider(
|
||||
mockBaseProvider,
|
||||
mockExerciseProvider,
|
||||
[workoutPlan],
|
||||
[routine],
|
||||
),
|
||||
child: ChangeNotifierProvider<ExercisesProvider>(
|
||||
create: (context) => mockExerciseProvider,
|
||||
@@ -60,14 +60,14 @@ void main() {
|
||||
home: TextButton(
|
||||
onPressed: () => key.currentState!.push(
|
||||
MaterialPageRoute<void>(
|
||||
settings: RouteSettings(arguments: workoutPlan.days.first),
|
||||
settings: RouteSettings(arguments: routine.days.first),
|
||||
builder: (_) => GymModeScreen(),
|
||||
),
|
||||
),
|
||||
child: const SizedBox(),
|
||||
),
|
||||
routes: {
|
||||
WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
|
||||
RoutineScreen.routeName: (ctx) => RoutineScreen(),
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -1,5 +1,5 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// in wger/test/workout/gym_mode_screen_test.dart.
|
||||
// Mocks generated by Mockito 5.4.0 from annotations
|
||||
// in wger/test/routine/gym_mode_screen_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
@@ -68,7 +68,8 @@ class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response {
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeWgerBaseProvider_4 extends _i1.SmartFake implements _i4.WgerBaseProvider {
|
||||
class _FakeWgerBaseProvider_4 extends _i1.SmartFake
|
||||
implements _i4.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_4(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
@@ -88,7 +89,8 @@ class _FakeExerciseBase_5 extends _i1.SmartFake implements _i5.ExerciseBase {
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeExerciseCategory_6 extends _i1.SmartFake implements _i6.ExerciseCategory {
|
||||
class _FakeExerciseCategory_6 extends _i1.SmartFake
|
||||
implements _i6.ExerciseCategory {
|
||||
_FakeExerciseCategory_6(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
@@ -144,7 +146,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
Invocation.getter(#auth),
|
||||
),
|
||||
) as _i2.AuthProvider);
|
||||
|
||||
@override
|
||||
set auth(_i2.AuthProvider? _auth) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
@@ -153,7 +154,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
_i3.Client get client => (super.noSuchMethod(
|
||||
Invocation.getter(#client),
|
||||
@@ -162,7 +162,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
Invocation.getter(#client),
|
||||
),
|
||||
) as _i3.Client);
|
||||
|
||||
@override
|
||||
set client(_i3.Client? _client) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
@@ -171,9 +170,9 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) => (super.noSuchMethod(
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getDefaultHeaders,
|
||||
[],
|
||||
@@ -181,7 +180,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValue: <String, String>{},
|
||||
) as Map<String, String>);
|
||||
|
||||
@override
|
||||
Uri makeUrl(
|
||||
String? path, {
|
||||
@@ -212,16 +210,15 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
),
|
||||
) as Uri);
|
||||
|
||||
@override
|
||||
_i10.Future<Map<String, dynamic>> fetch(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i10.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i10.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i10.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i10.Future<List<dynamic>> fetchPaginated(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -230,7 +227,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValue: _i10.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
) as _i10.Future<List<dynamic>>);
|
||||
|
||||
@override
|
||||
_i10.Future<Map<String, dynamic>> post(
|
||||
Map<String, dynamic>? data,
|
||||
@@ -244,9 +240,9 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i10.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i10.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i10.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i10.Future<Map<String, dynamic>> patch(
|
||||
Map<String, dynamic>? data,
|
||||
@@ -260,9 +256,9 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i10.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i10.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i10.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i10.Future<_i3.Response> deleteRequest(
|
||||
String? url,
|
||||
@@ -305,67 +301,60 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
Invocation.getter(#baseProvider),
|
||||
),
|
||||
) as _i4.WgerBaseProvider);
|
||||
|
||||
@override
|
||||
set exerciseBases(List<_i5.ExerciseBase>? exercisesBases) => super.noSuchMethod(
|
||||
set exerciseBases(List<_i5.ExerciseBase>? exercisesBases) =>
|
||||
super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#exerciseBases,
|
||||
exercisesBases,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i5.ExerciseBase> get filteredExerciseBases => (super.noSuchMethod(
|
||||
Invocation.getter(#filteredExerciseBases),
|
||||
returnValue: <_i5.ExerciseBase>[],
|
||||
) as List<_i5.ExerciseBase>);
|
||||
|
||||
@override
|
||||
set filteredExerciseBases(List<_i5.ExerciseBase>? newFilteredExercises) => super.noSuchMethod(
|
||||
set filteredExerciseBases(List<_i5.ExerciseBase>? newFilteredExercises) =>
|
||||
super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#filteredExerciseBases,
|
||||
newFilteredExercises,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<int, List<_i5.ExerciseBase>> get exerciseBasesByVariation => (super.noSuchMethod(
|
||||
Map<int, List<_i5.ExerciseBase>> get exerciseBasesByVariation =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#exerciseBasesByVariation),
|
||||
returnValue: <int, List<_i5.ExerciseBase>>{},
|
||||
) as Map<int, List<_i5.ExerciseBase>>);
|
||||
|
||||
@override
|
||||
List<_i5.ExerciseBase> get bases => (super.noSuchMethod(
|
||||
Invocation.getter(#bases),
|
||||
returnValue: <_i5.ExerciseBase>[],
|
||||
) as List<_i5.ExerciseBase>);
|
||||
|
||||
@override
|
||||
List<_i6.ExerciseCategory> get categories => (super.noSuchMethod(
|
||||
Invocation.getter(#categories),
|
||||
returnValue: <_i6.ExerciseCategory>[],
|
||||
) as List<_i6.ExerciseCategory>);
|
||||
|
||||
@override
|
||||
List<_i8.Muscle> get muscles => (super.noSuchMethod(
|
||||
Invocation.getter(#muscles),
|
||||
returnValue: <_i8.Muscle>[],
|
||||
) as List<_i8.Muscle>);
|
||||
|
||||
@override
|
||||
List<_i7.Equipment> get equipment => (super.noSuchMethod(
|
||||
Invocation.getter(#equipment),
|
||||
returnValue: <_i7.Equipment>[],
|
||||
) as List<_i7.Equipment>);
|
||||
|
||||
@override
|
||||
List<_i9.Language> get languages => (super.noSuchMethod(
|
||||
Invocation.getter(#languages),
|
||||
returnValue: <_i9.Language>[],
|
||||
) as List<_i9.Language>);
|
||||
|
||||
@override
|
||||
set languages(List<_i9.Language>? languages) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
@@ -374,13 +363,11 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
bool get hasListeners => (super.noSuchMethod(
|
||||
Invocation.getter(#hasListeners),
|
||||
returnValue: false,
|
||||
) as bool);
|
||||
|
||||
@override
|
||||
_i10.Future<void> setFilters(_i11.Filters? newFilters) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -390,7 +377,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> findByFilters() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -400,7 +386,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
void clear() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -409,7 +394,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
_i5.ExerciseBase findExerciseBaseById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -424,7 +408,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
),
|
||||
),
|
||||
) as _i5.ExerciseBase);
|
||||
|
||||
@override
|
||||
List<_i5.ExerciseBase> findExerciseBasesByVariationId(
|
||||
int? id, {
|
||||
@@ -438,7 +421,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
),
|
||||
returnValue: <_i5.ExerciseBase>[],
|
||||
) as List<_i5.ExerciseBase>);
|
||||
|
||||
@override
|
||||
_i6.ExerciseCategory findCategoryById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -453,7 +435,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
),
|
||||
),
|
||||
) as _i6.ExerciseCategory);
|
||||
|
||||
@override
|
||||
_i7.Equipment findEquipmentById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -468,7 +449,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
),
|
||||
),
|
||||
) as _i7.Equipment);
|
||||
|
||||
@override
|
||||
_i8.Muscle findMuscleById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -483,7 +463,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
),
|
||||
),
|
||||
) as _i8.Muscle);
|
||||
|
||||
@override
|
||||
_i9.Language findLanguageById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -498,7 +477,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
),
|
||||
),
|
||||
) as _i9.Language);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetCategories() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -508,7 +486,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetVariations() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -518,7 +495,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetMuscles() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -528,7 +504,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetEquipment() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -538,7 +513,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetLanguages() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -548,9 +522,9 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<_i5.ExerciseBase> fetchAndSetExerciseBase(int? exerciseBaseId) => (super.noSuchMethod(
|
||||
_i10.Future<_i5.ExerciseBase> fetchAndSetExerciseBase(int? exerciseBaseId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetExerciseBase,
|
||||
[exerciseBaseId],
|
||||
@@ -563,9 +537,9 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
),
|
||||
)),
|
||||
) as _i10.Future<_i5.ExerciseBase>);
|
||||
|
||||
@override
|
||||
_i5.ExerciseBase readExerciseBaseFromBaseInfo(dynamic baseData) => (super.noSuchMethod(
|
||||
_i5.ExerciseBase readExerciseBaseFromBaseInfo(dynamic baseData) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#readExerciseBaseFromBaseInfo,
|
||||
[baseData],
|
||||
@@ -578,7 +552,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
),
|
||||
),
|
||||
) as _i5.ExerciseBase);
|
||||
|
||||
@override
|
||||
_i10.Future<void> checkExerciseCacheVersion() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -588,7 +561,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetExercises() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -598,7 +570,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<List<_i5.ExerciseBase>> searchExercise(
|
||||
String? name, {
|
||||
@@ -614,9 +585,9 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
#searchEnglish: searchEnglish,
|
||||
},
|
||||
),
|
||||
returnValue: _i10.Future<List<_i5.ExerciseBase>>.value(<_i5.ExerciseBase>[]),
|
||||
returnValue:
|
||||
_i10.Future<List<_i5.ExerciseBase>>.value(<_i5.ExerciseBase>[]),
|
||||
) as _i10.Future<List<_i5.ExerciseBase>>);
|
||||
|
||||
@override
|
||||
void addListener(_i12.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -625,7 +596,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -634,7 +604,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -643,7 +612,6 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void notifyListeners() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -22,17 +22,17 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/models/workouts/repetition_unit.dart';
|
||||
import 'package:wger/models/workouts/setting.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/screens/workout_plan_screen.dart';
|
||||
import 'package:wger/widgets/workouts/forms.dart';
|
||||
import 'package:wger/models/routines/repetition_unit.dart';
|
||||
import 'package:wger/models/routines/setting.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
|
||||
import 'repetition_unit_form_widget_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([WorkoutPlansProvider])
|
||||
@GenerateMocks([RoutineProvider])
|
||||
void main() {
|
||||
var mockWorkoutPlans = MockWorkoutPlansProvider();
|
||||
var mockRoutineProvider = MockRoutineProvider();
|
||||
|
||||
const unit1 = RepetitionUnit(id: 1, name: 'some rep unit');
|
||||
const unit2 = RepetitionUnit(id: 2, name: 'another name');
|
||||
@@ -51,15 +51,15 @@ void main() {
|
||||
setting1.repetitionUnitObj = unit1;
|
||||
|
||||
setUp(() {
|
||||
mockWorkoutPlans = MockWorkoutPlansProvider();
|
||||
when(mockWorkoutPlans.repetitionUnits).thenAnswer((_) => [unit1, unit2, unit3]);
|
||||
mockRoutineProvider = MockRoutineProvider();
|
||||
when(mockRoutineProvider.repetitionUnits).thenAnswer((_) => [unit1, unit2, unit3]);
|
||||
});
|
||||
|
||||
Widget createHomeScreen() {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
|
||||
return ChangeNotifierProvider<WorkoutPlansProvider>(
|
||||
create: (context) => mockWorkoutPlans,
|
||||
return ChangeNotifierProvider<RoutineProvider>(
|
||||
create: (context) => mockRoutineProvider,
|
||||
child: MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
@@ -68,7 +68,7 @@ void main() {
|
||||
body: RepetitionUnitInputWidget(setting1),
|
||||
),
|
||||
routes: {
|
||||
WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
|
||||
RoutineScreen.routeName: (ctx) => RoutineScreen(),
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -1,5 +1,5 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// in wger/test/workout/repetition_unit_form_widget_test.dart.
|
||||
// Mocks generated by Mockito 5.4.0 from annotations
|
||||
// in wger/test/routine/repetition_unit_form_widget_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
@@ -9,16 +9,16 @@ import 'dart:ui' as _i15;
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:wger/models/exercises/base.dart' as _i13;
|
||||
import 'package:wger/models/exercises/translation.dart' as _i14;
|
||||
import 'package:wger/models/workouts/day.dart' as _i6;
|
||||
import 'package:wger/models/workouts/log.dart' as _i10;
|
||||
import 'package:wger/models/workouts/repetition_unit.dart' as _i4;
|
||||
import 'package:wger/models/workouts/session.dart' as _i9;
|
||||
import 'package:wger/models/workouts/set.dart' as _i7;
|
||||
import 'package:wger/models/workouts/setting.dart' as _i8;
|
||||
import 'package:wger/models/workouts/weight_unit.dart' as _i3;
|
||||
import 'package:wger/models/workouts/workout_plan.dart' as _i5;
|
||||
import 'package:wger/models/routines/day.dart' as _i6;
|
||||
import 'package:wger/models/routines/log.dart' as _i10;
|
||||
import 'package:wger/models/routines/repetition_unit.dart' as _i4;
|
||||
import 'package:wger/models/routines/routine.dart' as _i5;
|
||||
import 'package:wger/models/routines/session.dart' as _i9;
|
||||
import 'package:wger/models/routines/set.dart' as _i7;
|
||||
import 'package:wger/models/routines/setting.dart' as _i8;
|
||||
import 'package:wger/models/routines/weight_unit.dart' as _i3;
|
||||
import 'package:wger/providers/base_provider.dart' as _i2;
|
||||
import 'package:wger/providers/workout_plans.dart' as _i11;
|
||||
import 'package:wger/providers/routine.dart' as _i11;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
@@ -61,8 +61,8 @@ class _FakeRepetitionUnit_2 extends _i1.SmartFake implements _i4.RepetitionUnit
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeWorkoutPlan_3 extends _i1.SmartFake implements _i5.WorkoutPlan {
|
||||
_FakeWorkoutPlan_3(
|
||||
class _FakeRoutine_3 extends _i1.SmartFake implements _i5.Routine {
|
||||
_FakeRoutine_3(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
@@ -121,11 +121,11 @@ class _FakeLog_8 extends _i1.SmartFake implements _i10.Log {
|
||||
);
|
||||
}
|
||||
|
||||
/// A class which mocks [WorkoutPlansProvider].
|
||||
/// A class which mocks [RoutineProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProvider {
|
||||
MockWorkoutPlansProvider() {
|
||||
class MockRoutineProvider extends _i1.Mock implements _i11.RoutineProvider {
|
||||
MockRoutineProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@@ -139,10 +139,10 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
) as _i2.WgerBaseProvider);
|
||||
|
||||
@override
|
||||
List<_i5.WorkoutPlan> get items => (super.noSuchMethod(
|
||||
List<_i5.Routine> get items => (super.noSuchMethod(
|
||||
Invocation.getter(#items),
|
||||
returnValue: <_i5.WorkoutPlan>[],
|
||||
) as List<_i5.WorkoutPlan>);
|
||||
returnValue: <_i5.Routine>[],
|
||||
) as List<_i5.Routine>);
|
||||
|
||||
@override
|
||||
List<_i3.WeightUnit> get weightUnits => (super.noSuchMethod(
|
||||
@@ -190,28 +190,28 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i5.WorkoutPlan> getPlans() => (super.noSuchMethod(
|
||||
List<_i5.Routine> getPlans() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getPlans,
|
||||
[],
|
||||
),
|
||||
returnValue: <_i5.WorkoutPlan>[],
|
||||
) as List<_i5.WorkoutPlan>);
|
||||
returnValue: <_i5.Routine>[],
|
||||
) as List<_i5.Routine>);
|
||||
|
||||
@override
|
||||
_i5.WorkoutPlan findById(int? id) => (super.noSuchMethod(
|
||||
_i5.Routine findById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _FakeWorkoutPlan_3(
|
||||
returnValue: _FakeRoutine_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#findById,
|
||||
[id],
|
||||
),
|
||||
),
|
||||
) as _i5.WorkoutPlan);
|
||||
) as _i5.Routine);
|
||||
|
||||
@override
|
||||
int findIndexById(int? id) => (super.noSuchMethod(
|
||||
@@ -232,7 +232,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
);
|
||||
|
||||
@override
|
||||
void resetCurrentPlan() => super.noSuchMethod(
|
||||
void resetCurrentRoutine() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#resetCurrentPlan,
|
||||
[],
|
||||
@@ -241,7 +241,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
);
|
||||
|
||||
@override
|
||||
_i12.Future<void> fetchAndSetAllPlansFull() => (super.noSuchMethod(
|
||||
_i12.Future<void> fetchAndSetAllRoutinesFull() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetAllPlansFull,
|
||||
[],
|
||||
@@ -251,7 +251,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
) as _i12.Future<void>);
|
||||
|
||||
@override
|
||||
_i12.Future<void> fetchAndSetAllPlansSparse() => (super.noSuchMethod(
|
||||
_i12.Future<void> fetchAndSetAllRoutinesSparse() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetAllPlansSparse,
|
||||
[],
|
||||
@@ -261,52 +261,52 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
) as _i12.Future<void>);
|
||||
|
||||
@override
|
||||
_i12.Future<_i5.WorkoutPlan> fetchAndSetPlanSparse(int? planId) => (super.noSuchMethod(
|
||||
_i12.Future<_i5.Routine> fetchAndSetRoutineSparse(int? planId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanSparse,
|
||||
[planId],
|
||||
),
|
||||
returnValue: _i12.Future<_i5.WorkoutPlan>.value(_FakeWorkoutPlan_3(
|
||||
returnValue: _i12.Future<_i5.Routine>.value(_FakeRoutine_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanSparse,
|
||||
[planId],
|
||||
),
|
||||
)),
|
||||
) as _i12.Future<_i5.WorkoutPlan>);
|
||||
) as _i12.Future<_i5.Routine>);
|
||||
|
||||
@override
|
||||
_i12.Future<_i5.WorkoutPlan> fetchAndSetWorkoutPlanFull(int? workoutId) => (super.noSuchMethod(
|
||||
_i12.Future<_i5.Routine> fetchAndSetRoutineFull(int? workoutId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetWorkoutPlanFull,
|
||||
[workoutId],
|
||||
),
|
||||
returnValue: _i12.Future<_i5.WorkoutPlan>.value(_FakeWorkoutPlan_3(
|
||||
returnValue: _i12.Future<_i5.Routine>.value(_FakeRoutine_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchAndSetWorkoutPlanFull,
|
||||
[workoutId],
|
||||
),
|
||||
)),
|
||||
) as _i12.Future<_i5.WorkoutPlan>);
|
||||
) as _i12.Future<_i5.Routine>);
|
||||
|
||||
@override
|
||||
_i12.Future<_i5.WorkoutPlan> addWorkout(_i5.WorkoutPlan? workout) => (super.noSuchMethod(
|
||||
_i12.Future<_i5.Routine> addRoutine(_i5.Routine? workout) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addWorkout,
|
||||
[workout],
|
||||
),
|
||||
returnValue: _i12.Future<_i5.WorkoutPlan>.value(_FakeWorkoutPlan_3(
|
||||
returnValue: _i12.Future<_i5.Routine>.value(_FakeRoutine_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#addWorkout,
|
||||
[workout],
|
||||
),
|
||||
)),
|
||||
) as _i12.Future<_i5.WorkoutPlan>);
|
||||
) as _i12.Future<_i5.Routine>);
|
||||
|
||||
@override
|
||||
_i12.Future<void> editWorkout(_i5.WorkoutPlan? workout) => (super.noSuchMethod(
|
||||
_i12.Future<void> editRoutine(_i5.Routine? workout) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#editWorkout,
|
||||
[workout],
|
||||
@@ -316,7 +316,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
) as _i12.Future<void>);
|
||||
|
||||
@override
|
||||
_i12.Future<void> deleteWorkout(int? id) => (super.noSuchMethod(
|
||||
_i12.Future<void> deleteRoutine(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteWorkout,
|
||||
[id],
|
||||
@@ -327,7 +327,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
|
||||
@override
|
||||
_i12.Future<Map<String, dynamic>> fetchLogData(
|
||||
_i5.WorkoutPlan? workout,
|
||||
_i5.Routine? workout,
|
||||
_i13.ExerciseBase? base,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
@@ -374,7 +374,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
@override
|
||||
_i12.Future<_i6.Day> addDay(
|
||||
_i6.Day? day,
|
||||
_i5.WorkoutPlan? workout,
|
||||
_i5.Routine? workout,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -18,13 +18,13 @@
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../test_data/workouts.dart';
|
||||
import '../../test_data/routines.dart';
|
||||
|
||||
void main() {
|
||||
group('Test the getSmartTextRepr method for a set', () {
|
||||
test('Repetitions and weigh units', () async {
|
||||
final workout = getWorkout();
|
||||
final set = workout.days.first.sets.first;
|
||||
final routine = getRoutine();
|
||||
final set = routine.days.first.sets.first;
|
||||
final exercise1 = set.exerciseBasesObj[0];
|
||||
|
||||
expect(set.getSmartTextRepr(exercise1), '6 × 80 kg (3 RiR)');
|
||||
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:wger/models/workouts/repetition_unit.dart';
|
||||
import 'package:wger/models/workouts/setting.dart';
|
||||
import 'package:wger/models/workouts/weight_unit.dart';
|
||||
import 'package:wger/models/routines/repetition_unit.dart';
|
||||
import 'package:wger/models/routines/setting.dart';
|
||||
import 'package:wger/models/routines/weight_unit.dart';
|
||||
|
||||
void main() {
|
||||
group('Test the singleSettingRepText method', () {
|
||||
@@ -22,18 +22,18 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/models/workouts/setting.dart';
|
||||
import 'package:wger/models/workouts/weight_unit.dart';
|
||||
import 'package:wger/models/routines/setting.dart';
|
||||
import 'package:wger/models/routines/weight_unit.dart';
|
||||
import 'package:wger/providers/body_weight.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/screens/workout_plan_screen.dart';
|
||||
import 'package:wger/widgets/workouts/forms.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
|
||||
import './workout_form_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([BodyWeightProvider])
|
||||
void main() {
|
||||
var mockWorkoutPlans = MockWorkoutPlansProvider();
|
||||
var mockRoutineProvider = MockRoutineProvider();
|
||||
|
||||
const unit1 = WeightUnit(id: 1, name: 'kg');
|
||||
const unit2 = WeightUnit(id: 2, name: 'donkeys');
|
||||
@@ -52,15 +52,15 @@ void main() {
|
||||
setting1.weightUnitObj = unit1;
|
||||
|
||||
setUp(() {
|
||||
mockWorkoutPlans = MockWorkoutPlansProvider();
|
||||
when(mockWorkoutPlans.weightUnits).thenAnswer((_) => [unit1, unit2, unit3]);
|
||||
mockRoutineProvider = MockRoutineProvider();
|
||||
when(mockRoutineProvider.weightUnits).thenAnswer((_) => [unit1, unit2, unit3]);
|
||||
});
|
||||
|
||||
Widget createHomeScreen() {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
|
||||
return ChangeNotifierProvider<WorkoutPlansProvider>(
|
||||
create: (context) => mockWorkoutPlans,
|
||||
return ChangeNotifierProvider<RoutineProvider>(
|
||||
create: (context) => mockRoutineProvider,
|
||||
child: MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
@@ -69,7 +69,7 @@ void main() {
|
||||
body: WeightUnitInputWidget(setting1),
|
||||
),
|
||||
routes: {
|
||||
WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
|
||||
RoutineScreen.routeName: (ctx) => RoutineScreen(),
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -1,5 +1,5 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// in wger/test/workout/weight_unit_form_widget_test.dart.
|
||||
// Mocks generated by Mockito 5.4.0 from annotations
|
||||
// in wger/test/routine/weight_unit_form_widget_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
@@ -22,7 +22,8 @@ import 'package:wger/providers/body_weight.dart' as _i4;
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake
|
||||
implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
@@ -45,7 +46,8 @@ class _FakeWeightEntry_1 extends _i1.SmartFake implements _i3.WeightEntry {
|
||||
/// A class which mocks [BodyWeightProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockBodyWeightProvider extends _i1.Mock implements _i4.BodyWeightProvider {
|
||||
class MockBodyWeightProvider extends _i1.Mock
|
||||
implements _i4.BodyWeightProvider {
|
||||
MockBodyWeightProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
@@ -58,13 +60,11 @@ class MockBodyWeightProvider extends _i1.Mock implements _i4.BodyWeightProvider
|
||||
Invocation.getter(#baseProvider),
|
||||
),
|
||||
) as _i2.WgerBaseProvider);
|
||||
|
||||
@override
|
||||
List<_i3.WeightEntry> get items => (super.noSuchMethod(
|
||||
Invocation.getter(#items),
|
||||
returnValue: <_i3.WeightEntry>[],
|
||||
) as List<_i3.WeightEntry>);
|
||||
|
||||
@override
|
||||
set items(List<_i3.WeightEntry>? entries) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
@@ -73,13 +73,11 @@ class MockBodyWeightProvider extends _i1.Mock implements _i4.BodyWeightProvider
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
bool get hasListeners => (super.noSuchMethod(
|
||||
Invocation.getter(#hasListeners),
|
||||
returnValue: false,
|
||||
) as bool);
|
||||
|
||||
@override
|
||||
void clear() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -88,7 +86,6 @@ class MockBodyWeightProvider extends _i1.Mock implements _i4.BodyWeightProvider
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
_i3.WeightEntry findById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -103,24 +100,24 @@ class MockBodyWeightProvider extends _i1.Mock implements _i4.BodyWeightProvider
|
||||
),
|
||||
),
|
||||
) as _i3.WeightEntry);
|
||||
|
||||
@override
|
||||
_i3.WeightEntry? findByDate(DateTime? date) => (super.noSuchMethod(Invocation.method(
|
||||
_i3.WeightEntry? findByDate(DateTime? date) =>
|
||||
(super.noSuchMethod(Invocation.method(
|
||||
#findByDate,
|
||||
[date],
|
||||
)) as _i3.WeightEntry?);
|
||||
|
||||
@override
|
||||
_i5.Future<List<_i3.WeightEntry>> fetchAndSetEntries() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetEntries,
|
||||
[],
|
||||
),
|
||||
returnValue: _i5.Future<List<_i3.WeightEntry>>.value(<_i3.WeightEntry>[]),
|
||||
returnValue:
|
||||
_i5.Future<List<_i3.WeightEntry>>.value(<_i3.WeightEntry>[]),
|
||||
) as _i5.Future<List<_i3.WeightEntry>>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i3.WeightEntry> addEntry(_i3.WeightEntry? entry) => (super.noSuchMethod(
|
||||
_i5.Future<_i3.WeightEntry> addEntry(_i3.WeightEntry? entry) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addEntry,
|
||||
[entry],
|
||||
@@ -133,7 +130,6 @@ class MockBodyWeightProvider extends _i1.Mock implements _i4.BodyWeightProvider
|
||||
),
|
||||
)),
|
||||
) as _i5.Future<_i3.WeightEntry>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> editEntry(_i3.WeightEntry? entry) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -143,7 +139,6 @@ class MockBodyWeightProvider extends _i1.Mock implements _i4.BodyWeightProvider
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> deleteEntry(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -153,7 +148,6 @@ class MockBodyWeightProvider extends _i1.Mock implements _i4.BodyWeightProvider
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
void addListener(_i6.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -162,7 +156,6 @@ class MockBodyWeightProvider extends _i1.Mock implements _i4.BodyWeightProvider
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i6.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -171,7 +164,6 @@ class MockBodyWeightProvider extends _i1.Mock implements _i4.BodyWeightProvider
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -180,7 +172,6 @@ class MockBodyWeightProvider extends _i1.Mock implements _i4.BodyWeightProvider
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void notifyListeners() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -23,36 +23,36 @@ import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/widgets/workouts/forms.dart';
|
||||
import 'package:wger/models/routines/day.dart';
|
||||
import 'package:wger/models/routines/routine.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
|
||||
import '../../test_data/workouts.dart';
|
||||
import '../../test_data/routines.dart';
|
||||
import 'workout_day_form_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([WorkoutPlansProvider])
|
||||
@GenerateMocks([RoutineProvider])
|
||||
void main() {
|
||||
var mockWorkoutPlans = MockWorkoutPlansProvider();
|
||||
WorkoutPlan workoutPlan = WorkoutPlan.empty();
|
||||
var mockRoutineProvider = MockRoutineProvider();
|
||||
Routine routine = Routine.empty();
|
||||
|
||||
setUp(() {
|
||||
workoutPlan = getWorkout();
|
||||
mockWorkoutPlans = MockWorkoutPlansProvider();
|
||||
routine = getRoutine();
|
||||
mockRoutineProvider = MockRoutineProvider();
|
||||
});
|
||||
|
||||
Widget createHomeScreen({locale = 'en'}) {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
|
||||
return ChangeNotifierProvider<WorkoutPlansProvider>(
|
||||
create: (context) => mockWorkoutPlans,
|
||||
return ChangeNotifierProvider<RoutineProvider>(
|
||||
create: (context) => mockRoutineProvider,
|
||||
child: MaterialApp(
|
||||
locale: Locale(locale),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
navigatorKey: key,
|
||||
home: Scaffold(
|
||||
body: DayFormWidget(workoutPlan),
|
||||
body: DayFormWidget(routine),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -68,7 +68,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Test creating a new day', (WidgetTester tester) async {
|
||||
when(mockWorkoutPlans.addDay(any, any)).thenAnswer((_) => Future.value(Day()));
|
||||
when(mockRoutineProvider.addDay(any, any)).thenAnswer((_) => Future.value(Day()));
|
||||
|
||||
await tester.pumpWidget(createHomeScreen());
|
||||
await tester.pumpAndSettle();
|
||||
@@ -78,7 +78,7 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('field-checkbox-1')));
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
verify(mockWorkoutPlans.addDay(any, any));
|
||||
verify(mockRoutineProvider.addDay(any, any));
|
||||
|
||||
// Successful redirect to workout plan detail page
|
||||
//await tester.pumpAndSettle();
|
||||
@@ -1,5 +1,5 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// in wger/test/workout/workout_day_form_test.dart.
|
||||
// Mocks generated by Mockito 5.4.0 from annotations
|
||||
// in wger/test/routine/workout_day_form_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
@@ -9,16 +9,16 @@ import 'dart:ui' as _i15;
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:wger/models/exercises/base.dart' as _i13;
|
||||
import 'package:wger/models/exercises/translation.dart' as _i14;
|
||||
import 'package:wger/models/workouts/day.dart' as _i6;
|
||||
import 'package:wger/models/workouts/log.dart' as _i10;
|
||||
import 'package:wger/models/workouts/repetition_unit.dart' as _i4;
|
||||
import 'package:wger/models/workouts/session.dart' as _i9;
|
||||
import 'package:wger/models/workouts/set.dart' as _i7;
|
||||
import 'package:wger/models/workouts/setting.dart' as _i8;
|
||||
import 'package:wger/models/workouts/weight_unit.dart' as _i3;
|
||||
import 'package:wger/models/workouts/workout_plan.dart' as _i5;
|
||||
import 'package:wger/models/routines/day.dart' as _i6;
|
||||
import 'package:wger/models/routines/log.dart' as _i10;
|
||||
import 'package:wger/models/routines/repetition_unit.dart' as _i4;
|
||||
import 'package:wger/models/routines/routine.dart' as _i5;
|
||||
import 'package:wger/models/routines/session.dart' as _i9;
|
||||
import 'package:wger/models/routines/set.dart' as _i7;
|
||||
import 'package:wger/models/routines/setting.dart' as _i8;
|
||||
import 'package:wger/models/routines/weight_unit.dart' as _i3;
|
||||
import 'package:wger/providers/base_provider.dart' as _i2;
|
||||
import 'package:wger/providers/workout_plans.dart' as _i11;
|
||||
import 'package:wger/providers/routine.dart' as _i11;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
@@ -61,8 +61,8 @@ class _FakeRepetitionUnit_2 extends _i1.SmartFake implements _i4.RepetitionUnit
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeWorkoutPlan_3 extends _i1.SmartFake implements _i5.WorkoutPlan {
|
||||
_FakeWorkoutPlan_3(
|
||||
class _FakeRoutine_3 extends _i1.SmartFake implements _i5.Routine {
|
||||
_FakeRoutine_3(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
@@ -121,11 +121,11 @@ class _FakeLog_8 extends _i1.SmartFake implements _i10.Log {
|
||||
);
|
||||
}
|
||||
|
||||
/// A class which mocks [WorkoutPlansProvider].
|
||||
/// A class which mocks [RoutineProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProvider {
|
||||
MockWorkoutPlansProvider() {
|
||||
class MockRoutineProvider extends _i1.Mock implements _i11.RoutineProvider {
|
||||
MockRoutineProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@@ -139,10 +139,10 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
) as _i2.WgerBaseProvider);
|
||||
|
||||
@override
|
||||
List<_i5.WorkoutPlan> get items => (super.noSuchMethod(
|
||||
List<_i5.Routine> get items => (super.noSuchMethod(
|
||||
Invocation.getter(#items),
|
||||
returnValue: <_i5.WorkoutPlan>[],
|
||||
) as List<_i5.WorkoutPlan>);
|
||||
returnValue: <_i5.Routine>[],
|
||||
) as List<_i5.Routine>);
|
||||
|
||||
@override
|
||||
List<_i3.WeightUnit> get weightUnits => (super.noSuchMethod(
|
||||
@@ -190,28 +190,28 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i5.WorkoutPlan> getPlans() => (super.noSuchMethod(
|
||||
List<_i5.Routine> getPlans() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getPlans,
|
||||
[],
|
||||
),
|
||||
returnValue: <_i5.WorkoutPlan>[],
|
||||
) as List<_i5.WorkoutPlan>);
|
||||
returnValue: <_i5.Routine>[],
|
||||
) as List<_i5.Routine>);
|
||||
|
||||
@override
|
||||
_i5.WorkoutPlan findById(int? id) => (super.noSuchMethod(
|
||||
_i5.Routine findById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _FakeWorkoutPlan_3(
|
||||
returnValue: _FakeRoutine_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#findById,
|
||||
[id],
|
||||
),
|
||||
),
|
||||
) as _i5.WorkoutPlan);
|
||||
) as _i5.Routine);
|
||||
|
||||
@override
|
||||
int findIndexById(int? id) => (super.noSuchMethod(
|
||||
@@ -232,7 +232,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
);
|
||||
|
||||
@override
|
||||
void resetCurrentPlan() => super.noSuchMethod(
|
||||
void resetCurrentRoutine() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#resetCurrentPlan,
|
||||
[],
|
||||
@@ -241,7 +241,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
);
|
||||
|
||||
@override
|
||||
_i12.Future<void> fetchAndSetAllPlansFull() => (super.noSuchMethod(
|
||||
_i12.Future<void> fetchAndSetAllRoutinesFull() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetAllPlansFull,
|
||||
[],
|
||||
@@ -251,7 +251,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
) as _i12.Future<void>);
|
||||
|
||||
@override
|
||||
_i12.Future<void> fetchAndSetAllPlansSparse() => (super.noSuchMethod(
|
||||
_i12.Future<void> fetchAndSetAllRoutinesSparse() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetAllPlansSparse,
|
||||
[],
|
||||
@@ -261,52 +261,52 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
) as _i12.Future<void>);
|
||||
|
||||
@override
|
||||
_i12.Future<_i5.WorkoutPlan> fetchAndSetPlanSparse(int? planId) => (super.noSuchMethod(
|
||||
_i12.Future<_i5.Routine> fetchAndSetRoutineSparse(int? planId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanSparse,
|
||||
[planId],
|
||||
),
|
||||
returnValue: _i12.Future<_i5.WorkoutPlan>.value(_FakeWorkoutPlan_3(
|
||||
returnValue: _i12.Future<_i5.Routine>.value(_FakeRoutine_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanSparse,
|
||||
[planId],
|
||||
),
|
||||
)),
|
||||
) as _i12.Future<_i5.WorkoutPlan>);
|
||||
) as _i12.Future<_i5.Routine>);
|
||||
|
||||
@override
|
||||
_i12.Future<_i5.WorkoutPlan> fetchAndSetWorkoutPlanFull(int? workoutId) => (super.noSuchMethod(
|
||||
_i12.Future<_i5.Routine> fetchAndSetRoutineFull(int? workoutId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetWorkoutPlanFull,
|
||||
[workoutId],
|
||||
),
|
||||
returnValue: _i12.Future<_i5.WorkoutPlan>.value(_FakeWorkoutPlan_3(
|
||||
returnValue: _i12.Future<_i5.Routine>.value(_FakeRoutine_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchAndSetWorkoutPlanFull,
|
||||
[workoutId],
|
||||
),
|
||||
)),
|
||||
) as _i12.Future<_i5.WorkoutPlan>);
|
||||
) as _i12.Future<_i5.Routine>);
|
||||
|
||||
@override
|
||||
_i12.Future<_i5.WorkoutPlan> addWorkout(_i5.WorkoutPlan? workout) => (super.noSuchMethod(
|
||||
_i12.Future<_i5.Routine> addRoutine(_i5.Routine? workout) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addWorkout,
|
||||
[workout],
|
||||
),
|
||||
returnValue: _i12.Future<_i5.WorkoutPlan>.value(_FakeWorkoutPlan_3(
|
||||
returnValue: _i12.Future<_i5.Routine>.value(_FakeRoutine_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#addWorkout,
|
||||
[workout],
|
||||
),
|
||||
)),
|
||||
) as _i12.Future<_i5.WorkoutPlan>);
|
||||
) as _i12.Future<_i5.Routine>);
|
||||
|
||||
@override
|
||||
_i12.Future<void> editWorkout(_i5.WorkoutPlan? workout) => (super.noSuchMethod(
|
||||
_i12.Future<void> editRoutine(_i5.Routine? workout) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#editWorkout,
|
||||
[workout],
|
||||
@@ -316,7 +316,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
) as _i12.Future<void>);
|
||||
|
||||
@override
|
||||
_i12.Future<void> deleteWorkout(int? id) => (super.noSuchMethod(
|
||||
_i12.Future<void> deleteRoutine(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteWorkout,
|
||||
[id],
|
||||
@@ -327,7 +327,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
|
||||
@override
|
||||
_i12.Future<Map<String, dynamic>> fetchLogData(
|
||||
_i5.WorkoutPlan? workout,
|
||||
_i5.Routine? workout,
|
||||
_i13.ExerciseBase? base,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
@@ -374,7 +374,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
@override
|
||||
_i12.Future<_i6.Day> addDay(
|
||||
_i6.Day? day,
|
||||
_i5.WorkoutPlan? workout,
|
||||
_i5.Routine? workout,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -23,47 +23,47 @@ import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/screens/workout_plan_screen.dart';
|
||||
import 'package:wger/widgets/workouts/forms.dart';
|
||||
import 'package:wger/models/routines/routine.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
|
||||
import './workout_form_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([WorkoutPlansProvider])
|
||||
@GenerateMocks([RoutineProvider])
|
||||
void main() {
|
||||
var mockWorkoutPlans = MockWorkoutPlansProvider();
|
||||
var mockRoutineProvider = MockRoutineProvider();
|
||||
|
||||
final existingPlan = WorkoutPlan(
|
||||
final existingPlan = Routine(
|
||||
id: 1,
|
||||
creationDate: DateTime(2021, 1, 1),
|
||||
name: 'test 1',
|
||||
description: 'description 1',
|
||||
);
|
||||
final newPlan = WorkoutPlan.empty();
|
||||
final newPlan = Routine.empty();
|
||||
|
||||
setUp(() {
|
||||
mockWorkoutPlans = MockWorkoutPlansProvider();
|
||||
when(mockWorkoutPlans.editWorkout(any)).thenAnswer((_) => Future.value(existingPlan));
|
||||
when(mockWorkoutPlans.fetchAndSetWorkoutPlanFull(any))
|
||||
mockRoutineProvider = MockRoutineProvider();
|
||||
when(mockRoutineProvider.editRoutine(any)).thenAnswer((_) => Future.value(existingPlan));
|
||||
when(mockRoutineProvider.fetchAndSetRoutineFull(any))
|
||||
.thenAnswer((_) => Future.value(existingPlan));
|
||||
});
|
||||
|
||||
Widget createHomeScreen(WorkoutPlan workoutPlan, {locale = 'en'}) {
|
||||
Widget createHomeScreen(Routine workoutPlan, {locale = 'en'}) {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
|
||||
return ChangeNotifierProvider<WorkoutPlansProvider>(
|
||||
create: (context) => mockWorkoutPlans,
|
||||
return ChangeNotifierProvider<RoutineProvider>(
|
||||
create: (context) => mockRoutineProvider,
|
||||
child: MaterialApp(
|
||||
locale: Locale(locale),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
navigatorKey: key,
|
||||
home: Scaffold(
|
||||
body: WorkoutForm(workoutPlan),
|
||||
body: RoutineForm(workoutPlan),
|
||||
),
|
||||
routes: {
|
||||
WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
|
||||
RoutineScreen.routeName: (ctx) => RoutineScreen(),
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -95,8 +95,8 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
// Correct method was called
|
||||
verify(mockWorkoutPlans.editWorkout(any));
|
||||
verifyNever(mockWorkoutPlans.addWorkout(any));
|
||||
verify(mockRoutineProvider.editRoutine(any));
|
||||
verifyNever(mockRoutineProvider.addRoutine(any));
|
||||
|
||||
// TODO(x): edit calls Navigator.pop(), since the form can only be reached from the
|
||||
// detail page. The test needs to add the detail page to the stack so that
|
||||
@@ -108,13 +108,13 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Test creating a new workout - only name', (WidgetTester tester) async {
|
||||
final editWorkout = WorkoutPlan(
|
||||
final editWorkout = Routine(
|
||||
id: 2,
|
||||
creationDate: newPlan.creationDate,
|
||||
name: 'New cool workout',
|
||||
);
|
||||
|
||||
when(mockWorkoutPlans.addWorkout(any)).thenAnswer((_) => Future.value(editWorkout));
|
||||
when(mockRoutineProvider.addRoutine(any)).thenAnswer((_) => Future.value(editWorkout));
|
||||
|
||||
await tester.pumpWidget(createHomeScreen(newPlan));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -123,8 +123,8 @@ void main() {
|
||||
await tester.enterText(find.byKey(const Key('field-name')), editWorkout.name);
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
verifyNever(mockWorkoutPlans.editWorkout(any));
|
||||
verify(mockWorkoutPlans.addWorkout(any));
|
||||
verifyNever(mockRoutineProvider.editRoutine(any));
|
||||
verify(mockRoutineProvider.addRoutine(any));
|
||||
|
||||
// Detail page
|
||||
await tester.pumpAndSettle();
|
||||
@@ -132,9 +132,9 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Test creating a new workout - name and description', (WidgetTester tester) async {
|
||||
final editWorkout = WorkoutPlan(
|
||||
final editWorkout = Routine(
|
||||
id: 2, creationDate: newPlan.creationDate, name: 'My workout', description: 'Get yuuuge');
|
||||
when(mockWorkoutPlans.addWorkout(any)).thenAnswer((_) => Future.value(editWorkout));
|
||||
when(mockRoutineProvider.addRoutine(any)).thenAnswer((_) => Future.value(editWorkout));
|
||||
|
||||
await tester.pumpWidget(createHomeScreen(newPlan));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -144,8 +144,8 @@ void main() {
|
||||
await tester.enterText(find.byKey(const Key('field-description')), editWorkout.description);
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
verifyNever(mockWorkoutPlans.editWorkout(any));
|
||||
verify(mockWorkoutPlans.addWorkout(any));
|
||||
verifyNever(mockRoutineProvider.editRoutine(any));
|
||||
verify(mockRoutineProvider.addRoutine(any));
|
||||
|
||||
// Detail page
|
||||
await tester.pumpAndSettle();
|
||||
@@ -1,5 +1,5 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// in wger/test/workout/workout_form_test.dart.
|
||||
// Mocks generated by Mockito 5.4.0 from annotations
|
||||
// in wger/test/routine/workout_form_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
@@ -9,16 +9,16 @@ import 'dart:ui' as _i15;
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:wger/models/exercises/base.dart' as _i13;
|
||||
import 'package:wger/models/exercises/translation.dart' as _i14;
|
||||
import 'package:wger/models/workouts/day.dart' as _i6;
|
||||
import 'package:wger/models/workouts/log.dart' as _i10;
|
||||
import 'package:wger/models/workouts/repetition_unit.dart' as _i4;
|
||||
import 'package:wger/models/workouts/session.dart' as _i9;
|
||||
import 'package:wger/models/workouts/set.dart' as _i7;
|
||||
import 'package:wger/models/workouts/setting.dart' as _i8;
|
||||
import 'package:wger/models/workouts/weight_unit.dart' as _i3;
|
||||
import 'package:wger/models/workouts/workout_plan.dart' as _i5;
|
||||
import 'package:wger/models/routines/day.dart' as _i6;
|
||||
import 'package:wger/models/routines/log.dart' as _i10;
|
||||
import 'package:wger/models/routines/repetition_unit.dart' as _i4;
|
||||
import 'package:wger/models/routines/routine.dart' as _i5;
|
||||
import 'package:wger/models/routines/session.dart' as _i9;
|
||||
import 'package:wger/models/routines/set.dart' as _i7;
|
||||
import 'package:wger/models/routines/setting.dart' as _i8;
|
||||
import 'package:wger/models/routines/weight_unit.dart' as _i3;
|
||||
import 'package:wger/providers/base_provider.dart' as _i2;
|
||||
import 'package:wger/providers/workout_plans.dart' as _i11;
|
||||
import 'package:wger/providers/routine.dart' as _i11;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
@@ -61,8 +61,8 @@ class _FakeRepetitionUnit_2 extends _i1.SmartFake implements _i4.RepetitionUnit
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeWorkoutPlan_3 extends _i1.SmartFake implements _i5.WorkoutPlan {
|
||||
_FakeWorkoutPlan_3(
|
||||
class _FakeRoutine_3 extends _i1.SmartFake implements _i5.Routine {
|
||||
_FakeRoutine_3(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
@@ -121,11 +121,11 @@ class _FakeLog_8 extends _i1.SmartFake implements _i10.Log {
|
||||
);
|
||||
}
|
||||
|
||||
/// A class which mocks [WorkoutPlansProvider].
|
||||
/// A class which mocks [RoutineProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProvider {
|
||||
MockWorkoutPlansProvider() {
|
||||
class MockRoutineProvider extends _i1.Mock implements _i11.RoutineProvider {
|
||||
MockRoutineProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@@ -139,10 +139,10 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
) as _i2.WgerBaseProvider);
|
||||
|
||||
@override
|
||||
List<_i5.WorkoutPlan> get items => (super.noSuchMethod(
|
||||
List<_i5.Routine> get items => (super.noSuchMethod(
|
||||
Invocation.getter(#items),
|
||||
returnValue: <_i5.WorkoutPlan>[],
|
||||
) as List<_i5.WorkoutPlan>);
|
||||
returnValue: <_i5.Routine>[],
|
||||
) as List<_i5.Routine>);
|
||||
|
||||
@override
|
||||
List<_i3.WeightUnit> get weightUnits => (super.noSuchMethod(
|
||||
@@ -190,28 +190,28 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i5.WorkoutPlan> getPlans() => (super.noSuchMethod(
|
||||
List<_i5.Routine> getPlans() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getPlans,
|
||||
[],
|
||||
),
|
||||
returnValue: <_i5.WorkoutPlan>[],
|
||||
) as List<_i5.WorkoutPlan>);
|
||||
returnValue: <_i5.Routine>[],
|
||||
) as List<_i5.Routine>);
|
||||
|
||||
@override
|
||||
_i5.WorkoutPlan findById(int? id) => (super.noSuchMethod(
|
||||
_i5.Routine findById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _FakeWorkoutPlan_3(
|
||||
returnValue: _FakeRoutine_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#findById,
|
||||
[id],
|
||||
),
|
||||
),
|
||||
) as _i5.WorkoutPlan);
|
||||
) as _i5.Routine);
|
||||
|
||||
@override
|
||||
int findIndexById(int? id) => (super.noSuchMethod(
|
||||
@@ -232,7 +232,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
);
|
||||
|
||||
@override
|
||||
void resetCurrentPlan() => super.noSuchMethod(
|
||||
void resetCurrentRoutine() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#resetCurrentPlan,
|
||||
[],
|
||||
@@ -241,7 +241,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
);
|
||||
|
||||
@override
|
||||
_i12.Future<void> fetchAndSetAllPlansFull() => (super.noSuchMethod(
|
||||
_i12.Future<void> fetchAndSetAllRoutinesFull() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetAllPlansFull,
|
||||
[],
|
||||
@@ -251,7 +251,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
) as _i12.Future<void>);
|
||||
|
||||
@override
|
||||
_i12.Future<void> fetchAndSetAllPlansSparse() => (super.noSuchMethod(
|
||||
_i12.Future<void> fetchAndSetAllRoutinesSparse() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetAllPlansSparse,
|
||||
[],
|
||||
@@ -261,52 +261,52 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
) as _i12.Future<void>);
|
||||
|
||||
@override
|
||||
_i12.Future<_i5.WorkoutPlan> fetchAndSetPlanSparse(int? planId) => (super.noSuchMethod(
|
||||
_i12.Future<_i5.Routine> fetchAndSetRoutineSparse(int? planId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanSparse,
|
||||
[planId],
|
||||
),
|
||||
returnValue: _i12.Future<_i5.WorkoutPlan>.value(_FakeWorkoutPlan_3(
|
||||
returnValue: _i12.Future<_i5.Routine>.value(_FakeRoutine_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanSparse,
|
||||
[planId],
|
||||
),
|
||||
)),
|
||||
) as _i12.Future<_i5.WorkoutPlan>);
|
||||
) as _i12.Future<_i5.Routine>);
|
||||
|
||||
@override
|
||||
_i12.Future<_i5.WorkoutPlan> fetchAndSetWorkoutPlanFull(int? workoutId) => (super.noSuchMethod(
|
||||
_i12.Future<_i5.Routine> fetchAndSetRoutineFull(int? workoutId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetWorkoutPlanFull,
|
||||
[workoutId],
|
||||
),
|
||||
returnValue: _i12.Future<_i5.WorkoutPlan>.value(_FakeWorkoutPlan_3(
|
||||
returnValue: _i12.Future<_i5.Routine>.value(_FakeRoutine_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchAndSetWorkoutPlanFull,
|
||||
[workoutId],
|
||||
),
|
||||
)),
|
||||
) as _i12.Future<_i5.WorkoutPlan>);
|
||||
) as _i12.Future<_i5.Routine>);
|
||||
|
||||
@override
|
||||
_i12.Future<_i5.WorkoutPlan> addWorkout(_i5.WorkoutPlan? workout) => (super.noSuchMethod(
|
||||
_i12.Future<_i5.Routine> addRoutine(_i5.Routine? workout) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addWorkout,
|
||||
[workout],
|
||||
),
|
||||
returnValue: _i12.Future<_i5.WorkoutPlan>.value(_FakeWorkoutPlan_3(
|
||||
returnValue: _i12.Future<_i5.Routine>.value(_FakeRoutine_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#addWorkout,
|
||||
[workout],
|
||||
),
|
||||
)),
|
||||
) as _i12.Future<_i5.WorkoutPlan>);
|
||||
) as _i12.Future<_i5.Routine>);
|
||||
|
||||
@override
|
||||
_i12.Future<void> editWorkout(_i5.WorkoutPlan? workout) => (super.noSuchMethod(
|
||||
_i12.Future<void> editRoutine(_i5.Routine? workout) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#editWorkout,
|
||||
[workout],
|
||||
@@ -316,7 +316,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
) as _i12.Future<void>);
|
||||
|
||||
@override
|
||||
_i12.Future<void> deleteWorkout(int? id) => (super.noSuchMethod(
|
||||
_i12.Future<void> deleteRoutine(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteWorkout,
|
||||
[id],
|
||||
@@ -327,7 +327,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
|
||||
@override
|
||||
_i12.Future<Map<String, dynamic>> fetchLogData(
|
||||
_i5.WorkoutPlan? workout,
|
||||
_i5.Routine? workout,
|
||||
_i13.ExerciseBase? base,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
@@ -374,7 +374,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
@override
|
||||
_i12.Future<_i6.Day> addDay(
|
||||
_i6.Day? day,
|
||||
_i5.WorkoutPlan? workout,
|
||||
_i5.Routine? workout,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:wger/models/workouts/log.dart';
|
||||
import 'package:wger/models/routines/log.dart';
|
||||
|
||||
void main() {
|
||||
group('Test the workout log model', () {
|
||||
@@ -27,7 +27,7 @@ void main() {
|
||||
setUp(() {
|
||||
log1 = Log(
|
||||
id: 123,
|
||||
workoutPlan: 100,
|
||||
routineId: 100,
|
||||
exerciseBaseId: 1,
|
||||
reps: 10,
|
||||
rir: '1.5',
|
||||
@@ -38,7 +38,7 @@ void main() {
|
||||
);
|
||||
log2 = Log(
|
||||
id: 9,
|
||||
workoutPlan: 42,
|
||||
routineId: 42,
|
||||
exerciseBaseId: 1,
|
||||
reps: 10,
|
||||
rir: '1.5',
|
||||
@@ -19,24 +19,24 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../test_data/exercises.dart';
|
||||
import '../../test_data/workouts.dart';
|
||||
import '../../test_data/routines.dart';
|
||||
|
||||
void main() {
|
||||
group('model tests', () {
|
||||
test('Test the filterLogsByExercise method', () {
|
||||
final workout = getWorkout();
|
||||
final routine = getRoutine();
|
||||
|
||||
expect(workout.logs.length, 3);
|
||||
final logExercise1 = workout.filterLogsByExerciseBase(getTestExerciseBases()[0]);
|
||||
expect(routine.logs.length, 3);
|
||||
final logExercise1 = routine.filterLogsByExerciseBase(getTestExerciseBases()[0]);
|
||||
expect(logExercise1.length, 2);
|
||||
expect(logExercise1[0].id, 1);
|
||||
expect(logExercise1[1].id, 2);
|
||||
|
||||
final logExercise2 = workout.filterLogsByExerciseBase(getTestExerciseBases()[1]);
|
||||
final logExercise2 = routine.filterLogsByExerciseBase(getTestExerciseBases()[1]);
|
||||
expect(logExercise2.length, 1);
|
||||
expect(logExercise2[0].id, 3);
|
||||
|
||||
expect(workout.filterLogsByExerciseBase(getTestExerciseBases()[2]).length, 0);
|
||||
expect(routine.filterLogsByExerciseBase(getTestExerciseBases()[2]).length, 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -23,10 +23,10 @@ import 'package:mockito/annotations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/providers/base_provider.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/screens/workout_plan_screen.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
|
||||
import '../../test_data/workouts.dart';
|
||||
import '../../test_data/routines.dart';
|
||||
import 'workout_plan_screen_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([WgerBaseProvider])
|
||||
@@ -36,8 +36,8 @@ void main() {
|
||||
Widget createHomeScreen({locale = 'en'}) {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
|
||||
return ChangeNotifierProvider<WorkoutPlansProvider>(
|
||||
create: (context) => WorkoutPlansProvider(mockBaseProvider, exercisesProvider, []),
|
||||
return ChangeNotifierProvider<RoutineProvider>(
|
||||
create: (context) => RoutineProvider(mockBaseProvider, exercisesProvider, []),
|
||||
child: MaterialApp(
|
||||
locale: Locale(locale),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
@@ -46,14 +46,14 @@ void main() {
|
||||
home: TextButton(
|
||||
onPressed: () => key.currentState!.push(
|
||||
MaterialPageRoute<void>(
|
||||
settings: RouteSettings(arguments: getWorkout()),
|
||||
builder: (_) => WorkoutPlanScreen(),
|
||||
settings: RouteSettings(arguments: getRoutine()),
|
||||
builder: (_) => RoutineScreen(),
|
||||
),
|
||||
),
|
||||
child: const SizedBox(),
|
||||
),
|
||||
routes: {
|
||||
WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
|
||||
RoutineScreen.routeName: (ctx) => RoutineScreen(),
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -1,5 +1,5 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// in wger/test/workout/workout_plan_screen_test.dart.
|
||||
// Mocks generated by Mockito 5.4.0 from annotations
|
||||
// in wger/test/routine/workout_plan_screen_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
@@ -77,7 +77,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
Invocation.getter(#auth),
|
||||
),
|
||||
) as _i2.AuthProvider);
|
||||
|
||||
@override
|
||||
set auth(_i2.AuthProvider? _auth) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
@@ -86,7 +85,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
_i3.Client get client => (super.noSuchMethod(
|
||||
Invocation.getter(#client),
|
||||
@@ -95,7 +93,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
Invocation.getter(#client),
|
||||
),
|
||||
) as _i3.Client);
|
||||
|
||||
@override
|
||||
set client(_i3.Client? _client) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
@@ -104,9 +101,9 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) => (super.noSuchMethod(
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getDefaultHeaders,
|
||||
[],
|
||||
@@ -114,7 +111,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValue: <String, String>{},
|
||||
) as Map<String, String>);
|
||||
|
||||
@override
|
||||
Uri makeUrl(
|
||||
String? path, {
|
||||
@@ -145,16 +141,15 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
),
|
||||
) as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> fetch(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -163,7 +158,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
) as _i5.Future<List<dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> post(
|
||||
Map<String, dynamic>? data,
|
||||
@@ -177,9 +171,9 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> patch(
|
||||
Map<String, dynamic>? data,
|
||||
@@ -193,9 +187,9 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i3.Response> deleteRequest(
|
||||
String? url,
|
||||
@@ -23,14 +23,14 @@ import 'package:http/http.dart' as http;
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
import 'package:wger/models/routines/routine.dart';
|
||||
import 'package:wger/providers/base_provider.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/screens/workout_plans_screen.dart';
|
||||
import 'package:wger/screens/routines_screen.dart';
|
||||
import 'package:wger/widgets/nutrition/forms.dart';
|
||||
import 'package:wger/widgets/workouts/forms.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
|
||||
import 'workout_plans_screen_test.mocks.dart';
|
||||
|
||||
@@ -52,20 +52,20 @@ void main() {
|
||||
when(mockBaseProvider.makeUrl('workout', query: anyNamed('query'))).thenReturn(uri);
|
||||
when(mockBaseProvider.deleteRequest(any, any)).thenAnswer((_) async => http.Response('', 204));
|
||||
|
||||
return ChangeNotifierProvider<WorkoutPlansProvider>(
|
||||
create: (context) => WorkoutPlansProvider(
|
||||
return ChangeNotifierProvider<RoutineProvider>(
|
||||
create: (context) => RoutineProvider(
|
||||
mockBaseProvider,
|
||||
testExercisesProvider,
|
||||
[
|
||||
WorkoutPlan(id: 1, creationDate: DateTime(2021, 01, 01), name: 'test 1'),
|
||||
WorkoutPlan(id: 2, creationDate: DateTime(2021, 02, 12), name: 'test 2'),
|
||||
Routine(id: 1, creationDate: DateTime(2021, 01, 01), name: 'test 1'),
|
||||
Routine(id: 2, creationDate: DateTime(2021, 02, 12), name: 'test 2'),
|
||||
],
|
||||
),
|
||||
child: MaterialApp(
|
||||
locale: Locale(locale),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: WorkoutPlansScreen(),
|
||||
home: RoutinesScreen(),
|
||||
routes: {
|
||||
FormScreen.routeName: (ctx) => FormScreen(),
|
||||
},
|
||||
@@ -77,7 +77,7 @@ void main() {
|
||||
await tester.pumpWidget(createHomeScreen());
|
||||
|
||||
//debugDumpApp();
|
||||
expect(find.text('Workout plans'), findsOneWidget);
|
||||
expect(find.text('Routines'), findsOneWidget);
|
||||
expect(find.byType(Dismissible), findsNWidgets(2));
|
||||
expect(find.byType(ListTile), findsNWidgets(2));
|
||||
});
|
||||
@@ -114,7 +114,7 @@ void main() {
|
||||
expect(find.byType(PlanForm), findsNothing);
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(WorkoutForm), findsOneWidget);
|
||||
expect(find.byType(RoutineForm), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Tests the localization of dates - EN', (WidgetTester tester) async {
|
||||
@@ -1,5 +1,5 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// in wger/test/workout/workout_plans_screen_test.dart.
|
||||
// Mocks generated by Mockito 5.4.0 from annotations
|
||||
// in wger/test/routine/workout_plans_screen_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
@@ -77,7 +77,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
Invocation.getter(#auth),
|
||||
),
|
||||
) as _i2.AuthProvider);
|
||||
|
||||
@override
|
||||
set auth(_i2.AuthProvider? _auth) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
@@ -86,7 +85,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
_i3.Client get client => (super.noSuchMethod(
|
||||
Invocation.getter(#client),
|
||||
@@ -95,7 +93,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
Invocation.getter(#client),
|
||||
),
|
||||
) as _i3.Client);
|
||||
|
||||
@override
|
||||
set client(_i3.Client? _client) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
@@ -104,9 +101,9 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) => (super.noSuchMethod(
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getDefaultHeaders,
|
||||
[],
|
||||
@@ -114,7 +111,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValue: <String, String>{},
|
||||
) as Map<String, String>);
|
||||
|
||||
@override
|
||||
Uri makeUrl(
|
||||
String? path, {
|
||||
@@ -145,16 +141,15 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
),
|
||||
) as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> fetch(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -163,7 +158,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
) as _i5.Future<List<dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> post(
|
||||
Map<String, dynamic>? data,
|
||||
@@ -177,9 +171,9 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> patch(
|
||||
Map<String, dynamic>? data,
|
||||
@@ -193,9 +187,9 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i3.Response> deleteRequest(
|
||||
String? url,
|
||||
@@ -24,12 +24,12 @@ import 'package:http/http.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:wger/models/workouts/repetition_unit.dart';
|
||||
import 'package:wger/models/workouts/weight_unit.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
import 'package:wger/models/routines/repetition_unit.dart';
|
||||
import 'package:wger/models/routines/routine.dart';
|
||||
import 'package:wger/models/routines/weight_unit.dart';
|
||||
import 'package:wger/providers/base_provider.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
|
||||
import '../fixtures/fixture_reader.dart';
|
||||
import 'workout_provider_test.mocks.dart';
|
||||
@@ -56,12 +56,12 @@ void main() {
|
||||
);
|
||||
|
||||
// Load the entries
|
||||
final provider = WorkoutPlansProvider(mockBaseProvider, exercisesProvider, []);
|
||||
final plan = await provider.fetchAndSetPlanSparse(325397);
|
||||
final provider = RoutineProvider(mockBaseProvider, exercisesProvider, []);
|
||||
final plan = await provider.fetchAndSetRoutineSparse(325397);
|
||||
final plans = provider.getPlans();
|
||||
|
||||
// Check that everything is ok
|
||||
expect(plan, isA<WorkoutPlan>());
|
||||
expect(plan, isA<Routine>());
|
||||
expect(plan.id, 325397);
|
||||
expect(plan.description, 'Test workout abcd');
|
||||
expect(plans.length, 1);
|
||||
@@ -86,10 +86,10 @@ void main() {
|
||||
);
|
||||
|
||||
// Load the entries
|
||||
final provider = WorkoutPlansProvider(mockBaseProvider, exercisesProvider, []);
|
||||
final provider = RoutineProvider(mockBaseProvider, exercisesProvider, []);
|
||||
|
||||
await provider.fetchAndSetPlanSparse(325397);
|
||||
await provider.deleteWorkout(325397);
|
||||
await provider.fetchAndSetRoutineSparse(325397);
|
||||
await provider.deleteRoutine(325397);
|
||||
final plans = provider.getPlans();
|
||||
expect(plans.length, 0);
|
||||
});
|
||||
@@ -104,7 +104,7 @@ void main() {
|
||||
.thenAnswer((_) => Future.value(tRepetitionUnits['results']));
|
||||
|
||||
// Load the entries
|
||||
final provider = WorkoutPlansProvider(mockBaseProvider, exercisesProvider, []);
|
||||
final provider = RoutineProvider(mockBaseProvider, exercisesProvider, []);
|
||||
await provider.fetchAndSetRepetitionUnits();
|
||||
final repetitionUnits = provider.repetitionUnits;
|
||||
|
||||
@@ -121,7 +121,7 @@ void main() {
|
||||
final ExercisesProvider testExercisesProvider = ExercisesProvider(mockBaseProvider);
|
||||
|
||||
// Load the entries
|
||||
final provider = WorkoutPlansProvider(mockBaseProvider, testExercisesProvider, []);
|
||||
final provider = RoutineProvider(mockBaseProvider, testExercisesProvider, []);
|
||||
await provider.fetchAndSetWeightUnits();
|
||||
final weightUnits = provider.weightUnits;
|
||||
|
||||
@@ -148,7 +148,7 @@ void main() {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
// Load the entries
|
||||
final provider = WorkoutPlansProvider(mockBaseProvider, exercisesProvider, []);
|
||||
final provider = RoutineProvider(mockBaseProvider, exercisesProvider, []);
|
||||
await provider.fetchAndSetUnits();
|
||||
final prefsJson = jsonDecode(prefs.getString('workoutUnits')!);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// in wger/test/workout/workout_provider_test.dart.
|
||||
// Mocks generated by Mockito 5.4.0 from annotations
|
||||
// in wger/test/routine/workout_provider_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
@@ -77,7 +77,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
Invocation.getter(#auth),
|
||||
),
|
||||
) as _i2.AuthProvider);
|
||||
|
||||
@override
|
||||
set auth(_i2.AuthProvider? _auth) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
@@ -86,7 +85,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
_i3.Client get client => (super.noSuchMethod(
|
||||
Invocation.getter(#client),
|
||||
@@ -95,7 +93,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
Invocation.getter(#client),
|
||||
),
|
||||
) as _i3.Client);
|
||||
|
||||
@override
|
||||
set client(_i3.Client? _client) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
@@ -104,9 +101,9 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) => (super.noSuchMethod(
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getDefaultHeaders,
|
||||
[],
|
||||
@@ -114,7 +111,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValue: <String, String>{},
|
||||
) as Map<String, String>);
|
||||
|
||||
@override
|
||||
Uri makeUrl(
|
||||
String? path, {
|
||||
@@ -145,16 +141,15 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
),
|
||||
) as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> fetch(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -163,7 +158,6 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
) as _i5.Future<List<dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> post(
|
||||
Map<String, dynamic>? data,
|
||||
@@ -177,9 +171,9 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> patch(
|
||||
Map<String, dynamic>? data,
|
||||
@@ -193,9 +187,9 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i3.Response> deleteRequest(
|
||||
String? url,
|
||||
@@ -23,37 +23,37 @@ import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
import 'package:wger/models/workouts/set.dart';
|
||||
import 'package:wger/models/workouts/setting.dart';
|
||||
import 'package:wger/models/routines/day.dart';
|
||||
import 'package:wger/models/routines/set.dart';
|
||||
import 'package:wger/models/routines/setting.dart';
|
||||
import 'package:wger/providers/base_provider.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/widgets/workouts/forms.dart';
|
||||
import 'package:wger/providers/routine.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
|
||||
import '../../test_data/workouts.dart';
|
||||
import '../../test_data/routines.dart';
|
||||
import 'workout_set_form_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([ExercisesProvider, WgerBaseProvider, WorkoutPlansProvider])
|
||||
@GenerateMocks([ExercisesProvider, WgerBaseProvider, RoutineProvider])
|
||||
void main() {
|
||||
var mockWorkoutPlans = MockWorkoutPlansProvider();
|
||||
var mockRoutineProvider = MockRoutineProvider();
|
||||
final mockBaseProvider = MockWgerBaseProvider();
|
||||
final mockExerciseProvider = MockExercisesProvider();
|
||||
final workoutPlan = getWorkout();
|
||||
final routine = getRoutine();
|
||||
|
||||
Day day = Day();
|
||||
|
||||
setUp(() {
|
||||
day = workoutPlan.days.first;
|
||||
mockWorkoutPlans = MockWorkoutPlansProvider();
|
||||
day = routine.days.first;
|
||||
mockRoutineProvider = MockRoutineProvider();
|
||||
});
|
||||
|
||||
Widget createHomeScreen({locale = 'en'}) {
|
||||
return ChangeNotifierProvider<WorkoutPlansProvider>(
|
||||
create: (context) => WorkoutPlansProvider(
|
||||
return ChangeNotifierProvider<RoutineProvider>(
|
||||
create: (context) => RoutineProvider(
|
||||
mockBaseProvider,
|
||||
mockExerciseProvider,
|
||||
[workoutPlan],
|
||||
[routine],
|
||||
),
|
||||
child: ChangeNotifierProvider<ExercisesProvider>(
|
||||
create: (context) => mockExerciseProvider,
|
||||
@@ -81,9 +81,9 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Test creating a new set', (WidgetTester tester) async {
|
||||
when(mockWorkoutPlans.addSet(any)).thenAnswer((_) => Future.value(Set.empty()));
|
||||
when(mockWorkoutPlans.addSetting(any)).thenAnswer((_) => Future.value(Setting.empty()));
|
||||
when(mockWorkoutPlans.fetchSmartText(any, any)).thenAnswer((_) => Future.value('2 x 10'));
|
||||
when(mockRoutineProvider.addSet(any)).thenAnswer((_) => Future.value(Set.empty()));
|
||||
when(mockRoutineProvider.addSetting(any)).thenAnswer((_) => Future.value(Setting.empty()));
|
||||
when(mockRoutineProvider.fetchSmartText(any, any)).thenAnswer((_) => Future.value('2 x 10'));
|
||||
|
||||
await tester.pumpWidget(createHomeScreen());
|
||||
await tester.pumpAndSettle();
|
||||
@@ -1,5 +1,5 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// in wger/test/workout/workout_set_form_test.dart.
|
||||
// Mocks generated by Mockito 5.4.0 from annotations
|
||||
// in wger/test/routine/workout_set_form_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
@@ -14,18 +14,18 @@ import 'package:wger/models/exercises/equipment.dart' as _i5;
|
||||
import 'package:wger/models/exercises/language.dart' as _i7;
|
||||
import 'package:wger/models/exercises/muscle.dart' as _i6;
|
||||
import 'package:wger/models/exercises/translation.dart' as _i22;
|
||||
import 'package:wger/models/workouts/day.dart' as _i13;
|
||||
import 'package:wger/models/workouts/log.dart' as _i17;
|
||||
import 'package:wger/models/workouts/repetition_unit.dart' as _i11;
|
||||
import 'package:wger/models/workouts/session.dart' as _i16;
|
||||
import 'package:wger/models/workouts/set.dart' as _i14;
|
||||
import 'package:wger/models/workouts/setting.dart' as _i15;
|
||||
import 'package:wger/models/workouts/weight_unit.dart' as _i10;
|
||||
import 'package:wger/models/workouts/workout_plan.dart' as _i12;
|
||||
import 'package:wger/models/routines/day.dart' as _i13;
|
||||
import 'package:wger/models/routines/log.dart' as _i17;
|
||||
import 'package:wger/models/routines/repetition_unit.dart' as _i11;
|
||||
import 'package:wger/models/routines/routine.dart' as _i12;
|
||||
import 'package:wger/models/routines/session.dart' as _i16;
|
||||
import 'package:wger/models/routines/set.dart' as _i14;
|
||||
import 'package:wger/models/routines/setting.dart' as _i15;
|
||||
import 'package:wger/models/routines/weight_unit.dart' as _i10;
|
||||
import 'package:wger/providers/auth.dart' as _i8;
|
||||
import 'package:wger/providers/base_provider.dart' as _i2;
|
||||
import 'package:wger/providers/exercises.dart' as _i18;
|
||||
import 'package:wger/providers/workout_plans.dart' as _i21;
|
||||
import 'package:wger/providers/routine.dart' as _i21;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
@@ -158,8 +158,8 @@ class _FakeRepetitionUnit_11 extends _i1.SmartFake implements _i11.RepetitionUni
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeWorkoutPlan_12 extends _i1.SmartFake implements _i12.WorkoutPlan {
|
||||
_FakeWorkoutPlan_12(
|
||||
class _FakeRoutine_12 extends _i1.SmartFake implements _i12.Routine {
|
||||
_FakeRoutine_12(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
@@ -744,11 +744,11 @@ class MockWgerBaseProvider extends _i1.Mock implements _i2.WgerBaseProvider {
|
||||
) as _i19.Future<_i9.Response>);
|
||||
}
|
||||
|
||||
/// A class which mocks [WorkoutPlansProvider].
|
||||
/// A class which mocks [RoutineProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockWorkoutPlansProvider extends _i1.Mock implements _i21.WorkoutPlansProvider {
|
||||
MockWorkoutPlansProvider() {
|
||||
class MockRoutineProvider extends _i1.Mock implements _i21.RoutineProvider {
|
||||
MockRoutineProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@@ -762,10 +762,10 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i21.WorkoutPlansProv
|
||||
) as _i2.WgerBaseProvider);
|
||||
|
||||
@override
|
||||
List<_i12.WorkoutPlan> get items => (super.noSuchMethod(
|
||||
List<_i12.Routine> get items => (super.noSuchMethod(
|
||||
Invocation.getter(#items),
|
||||
returnValue: <_i12.WorkoutPlan>[],
|
||||
) as List<_i12.WorkoutPlan>);
|
||||
returnValue: <_i12.Routine>[],
|
||||
) as List<_i12.Routine>);
|
||||
|
||||
@override
|
||||
List<_i10.WeightUnit> get weightUnits => (super.noSuchMethod(
|
||||
@@ -813,28 +813,28 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i21.WorkoutPlansProv
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i12.WorkoutPlan> getPlans() => (super.noSuchMethod(
|
||||
List<_i12.Routine> getPlans() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getPlans,
|
||||
[],
|
||||
),
|
||||
returnValue: <_i12.WorkoutPlan>[],
|
||||
) as List<_i12.WorkoutPlan>);
|
||||
returnValue: <_i12.Routine>[],
|
||||
) as List<_i12.Routine>);
|
||||
|
||||
@override
|
||||
_i12.WorkoutPlan findById(int? id) => (super.noSuchMethod(
|
||||
_i12.Routine findById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _FakeWorkoutPlan_12(
|
||||
returnValue: _FakeRoutine_12(
|
||||
this,
|
||||
Invocation.method(
|
||||
#findById,
|
||||
[id],
|
||||
),
|
||||
),
|
||||
) as _i12.WorkoutPlan);
|
||||
) as _i12.Routine);
|
||||
|
||||
@override
|
||||
int findIndexById(int? id) => (super.noSuchMethod(
|
||||
@@ -855,7 +855,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i21.WorkoutPlansProv
|
||||
);
|
||||
|
||||
@override
|
||||
void resetCurrentPlan() => super.noSuchMethod(
|
||||
void resetCurrentRoutine() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#resetCurrentPlan,
|
||||
[],
|
||||
@@ -864,7 +864,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i21.WorkoutPlansProv
|
||||
);
|
||||
|
||||
@override
|
||||
_i19.Future<void> fetchAndSetAllPlansFull() => (super.noSuchMethod(
|
||||
_i19.Future<void> fetchAndSetAllRoutinesFull() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetAllPlansFull,
|
||||
[],
|
||||
@@ -874,7 +874,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i21.WorkoutPlansProv
|
||||
) as _i19.Future<void>);
|
||||
|
||||
@override
|
||||
_i19.Future<void> fetchAndSetAllPlansSparse() => (super.noSuchMethod(
|
||||
_i19.Future<void> fetchAndSetAllRoutinesSparse() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetAllPlansSparse,
|
||||
[],
|
||||
@@ -884,52 +884,52 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i21.WorkoutPlansProv
|
||||
) as _i19.Future<void>);
|
||||
|
||||
@override
|
||||
_i19.Future<_i12.WorkoutPlan> fetchAndSetPlanSparse(int? planId) => (super.noSuchMethod(
|
||||
_i19.Future<_i12.Routine> fetchAndSetRoutineSparse(int? planId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanSparse,
|
||||
[planId],
|
||||
),
|
||||
returnValue: _i19.Future<_i12.WorkoutPlan>.value(_FakeWorkoutPlan_12(
|
||||
returnValue: _i19.Future<_i12.Routine>.value(_FakeRoutine_12(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchAndSetPlanSparse,
|
||||
[planId],
|
||||
),
|
||||
)),
|
||||
) as _i19.Future<_i12.WorkoutPlan>);
|
||||
) as _i19.Future<_i12.Routine>);
|
||||
|
||||
@override
|
||||
_i19.Future<_i12.WorkoutPlan> fetchAndSetWorkoutPlanFull(int? workoutId) => (super.noSuchMethod(
|
||||
_i19.Future<_i12.Routine> fetchAndSetRoutineFull(int? workoutId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetWorkoutPlanFull,
|
||||
[workoutId],
|
||||
),
|
||||
returnValue: _i19.Future<_i12.WorkoutPlan>.value(_FakeWorkoutPlan_12(
|
||||
returnValue: _i19.Future<_i12.Routine>.value(_FakeRoutine_12(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchAndSetWorkoutPlanFull,
|
||||
[workoutId],
|
||||
),
|
||||
)),
|
||||
) as _i19.Future<_i12.WorkoutPlan>);
|
||||
) as _i19.Future<_i12.Routine>);
|
||||
|
||||
@override
|
||||
_i19.Future<_i12.WorkoutPlan> addWorkout(_i12.WorkoutPlan? workout) => (super.noSuchMethod(
|
||||
_i19.Future<_i12.Routine> addRoutine(_i12.Routine? workout) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addWorkout,
|
||||
[workout],
|
||||
),
|
||||
returnValue: _i19.Future<_i12.WorkoutPlan>.value(_FakeWorkoutPlan_12(
|
||||
returnValue: _i19.Future<_i12.Routine>.value(_FakeRoutine_12(
|
||||
this,
|
||||
Invocation.method(
|
||||
#addWorkout,
|
||||
[workout],
|
||||
),
|
||||
)),
|
||||
) as _i19.Future<_i12.WorkoutPlan>);
|
||||
) as _i19.Future<_i12.Routine>);
|
||||
|
||||
@override
|
||||
_i19.Future<void> editWorkout(_i12.WorkoutPlan? workout) => (super.noSuchMethod(
|
||||
_i19.Future<void> editRoutine(_i12.Routine? workout) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#editWorkout,
|
||||
[workout],
|
||||
@@ -939,7 +939,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i21.WorkoutPlansProv
|
||||
) as _i19.Future<void>);
|
||||
|
||||
@override
|
||||
_i19.Future<void> deleteWorkout(int? id) => (super.noSuchMethod(
|
||||
_i19.Future<void> deleteRoutine(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteWorkout,
|
||||
[id],
|
||||
@@ -950,7 +950,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i21.WorkoutPlansProv
|
||||
|
||||
@override
|
||||
_i19.Future<Map<String, dynamic>> fetchLogData(
|
||||
_i12.WorkoutPlan? workout,
|
||||
_i12.Routine? workout,
|
||||
_i3.ExerciseBase? base,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
@@ -997,7 +997,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i21.WorkoutPlansProv
|
||||
@override
|
||||
_i19.Future<_i13.Day> addDay(
|
||||
_i13.Day? day,
|
||||
_i12.WorkoutPlan? workout,
|
||||
_i12.Routine? workout,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -106,7 +106,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) => (super.noSuchMethod(
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getDefaultHeaders,
|
||||
[],
|
||||
@@ -152,7 +153,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -177,7 +179,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -193,7 +196,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
|
||||
@@ -106,7 +106,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) => (super.noSuchMethod(
|
||||
Map<String, String> getDefaultHeaders({dynamic includeAuth = false}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getDefaultHeaders,
|
||||
[],
|
||||
@@ -152,7 +153,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -177,7 +179,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
@@ -193,7 +196,8 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
returnValue:
|
||||
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
|
||||
@@ -22,7 +22,8 @@ import 'package:wger/providers/body_weight.dart' as _i4;
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake
|
||||
implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
@@ -45,7 +46,8 @@ class _FakeWeightEntry_1 extends _i1.SmartFake implements _i3.WeightEntry {
|
||||
/// A class which mocks [BodyWeightProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockBodyWeightProvider extends _i1.Mock implements _i4.BodyWeightProvider {
|
||||
class MockBodyWeightProvider extends _i1.Mock
|
||||
implements _i4.BodyWeightProvider {
|
||||
MockBodyWeightProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
@@ -105,7 +107,8 @@ class MockBodyWeightProvider extends _i1.Mock implements _i4.BodyWeightProvider
|
||||
) as _i3.WeightEntry);
|
||||
|
||||
@override
|
||||
_i3.WeightEntry? findByDate(DateTime? date) => (super.noSuchMethod(Invocation.method(
|
||||
_i3.WeightEntry? findByDate(DateTime? date) =>
|
||||
(super.noSuchMethod(Invocation.method(
|
||||
#findByDate,
|
||||
[date],
|
||||
)) as _i3.WeightEntry?);
|
||||
@@ -116,11 +119,13 @@ class MockBodyWeightProvider extends _i1.Mock implements _i4.BodyWeightProvider
|
||||
#fetchAndSetEntries,
|
||||
[],
|
||||
),
|
||||
returnValue: _i5.Future<List<_i3.WeightEntry>>.value(<_i3.WeightEntry>[]),
|
||||
returnValue:
|
||||
_i5.Future<List<_i3.WeightEntry>>.value(<_i3.WeightEntry>[]),
|
||||
) as _i5.Future<List<_i3.WeightEntry>>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i3.WeightEntry> addEntry(_i3.WeightEntry? entry) => (super.noSuchMethod(
|
||||
_i5.Future<_i3.WeightEntry> addEntry(_i3.WeightEntry? entry) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addEntry,
|
||||
[entry],
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
import 'package:wger/models/workouts/log.dart';
|
||||
import 'package:wger/models/workouts/repetition_unit.dart';
|
||||
import 'package:wger/models/workouts/set.dart';
|
||||
import 'package:wger/models/workouts/setting.dart';
|
||||
import 'package:wger/models/workouts/weight_unit.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
import 'package:wger/models/routines/day.dart';
|
||||
import 'package:wger/models/routines/log.dart';
|
||||
import 'package:wger/models/routines/repetition_unit.dart';
|
||||
import 'package:wger/models/routines/routine.dart';
|
||||
import 'package:wger/models/routines/set.dart';
|
||||
import 'package:wger/models/routines/setting.dart';
|
||||
import 'package:wger/models/routines/weight_unit.dart';
|
||||
|
||||
import './exercises.dart';
|
||||
|
||||
@@ -32,7 +32,7 @@ const weightUnit2 = WeightUnit(id: 2, name: 'metric tonnes');
|
||||
const RepetitionUnit repetitionUnit1 = RepetitionUnit(id: 1, name: 'Repetitions');
|
||||
const RepetitionUnit repetitionUnit2 = RepetitionUnit(id: 2, name: 'Hours');
|
||||
|
||||
WorkoutPlan getWorkout() {
|
||||
Routine getRoutine() {
|
||||
final testBases = getTestExerciseBases();
|
||||
|
||||
final log1 = Log.empty()
|
||||
@@ -41,7 +41,7 @@ WorkoutPlan getWorkout() {
|
||||
..rir = '1.5'
|
||||
..date = DateTime(2021, 5, 1)
|
||||
..reps = 10
|
||||
..workoutPlan = 1;
|
||||
..routineId = 1;
|
||||
log1.exerciseBase = testBases[0];
|
||||
log1.weightUnit = weightUnit1;
|
||||
log1.repetitionUnit = repetitionUnit1;
|
||||
@@ -52,7 +52,7 @@ WorkoutPlan getWorkout() {
|
||||
..rir = '2'
|
||||
..date = DateTime(2021, 5, 1)
|
||||
..reps = 12
|
||||
..workoutPlan = 1;
|
||||
..routineId = 1;
|
||||
log2.exerciseBase = testBases[0];
|
||||
log2.weightUnit = weightUnit1;
|
||||
log2.repetitionUnit = repetitionUnit1;
|
||||
@@ -63,7 +63,7 @@ WorkoutPlan getWorkout() {
|
||||
..rir = ''
|
||||
..date = DateTime(2021, 5, 2)
|
||||
..reps = 8
|
||||
..workoutPlan = 1;
|
||||
..routineId = 1;
|
||||
log3.exerciseBase = testBases[1];
|
||||
log3.weightUnit = weightUnit1;
|
||||
log3.repetitionUnit = repetitionUnit1;
|
||||
@@ -146,7 +146,7 @@ WorkoutPlan getWorkout() {
|
||||
|
||||
final dayChestShoulders = Day()
|
||||
..id = 1
|
||||
..workoutId = 1
|
||||
..routineId = 1
|
||||
..description = 'chest, shoulders'
|
||||
..daysOfWeek = [1, 2];
|
||||
dayChestShoulders.sets.add(setBenchPress);
|
||||
@@ -154,12 +154,12 @@ WorkoutPlan getWorkout() {
|
||||
|
||||
final dayLegs = Day()
|
||||
..id = 2
|
||||
..workoutId = 1
|
||||
..routineId = 1
|
||||
..description = 'legs'
|
||||
..daysOfWeek = [4];
|
||||
dayLegs.sets.add(setSquat);
|
||||
|
||||
final workout = WorkoutPlan(
|
||||
final workout = Routine(
|
||||
id: 1,
|
||||
creationDate: DateTime(2021, 01, 01),
|
||||
name: '3 day workout',
|
||||
Reference in New Issue
Block a user