mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Allow passing the language to the fetch request
This allows us to use the trophy translations from the server.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 wger Team
|
||||
* Copyright (c) 2025 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
|
||||
@@ -37,7 +37,7 @@ class WgerBaseProvider {
|
||||
this.client = client ?? http.Client();
|
||||
}
|
||||
|
||||
Map<String, String> getDefaultHeaders({bool includeAuth = false}) {
|
||||
Map<String, String> getDefaultHeaders({bool includeAuth = false, String? language}) {
|
||||
final out = {
|
||||
HttpHeaders.contentTypeHeader: 'application/json; charset=UTF-8',
|
||||
HttpHeaders.userAgentHeader: auth.getAppNameHeader(),
|
||||
@@ -47,6 +47,10 @@ class WgerBaseProvider {
|
||||
out[HttpHeaders.authorizationHeader] = 'Token ${auth.token}';
|
||||
}
|
||||
|
||||
if (language != null) {
|
||||
out[HttpHeaders.acceptLanguageHeader] = language;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -56,8 +60,7 @@ class WgerBaseProvider {
|
||||
}
|
||||
|
||||
/// Fetch and retrieve the overview list of objects, returns the JSON parsed response
|
||||
Future<dynamic> fetch(Uri uri) async {
|
||||
// Future<Map<String, dynamic> | List<dynamic>> fetch(Uri uri) async {
|
||||
Future<dynamic> fetch(Uri uri, {String? language}) async {
|
||||
// Send the request
|
||||
final response = await client.get(
|
||||
uri,
|
||||
@@ -74,13 +77,13 @@ class WgerBaseProvider {
|
||||
}
|
||||
|
||||
/// Fetch and retrieve the overview list of objects, returns the JSON parsed response
|
||||
Future<List<dynamic>> fetchPaginated(Uri uri) async {
|
||||
Future<List<dynamic>> fetchPaginated(Uri uri, {String? language}) async {
|
||||
final out = [];
|
||||
var url = uri;
|
||||
var allPagesProcessed = false;
|
||||
|
||||
while (!allPagesProcessed) {
|
||||
final data = await fetch(url);
|
||||
final data = await fetch(url, language: language);
|
||||
|
||||
data['results'].forEach((e) => out.add(e));
|
||||
|
||||
|
||||
@@ -38,10 +38,10 @@ class TrophyRepository {
|
||||
|
||||
TrophyRepository(this.base);
|
||||
|
||||
Future<List<Trophy>> fetchTrophies() async {
|
||||
Future<List<Trophy>> fetchTrophies({String? language}) async {
|
||||
try {
|
||||
final url = base.makeUrl(trophiesPath, query: {'limit': API_MAX_PAGE_SIZE});
|
||||
final trophyData = await base.fetchPaginated(url);
|
||||
final trophyData = await base.fetchPaginated(url, language: language);
|
||||
return trophyData.map((e) => Trophy.fromJson(e)).toList();
|
||||
} catch (e, stk) {
|
||||
_logger.warning('Error fetching trophies:', e, stk);
|
||||
@@ -49,7 +49,10 @@ class TrophyRepository {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<UserTrophy>> fetchUserTrophies({Map<String, String>? filterQuery}) async {
|
||||
Future<List<UserTrophy>> fetchUserTrophies({
|
||||
Map<String, String>? filterQuery,
|
||||
String? language,
|
||||
}) async {
|
||||
final query = {'limit': API_MAX_PAGE_SIZE};
|
||||
if (filterQuery != null) {
|
||||
query.addAll(filterQuery);
|
||||
@@ -57,7 +60,7 @@ class TrophyRepository {
|
||||
|
||||
try {
|
||||
final url = base.makeUrl(userTrophiesPath, query: query);
|
||||
final trophyData = await base.fetchPaginated(url);
|
||||
final trophyData = await base.fetchPaginated(url, language: language);
|
||||
return trophyData.map((e) => UserTrophy.fromJson(e)).toList();
|
||||
} catch (e, stk) {
|
||||
_logger.warning('Error fetching user trophies:');
|
||||
@@ -67,10 +70,13 @@ class TrophyRepository {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<UserTrophyProgression>> fetchProgression({Map<String, String>? filterQuery}) async {
|
||||
Future<List<UserTrophyProgression>> fetchProgression({
|
||||
Map<String, String>? filterQuery,
|
||||
String? language,
|
||||
}) async {
|
||||
try {
|
||||
final url = base.makeUrl(userTrophyProgressionPath, query: filterQuery);
|
||||
final List<dynamic> data = await base.fetch(url);
|
||||
final List<dynamic> data = await base.fetch(url, language: language);
|
||||
return data.map((e) => UserTrophyProgression.fromJson(e)).toList();
|
||||
} catch (e, stk) {
|
||||
_logger.warning('Error fetching user trophy progression:', e, stk);
|
||||
@@ -102,24 +108,28 @@ final class TrophyStateNotifier extends _$TrophyStateNotifier {
|
||||
/// Fetch trophies awarded to the user.
|
||||
/// Excludes hidden trophies as well as repeatable (PR) trophies since they are
|
||||
/// handled separately
|
||||
Future<List<UserTrophy>> fetchUserTrophies() async {
|
||||
Future<List<UserTrophy>> fetchUserTrophies({String? language}) async {
|
||||
final repo = ref.read(trophyRepositoryProvider);
|
||||
return repo.fetchUserTrophies(
|
||||
filterQuery: {'trophy__is_hidden': 'false', 'trophy__is_repeatable': 'false'},
|
||||
language: language,
|
||||
);
|
||||
}
|
||||
|
||||
/// Fetch PR trophies awarded to the user
|
||||
Future<List<UserTrophy>> fetchUserPRTrophies() async {
|
||||
Future<List<UserTrophy>> fetchUserPRTrophies({String? language}) async {
|
||||
final repo = ref.read(trophyRepositoryProvider);
|
||||
return repo.fetchUserTrophies(filterQuery: {'trophy__trophy_type': TrophyType.pr.name});
|
||||
return repo.fetchUserTrophies(
|
||||
filterQuery: {'trophy__trophy_type': TrophyType.pr.name},
|
||||
language: language,
|
||||
);
|
||||
}
|
||||
|
||||
/// Fetch trophy progression for the user
|
||||
Future<List<UserTrophyProgression>> fetchTrophyProgression() async {
|
||||
Future<List<UserTrophyProgression>> fetchTrophyProgression({String? language}) async {
|
||||
final repo = ref.read(trophyRepositoryProvider);
|
||||
return repo.fetchProgression(
|
||||
filterQuery: {'trophy__is_hidden': 'false', 'trophy__is_repeatable': 'false'},
|
||||
);
|
||||
|
||||
// Note that repeatable trophies are filtered out in the backend
|
||||
return repo.fetchProgression(language: language);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ final class TrophyStateNotifierProvider extends $NotifierProvider<TrophyStateNot
|
||||
}
|
||||
}
|
||||
|
||||
String _$trophyStateNotifierHash() => r'7f50ce352d980168dae169916a17d9b62b388d28';
|
||||
String _$trophyStateNotifierHash() => r'47b4babf337bbb8bf60142ebe59dc760fa08dce3';
|
||||
|
||||
abstract class _$TrophyStateNotifier extends $Notifier<void> {
|
||||
void build();
|
||||
|
||||
@@ -29,9 +29,10 @@ class DashboardTrophiesWidget extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final provider = ref.watch(trophyStateProvider.notifier);
|
||||
final languageCode = Localizations.localeOf(context).languageCode;
|
||||
|
||||
return FutureBuilder(
|
||||
future: provider.fetchUserTrophies(),
|
||||
future: provider.fetchUserTrophies(language: languageCode),
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState != ConnectionState.done) {
|
||||
return const Card(child: BoxedProgressIndicator());
|
||||
|
||||
@@ -549,6 +549,9 @@ class _LogFormWidgetState extends ConsumerState<LogFormWidget> {
|
||||
_weightController = TextEditingController();
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
_syncControllersWithWidget();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import '../logs/muscle_groups.dart';
|
||||
|
||||
class WorkoutSummary extends ConsumerStatefulWidget {
|
||||
final _logger = Logger('WorkoutSummary');
|
||||
|
||||
final PageController _controller;
|
||||
|
||||
WorkoutSummary(this._controller);
|
||||
@@ -51,14 +50,24 @@ class _WorkoutSummaryState extends ConsumerState<WorkoutSummary> {
|
||||
late Future<void> _initData;
|
||||
late Routine _routine;
|
||||
late List<UserTrophy> _userPrTrophies;
|
||||
bool _didInit = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initData = _reloadRoutineData();
|
||||
}
|
||||
|
||||
Future<void> _reloadRoutineData() async {
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
if (!_didInit) {
|
||||
final languageCode = Localizations.localeOf(context).languageCode;
|
||||
_initData = _reloadRoutineData(languageCode);
|
||||
_didInit = true;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _reloadRoutineData(String languageCode) async {
|
||||
widget._logger.fine('Loading routine data');
|
||||
final gymState = ref.read(gymStateProvider);
|
||||
|
||||
@@ -67,7 +76,7 @@ class _WorkoutSummaryState extends ConsumerState<WorkoutSummary> {
|
||||
);
|
||||
|
||||
final trophyNotifier = ref.read(trophyStateProvider.notifier);
|
||||
_userPrTrophies = await trophyNotifier.fetchUserPRTrophies();
|
||||
_userPrTrophies = await trophyNotifier.fetchUserPRTrophies(language: languageCode);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -86,7 +95,9 @@ class _WorkoutSummaryState extends ConsumerState<WorkoutSummary> {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const BoxedProgressIndicator();
|
||||
} else if (snapshot.hasError) {
|
||||
return Center(child: Text('Error: ${snapshot.error}: ${snapshot.stackTrace}'));
|
||||
widget._logger.warning(snapshot.error);
|
||||
widget._logger.warning(snapshot.stackTrace);
|
||||
return Center(child: Text('Error: ${snapshot.error}'));
|
||||
} else if (snapshot.connectionState == ConnectionState.done) {
|
||||
final apiSession = _routine.sessions.firstWhereOrNull(
|
||||
(s) => s.session.date.isSameDayAs(clock.now()),
|
||||
|
||||
@@ -29,6 +29,7 @@ class TrophiesOverview extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final notifier = ref.watch(trophyStateProvider.notifier);
|
||||
final languageCode = Localizations.localeOf(context).languageCode;
|
||||
|
||||
// Responsive grid: determine columns based on screen width
|
||||
final width = MediaQuery.widthOf(context);
|
||||
@@ -44,7 +45,7 @@ class TrophiesOverview extends ConsumerWidget {
|
||||
}
|
||||
|
||||
return FutureBuilder<List<UserTrophyProgression>>(
|
||||
future: notifier.fetchTrophyProgression(),
|
||||
future: notifier.fetchTrophyProgression(language: languageCode),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) {
|
||||
return const Card(child: BoxedProgressIndicator());
|
||||
|
||||
@@ -1066,10 +1066,14 @@ class MockWgerBaseProvider extends _i1.Mock implements _i2.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
Map<String, String> getDefaultHeaders({
|
||||
bool? includeAuth = false,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
@@ -1100,17 +1104,17 @@ class MockWgerBaseProvider extends _i1.Mock implements _i2.WgerBaseProvider {
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i18.Future<dynamic> fetch(Uri? uri) =>
|
||||
_i18.Future<dynamic> fetch(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(#fetch, [uri], {#language: language}),
|
||||
returnValue: _i18.Future<dynamic>.value(),
|
||||
)
|
||||
as _i18.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i18.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
_i18.Future<List<dynamic>> fetchPaginated(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(#fetchPaginated, [uri], {#language: language}),
|
||||
returnValue: _i18.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i18.Future<List<dynamic>>);
|
||||
|
||||
@@ -368,10 +368,14 @@ class MockWgerBaseProvider extends _i1.Mock implements _i2.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
Map<String, String> getDefaultHeaders({
|
||||
bool? includeAuth = false,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
@@ -402,17 +406,17 @@ class MockWgerBaseProvider extends _i1.Mock implements _i2.WgerBaseProvider {
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i14.Future<dynamic> fetch(Uri? uri) =>
|
||||
_i14.Future<dynamic> fetch(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(#fetch, [uri], {#language: language}),
|
||||
returnValue: _i14.Future<dynamic>.value(),
|
||||
)
|
||||
as _i14.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i14.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
_i14.Future<List<dynamic>> fetchPaginated(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(#fetchPaginated, [uri], {#language: language}),
|
||||
returnValue: _i14.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i14.Future<List<dynamic>>);
|
||||
|
||||
@@ -141,10 +141,14 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
|
||||
as _i6.Future<void>);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
Map<String, String> getDefaultHeaders({
|
||||
bool? includeAuth = false,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
@@ -175,17 +179,17 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i6.Future<dynamic> fetch(Uri? uri) =>
|
||||
_i6.Future<dynamic> fetch(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(#fetch, [uri], {#language: language}),
|
||||
returnValue: _i6.Future<dynamic>.value(),
|
||||
)
|
||||
as _i6.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i6.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
_i6.Future<List<dynamic>> fetchPaginated(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(#fetchPaginated, [uri], {#language: language}),
|
||||
returnValue: _i6.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i6.Future<List<dynamic>>);
|
||||
|
||||
@@ -141,10 +141,14 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
|
||||
as _i6.Future<void>);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
Map<String, String> getDefaultHeaders({
|
||||
bool? includeAuth = false,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
@@ -175,17 +179,17 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i6.Future<dynamic> fetch(Uri? uri) =>
|
||||
_i6.Future<dynamic> fetch(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(#fetch, [uri], {#language: language}),
|
||||
returnValue: _i6.Future<dynamic>.value(),
|
||||
)
|
||||
as _i6.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i6.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
_i6.Future<List<dynamic>> fetchPaginated(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(#fetchPaginated, [uri], {#language: language}),
|
||||
returnValue: _i6.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i6.Future<List<dynamic>>);
|
||||
|
||||
@@ -78,10 +78,14 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
Map<String, String> getDefaultHeaders({
|
||||
bool? includeAuth = false,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
@@ -112,17 +116,17 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<dynamic> fetch(Uri? uri) =>
|
||||
_i5.Future<dynamic> fetch(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(#fetch, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<dynamic>.value(),
|
||||
)
|
||||
as _i5.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(#fetchPaginated, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i5.Future<List<dynamic>>);
|
||||
|
||||
@@ -88,10 +88,14 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
Map<String, String> getDefaultHeaders({
|
||||
bool? includeAuth = false,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
@@ -122,17 +126,17 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<dynamic> fetch(Uri? uri) =>
|
||||
_i5.Future<dynamic> fetch(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(#fetch, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<dynamic>.value(),
|
||||
)
|
||||
as _i5.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(#fetchPaginated, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i5.Future<List<dynamic>>);
|
||||
|
||||
@@ -323,10 +323,14 @@ class MockWgerBaseProvider extends _i1.Mock implements _i8.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
Map<String, String> getDefaultHeaders({
|
||||
bool? includeAuth = false,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
@@ -357,17 +361,17 @@ class MockWgerBaseProvider extends _i1.Mock implements _i8.WgerBaseProvider {
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<dynamic> fetch(Uri? uri) =>
|
||||
_i5.Future<dynamic> fetch(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(#fetch, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<dynamic>.value(),
|
||||
)
|
||||
as _i5.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(#fetchPaginated, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i5.Future<List<dynamic>>);
|
||||
|
||||
@@ -167,10 +167,14 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
Map<String, String> getDefaultHeaders({
|
||||
bool? includeAuth = false,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
@@ -201,17 +205,17 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i20.Future<dynamic> fetch(Uri? uri) =>
|
||||
_i20.Future<dynamic> fetch(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(#fetch, [uri], {#language: language}),
|
||||
returnValue: _i20.Future<dynamic>.value(),
|
||||
)
|
||||
as _i20.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i20.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
_i20.Future<List<dynamic>> fetchPaginated(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(#fetchPaginated, [uri], {#language: language}),
|
||||
returnValue: _i20.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i20.Future<List<dynamic>>);
|
||||
|
||||
@@ -78,10 +78,14 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
Map<String, String> getDefaultHeaders({
|
||||
bool? includeAuth = false,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
@@ -112,17 +116,17 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<dynamic> fetch(Uri? uri) =>
|
||||
_i5.Future<dynamic> fetch(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(#fetch, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<dynamic>.value(),
|
||||
)
|
||||
as _i5.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(#fetchPaginated, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i5.Future<List<dynamic>>);
|
||||
|
||||
@@ -117,10 +117,14 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
Map<String, String> getDefaultHeaders({
|
||||
bool? includeAuth = false,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
@@ -151,17 +155,17 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i11.Future<dynamic> fetch(Uri? uri) =>
|
||||
_i11.Future<dynamic> fetch(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(#fetch, [uri], {#language: language}),
|
||||
returnValue: _i11.Future<dynamic>.value(),
|
||||
)
|
||||
as _i11.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i11.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
_i11.Future<List<dynamic>> fetchPaginated(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(#fetchPaginated, [uri], {#language: language}),
|
||||
returnValue: _i11.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i11.Future<List<dynamic>>);
|
||||
|
||||
@@ -78,10 +78,14 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
Map<String, String> getDefaultHeaders({
|
||||
bool? includeAuth = false,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
@@ -112,17 +116,17 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<dynamic> fetch(Uri? uri) =>
|
||||
_i5.Future<dynamic> fetch(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(#fetch, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<dynamic>.value(),
|
||||
)
|
||||
as _i5.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(#fetchPaginated, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i5.Future<List<dynamic>>);
|
||||
|
||||
@@ -78,10 +78,14 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
Map<String, String> getDefaultHeaders({
|
||||
bool? includeAuth = false,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
@@ -112,17 +116,17 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<dynamic> fetch(Uri? uri) =>
|
||||
_i5.Future<dynamic> fetch(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(#fetch, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<dynamic>.value(),
|
||||
)
|
||||
as _i5.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(#fetchPaginated, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i5.Future<List<dynamic>>);
|
||||
|
||||
@@ -34,7 +34,10 @@ void main() {
|
||||
// Arrange
|
||||
final mockRepository = MockTrophyRepository();
|
||||
when(
|
||||
mockRepository.fetchUserTrophies(filterQuery: anyNamed('filterQuery')),
|
||||
mockRepository.fetchUserTrophies(
|
||||
filterQuery: anyNamed('filterQuery'),
|
||||
language: anyNamed('language'),
|
||||
),
|
||||
).thenAnswer((_) async => getUserTrophies());
|
||||
|
||||
// Act
|
||||
|
||||
@@ -86,9 +86,9 @@ class MockTrophyRepository extends _i1.Mock implements _i3.TrophyRepository {
|
||||
as String);
|
||||
|
||||
@override
|
||||
_i5.Future<List<_i6.Trophy>> fetchTrophies() =>
|
||||
_i5.Future<List<_i6.Trophy>> fetchTrophies({String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchTrophies, []),
|
||||
Invocation.method(#fetchTrophies, [], {#language: language}),
|
||||
returnValue: _i5.Future<List<_i6.Trophy>>.value(<_i6.Trophy>[]),
|
||||
)
|
||||
as _i5.Future<List<_i6.Trophy>>);
|
||||
@@ -96,10 +96,12 @@ class MockTrophyRepository extends _i1.Mock implements _i3.TrophyRepository {
|
||||
@override
|
||||
_i5.Future<List<_i7.UserTrophy>> fetchUserTrophies({
|
||||
Map<String, String>? filterQuery,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchUserTrophies, [], {
|
||||
#filterQuery: filterQuery,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: _i5.Future<List<_i7.UserTrophy>>.value(
|
||||
<_i7.UserTrophy>[],
|
||||
@@ -110,10 +112,12 @@ class MockTrophyRepository extends _i1.Mock implements _i3.TrophyRepository {
|
||||
@override
|
||||
_i5.Future<List<_i8.UserTrophyProgression>> fetchProgression({
|
||||
Map<String, String>? filterQuery,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchProgression, [], {
|
||||
#filterQuery: filterQuery,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: _i5.Future<List<_i8.UserTrophyProgression>>.value(
|
||||
<_i8.UserTrophyProgression>[],
|
||||
|
||||
@@ -34,7 +34,10 @@ void main() {
|
||||
// Arrange
|
||||
final mockRepository = MockTrophyRepository();
|
||||
when(
|
||||
mockRepository.fetchProgression(filterQuery: anyNamed('filterQuery')),
|
||||
mockRepository.fetchProgression(
|
||||
filterQuery: anyNamed('filterQuery'),
|
||||
language: anyNamed('language'),
|
||||
),
|
||||
).thenAnswer((_) async => getUserTrophyProgression());
|
||||
|
||||
// Act
|
||||
|
||||
@@ -86,9 +86,9 @@ class MockTrophyRepository extends _i1.Mock implements _i3.TrophyRepository {
|
||||
as String);
|
||||
|
||||
@override
|
||||
_i5.Future<List<_i6.Trophy>> fetchTrophies() =>
|
||||
_i5.Future<List<_i6.Trophy>> fetchTrophies({String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchTrophies, []),
|
||||
Invocation.method(#fetchTrophies, [], {#language: language}),
|
||||
returnValue: _i5.Future<List<_i6.Trophy>>.value(<_i6.Trophy>[]),
|
||||
)
|
||||
as _i5.Future<List<_i6.Trophy>>);
|
||||
@@ -96,10 +96,12 @@ class MockTrophyRepository extends _i1.Mock implements _i3.TrophyRepository {
|
||||
@override
|
||||
_i5.Future<List<_i7.UserTrophy>> fetchUserTrophies({
|
||||
Map<String, String>? filterQuery,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchUserTrophies, [], {
|
||||
#filterQuery: filterQuery,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: _i5.Future<List<_i7.UserTrophy>>.value(
|
||||
<_i7.UserTrophy>[],
|
||||
@@ -110,10 +112,12 @@ class MockTrophyRepository extends _i1.Mock implements _i3.TrophyRepository {
|
||||
@override
|
||||
_i5.Future<List<_i8.UserTrophyProgression>> fetchProgression({
|
||||
Map<String, String>? filterQuery,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchProgression, [], {
|
||||
#filterQuery: filterQuery,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: _i5.Future<List<_i8.UserTrophyProgression>>.value(
|
||||
<_i8.UserTrophyProgression>[],
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (c) 2025 wger Team
|
||||
*
|
||||
* wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Mocks generated by Mockito 5.4.6 from annotations
|
||||
// in wger/test/user/provider_test.dart.
|
||||
// Do not manually edit this file.
|
||||
@@ -96,10 +78,14 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
Map<String, String> getDefaultHeaders({
|
||||
bool? includeAuth = false,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
@@ -130,17 +116,17 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<dynamic> fetch(Uri? uri) =>
|
||||
_i5.Future<dynamic> fetch(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(#fetch, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<dynamic>.value(),
|
||||
)
|
||||
as _i5.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(#fetchPaginated, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i5.Future<List<dynamic>>);
|
||||
|
||||
@@ -78,10 +78,14 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
Map<String, String> getDefaultHeaders({
|
||||
bool? includeAuth = false,
|
||||
String? language,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
#language: language,
|
||||
}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
@@ -112,17 +116,17 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<dynamic> fetch(Uri? uri) =>
|
||||
_i5.Future<dynamic> fetch(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
Invocation.method(#fetch, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<dynamic>.value(),
|
||||
)
|
||||
as _i5.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri, {String? language}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
Invocation.method(#fetchPaginated, [uri], {#language: language}),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i5.Future<List<dynamic>>);
|
||||
|
||||
Reference in New Issue
Block a user