From 7b0f02e88fff6e61a0433cf6913aed44756cd629 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Thu, 12 May 2022 15:28:26 +0200 Subject: [PATCH] Add user profile page Closes #71 --- lib/l10n/app_en.arb | 9 ++ lib/main.dart | 7 ++ lib/models/user/profile.dart | 43 ++++++++ lib/providers/exercises.dart | 2 +- lib/providers/user.dart | 64 ++++++++++++ lib/screens/home_tabs_screen.dart | 21 ++-- lib/widgets/core/app_bar.dart | 33 +++++-- lib/widgets/user/forms.dart | 96 ++++++++++++++++++ test/fixtures/user/userprofile_response.json | 36 +++++++ test/user/provider_test.dart | 94 ++++++++++++++++++ test/workout/workout_set_form_test.mocks.dart | 98 +++++++++++-------- 11 files changed, 447 insertions(+), 56 deletions(-) create mode 100644 lib/models/user/profile.dart create mode 100644 lib/providers/user.dart create mode 100644 lib/widgets/user/forms.dart create mode 100644 test/fixtures/user/userprofile_response.json create mode 100644 test/user/provider_test.dart diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 3868b8f82..217e0bc9a 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -1,5 +1,6 @@ { "@@last_modified": "2020-11-11T15:04:05.523531", + "userProfile": "User profile", "login": "Log in", "@login": { "description": "Text for login button" @@ -577,6 +578,14 @@ }, "description": "List of alternative names for an exercise" }, + "verifiedEmail": "Verified email", + "verifiedEmailReason": "You need to verify your email to contribute exercises", + "verifiedEmailInfo": "A verification email was sent to {email}", + "@verifiedEmailInfo": { + "placeholders": { + "email": {} + } + }, "alternativeNames": "Alternative names", "oneNamePerLine": "One name per line", "whatVariationsExist": "What variations of this exercise exist, if any?", diff --git a/lib/main.dart b/lib/main.dart index cfd9eedba..97b600b27 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -26,6 +26,7 @@ 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/user.dart'; import 'package:wger/providers/workout_plans.dart'; import 'package:wger/screens/add_exercise_screen.dart'; import 'package:wger/screens/auth_screen.dart'; @@ -94,6 +95,12 @@ class MyApp extends StatelessWidget { update: (context, base, previous) => previous ?? MeasurementProvider(WgerBaseProvider(base)), ), + ChangeNotifierProxyProvider( + create: (context) => UserProvider( + WgerBaseProvider(Provider.of(context, listen: false)), + ), + update: (context, base, previous) => previous ?? UserProvider(WgerBaseProvider(base)), + ), ChangeNotifierProxyProvider( create: (context) => BodyWeightProvider(Provider.of(context, listen: false), []), diff --git a/lib/models/user/profile.dart b/lib/models/user/profile.dart new file mode 100644 index 000000000..bf80eefbc --- /dev/null +++ b/lib/models/user/profile.dart @@ -0,0 +1,43 @@ +/* + * This file is part of wger Workout Manager . + * Copyright (C) 2020, 2021 wger Team + * + * wger Workout Manager is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wger Workout Manager is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import 'package:json_annotation/json_annotation.dart'; + +part 'profile.g.dart'; + +@JsonSerializable() +class Profile { + @JsonKey(required: true) + int id; + + @JsonKey(required: true, name: 'email_verified') + bool emailVerified; + + @JsonKey(required: true) + String email; + + Profile({ + required this.id, + required this.emailVerified, + required this.email, + }); + + // Boilerplate + factory Profile.fromJson(Map json) => _$ProfileFromJson(json); + Map toJson() => _$ProfileToJson(this); +} diff --git a/lib/providers/exercises.dart b/lib/providers/exercises.dart index d5598bfed..53d0dab0d 100644 --- a/lib/providers/exercises.dart +++ b/lib/providers/exercises.dart @@ -42,7 +42,7 @@ class ExercisesProvider with ChangeNotifier { ExercisesProvider(this.baseProvider); static const EXERCISE_CACHE_DAYS = 7; - static const CACHE_VERSION = 3; + static const CACHE_VERSION = 4; static const daysToCache = 7; static const _exerciseBaseInfoUrlPath = 'exercisebaseinfo'; diff --git a/lib/providers/user.dart b/lib/providers/user.dart new file mode 100644 index 000000000..be1adbb65 --- /dev/null +++ b/lib/providers/user.dart @@ -0,0 +1,64 @@ +/* + * This file is part of wger Workout Manager . + * Copyright (C) 2020, 2021 wger Team + * + * wger Workout Manager is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:wger/models/user/profile.dart'; +import 'package:wger/providers/base_provider.dart'; + +class UserProvider with ChangeNotifier { + final WgerBaseProvider baseProvider; + UserProvider(this.baseProvider); + + static const _profileUrlPath = 'userprofile'; + static const _verifyEmail = 'verify-email'; + + Profile? _profile; + + Profile? get profile => _profile; + set profile(Profile? profile) { + _profile = profile; + } + + int get userId => _profile!.id; + + /// Clear the current profile + void clear() { + _profile = null; + } + + /// Fetch the current user's profile + Future fetchAndSetProfile() async { + final userData = await baseProvider.fetch(baseProvider.makeUrl(_profileUrlPath)); + try { + _profile = Profile.fromJson(userData['results'][0]); + } catch (error) { + rethrow; + } + } + + /// Verify the user's email + Future verifyEmail() async { + final userData = await baseProvider.fetch(baseProvider.makeUrl( + _profileUrlPath, + id: userId, + objectMethod: _verifyEmail, + )); + } +} diff --git a/lib/screens/home_tabs_screen.dart b/lib/screens/home_tabs_screen.dart index 48389d863..588dbf04a 100644 --- a/lib/screens/home_tabs_screen.dart +++ b/lib/screens/home_tabs_screen.dart @@ -29,6 +29,7 @@ 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/user.dart'; import 'package:wger/providers/workout_plans.dart'; import 'package:wger/screens/dashboard.dart'; import 'package:wger/screens/gallery_screen.dart'; @@ -72,18 +73,20 @@ class _HomeTabsScreenState extends State with SingleTickerProvid /// Load initial data from the server Future _loadEntries() async { if (!Provider.of(context, listen: false).dataInit) { - Provider.of(context, listen: false).setServerVersion(); - - final workoutPlansProvider = Provider.of(context, listen: false); - final nutritionPlansProvider = Provider.of(context, listen: false); - final exercisesProvider = Provider.of(context, listen: false); - final galleryProvider = Provider.of(context, listen: false); - final weightProvider = Provider.of(context, listen: false); - final measurementProvider = Provider.of(context, listen: false); + final authProvider = context.read(); + final workoutPlansProvider = context.read(); + final nutritionPlansProvider = context.read(); + final exercisesProvider = context.read(); + final galleryProvider = context.read(); + final weightProvider = context.read(); + final measurementProvider = context.read(); + final userProvider = context.read(); // Base data log('Loading base data'); await Future.wait([ + authProvider.setServerVersion(), + userProvider.fetchAndSetProfile(), workoutPlansProvider.fetchAndSetUnits(), nutritionPlansProvider.fetchIngredientsFromCache(), exercisesProvider.fetchAndSetExercises(), @@ -115,7 +118,7 @@ class _HomeTabsScreenState extends State with SingleTickerProvid } } - Provider.of(context, listen: false).dataInit = true; + context.read().dataInit = true; } @override diff --git a/lib/widgets/core/app_bar.dart b/lib/widgets/core/app_bar.dart index 5311f681c..53c0dffda 100644 --- a/lib/widgets/core/app_bar.dart +++ b/lib/widgets/core/app_bar.dart @@ -24,8 +24,11 @@ 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/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'; class MainAppBar extends StatelessWidget with PreferredSizeWidget { final String _title; @@ -57,22 +60,40 @@ class MainAppBar extends StatelessWidget with PreferredSizeWidget { content: Column( mainAxisSize: MainAxisSize.min, children: [ + ListTile( + //dense: true, + leading: const Icon(Icons.person), + title: Text(AppLocalizations.of(context).userProfile), + onTap: () async { + await context.read().fetchAndSetProfile(); + Navigator.pushNamed( + context, + FormScreen.routeName, + arguments: FormScreenArguments( + AppLocalizations.of(context).userProfile, + UserProfileForm(), + ), + ); + }, + ), + WgerAboutListTile(), const Divider(), ListTile( //dense: true, leading: const Icon(Icons.exit_to_app), title: Text(AppLocalizations.of(context).logout), onTap: () { - Provider.of(context, listen: false).logout(); - Provider.of(context, listen: false).clear(); - Provider.of(context, listen: false).clear(); - Provider.of(context, listen: false).clear(); - Provider.of(context, listen: false).clear(); + context.read().logout(); + context.read().clear(); + context.read().clear(); + context.read().clear(); + context.read().clear(); + context.read().clear(); + Navigator.of(context).pop(); Navigator.of(context).pushReplacementNamed('/'); }, ), - WgerAboutListTile() ], ), ); diff --git a/lib/widgets/user/forms.dart b/lib/widgets/user/forms.dart new file mode 100644 index 000000000..06557085e --- /dev/null +++ b/lib/widgets/user/forms.dart @@ -0,0 +1,96 @@ +/* + * This file is part of wger Workout Manager . + * Copyright (C) 2020, 2021 wger Team + * + * wger Workout Manager is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wger Workout Manager is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:provider/provider.dart'; +import 'package:wger/models/user/profile.dart'; +import 'package:wger/providers/user.dart'; + +class UserProfileForm extends StatefulWidget { + late Profile _profile; + + UserProfileForm() { + //_weightEntry = weightEntry ?? WeightEntry(date: DateTime.now()); + //weightController.text = _weightEntry.id == null ? '' : _weightEntry.weight.toString(); + //dateController.text = toDate(_weightEntry.date)!; + } + + @override + State createState() => _UserProfileFormState(); +} + +class _UserProfileFormState extends State { + final _form = GlobalKey(); + + final dateController = TextEditingController(); + + final weightController = TextEditingController(); + + @override + Widget build(BuildContext context) { + widget._profile = context.read().profile!; + + return Form( + key: _form, + child: Column( + children: [ + // Weight date + SwitchListTile( + title: Text(AppLocalizations.of(context).verifiedEmail), + subtitle: Text(AppLocalizations.of(context).verifiedEmailReason), + value: widget._profile.emailVerified, + onChanged: (bool value) async { + // Email is already verified + if (widget._profile.emailVerified) { + return; + } + + // Verify + await context.read().verifyEmail(); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + AppLocalizations.of(context).verifiedEmailInfo(widget._profile.email), + ), + ), + ); + }, + ), + ElevatedButton( + child: Text(AppLocalizations.of(context).save), + onPressed: () async { + // Validate and save the current values to the weightEntry + final isValid = _form.currentState!.validate(); + if (!isValid) { + return; + } + _form.currentState!.save(); + + // Update profile + //context.read().updateProfile(); + + Navigator.of(context).pop(); + }, + ), + ], + ), + ); + } +} diff --git a/test/fixtures/user/userprofile_response.json b/test/fixtures/user/userprofile_response.json new file mode 100644 index 000000000..5405b27ec --- /dev/null +++ b/test/fixtures/user/userprofile_response.json @@ -0,0 +1,36 @@ +{ + "count": 1, + "next": null, + "previous": null, + "results": [ + { + "id": 42, + "email": "me@example.com", + "email_verified": false, + "gym": 1, + "is_temporary": false, + "show_comments": false, + "show_english_ingredients": false, + "workout_reminder_active": false, + "workout_reminder": 14, + "workout_duration": 12, + "last_workout_notification": null, + "notification_language": 2, + "age": null, + "birthdate": null, + "height": null, + "gender": "1", + "sleep_hours": 7, + "work_hours": 8, + "work_intensity": "1", + "sport_hours": 3, + "sport_intensity": "2", + "freetime_hours": 8, + "freetime_intensity": "1", + "calories": 2500, + "weight_unit": "kg", + "ro_access": false, + "num_days_weight_reminder": 0 + } + ] +} \ No newline at end of file diff --git a/test/user/provider_test.dart b/test/user/provider_test.dart new file mode 100644 index 000000000..1d248ac29 --- /dev/null +++ b/test/user/provider_test.dart @@ -0,0 +1,94 @@ +/* + * This file is part of wger Workout Manager . + * Copyright (C) 2020, 2021 wger Team + * + * wger Workout Manager is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wger Workout Manager is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import 'dart:convert'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; +import 'package:wger/providers/user.dart'; + +import '../fixtures/fixture_reader.dart'; +import '../measurements/measurement_provider_test.mocks.dart'; + +void main() { + late UserProvider userProvider; + late MockWgerBaseProvider mockWgerBaseProvider; + + const String profileUrl = 'userprofile'; + final Map tUserProfileMap = + jsonDecode(fixture('user/userprofile_response.json')); + final Uri tProfileUri = Uri( + scheme: 'http', + host: 'localhost', + path: 'api/v2/$profileUrl/', + ); + final Uri tEmailVerifyUri = Uri( + scheme: 'http', + host: 'localhost', + path: 'api/v2/$profileUrl/verify-email', + ); + + setUp(() { + mockWgerBaseProvider = MockWgerBaseProvider(); + userProvider = UserProvider(mockWgerBaseProvider); + + when(mockWgerBaseProvider.makeUrl(any)).thenReturn(tProfileUri); + when(mockWgerBaseProvider.makeUrl(any, id: 42, objectMethod: 'verify-email')) + .thenReturn(tEmailVerifyUri); + when(mockWgerBaseProvider.fetch(any)) + .thenAnswer((realInvocation) => Future.value(tUserProfileMap)); + }); + + group('house keeping', () { + test('should clear the profile list with clear()', () async { + // arrange + await userProvider.fetchAndSetProfile(); + + // assert + expect(userProvider.profile, isNot(null)); + expect(userProvider.profile!.id, 42); + + // act + userProvider.clear(); + + // assert + expect(userProvider.profile, null); + }); + }); + + group('profile', () { + test('Loading the profile from the server works', () async { + // arrange + await userProvider.fetchAndSetProfile(); + + // assert + expect(userProvider.profile!.id, 42); + expect(userProvider.profile!.emailVerified, false); + expect(userProvider.profile!.email, 'me@example.com'); + }); + + test('Sending the verify email works', () async { + // arrange + await userProvider.fetchAndSetProfile(); + await userProvider.verifyEmail(); + + // assert + verify(userProvider.baseProvider.fetch(tEmailVerifyUri)); + }); + }); +} diff --git a/test/workout/workout_set_form_test.mocks.dart b/test/workout/workout_set_form_test.mocks.dart index e714be8f8..dc4453f1a 100644 --- a/test/workout/workout_set_form_test.mocks.dart +++ b/test/workout/workout_set_form_test.mocks.dart @@ -24,11 +24,13 @@ import 'package:wger/providers/exercises.dart' as _i8; // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types -class _FakeWgerBaseProvider_0 extends _i1.Fake implements _i2.WgerBaseProvider {} +class _FakeWgerBaseProvider_0 extends _i1.Fake implements _i2.WgerBaseProvider { +} class _FakeExerciseBase_1 extends _i1.Fake implements _i3.ExerciseBase {} -class _FakeExerciseCategory_2 extends _i1.Fake implements _i4.ExerciseCategory {} +class _FakeExerciseCategory_2 extends _i1.Fake implements _i4.ExerciseCategory { +} class _FakeEquipment_3 extends _i1.Fake implements _i5.Equipment {} @@ -46,8 +48,8 @@ class MockExercisesProvider extends _i1.Mock implements _i8.ExercisesProvider { @override _i2.WgerBaseProvider get baseProvider => - (super.noSuchMethod(Invocation.getter(#baseProvider), returnValue: _FakeWgerBaseProvider_0()) - as _i2.WgerBaseProvider); + (super.noSuchMethod(Invocation.getter(#baseProvider), + returnValue: _FakeWgerBaseProvider_0()) as _i2.WgerBaseProvider); @override set exerciseBases(List<_i3.ExerciseBase>? exercisesBases) => super.noSuchMethod(Invocation.setter(#exerciseBases, exercisesBases), @@ -58,57 +60,65 @@ class MockExercisesProvider extends _i1.Mock implements _i8.ExercisesProvider { returnValue: <_i3.ExerciseBase>[]) as List<_i3.ExerciseBase>); @override set filteredExerciseBases(List<_i3.ExerciseBase>? newFilteredExercises) => - super.noSuchMethod(Invocation.setter(#filteredExerciseBases, newFilteredExercises), + super.noSuchMethod( + Invocation.setter(#filteredExerciseBases, newFilteredExercises), returnValueForMissingStub: null); @override Map> get exerciseBasesByVariation => (super.noSuchMethod(Invocation.getter(#exerciseBasesByVariation), - returnValue: >{}) as Map>); + returnValue: >{}) + as Map>); @override List<_i3.ExerciseBase> get bases => - (super.noSuchMethod(Invocation.getter(#bases), returnValue: <_i3.ExerciseBase>[]) - as List<_i3.ExerciseBase>); + (super.noSuchMethod(Invocation.getter(#bases), + returnValue: <_i3.ExerciseBase>[]) as List<_i3.ExerciseBase>); @override List<_i4.ExerciseCategory> get categories => - (super.noSuchMethod(Invocation.getter(#categories), returnValue: <_i4.ExerciseCategory>[]) - as List<_i4.ExerciseCategory>); + (super.noSuchMethod(Invocation.getter(#categories), + returnValue: <_i4.ExerciseCategory>[]) as List<_i4.ExerciseCategory>); @override List<_i6.Muscle> get muscles => - (super.noSuchMethod(Invocation.getter(#muscles), returnValue: <_i6.Muscle>[]) - as List<_i6.Muscle>); + (super.noSuchMethod(Invocation.getter(#muscles), + returnValue: <_i6.Muscle>[]) as List<_i6.Muscle>); @override List<_i5.Equipment> get equipment => - (super.noSuchMethod(Invocation.getter(#equipment), returnValue: <_i5.Equipment>[]) - as List<_i5.Equipment>); + (super.noSuchMethod(Invocation.getter(#equipment), + returnValue: <_i5.Equipment>[]) as List<_i5.Equipment>); @override List<_i7.Language> get languages => - (super.noSuchMethod(Invocation.getter(#languages), returnValue: <_i7.Language>[]) - as List<_i7.Language>); + (super.noSuchMethod(Invocation.getter(#languages), + returnValue: <_i7.Language>[]) as List<_i7.Language>); + @override + set languages(List<_i7.Language>? languages) => + super.noSuchMethod(Invocation.setter(#languages, languages), + returnValueForMissingStub: null); @override bool get hasListeners => - (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool); + (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) + as bool); @override _i9.Future setFilters(_i8.Filters? newFilters) => (super.noSuchMethod(Invocation.method(#setFilters, [newFilters]), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i9.Future); @override - _i9.Future findByFilters() => (super.noSuchMethod(Invocation.method(#findByFilters, []), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i9.Future); + _i9.Future findByFilters() => + (super.noSuchMethod(Invocation.method(#findByFilters, []), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i9.Future); @override - void clear() => - super.noSuchMethod(Invocation.method(#clear, []), returnValueForMissingStub: null); + void clear() => super.noSuchMethod(Invocation.method(#clear, []), + returnValueForMissingStub: null); @override _i3.ExerciseBase findExerciseBaseById(int? id) => (super.noSuchMethod(Invocation.method(#findExerciseBaseById, [id]), returnValue: _FakeExerciseBase_1()) as _i3.ExerciseBase); @override List<_i3.ExerciseBase> findExerciseBasesByVariationId(int? id, - {int? exerciseBaseIdToExclude, int? languageId}) => + {int? exerciseBaseIdToExclude}) => (super.noSuchMethod( Invocation.method(#findExerciseBasesByVariationId, [id], - {#exerciseIdToExclude: exerciseBaseIdToExclude, #languageId: languageId}), + {#exerciseBaseIdToExclude: exerciseBaseIdToExclude}), returnValue: <_i3.ExerciseBase>[]) as List<_i3.ExerciseBase>); @override _i4.ExerciseCategory findCategoryById(int? id) => @@ -120,12 +130,12 @@ class MockExercisesProvider extends _i1.Mock implements _i8.ExercisesProvider { returnValue: _FakeEquipment_3()) as _i5.Equipment); @override _i6.Muscle findMuscleById(int? id) => - (super.noSuchMethod(Invocation.method(#findMuscleById, [id]), returnValue: _FakeMuscle_4()) - as _i6.Muscle); + (super.noSuchMethod(Invocation.method(#findMuscleById, [id]), + returnValue: _FakeMuscle_4()) as _i6.Muscle); @override - _i7.Language findLanguageById(int? id) => (super - .noSuchMethod(Invocation.method(#findLanguageById, [id]), returnValue: _FakeLanguage_5()) - as _i7.Language); + _i7.Language findLanguageById(int? id) => + (super.noSuchMethod(Invocation.method(#findLanguageById, [id]), + returnValue: _FakeLanguage_5()) as _i7.Language); @override _i9.Future fetchAndSetCategories() => (super.noSuchMethod(Invocation.method(#fetchAndSetCategories, []), @@ -153,12 +163,15 @@ class MockExercisesProvider extends _i1.Mock implements _i8.ExercisesProvider { returnValueForMissingStub: Future.value()) as _i9.Future); @override _i9.Future<_i3.ExerciseBase> fetchAndSetExerciseBase(int? exerciseBaseId) => - (super.noSuchMethod(Invocation.method(#fetchAndSetExerciseBase, [exerciseBaseId]), - returnValue: Future<_i3.ExerciseBase>.value(_FakeExerciseBase_1())) + (super.noSuchMethod( + Invocation.method(#fetchAndSetExerciseBase, [exerciseBaseId]), + returnValue: + Future<_i3.ExerciseBase>.value(_FakeExerciseBase_1())) as _i9.Future<_i3.ExerciseBase>); @override _i3.ExerciseBase readExerciseBaseFromBaseInfo(dynamic baseData) => - (super.noSuchMethod(Invocation.method(#readExerciseBaseFromBaseInfo, [baseData]), + (super.noSuchMethod( + Invocation.method(#readExerciseBaseFromBaseInfo, [baseData]), returnValue: _FakeExerciseBase_1()) as _i3.ExerciseBase); @override _i9.Future checkExerciseCacheVersion() => @@ -171,21 +184,26 @@ class MockExercisesProvider extends _i1.Mock implements _i8.ExercisesProvider { returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i9.Future); @override - _i9.Future> searchExercise(String? name, [String? languageCode = r'en']) => - (super.noSuchMethod(Invocation.method(#searchExercise, [name, languageCode]), - returnValue: Future>.value(<_i3.ExerciseBase>[])) + _i9.Future> searchExercise(String? name, + [String? languageCode = r'en']) => + (super.noSuchMethod( + Invocation.method(#searchExercise, [name, languageCode]), + returnValue: + Future>.value(<_i3.ExerciseBase>[])) as _i9.Future>); @override - void addListener(_i10.VoidCallback? listener) => super - .noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); + void addListener(_i10.VoidCallback? listener) => + super.noSuchMethod(Invocation.method(#addListener, [listener]), + returnValueForMissingStub: null); @override void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#removeListener, [listener]), returnValueForMissingStub: null); @override - void dispose() => - super.noSuchMethod(Invocation.method(#dispose, []), returnValueForMissingStub: null); + void dispose() => super.noSuchMethod(Invocation.method(#dispose, []), + returnValueForMissingStub: null); @override void notifyListeners() => - super.noSuchMethod(Invocation.method(#notifyListeners, []), returnValueForMissingStub: null); + super.noSuchMethod(Invocation.method(#notifyListeners, []), + returnValueForMissingStub: null); }