mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Merge pull request #453 from wger-project/feat/data-persistence
feat(drift-database): Shifted from shared prefs to drift for Exercises
This commit is contained in:
@@ -44,9 +44,8 @@ class Icon {
|
||||
_fileExtension = path.split('.').last;
|
||||
}
|
||||
|
||||
String getFilename(String appId) => (type == _symbolicType)
|
||||
? '$appId-symbolic.$_fileExtension'
|
||||
: '$appId.$_fileExtension';
|
||||
String getFilename(String appId) =>
|
||||
(type == _symbolicType) ? '$appId-symbolic.$_fileExtension' : '$appId.$_fileExtension';
|
||||
}
|
||||
|
||||
class GithubReleases {
|
||||
@@ -75,8 +74,7 @@ class GithubReleases {
|
||||
final releaseJsonContent = (await http.get(Uri(
|
||||
scheme: 'https',
|
||||
host: 'api.github.com',
|
||||
path:
|
||||
'/repos/$githubReleaseOrganization/$githubReleaseProject/releases')))
|
||||
path: '/repos/$githubReleaseOrganization/$githubReleaseProject/releases')))
|
||||
.body;
|
||||
final decodedJson = jsonDecode(releaseJsonContent) as List;
|
||||
|
||||
@@ -87,23 +85,19 @@ class GithubReleases {
|
||||
await Future.forEach<dynamic>(decodedJson, (dynamic releaseDynamic) async {
|
||||
final releaseMap = releaseDynamic as Map;
|
||||
|
||||
final releaseDateAndTime =
|
||||
DateTime.parse(releaseMap['published_at'] as String);
|
||||
final releaseDateString =
|
||||
releaseDateAndTime.toIso8601String().split('T').first;
|
||||
final releaseDateAndTime = DateTime.parse(releaseMap['published_at'] as String);
|
||||
final releaseDateString = releaseDateAndTime.toIso8601String().split('T').first;
|
||||
|
||||
if (latestReleaseAssetDate == null ||
|
||||
(latestReleaseAssetDate?.compareTo(releaseDateAndTime) == -1)) {
|
||||
final assets =
|
||||
await _parseGithubReleaseAssets(releaseMap['assets'] as List);
|
||||
final assets = await _parseGithubReleaseAssets(releaseMap['assets'] as List);
|
||||
if (assets != null) {
|
||||
_latestReleaseAssets = assets;
|
||||
latestReleaseAssetDate = releaseDateAndTime;
|
||||
}
|
||||
}
|
||||
|
||||
releases.add(Release(
|
||||
version: releaseMap['name'] as String, date: releaseDateString));
|
||||
releases.add(Release(version: releaseMap['name'] as String, date: releaseDateString));
|
||||
});
|
||||
|
||||
if (releases.isNotEmpty || canBeEmpty) {
|
||||
@@ -124,8 +118,7 @@ class GithubReleases {
|
||||
final downloadUrl = amMap['browser_download_url'] as String;
|
||||
final filename = amMap['name'] as String;
|
||||
final fileExtension = filename.substring(filename.indexOf('.') + 1);
|
||||
final filenameWithoutExtension =
|
||||
filename.substring(0, filename.indexOf('.'));
|
||||
final filenameWithoutExtension = filename.substring(0, filename.indexOf('.'));
|
||||
|
||||
final arch = filenameWithoutExtension.endsWith('aarch64')
|
||||
? CPUArchitecture.aarch64
|
||||
@@ -221,8 +214,7 @@ class FlatpakMeta {
|
||||
: _localReleases = localReleases,
|
||||
_localReleaseAssets = localReleaseAssets {
|
||||
if (githubReleaseOrganization != null && githubReleaseProject != null) {
|
||||
_githubReleases =
|
||||
GithubReleases(githubReleaseOrganization!, githubReleaseProject!);
|
||||
_githubReleases = GithubReleases(githubReleaseOrganization!, githubReleaseProject!);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,20 +223,17 @@ class FlatpakMeta {
|
||||
final releases = List<Release>.empty(growable: true);
|
||||
if (addedTodaysVersion != null) {
|
||||
releases.add(Release(
|
||||
version: addedTodaysVersion,
|
||||
date: DateTime.now().toIso8601String().split("T").first));
|
||||
version: addedTodaysVersion, date: DateTime.now().toIso8601String().split("T").first));
|
||||
}
|
||||
if (fetchReleasesFromGithub) {
|
||||
if (_githubReleases == null) {
|
||||
throw Exception(
|
||||
'Metadata must include Github repository info if fetching releases from Github.');
|
||||
}
|
||||
releases.addAll(
|
||||
await _githubReleases!.getReleases(addedTodaysVersion != null));
|
||||
releases.addAll(await _githubReleases!.getReleases(addedTodaysVersion != null));
|
||||
} else {
|
||||
if (_localReleases == null && addedTodaysVersion == null) {
|
||||
throw Exception(
|
||||
'Metadata must include releases if not fetching releases from Github.');
|
||||
throw Exception('Metadata must include releases if not fetching releases from Github.');
|
||||
}
|
||||
if (_localReleases?.isNotEmpty ?? false) {
|
||||
releases.addAll(_localReleases!);
|
||||
@@ -253,8 +242,7 @@ class FlatpakMeta {
|
||||
return releases;
|
||||
}
|
||||
|
||||
Future<List<ReleaseAsset>?> getLatestReleaseAssets(
|
||||
bool fetchReleasesFromGithub) async {
|
||||
Future<List<ReleaseAsset>?> getLatestReleaseAssets(bool fetchReleasesFromGithub) async {
|
||||
if (fetchReleasesFromGithub) {
|
||||
if (_githubReleases == null) {
|
||||
throw Exception(
|
||||
@@ -263,8 +251,7 @@ class FlatpakMeta {
|
||||
return await _githubReleases!.getLatestReleaseAssets();
|
||||
} else {
|
||||
if (_localReleases == null) {
|
||||
throw Exception(
|
||||
'Metadata must include releases if not fetching releases from Github.');
|
||||
throw Exception('Metadata must include releases if not fetching releases from Github.');
|
||||
}
|
||||
return _localReleaseAssets;
|
||||
}
|
||||
@@ -276,24 +263,20 @@ class FlatpakMeta {
|
||||
return FlatpakMeta(
|
||||
appId: json['appId'] as String,
|
||||
lowercaseAppName: json['lowercaseAppName'] as String,
|
||||
githubReleaseOrganization:
|
||||
json['githubReleaseOrganization'] as String?,
|
||||
githubReleaseOrganization: json['githubReleaseOrganization'] as String?,
|
||||
githubReleaseProject: json['githubReleaseProject'] as String?,
|
||||
localReleases: skipLocalReleases
|
||||
? null
|
||||
: (json['localReleases'] as List?)?.map((dynamic r) {
|
||||
final rMap = r as Map;
|
||||
return Release(
|
||||
version: rMap['version'] as String,
|
||||
date: rMap['date'] as String);
|
||||
return Release(version: rMap['version'] as String, date: rMap['date'] as String);
|
||||
}).toList(),
|
||||
localReleaseAssets: skipLocalReleases
|
||||
? null
|
||||
: (json['localReleaseAssets'] as List?)?.map((dynamic ra) {
|
||||
final raMap = ra as Map;
|
||||
final archString = raMap['arch'] as String;
|
||||
final arch = (archString ==
|
||||
CPUArchitecture.x86_64.flatpakArchCode)
|
||||
final arch = (archString == CPUArchitecture.x86_64.flatpakArchCode)
|
||||
? CPUArchitecture.x86_64
|
||||
: (archString == CPUArchitecture.aarch64.flatpakArchCode)
|
||||
? CPUArchitecture.aarch64
|
||||
@@ -302,11 +285,10 @@ class FlatpakMeta {
|
||||
throw Exception(
|
||||
'Architecture must be either "${CPUArchitecture.x86_64.flatpakArchCode}" or "${CPUArchitecture.aarch64.flatpakArchCode}"');
|
||||
}
|
||||
final tarballFile = File(
|
||||
'${jsonFile.parent.path}/${raMap['tarballPath'] as String}');
|
||||
final tarballFile =
|
||||
File('${jsonFile.parent.path}/${raMap['tarballPath'] as String}');
|
||||
final tarballPath = tarballFile.absolute.path;
|
||||
final preShasum =
|
||||
Process.runSync('shasum', ['-a', '256', tarballPath]);
|
||||
final preShasum = Process.runSync('shasum', ['-a', '256', tarballPath]);
|
||||
final shasum = preShasum.stdout.toString().split(' ').first;
|
||||
if (preShasum.exitCode != 0) {
|
||||
throw Exception(preShasum.stderr);
|
||||
@@ -321,17 +303,14 @@ class FlatpakMeta {
|
||||
appStreamPath: json['appStreamPath'] as String,
|
||||
desktopPath: json['desktopPath'] as String,
|
||||
icons: (json['icons'] as Map).entries.map((mapEntry) {
|
||||
return Icon(
|
||||
type: mapEntry.key as String, path: mapEntry.value as String);
|
||||
return Icon(type: mapEntry.key as String, path: mapEntry.value as String);
|
||||
}).toList(),
|
||||
freedesktopRuntime: json['freedesktopRuntime'] as String,
|
||||
buildCommandsAfterUnpack: (json['buildCommandsAfterUnpack'] as List?)
|
||||
?.map((dynamic bc) => bc as String)
|
||||
.toList(),
|
||||
extraModules: json['extraModules'] as List?,
|
||||
finishArgs: (json['finishArgs'] as List)
|
||||
.map((dynamic fa) => fa as String)
|
||||
.toList());
|
||||
finishArgs: (json['finishArgs'] as List).map((dynamic fa) => fa as String).toList());
|
||||
} catch (e) {
|
||||
throw Exception('Could not parse JSON file, due to this error:\n$e');
|
||||
}
|
||||
|
||||
@@ -26,8 +26,7 @@ void main(List<String> arguments) async {
|
||||
'You must run this script with a metadata file argument, using the --meta flag.');
|
||||
}
|
||||
if (arguments.length == metaIndex + 1) {
|
||||
throw Exception(
|
||||
'The --meta flag must be followed by the path to the metadata file.');
|
||||
throw Exception('The --meta flag must be followed by the path to the metadata file.');
|
||||
}
|
||||
|
||||
final metaFile = File(arguments[metaIndex + 1]);
|
||||
@@ -37,23 +36,19 @@ void main(List<String> arguments) async {
|
||||
|
||||
final fetchFromGithub = arguments.contains('--github');
|
||||
|
||||
final meta =
|
||||
FlatpakMeta.fromJson(metaFile, skipLocalReleases: fetchFromGithub);
|
||||
final meta = FlatpakMeta.fromJson(metaFile, skipLocalReleases: fetchFromGithub);
|
||||
|
||||
final outputDir =
|
||||
Directory('${Directory.current.path}/flatpak_generator_exports');
|
||||
final outputDir = Directory('${Directory.current.path}/flatpak_generator_exports');
|
||||
outputDir.createSync();
|
||||
|
||||
final manifestGenerator = FlatpakManifestGenerator(meta);
|
||||
final manifestContent =
|
||||
await manifestGenerator.generateFlatpakManifest(fetchFromGithub);
|
||||
final manifestContent = await manifestGenerator.generateFlatpakManifest(fetchFromGithub);
|
||||
final manifestPath = '${outputDir.path}/${meta.appId}.json';
|
||||
final manifestFile = File(manifestPath);
|
||||
manifestFile.writeAsStringSync(manifestContent);
|
||||
print('Generated $manifestPath');
|
||||
|
||||
final flathubJsonContent =
|
||||
await manifestGenerator.generateFlathubJson(fetchFromGithub);
|
||||
final flathubJsonContent = await manifestGenerator.generateFlathubJson(fetchFromGithub);
|
||||
if (flathubJsonContent != null) {
|
||||
final flathubJsonPath = '${outputDir.path}/flathub.json';
|
||||
final flathubJsonFile = File(flathubJsonPath);
|
||||
@@ -132,8 +127,7 @@ class FlatpakManifestGenerator {
|
||||
|
||||
const encoder = JsonEncoder.withIndent(' ');
|
||||
|
||||
final onlyArchListInput =
|
||||
fetchFromGithub ? _githubArchSupport! : _localArchSupport!;
|
||||
final onlyArchListInput = fetchFromGithub ? _githubArchSupport! : _localArchSupport!;
|
||||
|
||||
final onlyArchList = List<String>.empty(growable: true);
|
||||
for (final e in onlyArchListInput.entries) {
|
||||
@@ -149,8 +143,7 @@ class FlatpakManifestGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
void _lazyGenerateArchSupportMap(
|
||||
bool fetchFromGithub, List<ReleaseAsset> assets) {
|
||||
void _lazyGenerateArchSupportMap(bool fetchFromGithub, List<ReleaseAsset> assets) {
|
||||
if (fetchFromGithub) {
|
||||
if (_githubArchSupport == null) {
|
||||
_githubArchSupport = <CPUArchitecture, bool>{
|
||||
|
||||
@@ -20,8 +20,8 @@ Widget createGymModeScreen({locale = 'en'}) {
|
||||
|
||||
final mockExerciseProvider = MockExercisesProvider();
|
||||
|
||||
when(mockExerciseProvider.findExerciseBaseById(1)).thenReturn(bases[0]); // bench press
|
||||
when(mockExerciseProvider.findExerciseBaseById(6)).thenReturn(bases[5]); // side raises
|
||||
when(mockExerciseProvider.findExerciseById(1)).thenReturn(bases[0]); // bench press
|
||||
when(mockExerciseProvider.findExerciseById(6)).thenReturn(bases[5]); // side raises
|
||||
//when(mockExerciseProvider.findExerciseBaseById(2)).thenReturn(bases[1]); // crunches
|
||||
//when(mockExerciseProvider.findExerciseBaseById(3)).thenReturn(bases[2]); // dead lift
|
||||
|
||||
|
||||
44
lib/core/locator.dart
Normal file
44
lib/core/locator.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:wger/database/exercises/exercise_database.dart';
|
||||
import 'package:wger/database/ingredients/ingredients_database.dart';
|
||||
|
||||
final locator = GetIt.asNewInstance();
|
||||
|
||||
class ServiceLocator {
|
||||
factory ServiceLocator() => _singleton;
|
||||
|
||||
ServiceLocator._internal();
|
||||
|
||||
static final ServiceLocator _singleton = ServiceLocator._internal();
|
||||
|
||||
Future<void> _initDB() async {
|
||||
ExerciseDatabase exerciseDB;
|
||||
IngredientDatabase ingredientDB;
|
||||
// final exerciseDB = ExerciseDatabase();
|
||||
// final ingredientDB = IngredientDatabase();
|
||||
|
||||
if (Platform.environment.containsKey('FLUTTER_TEST')) {
|
||||
exerciseDB = ExerciseDatabase.inMemory(NativeDatabase.memory());
|
||||
ingredientDB = IngredientDatabase.inMemory(NativeDatabase.memory());
|
||||
} else {
|
||||
exerciseDB = ExerciseDatabase();
|
||||
ingredientDB = IngredientDatabase();
|
||||
}
|
||||
|
||||
locator.registerSingleton<ExerciseDatabase>(exerciseDB);
|
||||
locator.registerSingleton<IngredientDatabase>(ingredientDB);
|
||||
}
|
||||
|
||||
Future<void> configure() async {
|
||||
try {
|
||||
await _initDB();
|
||||
} catch (e, _) {
|
||||
log(e.toString());
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
85
lib/database/exercises/exercise_database.dart
Normal file
85
lib/database/exercises/exercise_database.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:wger/database/exercises/type_converters.dart';
|
||||
import 'package:wger/models/exercises/category.dart';
|
||||
import 'package:wger/models/exercises/equipment.dart';
|
||||
import 'package:wger/models/exercises/language.dart';
|
||||
import 'package:wger/models/exercises/muscle.dart';
|
||||
|
||||
part 'exercise_database.g.dart';
|
||||
|
||||
@DataClassName('ExerciseTable')
|
||||
class Exercises extends Table {
|
||||
IntColumn get id => integer()();
|
||||
|
||||
TextColumn get data => text()();
|
||||
|
||||
// TextColumn get data => text().map(const ExerciseBaseConverter())();
|
||||
|
||||
DateTimeColumn get lastUpdate => dateTime()();
|
||||
|
||||
/// The date when the exercise was last fetched from the API. While we know
|
||||
/// when the exercise itself was last updated in `lastUpdate`, we can save
|
||||
/// ourselves a lot of requests if we don't check too often
|
||||
DateTimeColumn get lastFetched => dateTime()();
|
||||
}
|
||||
|
||||
@DataClassName('MuscleTable')
|
||||
class Muscles extends Table {
|
||||
IntColumn get id => integer()();
|
||||
|
||||
TextColumn get data => text().map(const MuscleConverter())();
|
||||
}
|
||||
|
||||
@DataClassName('CategoryTable')
|
||||
class Categories extends Table {
|
||||
IntColumn get id => integer()();
|
||||
|
||||
TextColumn get data => text().map(const ExerciseCategoryConverter())();
|
||||
}
|
||||
|
||||
@DataClassName('LanguagesTable')
|
||||
class Languages extends Table {
|
||||
IntColumn get id => integer()();
|
||||
|
||||
TextColumn get data => text().map(const LanguageConverter())();
|
||||
}
|
||||
|
||||
@DataClassName('EquipmentTable')
|
||||
class Equipments extends Table {
|
||||
IntColumn get id => integer()();
|
||||
|
||||
TextColumn get data => text().map(const EquipmentConverter())();
|
||||
}
|
||||
|
||||
@DriftDatabase(tables: [Exercises, Muscles, Equipments, Categories, Languages])
|
||||
class ExerciseDatabase extends _$ExerciseDatabase {
|
||||
ExerciseDatabase() : super(_openConnection());
|
||||
|
||||
// Named constructor for creating in-memory database
|
||||
ExerciseDatabase.inMemory(super.e);
|
||||
|
||||
@override
|
||||
// TODO: implement schemaVersion
|
||||
int get schemaVersion => 1;
|
||||
|
||||
Future<void> deleteEverything() {
|
||||
return transaction(() async {
|
||||
for (final table in allTables) {
|
||||
await delete(table).go();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
LazyDatabase _openConnection() {
|
||||
return LazyDatabase(() async {
|
||||
final dbFolder = await getApplicationCacheDirectory();
|
||||
final file = File(p.join(dbFolder.path, 'exercises.sqlite'));
|
||||
return NativeDatabase.createInBackground(file);
|
||||
});
|
||||
}
|
||||
968
lib/database/exercises/exercise_database.g.dart
Normal file
968
lib/database/exercises/exercise_database.g.dart
Normal file
@@ -0,0 +1,968 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'exercise_database.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
class $ExercisesTable extends Exercises with TableInfo<$ExercisesTable, ExerciseTable> {
|
||||
@override
|
||||
final GeneratedDatabase attachedDatabase;
|
||||
final String? _alias;
|
||||
$ExercisesTable(this.attachedDatabase, [this._alias]);
|
||||
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
||||
@override
|
||||
late final GeneratedColumn<int> id = GeneratedColumn<int>('id', aliasedName, false,
|
||||
type: DriftSqlType.int, requiredDuringInsert: true);
|
||||
static const VerificationMeta _dataMeta = const VerificationMeta('data');
|
||||
@override
|
||||
late final GeneratedColumn<String> data = GeneratedColumn<String>('data', aliasedName, false,
|
||||
type: DriftSqlType.string, requiredDuringInsert: true);
|
||||
static const VerificationMeta _lastUpdateMeta = const VerificationMeta('lastUpdate');
|
||||
@override
|
||||
late final GeneratedColumn<DateTime> lastUpdate = GeneratedColumn<DateTime>(
|
||||
'last_update', aliasedName, false,
|
||||
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
||||
static const VerificationMeta _lastFetchedMeta = const VerificationMeta('lastFetched');
|
||||
@override
|
||||
late final GeneratedColumn<DateTime> lastFetched = GeneratedColumn<DateTime>(
|
||||
'last_fetched', aliasedName, false,
|
||||
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
||||
@override
|
||||
List<GeneratedColumn> get $columns => [id, data, lastUpdate, lastFetched];
|
||||
@override
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'exercises';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<ExerciseTable> instance,
|
||||
{bool isInserting = false}) {
|
||||
final context = VerificationContext();
|
||||
final data = instance.toColumns(true);
|
||||
if (data.containsKey('id')) {
|
||||
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
||||
} else if (isInserting) {
|
||||
context.missing(_idMeta);
|
||||
}
|
||||
if (data.containsKey('data')) {
|
||||
context.handle(_dataMeta, this.data.isAcceptableOrUnknown(data['data']!, _dataMeta));
|
||||
} else if (isInserting) {
|
||||
context.missing(_dataMeta);
|
||||
}
|
||||
if (data.containsKey('last_update')) {
|
||||
context.handle(
|
||||
_lastUpdateMeta, lastUpdate.isAcceptableOrUnknown(data['last_update']!, _lastUpdateMeta));
|
||||
} else if (isInserting) {
|
||||
context.missing(_lastUpdateMeta);
|
||||
}
|
||||
if (data.containsKey('last_fetched')) {
|
||||
context.handle(_lastFetchedMeta,
|
||||
lastFetched.isAcceptableOrUnknown(data['last_fetched']!, _lastFetchedMeta));
|
||||
} else if (isInserting) {
|
||||
context.missing(_lastFetchedMeta);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
@override
|
||||
Set<GeneratedColumn> get $primaryKey => const {};
|
||||
@override
|
||||
ExerciseTable map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return ExerciseTable(
|
||||
id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
data: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}data'])!,
|
||||
lastUpdate: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.dateTime, data['${effectivePrefix}last_update'])!,
|
||||
lastFetched: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.dateTime, data['${effectivePrefix}last_fetched'])!,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
$ExercisesTable createAlias(String alias) {
|
||||
return $ExercisesTable(attachedDatabase, alias);
|
||||
}
|
||||
}
|
||||
|
||||
class ExerciseTable extends DataClass implements Insertable<ExerciseTable> {
|
||||
final int id;
|
||||
final String data;
|
||||
final DateTime lastUpdate;
|
||||
|
||||
/// The date when the exercise was last fetched from the API. While we know
|
||||
/// when the exercise itself was last updated in `lastUpdate`, we can save
|
||||
/// ourselves a lot of requests if we don't check too often
|
||||
final DateTime lastFetched;
|
||||
const ExerciseTable(
|
||||
{required this.id, required this.data, required this.lastUpdate, required this.lastFetched});
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
map['id'] = Variable<int>(id);
|
||||
map['data'] = Variable<String>(data);
|
||||
map['last_update'] = Variable<DateTime>(lastUpdate);
|
||||
map['last_fetched'] = Variable<DateTime>(lastFetched);
|
||||
return map;
|
||||
}
|
||||
|
||||
ExercisesCompanion toCompanion(bool nullToAbsent) {
|
||||
return ExercisesCompanion(
|
||||
id: Value(id),
|
||||
data: Value(data),
|
||||
lastUpdate: Value(lastUpdate),
|
||||
lastFetched: Value(lastFetched),
|
||||
);
|
||||
}
|
||||
|
||||
factory ExerciseTable.fromJson(Map<String, dynamic> json, {ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return ExerciseTable(
|
||||
id: serializer.fromJson<int>(json['id']),
|
||||
data: serializer.fromJson<String>(json['data']),
|
||||
lastUpdate: serializer.fromJson<DateTime>(json['lastUpdate']),
|
||||
lastFetched: serializer.fromJson<DateTime>(json['lastFetched']),
|
||||
);
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return <String, dynamic>{
|
||||
'id': serializer.toJson<int>(id),
|
||||
'data': serializer.toJson<String>(data),
|
||||
'lastUpdate': serializer.toJson<DateTime>(lastUpdate),
|
||||
'lastFetched': serializer.toJson<DateTime>(lastFetched),
|
||||
};
|
||||
}
|
||||
|
||||
ExerciseTable copyWith({int? id, String? data, DateTime? lastUpdate, DateTime? lastFetched}) =>
|
||||
ExerciseTable(
|
||||
id: id ?? this.id,
|
||||
data: data ?? this.data,
|
||||
lastUpdate: lastUpdate ?? this.lastUpdate,
|
||||
lastFetched: lastFetched ?? this.lastFetched,
|
||||
);
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('ExerciseTable(')
|
||||
..write('id: $id, ')
|
||||
..write('data: $data, ')
|
||||
..write('lastUpdate: $lastUpdate, ')
|
||||
..write('lastFetched: $lastFetched')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(id, data, lastUpdate, lastFetched);
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is ExerciseTable &&
|
||||
other.id == this.id &&
|
||||
other.data == this.data &&
|
||||
other.lastUpdate == this.lastUpdate &&
|
||||
other.lastFetched == this.lastFetched);
|
||||
}
|
||||
|
||||
class ExercisesCompanion extends UpdateCompanion<ExerciseTable> {
|
||||
final Value<int> id;
|
||||
final Value<String> data;
|
||||
final Value<DateTime> lastUpdate;
|
||||
final Value<DateTime> lastFetched;
|
||||
final Value<int> rowid;
|
||||
const ExercisesCompanion({
|
||||
this.id = const Value.absent(),
|
||||
this.data = const Value.absent(),
|
||||
this.lastUpdate = const Value.absent(),
|
||||
this.lastFetched = const Value.absent(),
|
||||
this.rowid = const Value.absent(),
|
||||
});
|
||||
ExercisesCompanion.insert({
|
||||
required int id,
|
||||
required String data,
|
||||
required DateTime lastUpdate,
|
||||
required DateTime lastFetched,
|
||||
this.rowid = const Value.absent(),
|
||||
}) : id = Value(id),
|
||||
data = Value(data),
|
||||
lastUpdate = Value(lastUpdate),
|
||||
lastFetched = Value(lastFetched);
|
||||
static Insertable<ExerciseTable> custom({
|
||||
Expression<int>? id,
|
||||
Expression<String>? data,
|
||||
Expression<DateTime>? lastUpdate,
|
||||
Expression<DateTime>? lastFetched,
|
||||
Expression<int>? rowid,
|
||||
}) {
|
||||
return RawValuesInsertable({
|
||||
if (id != null) 'id': id,
|
||||
if (data != null) 'data': data,
|
||||
if (lastUpdate != null) 'last_update': lastUpdate,
|
||||
if (lastFetched != null) 'last_fetched': lastFetched,
|
||||
if (rowid != null) 'rowid': rowid,
|
||||
});
|
||||
}
|
||||
|
||||
ExercisesCompanion copyWith(
|
||||
{Value<int>? id,
|
||||
Value<String>? data,
|
||||
Value<DateTime>? lastUpdate,
|
||||
Value<DateTime>? lastFetched,
|
||||
Value<int>? rowid}) {
|
||||
return ExercisesCompanion(
|
||||
id: id ?? this.id,
|
||||
data: data ?? this.data,
|
||||
lastUpdate: lastUpdate ?? this.lastUpdate,
|
||||
lastFetched: lastFetched ?? this.lastFetched,
|
||||
rowid: rowid ?? this.rowid,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
if (id.present) {
|
||||
map['id'] = Variable<int>(id.value);
|
||||
}
|
||||
if (data.present) {
|
||||
map['data'] = Variable<String>(data.value);
|
||||
}
|
||||
if (lastUpdate.present) {
|
||||
map['last_update'] = Variable<DateTime>(lastUpdate.value);
|
||||
}
|
||||
if (lastFetched.present) {
|
||||
map['last_fetched'] = Variable<DateTime>(lastFetched.value);
|
||||
}
|
||||
if (rowid.present) {
|
||||
map['rowid'] = Variable<int>(rowid.value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('ExercisesCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('data: $data, ')
|
||||
..write('lastUpdate: $lastUpdate, ')
|
||||
..write('lastFetched: $lastFetched, ')
|
||||
..write('rowid: $rowid')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $MusclesTable extends Muscles with TableInfo<$MusclesTable, MuscleTable> {
|
||||
@override
|
||||
final GeneratedDatabase attachedDatabase;
|
||||
final String? _alias;
|
||||
$MusclesTable(this.attachedDatabase, [this._alias]);
|
||||
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
||||
@override
|
||||
late final GeneratedColumn<int> id = GeneratedColumn<int>('id', aliasedName, false,
|
||||
type: DriftSqlType.int, requiredDuringInsert: true);
|
||||
static const VerificationMeta _dataMeta = const VerificationMeta('data');
|
||||
@override
|
||||
late final GeneratedColumnWithTypeConverter<Muscle, String> data = GeneratedColumn<String>(
|
||||
'data', aliasedName, false,
|
||||
type: DriftSqlType.string, requiredDuringInsert: true)
|
||||
.withConverter<Muscle>($MusclesTable.$converterdata);
|
||||
@override
|
||||
List<GeneratedColumn> get $columns => [id, data];
|
||||
@override
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'muscles';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<MuscleTable> instance,
|
||||
{bool isInserting = false}) {
|
||||
final context = VerificationContext();
|
||||
final data = instance.toColumns(true);
|
||||
if (data.containsKey('id')) {
|
||||
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
||||
} else if (isInserting) {
|
||||
context.missing(_idMeta);
|
||||
}
|
||||
context.handle(_dataMeta, const VerificationResult.success());
|
||||
return context;
|
||||
}
|
||||
|
||||
@override
|
||||
Set<GeneratedColumn> get $primaryKey => const {};
|
||||
@override
|
||||
MuscleTable map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return MuscleTable(
|
||||
id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
data: $MusclesTable.$converterdata.fromSql(
|
||||
attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}data'])!),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
$MusclesTable createAlias(String alias) {
|
||||
return $MusclesTable(attachedDatabase, alias);
|
||||
}
|
||||
|
||||
static TypeConverter<Muscle, String> $converterdata = const MuscleConverter();
|
||||
}
|
||||
|
||||
class MuscleTable extends DataClass implements Insertable<MuscleTable> {
|
||||
final int id;
|
||||
final Muscle data;
|
||||
const MuscleTable({required this.id, required this.data});
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
map['id'] = Variable<int>(id);
|
||||
{
|
||||
map['data'] = Variable<String>($MusclesTable.$converterdata.toSql(data));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
MusclesCompanion toCompanion(bool nullToAbsent) {
|
||||
return MusclesCompanion(
|
||||
id: Value(id),
|
||||
data: Value(data),
|
||||
);
|
||||
}
|
||||
|
||||
factory MuscleTable.fromJson(Map<String, dynamic> json, {ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return MuscleTable(
|
||||
id: serializer.fromJson<int>(json['id']),
|
||||
data: serializer.fromJson<Muscle>(json['data']),
|
||||
);
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return <String, dynamic>{
|
||||
'id': serializer.toJson<int>(id),
|
||||
'data': serializer.toJson<Muscle>(data),
|
||||
};
|
||||
}
|
||||
|
||||
MuscleTable copyWith({int? id, Muscle? data}) => MuscleTable(
|
||||
id: id ?? this.id,
|
||||
data: data ?? this.data,
|
||||
);
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('MuscleTable(')
|
||||
..write('id: $id, ')
|
||||
..write('data: $data')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(id, data);
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is MuscleTable && other.id == this.id && other.data == this.data);
|
||||
}
|
||||
|
||||
class MusclesCompanion extends UpdateCompanion<MuscleTable> {
|
||||
final Value<int> id;
|
||||
final Value<Muscle> data;
|
||||
final Value<int> rowid;
|
||||
const MusclesCompanion({
|
||||
this.id = const Value.absent(),
|
||||
this.data = const Value.absent(),
|
||||
this.rowid = const Value.absent(),
|
||||
});
|
||||
MusclesCompanion.insert({
|
||||
required int id,
|
||||
required Muscle data,
|
||||
this.rowid = const Value.absent(),
|
||||
}) : id = Value(id),
|
||||
data = Value(data);
|
||||
static Insertable<MuscleTable> custom({
|
||||
Expression<int>? id,
|
||||
Expression<String>? data,
|
||||
Expression<int>? rowid,
|
||||
}) {
|
||||
return RawValuesInsertable({
|
||||
if (id != null) 'id': id,
|
||||
if (data != null) 'data': data,
|
||||
if (rowid != null) 'rowid': rowid,
|
||||
});
|
||||
}
|
||||
|
||||
MusclesCompanion copyWith({Value<int>? id, Value<Muscle>? data, Value<int>? rowid}) {
|
||||
return MusclesCompanion(
|
||||
id: id ?? this.id,
|
||||
data: data ?? this.data,
|
||||
rowid: rowid ?? this.rowid,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
if (id.present) {
|
||||
map['id'] = Variable<int>(id.value);
|
||||
}
|
||||
if (data.present) {
|
||||
map['data'] = Variable<String>($MusclesTable.$converterdata.toSql(data.value));
|
||||
}
|
||||
if (rowid.present) {
|
||||
map['rowid'] = Variable<int>(rowid.value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('MusclesCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('data: $data, ')
|
||||
..write('rowid: $rowid')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $EquipmentsTable extends Equipments with TableInfo<$EquipmentsTable, EquipmentTable> {
|
||||
@override
|
||||
final GeneratedDatabase attachedDatabase;
|
||||
final String? _alias;
|
||||
$EquipmentsTable(this.attachedDatabase, [this._alias]);
|
||||
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
||||
@override
|
||||
late final GeneratedColumn<int> id = GeneratedColumn<int>('id', aliasedName, false,
|
||||
type: DriftSqlType.int, requiredDuringInsert: true);
|
||||
static const VerificationMeta _dataMeta = const VerificationMeta('data');
|
||||
@override
|
||||
late final GeneratedColumnWithTypeConverter<Equipment, String> data = GeneratedColumn<String>(
|
||||
'data', aliasedName, false,
|
||||
type: DriftSqlType.string, requiredDuringInsert: true)
|
||||
.withConverter<Equipment>($EquipmentsTable.$converterdata);
|
||||
@override
|
||||
List<GeneratedColumn> get $columns => [id, data];
|
||||
@override
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'equipments';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<EquipmentTable> instance,
|
||||
{bool isInserting = false}) {
|
||||
final context = VerificationContext();
|
||||
final data = instance.toColumns(true);
|
||||
if (data.containsKey('id')) {
|
||||
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
||||
} else if (isInserting) {
|
||||
context.missing(_idMeta);
|
||||
}
|
||||
context.handle(_dataMeta, const VerificationResult.success());
|
||||
return context;
|
||||
}
|
||||
|
||||
@override
|
||||
Set<GeneratedColumn> get $primaryKey => const {};
|
||||
@override
|
||||
EquipmentTable map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return EquipmentTable(
|
||||
id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
data: $EquipmentsTable.$converterdata.fromSql(
|
||||
attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}data'])!),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
$EquipmentsTable createAlias(String alias) {
|
||||
return $EquipmentsTable(attachedDatabase, alias);
|
||||
}
|
||||
|
||||
static TypeConverter<Equipment, String> $converterdata = const EquipmentConverter();
|
||||
}
|
||||
|
||||
class EquipmentTable extends DataClass implements Insertable<EquipmentTable> {
|
||||
final int id;
|
||||
final Equipment data;
|
||||
const EquipmentTable({required this.id, required this.data});
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
map['id'] = Variable<int>(id);
|
||||
{
|
||||
map['data'] = Variable<String>($EquipmentsTable.$converterdata.toSql(data));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
EquipmentsCompanion toCompanion(bool nullToAbsent) {
|
||||
return EquipmentsCompanion(
|
||||
id: Value(id),
|
||||
data: Value(data),
|
||||
);
|
||||
}
|
||||
|
||||
factory EquipmentTable.fromJson(Map<String, dynamic> json, {ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return EquipmentTable(
|
||||
id: serializer.fromJson<int>(json['id']),
|
||||
data: serializer.fromJson<Equipment>(json['data']),
|
||||
);
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return <String, dynamic>{
|
||||
'id': serializer.toJson<int>(id),
|
||||
'data': serializer.toJson<Equipment>(data),
|
||||
};
|
||||
}
|
||||
|
||||
EquipmentTable copyWith({int? id, Equipment? data}) => EquipmentTable(
|
||||
id: id ?? this.id,
|
||||
data: data ?? this.data,
|
||||
);
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('EquipmentTable(')
|
||||
..write('id: $id, ')
|
||||
..write('data: $data')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(id, data);
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is EquipmentTable && other.id == this.id && other.data == this.data);
|
||||
}
|
||||
|
||||
class EquipmentsCompanion extends UpdateCompanion<EquipmentTable> {
|
||||
final Value<int> id;
|
||||
final Value<Equipment> data;
|
||||
final Value<int> rowid;
|
||||
const EquipmentsCompanion({
|
||||
this.id = const Value.absent(),
|
||||
this.data = const Value.absent(),
|
||||
this.rowid = const Value.absent(),
|
||||
});
|
||||
EquipmentsCompanion.insert({
|
||||
required int id,
|
||||
required Equipment data,
|
||||
this.rowid = const Value.absent(),
|
||||
}) : id = Value(id),
|
||||
data = Value(data);
|
||||
static Insertable<EquipmentTable> custom({
|
||||
Expression<int>? id,
|
||||
Expression<String>? data,
|
||||
Expression<int>? rowid,
|
||||
}) {
|
||||
return RawValuesInsertable({
|
||||
if (id != null) 'id': id,
|
||||
if (data != null) 'data': data,
|
||||
if (rowid != null) 'rowid': rowid,
|
||||
});
|
||||
}
|
||||
|
||||
EquipmentsCompanion copyWith({Value<int>? id, Value<Equipment>? data, Value<int>? rowid}) {
|
||||
return EquipmentsCompanion(
|
||||
id: id ?? this.id,
|
||||
data: data ?? this.data,
|
||||
rowid: rowid ?? this.rowid,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
if (id.present) {
|
||||
map['id'] = Variable<int>(id.value);
|
||||
}
|
||||
if (data.present) {
|
||||
map['data'] = Variable<String>($EquipmentsTable.$converterdata.toSql(data.value));
|
||||
}
|
||||
if (rowid.present) {
|
||||
map['rowid'] = Variable<int>(rowid.value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('EquipmentsCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('data: $data, ')
|
||||
..write('rowid: $rowid')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $CategoriesTable extends Categories with TableInfo<$CategoriesTable, CategoryTable> {
|
||||
@override
|
||||
final GeneratedDatabase attachedDatabase;
|
||||
final String? _alias;
|
||||
$CategoriesTable(this.attachedDatabase, [this._alias]);
|
||||
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
||||
@override
|
||||
late final GeneratedColumn<int> id = GeneratedColumn<int>('id', aliasedName, false,
|
||||
type: DriftSqlType.int, requiredDuringInsert: true);
|
||||
static const VerificationMeta _dataMeta = const VerificationMeta('data');
|
||||
@override
|
||||
late final GeneratedColumnWithTypeConverter<ExerciseCategory, String> data =
|
||||
GeneratedColumn<String>('data', aliasedName, false,
|
||||
type: DriftSqlType.string, requiredDuringInsert: true)
|
||||
.withConverter<ExerciseCategory>($CategoriesTable.$converterdata);
|
||||
@override
|
||||
List<GeneratedColumn> get $columns => [id, data];
|
||||
@override
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'categories';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<CategoryTable> instance,
|
||||
{bool isInserting = false}) {
|
||||
final context = VerificationContext();
|
||||
final data = instance.toColumns(true);
|
||||
if (data.containsKey('id')) {
|
||||
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
||||
} else if (isInserting) {
|
||||
context.missing(_idMeta);
|
||||
}
|
||||
context.handle(_dataMeta, const VerificationResult.success());
|
||||
return context;
|
||||
}
|
||||
|
||||
@override
|
||||
Set<GeneratedColumn> get $primaryKey => const {};
|
||||
@override
|
||||
CategoryTable map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return CategoryTable(
|
||||
id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
data: $CategoriesTable.$converterdata.fromSql(
|
||||
attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}data'])!),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
$CategoriesTable createAlias(String alias) {
|
||||
return $CategoriesTable(attachedDatabase, alias);
|
||||
}
|
||||
|
||||
static TypeConverter<ExerciseCategory, String> $converterdata = const ExerciseCategoryConverter();
|
||||
}
|
||||
|
||||
class CategoryTable extends DataClass implements Insertable<CategoryTable> {
|
||||
final int id;
|
||||
final ExerciseCategory data;
|
||||
const CategoryTable({required this.id, required this.data});
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
map['id'] = Variable<int>(id);
|
||||
{
|
||||
map['data'] = Variable<String>($CategoriesTable.$converterdata.toSql(data));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
CategoriesCompanion toCompanion(bool nullToAbsent) {
|
||||
return CategoriesCompanion(
|
||||
id: Value(id),
|
||||
data: Value(data),
|
||||
);
|
||||
}
|
||||
|
||||
factory CategoryTable.fromJson(Map<String, dynamic> json, {ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return CategoryTable(
|
||||
id: serializer.fromJson<int>(json['id']),
|
||||
data: serializer.fromJson<ExerciseCategory>(json['data']),
|
||||
);
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return <String, dynamic>{
|
||||
'id': serializer.toJson<int>(id),
|
||||
'data': serializer.toJson<ExerciseCategory>(data),
|
||||
};
|
||||
}
|
||||
|
||||
CategoryTable copyWith({int? id, ExerciseCategory? data}) => CategoryTable(
|
||||
id: id ?? this.id,
|
||||
data: data ?? this.data,
|
||||
);
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('CategoryTable(')
|
||||
..write('id: $id, ')
|
||||
..write('data: $data')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(id, data);
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is CategoryTable && other.id == this.id && other.data == this.data);
|
||||
}
|
||||
|
||||
class CategoriesCompanion extends UpdateCompanion<CategoryTable> {
|
||||
final Value<int> id;
|
||||
final Value<ExerciseCategory> data;
|
||||
final Value<int> rowid;
|
||||
const CategoriesCompanion({
|
||||
this.id = const Value.absent(),
|
||||
this.data = const Value.absent(),
|
||||
this.rowid = const Value.absent(),
|
||||
});
|
||||
CategoriesCompanion.insert({
|
||||
required int id,
|
||||
required ExerciseCategory data,
|
||||
this.rowid = const Value.absent(),
|
||||
}) : id = Value(id),
|
||||
data = Value(data);
|
||||
static Insertable<CategoryTable> custom({
|
||||
Expression<int>? id,
|
||||
Expression<String>? data,
|
||||
Expression<int>? rowid,
|
||||
}) {
|
||||
return RawValuesInsertable({
|
||||
if (id != null) 'id': id,
|
||||
if (data != null) 'data': data,
|
||||
if (rowid != null) 'rowid': rowid,
|
||||
});
|
||||
}
|
||||
|
||||
CategoriesCompanion copyWith({Value<int>? id, Value<ExerciseCategory>? data, Value<int>? rowid}) {
|
||||
return CategoriesCompanion(
|
||||
id: id ?? this.id,
|
||||
data: data ?? this.data,
|
||||
rowid: rowid ?? this.rowid,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
if (id.present) {
|
||||
map['id'] = Variable<int>(id.value);
|
||||
}
|
||||
if (data.present) {
|
||||
map['data'] = Variable<String>($CategoriesTable.$converterdata.toSql(data.value));
|
||||
}
|
||||
if (rowid.present) {
|
||||
map['rowid'] = Variable<int>(rowid.value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('CategoriesCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('data: $data, ')
|
||||
..write('rowid: $rowid')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $LanguagesTable extends Languages with TableInfo<$LanguagesTable, LanguagesTable> {
|
||||
@override
|
||||
final GeneratedDatabase attachedDatabase;
|
||||
final String? _alias;
|
||||
$LanguagesTable(this.attachedDatabase, [this._alias]);
|
||||
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
||||
@override
|
||||
late final GeneratedColumn<int> id = GeneratedColumn<int>('id', aliasedName, false,
|
||||
type: DriftSqlType.int, requiredDuringInsert: true);
|
||||
static const VerificationMeta _dataMeta = const VerificationMeta('data');
|
||||
@override
|
||||
late final GeneratedColumnWithTypeConverter<Language, String> data = GeneratedColumn<String>(
|
||||
'data', aliasedName, false,
|
||||
type: DriftSqlType.string, requiredDuringInsert: true)
|
||||
.withConverter<Language>($LanguagesTable.$converterdata);
|
||||
@override
|
||||
List<GeneratedColumn> get $columns => [id, data];
|
||||
@override
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'languages';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<LanguagesTable> instance,
|
||||
{bool isInserting = false}) {
|
||||
final context = VerificationContext();
|
||||
final data = instance.toColumns(true);
|
||||
if (data.containsKey('id')) {
|
||||
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
||||
} else if (isInserting) {
|
||||
context.missing(_idMeta);
|
||||
}
|
||||
context.handle(_dataMeta, const VerificationResult.success());
|
||||
return context;
|
||||
}
|
||||
|
||||
@override
|
||||
Set<GeneratedColumn> get $primaryKey => const {};
|
||||
@override
|
||||
LanguagesTable map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return LanguagesTable(
|
||||
id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
data: $LanguagesTable.$converterdata.fromSql(
|
||||
attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}data'])!),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
$LanguagesTable createAlias(String alias) {
|
||||
return $LanguagesTable(attachedDatabase, alias);
|
||||
}
|
||||
|
||||
static TypeConverter<Language, String> $converterdata = const LanguageConverter();
|
||||
}
|
||||
|
||||
class LanguagesTable extends DataClass implements Insertable<LanguagesTable> {
|
||||
final int id;
|
||||
final Language data;
|
||||
const LanguagesTable({required this.id, required this.data});
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
map['id'] = Variable<int>(id);
|
||||
{
|
||||
map['data'] = Variable<String>($LanguagesTable.$converterdata.toSql(data));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
LanguagesCompanion toCompanion(bool nullToAbsent) {
|
||||
return LanguagesCompanion(
|
||||
id: Value(id),
|
||||
data: Value(data),
|
||||
);
|
||||
}
|
||||
|
||||
factory LanguagesTable.fromJson(Map<String, dynamic> json, {ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return LanguagesTable(
|
||||
id: serializer.fromJson<int>(json['id']),
|
||||
data: serializer.fromJson<Language>(json['data']),
|
||||
);
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return <String, dynamic>{
|
||||
'id': serializer.toJson<int>(id),
|
||||
'data': serializer.toJson<Language>(data),
|
||||
};
|
||||
}
|
||||
|
||||
LanguagesTable copyWith({int? id, Language? data}) => LanguagesTable(
|
||||
id: id ?? this.id,
|
||||
data: data ?? this.data,
|
||||
);
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('LanguagesTable(')
|
||||
..write('id: $id, ')
|
||||
..write('data: $data')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(id, data);
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is LanguagesTable && other.id == this.id && other.data == this.data);
|
||||
}
|
||||
|
||||
class LanguagesCompanion extends UpdateCompanion<LanguagesTable> {
|
||||
final Value<int> id;
|
||||
final Value<Language> data;
|
||||
final Value<int> rowid;
|
||||
const LanguagesCompanion({
|
||||
this.id = const Value.absent(),
|
||||
this.data = const Value.absent(),
|
||||
this.rowid = const Value.absent(),
|
||||
});
|
||||
LanguagesCompanion.insert({
|
||||
required int id,
|
||||
required Language data,
|
||||
this.rowid = const Value.absent(),
|
||||
}) : id = Value(id),
|
||||
data = Value(data);
|
||||
static Insertable<LanguagesTable> custom({
|
||||
Expression<int>? id,
|
||||
Expression<String>? data,
|
||||
Expression<int>? rowid,
|
||||
}) {
|
||||
return RawValuesInsertable({
|
||||
if (id != null) 'id': id,
|
||||
if (data != null) 'data': data,
|
||||
if (rowid != null) 'rowid': rowid,
|
||||
});
|
||||
}
|
||||
|
||||
LanguagesCompanion copyWith({Value<int>? id, Value<Language>? data, Value<int>? rowid}) {
|
||||
return LanguagesCompanion(
|
||||
id: id ?? this.id,
|
||||
data: data ?? this.data,
|
||||
rowid: rowid ?? this.rowid,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
if (id.present) {
|
||||
map['id'] = Variable<int>(id.value);
|
||||
}
|
||||
if (data.present) {
|
||||
map['data'] = Variable<String>($LanguagesTable.$converterdata.toSql(data.value));
|
||||
}
|
||||
if (rowid.present) {
|
||||
map['rowid'] = Variable<int>(rowid.value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('LanguagesCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('data: $data, ')
|
||||
..write('rowid: $rowid')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _$ExerciseDatabase extends GeneratedDatabase {
|
||||
_$ExerciseDatabase(QueryExecutor e) : super(e);
|
||||
late final $ExercisesTable exercises = $ExercisesTable(this);
|
||||
late final $MusclesTable muscles = $MusclesTable(this);
|
||||
late final $EquipmentsTable equipments = $EquipmentsTable(this);
|
||||
late final $CategoriesTable categories = $CategoriesTable(this);
|
||||
late final $LanguagesTable languages = $LanguagesTable(this);
|
||||
@override
|
||||
Iterable<TableInfo<Table, Object?>> get allTables =>
|
||||
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||
@override
|
||||
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
||||
[exercises, muscles, equipments, categories, languages];
|
||||
}
|
||||
134
lib/database/exercises/type_converters.dart
Normal file
134
lib/database/exercises/type_converters.dart
Normal file
@@ -0,0 +1,134 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:wger/models/exercises/alias.dart';
|
||||
import 'package:wger/models/exercises/category.dart';
|
||||
import 'package:wger/models/exercises/comment.dart';
|
||||
import 'package:wger/models/exercises/equipment.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/models/exercises/image.dart';
|
||||
import 'package:wger/models/exercises/language.dart';
|
||||
import 'package:wger/models/exercises/muscle.dart';
|
||||
import 'package:wger/models/exercises/translation.dart';
|
||||
import 'package:wger/models/exercises/variation.dart';
|
||||
import 'package:wger/models/exercises/video.dart';
|
||||
|
||||
class ExerciseBaseConverter extends TypeConverter<Exercise, String> {
|
||||
const ExerciseBaseConverter();
|
||||
|
||||
@override
|
||||
Exercise fromSql(String fromDb) {
|
||||
final Map<String, dynamic> baseData = json.decode(fromDb);
|
||||
|
||||
final category = ExerciseCategory.fromJson(baseData['categories']);
|
||||
final musclesPrimary = baseData['muscless'].map((e) => Muscle.fromJson(e)).toList();
|
||||
final musclesSecondary = baseData['musclesSecondary'].map((e) => Muscle.fromJson(e)).toList();
|
||||
final equipment = baseData['equipments'].map((e) => Equipment.fromJson(e)).toList();
|
||||
final images = baseData['images'].map((e) => ExerciseImage.fromJson(e)).toList();
|
||||
final videos = baseData['videos'].map((e) => Video.fromJson(e)).toList();
|
||||
|
||||
final List<Translation> translations = [];
|
||||
for (final exerciseData in baseData['translations']) {
|
||||
final translation = Translation(
|
||||
id: exerciseData['id'],
|
||||
name: exerciseData['name'],
|
||||
description: exerciseData['description'],
|
||||
exerciseId: baseData['id'],
|
||||
);
|
||||
translation.aliases = exerciseData['aliases'].map((e) => Alias.fromJson(e)).toList();
|
||||
translation.notes = exerciseData['notes'].map((e) => Comment.fromJson(e)).toList();
|
||||
translation.language = Language.fromJson(exerciseData['languageObj']);
|
||||
translations.add(translation);
|
||||
}
|
||||
|
||||
final exerciseBase = Exercise(
|
||||
id: baseData['id'],
|
||||
uuid: baseData['uuid'],
|
||||
created: null,
|
||||
//creationDate: toDate(baseData['creation_date']),
|
||||
musclesSecondary: musclesSecondary.cast<Muscle>(),
|
||||
muscles: musclesPrimary.cast<Muscle>(),
|
||||
equipment: equipment.cast<Equipment>(),
|
||||
category: category,
|
||||
images: images.cast<ExerciseImage>(),
|
||||
translations: translations,
|
||||
videos: videos.cast<Video>(),
|
||||
);
|
||||
return exerciseBase;
|
||||
}
|
||||
|
||||
@override
|
||||
String toSql(Exercise value) {
|
||||
return json.encode(value.toJson());
|
||||
}
|
||||
}
|
||||
|
||||
class MuscleConverter extends TypeConverter<Muscle, String> {
|
||||
const MuscleConverter();
|
||||
|
||||
@override
|
||||
Muscle fromSql(String fromDb) {
|
||||
return Muscle.fromJson(json.decode(fromDb) as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
@override
|
||||
String toSql(Muscle value) {
|
||||
return json.encode(value.toJson());
|
||||
}
|
||||
}
|
||||
|
||||
class EquipmentConverter extends TypeConverter<Equipment, String> {
|
||||
const EquipmentConverter();
|
||||
|
||||
@override
|
||||
Equipment fromSql(String fromDb) {
|
||||
return Equipment.fromJson(json.decode(fromDb) as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
@override
|
||||
String toSql(Equipment value) {
|
||||
return json.encode(value.toJson());
|
||||
}
|
||||
}
|
||||
|
||||
class ExerciseCategoryConverter extends TypeConverter<ExerciseCategory, String> {
|
||||
const ExerciseCategoryConverter();
|
||||
|
||||
@override
|
||||
ExerciseCategory fromSql(String fromDb) {
|
||||
return ExerciseCategory.fromJson(json.decode(fromDb) as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
@override
|
||||
String toSql(ExerciseCategory value) {
|
||||
return json.encode(value.toJson());
|
||||
}
|
||||
}
|
||||
|
||||
class LanguageConverter extends TypeConverter<Language, String> {
|
||||
const LanguageConverter();
|
||||
|
||||
@override
|
||||
Language fromSql(String fromDb) {
|
||||
return Language.fromJson(json.decode(fromDb) as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
@override
|
||||
String toSql(Language value) {
|
||||
return json.encode(value.toJson());
|
||||
}
|
||||
}
|
||||
|
||||
class VariationConverter extends TypeConverter<Variation, String> {
|
||||
const VariationConverter();
|
||||
|
||||
@override
|
||||
Variation fromSql(String fromDb) {
|
||||
return Variation.fromJson(json.decode(fromDb) as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
@override
|
||||
String toSql(Variation value) {
|
||||
return json.encode(value.toJson());
|
||||
}
|
||||
}
|
||||
37
lib/database/ingredients/ingredients_database.dart
Normal file
37
lib/database/ingredients/ingredients_database.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
part 'ingredients_database.g.dart';
|
||||
|
||||
@DataClassName('IngredientTable')
|
||||
class Ingredients extends Table {
|
||||
IntColumn get id => integer()();
|
||||
|
||||
TextColumn get data => text()();
|
||||
|
||||
DateTimeColumn get lastUpdate => dateTime()();
|
||||
}
|
||||
|
||||
@DriftDatabase(tables: [Ingredients])
|
||||
class IngredientDatabase extends _$IngredientDatabase {
|
||||
IngredientDatabase() : super(_openConnection());
|
||||
|
||||
// Named constructor for creating in-memory database
|
||||
IngredientDatabase.inMemory(super.e);
|
||||
|
||||
@override
|
||||
// TODO: implement schemaVersion
|
||||
int get schemaVersion => 1;
|
||||
}
|
||||
|
||||
LazyDatabase _openConnection() {
|
||||
return LazyDatabase(() async {
|
||||
final dbFolder = await getApplicationCacheDirectory();
|
||||
final file = File(p.join(dbFolder.path, 'ingredients.sqlite'));
|
||||
return NativeDatabase.createInBackground(file);
|
||||
});
|
||||
}
|
||||
221
lib/database/ingredients/ingredients_database.g.dart
Normal file
221
lib/database/ingredients/ingredients_database.g.dart
Normal file
@@ -0,0 +1,221 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'ingredients_database.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
class $IngredientsTable extends Ingredients with TableInfo<$IngredientsTable, IngredientTable> {
|
||||
@override
|
||||
final GeneratedDatabase attachedDatabase;
|
||||
final String? _alias;
|
||||
$IngredientsTable(this.attachedDatabase, [this._alias]);
|
||||
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
||||
@override
|
||||
late final GeneratedColumn<int> id = GeneratedColumn<int>('id', aliasedName, false,
|
||||
type: DriftSqlType.int, requiredDuringInsert: true);
|
||||
static const VerificationMeta _dataMeta = const VerificationMeta('data');
|
||||
@override
|
||||
late final GeneratedColumn<String> data = GeneratedColumn<String>('data', aliasedName, false,
|
||||
type: DriftSqlType.string, requiredDuringInsert: true);
|
||||
static const VerificationMeta _lastUpdateMeta = const VerificationMeta('lastUpdate');
|
||||
@override
|
||||
late final GeneratedColumn<DateTime> lastUpdate = GeneratedColumn<DateTime>(
|
||||
'last_update', aliasedName, false,
|
||||
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
||||
@override
|
||||
List<GeneratedColumn> get $columns => [id, data, lastUpdate];
|
||||
@override
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'ingredients';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<IngredientTable> instance,
|
||||
{bool isInserting = false}) {
|
||||
final context = VerificationContext();
|
||||
final data = instance.toColumns(true);
|
||||
if (data.containsKey('id')) {
|
||||
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
||||
} else if (isInserting) {
|
||||
context.missing(_idMeta);
|
||||
}
|
||||
if (data.containsKey('data')) {
|
||||
context.handle(_dataMeta, this.data.isAcceptableOrUnknown(data['data']!, _dataMeta));
|
||||
} else if (isInserting) {
|
||||
context.missing(_dataMeta);
|
||||
}
|
||||
if (data.containsKey('last_update')) {
|
||||
context.handle(
|
||||
_lastUpdateMeta, lastUpdate.isAcceptableOrUnknown(data['last_update']!, _lastUpdateMeta));
|
||||
} else if (isInserting) {
|
||||
context.missing(_lastUpdateMeta);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
@override
|
||||
Set<GeneratedColumn> get $primaryKey => const {};
|
||||
@override
|
||||
IngredientTable map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return IngredientTable(
|
||||
id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
data: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}data'])!,
|
||||
lastUpdate: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.dateTime, data['${effectivePrefix}last_update'])!,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
$IngredientsTable createAlias(String alias) {
|
||||
return $IngredientsTable(attachedDatabase, alias);
|
||||
}
|
||||
}
|
||||
|
||||
class IngredientTable extends DataClass implements Insertable<IngredientTable> {
|
||||
final int id;
|
||||
final String data;
|
||||
final DateTime lastUpdate;
|
||||
const IngredientTable({required this.id, required this.data, required this.lastUpdate});
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
map['id'] = Variable<int>(id);
|
||||
map['data'] = Variable<String>(data);
|
||||
map['last_update'] = Variable<DateTime>(lastUpdate);
|
||||
return map;
|
||||
}
|
||||
|
||||
IngredientsCompanion toCompanion(bool nullToAbsent) {
|
||||
return IngredientsCompanion(
|
||||
id: Value(id),
|
||||
data: Value(data),
|
||||
lastUpdate: Value(lastUpdate),
|
||||
);
|
||||
}
|
||||
|
||||
factory IngredientTable.fromJson(Map<String, dynamic> json, {ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return IngredientTable(
|
||||
id: serializer.fromJson<int>(json['id']),
|
||||
data: serializer.fromJson<String>(json['data']),
|
||||
lastUpdate: serializer.fromJson<DateTime>(json['lastUpdate']),
|
||||
);
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return <String, dynamic>{
|
||||
'id': serializer.toJson<int>(id),
|
||||
'data': serializer.toJson<String>(data),
|
||||
'lastUpdate': serializer.toJson<DateTime>(lastUpdate),
|
||||
};
|
||||
}
|
||||
|
||||
IngredientTable copyWith({int? id, String? data, DateTime? lastUpdate}) => IngredientTable(
|
||||
id: id ?? this.id,
|
||||
data: data ?? this.data,
|
||||
lastUpdate: lastUpdate ?? this.lastUpdate,
|
||||
);
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('IngredientTable(')
|
||||
..write('id: $id, ')
|
||||
..write('data: $data, ')
|
||||
..write('lastUpdate: $lastUpdate')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(id, data, lastUpdate);
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is IngredientTable &&
|
||||
other.id == this.id &&
|
||||
other.data == this.data &&
|
||||
other.lastUpdate == this.lastUpdate);
|
||||
}
|
||||
|
||||
class IngredientsCompanion extends UpdateCompanion<IngredientTable> {
|
||||
final Value<int> id;
|
||||
final Value<String> data;
|
||||
final Value<DateTime> lastUpdate;
|
||||
final Value<int> rowid;
|
||||
const IngredientsCompanion({
|
||||
this.id = const Value.absent(),
|
||||
this.data = const Value.absent(),
|
||||
this.lastUpdate = const Value.absent(),
|
||||
this.rowid = const Value.absent(),
|
||||
});
|
||||
IngredientsCompanion.insert({
|
||||
required int id,
|
||||
required String data,
|
||||
required DateTime lastUpdate,
|
||||
this.rowid = const Value.absent(),
|
||||
}) : id = Value(id),
|
||||
data = Value(data),
|
||||
lastUpdate = Value(lastUpdate);
|
||||
static Insertable<IngredientTable> custom({
|
||||
Expression<int>? id,
|
||||
Expression<String>? data,
|
||||
Expression<DateTime>? lastUpdate,
|
||||
Expression<int>? rowid,
|
||||
}) {
|
||||
return RawValuesInsertable({
|
||||
if (id != null) 'id': id,
|
||||
if (data != null) 'data': data,
|
||||
if (lastUpdate != null) 'last_update': lastUpdate,
|
||||
if (rowid != null) 'rowid': rowid,
|
||||
});
|
||||
}
|
||||
|
||||
IngredientsCompanion copyWith(
|
||||
{Value<int>? id, Value<String>? data, Value<DateTime>? lastUpdate, Value<int>? rowid}) {
|
||||
return IngredientsCompanion(
|
||||
id: id ?? this.id,
|
||||
data: data ?? this.data,
|
||||
lastUpdate: lastUpdate ?? this.lastUpdate,
|
||||
rowid: rowid ?? this.rowid,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
if (id.present) {
|
||||
map['id'] = Variable<int>(id.value);
|
||||
}
|
||||
if (data.present) {
|
||||
map['data'] = Variable<String>(data.value);
|
||||
}
|
||||
if (lastUpdate.present) {
|
||||
map['last_update'] = Variable<DateTime>(lastUpdate.value);
|
||||
}
|
||||
if (rowid.present) {
|
||||
map['rowid'] = Variable<int>(rowid.value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('IngredientsCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('data: $data, ')
|
||||
..write('lastUpdate: $lastUpdate, ')
|
||||
..write('rowid: $rowid')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _$IngredientDatabase extends GeneratedDatabase {
|
||||
_$IngredientDatabase(QueryExecutor e) : super(e);
|
||||
late final $IngredientsTable ingredients = $IngredientsTable(this);
|
||||
@override
|
||||
Iterable<TableInfo<Table, Object?>> get allTables =>
|
||||
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||
@override
|
||||
List<DatabaseSchemaEntity> get allSchemaEntities => [ingredients];
|
||||
}
|
||||
@@ -56,6 +56,10 @@ const SUBMIT_BUTTON_KEY_NAME = 'submit-button';
|
||||
|
||||
/// Local Preferences keys
|
||||
const PREFS_EXERCISES = 'exerciseData';
|
||||
const PREFS_LAST_UPDATED_MUSCLES = 'lastUpdatedMuscles';
|
||||
const PREFS_LAST_UPDATED_EQUIPMENT = 'lastUpdatedEquipment';
|
||||
const PREFS_LAST_UPDATED_CATEGORIES = 'lastUpdatedCategories';
|
||||
const PREFS_LAST_UPDATED_LANGUAGES = 'lastUpdatedLanguages';
|
||||
const PREFS_EXERCISE_CACHE_VERSION = 'cacheVersion';
|
||||
const PREFS_INGREDIENTS = 'ingredientData';
|
||||
|
||||
|
||||
@@ -92,6 +92,15 @@ extension TimeOfDayExtension on TimeOfDay {
|
||||
}
|
||||
}
|
||||
|
||||
extension DateTimeExtension on DateTime {
|
||||
bool isSameDayAs(DateTime other) {
|
||||
final thisDay = DateTime(year, month, day);
|
||||
final otherDay = DateTime(other.year, other.month, other.day);
|
||||
|
||||
return thisDay.isAtSameMomentAs(otherDay);
|
||||
}
|
||||
}
|
||||
|
||||
void launchURL(String url, BuildContext context) async {
|
||||
final scaffoldMessenger = ScaffoldMessenger.of(context);
|
||||
final launched = await launchUrl(Uri.parse(url));
|
||||
|
||||
@@ -22,7 +22,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/exceptions/http_exception.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/models/exercises/translation.dart';
|
||||
import 'package:wger/models/workouts/log.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
@@ -108,7 +108,7 @@ dynamic showDeleteDialog(
|
||||
String confirmDeleteName,
|
||||
Log log,
|
||||
Translation exercise,
|
||||
Map<ExerciseBase, List<Log>> exerciseData,
|
||||
Map<Exercise, List<Log>> exerciseData,
|
||||
) async {
|
||||
final res = await showDialog(
|
||||
context: context,
|
||||
|
||||
@@ -639,6 +639,10 @@
|
||||
"@baseData": {
|
||||
"description": "The base data for an exercise such as category, trained muscles, etc."
|
||||
},
|
||||
"settingsTitle": "Settings",
|
||||
"settingsCacheTitle": "Cache",
|
||||
"settingsCacheDescription": "Exercise cache",
|
||||
"settingsCacheDeletedSnackbar": "Cache successfully cleared",
|
||||
"aboutPageTitle": "About Wger",
|
||||
"contributeExerciseWarning": "You can only contribute exercises if your account is older than {days} days and have verified your email",
|
||||
"@contributeExerciseWarning": {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/core/locator.dart';
|
||||
import 'package:wger/providers/add_exercise.dart';
|
||||
import 'package:wger/providers/base_provider.dart';
|
||||
import 'package:wger/providers/body_weight.dart';
|
||||
@@ -48,15 +49,18 @@ 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';
|
||||
import 'package:wger/widgets/core/settings.dart';
|
||||
|
||||
import 'providers/auth.dart';
|
||||
|
||||
void main() {
|
||||
void main() async {
|
||||
//zx.setLogEnabled(kDebugMode);
|
||||
|
||||
// Needs to be called before runApp
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
// Locator to initialize exerciseDB
|
||||
await ServiceLocator().configure();
|
||||
// Application
|
||||
runApp(MyApp());
|
||||
}
|
||||
@@ -161,6 +165,7 @@ class MyApp extends StatelessWidget {
|
||||
ExerciseDetailScreen.routeName: (ctx) => const ExerciseDetailScreen(),
|
||||
AddExerciseScreen.routeName: (ctx) => const AddExerciseScreen(),
|
||||
AboutPage.routeName: (ctx) => const AboutPage(),
|
||||
SettingsPage.routeName: (ctx) => const SettingsPage(),
|
||||
},
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
|
||||
@@ -25,8 +25,8 @@ class Alias {
|
||||
@JsonKey(required: true)
|
||||
final int? id;
|
||||
|
||||
@JsonKey(required: true, name: 'exercise')
|
||||
final int exerciseId;
|
||||
@JsonKey(name: 'exercise')
|
||||
final int? exerciseId;
|
||||
|
||||
@JsonKey(required: true)
|
||||
final String alias;
|
||||
|
||||
@@ -9,11 +9,11 @@ part of 'alias.dart';
|
||||
Alias _$AliasFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(
|
||||
json,
|
||||
requiredKeys: const ['id', 'exercise', 'alias'],
|
||||
requiredKeys: const ['id', 'alias'],
|
||||
);
|
||||
return Alias(
|
||||
id: json['id'] as int?,
|
||||
exerciseId: json['exercise'] as int,
|
||||
exerciseId: json['exercise'] as int?,
|
||||
alias: json['alias'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class Comment {
|
||||
@JsonKey(required: true)
|
||||
final int id;
|
||||
|
||||
@JsonKey(required: true, name: 'exercise')
|
||||
@JsonKey(name: 'exercise')
|
||||
final int exerciseId;
|
||||
|
||||
@JsonKey(required: true)
|
||||
|
||||
@@ -9,7 +9,7 @@ part of 'comment.dart';
|
||||
Comment _$CommentFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(
|
||||
json,
|
||||
requiredKeys: const ['id', 'exercise', 'comment'],
|
||||
requiredKeys: const ['id', 'comment'],
|
||||
);
|
||||
return Comment(
|
||||
id: json['id'] as int,
|
||||
|
||||
@@ -21,35 +21,40 @@ import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/models/exercises/category.dart';
|
||||
import 'package:wger/models/exercises/equipment.dart';
|
||||
import 'package:wger/models/exercises/exercise_api.dart';
|
||||
import 'package:wger/models/exercises/image.dart';
|
||||
import 'package:wger/models/exercises/language.dart';
|
||||
import 'package:wger/models/exercises/muscle.dart';
|
||||
import 'package:wger/models/exercises/translation.dart';
|
||||
import 'package:wger/models/exercises/video.dart';
|
||||
|
||||
part 'base.g.dart';
|
||||
part 'exercise.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class ExerciseBase extends Equatable {
|
||||
class Exercise extends Equatable {
|
||||
@JsonKey(required: true)
|
||||
final int? id;
|
||||
late final int? id;
|
||||
|
||||
@JsonKey(required: true)
|
||||
final String? uuid;
|
||||
late final String? uuid;
|
||||
|
||||
@JsonKey(required: true, name: 'variations')
|
||||
final int? variationId;
|
||||
late final int? variationId;
|
||||
|
||||
@JsonKey(required: true, name: 'created')
|
||||
final DateTime? created;
|
||||
late final DateTime? created;
|
||||
|
||||
@JsonKey(required: true, name: 'last_update')
|
||||
final DateTime? lastUpdate;
|
||||
late final DateTime? lastUpdate;
|
||||
|
||||
@JsonKey(required: true, name: 'last_update_global')
|
||||
late final DateTime? lastUpdateGlobal;
|
||||
|
||||
@JsonKey(required: true, name: 'category')
|
||||
late int categoryId;
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
late final ExerciseCategory category;
|
||||
@JsonKey(includeFromJson: true, includeToJson: true, name: 'categories')
|
||||
ExerciseCategory? category;
|
||||
|
||||
@JsonKey(required: true, name: 'muscles')
|
||||
List<int> musclesIds = [];
|
||||
@@ -60,7 +65,7 @@ class ExerciseBase extends Equatable {
|
||||
@JsonKey(required: true, name: 'muscles_secondary')
|
||||
List<int> musclesSecondaryIds = [];
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@JsonKey(includeFromJson: false, includeToJson: true)
|
||||
List<Muscle> musclesSecondary = [];
|
||||
|
||||
@JsonKey(required: true, name: 'equipment')
|
||||
@@ -72,25 +77,34 @@ class ExerciseBase extends Equatable {
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
List<ExerciseImage> images = [];
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@JsonKey(includeFromJson: true, includeToJson: false)
|
||||
List<Translation> translations = [];
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
List<Video> videos = [];
|
||||
|
||||
ExerciseBase({
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
List<String> authors = [];
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
List<String> authorsGlobal = [];
|
||||
|
||||
Exercise({
|
||||
this.id,
|
||||
this.uuid,
|
||||
this.created,
|
||||
this.lastUpdate,
|
||||
this.lastUpdateGlobal,
|
||||
this.variationId,
|
||||
List<Muscle>? muscles,
|
||||
List<Muscle>? musclesSecondary,
|
||||
List<Equipment>? equipment,
|
||||
List<ExerciseImage>? images,
|
||||
List<Translation>? exercises,
|
||||
List<Translation>? translations,
|
||||
ExerciseCategory? category,
|
||||
List<Video>? videos,
|
||||
List<String>? authors,
|
||||
List<String>? authorsGlobal,
|
||||
}) {
|
||||
this.images = images ?? [];
|
||||
this.equipment = equipment ?? [];
|
||||
@@ -114,13 +128,48 @@ class ExerciseBase extends Equatable {
|
||||
equipmentIds = equipment.map((e) => e.id).toList();
|
||||
}
|
||||
|
||||
if (exercises != null) {
|
||||
translations = exercises;
|
||||
if (translations != null) {
|
||||
this.translations = translations;
|
||||
}
|
||||
|
||||
if (videos != null) {
|
||||
this.videos = videos;
|
||||
}
|
||||
this.authors = authors ?? [];
|
||||
this.authorsGlobal = authorsGlobal ?? [];
|
||||
}
|
||||
|
||||
Exercise.fromApiDataString(String baseData, List<Language> languages)
|
||||
: this.fromApiData(ExerciseApiData.fromString(baseData), languages);
|
||||
|
||||
Exercise.fromApiDataJson(Map<String, dynamic> baseData, List<Language> languages)
|
||||
: this.fromApiData(ExerciseApiData.fromJson(baseData), languages);
|
||||
|
||||
Exercise.fromApiData(ExerciseApiData baseData, List<Language> languages) {
|
||||
id = baseData.id;
|
||||
uuid = baseData.uuid;
|
||||
categoryId = baseData.category.id;
|
||||
category = baseData.category;
|
||||
|
||||
created = baseData.created;
|
||||
lastUpdate = baseData.lastUpdate;
|
||||
lastUpdateGlobal = baseData.lastUpdateGlobal;
|
||||
|
||||
musclesSecondary = baseData.muscles;
|
||||
muscles = baseData.muscles;
|
||||
equipment = baseData.equipment;
|
||||
category = baseData.category;
|
||||
translations = baseData.translations.map((e) {
|
||||
e.language = languages.firstWhere((l) => l.id == e.languageId);
|
||||
return e;
|
||||
}).toList();
|
||||
videos = baseData.videos;
|
||||
images = baseData.images;
|
||||
|
||||
authors = baseData.authors;
|
||||
authorsGlobal = baseData.authorsGlobal;
|
||||
|
||||
variationId = baseData.variationId;
|
||||
}
|
||||
|
||||
/// Returns exercises for the given language
|
||||
@@ -158,9 +207,9 @@ class ExerciseBase extends Equatable {
|
||||
}
|
||||
|
||||
// Boilerplate
|
||||
factory ExerciseBase.fromJson(Map<String, dynamic> json) => _$ExerciseBaseFromJson(json);
|
||||
factory Exercise.fromJson(Map<String, dynamic> json) => _$ExerciseFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$ExerciseBaseToJson(this);
|
||||
Map<String, dynamic> toJson() => _$ExerciseToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -1,12 +1,12 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'base.dart';
|
||||
part of 'exercise.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ExerciseBase _$ExerciseBaseFromJson(Map<String, dynamic> json) {
|
||||
Exercise _$ExerciseFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(
|
||||
json,
|
||||
requiredKeys: const [
|
||||
@@ -15,18 +15,28 @@ ExerciseBase _$ExerciseBaseFromJson(Map<String, dynamic> json) {
|
||||
'variations',
|
||||
'created',
|
||||
'last_update',
|
||||
'last_update_global',
|
||||
'category',
|
||||
'muscles',
|
||||
'muscles_secondary',
|
||||
'equipment'
|
||||
],
|
||||
);
|
||||
return ExerciseBase(
|
||||
return Exercise(
|
||||
id: json['id'] as int?,
|
||||
uuid: json['uuid'] as String?,
|
||||
created: json['created'] == null ? null : DateTime.parse(json['created'] as String),
|
||||
lastUpdate: json['last_update'] == null ? null : DateTime.parse(json['last_update'] as String),
|
||||
lastUpdateGlobal: json['last_update_global'] == null
|
||||
? null
|
||||
: DateTime.parse(json['last_update_global'] as String),
|
||||
variationId: json['variations'] as int?,
|
||||
translations: (json['translations'] as List<dynamic>?)
|
||||
?.map((e) => Translation.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
category: json['categories'] == null
|
||||
? null
|
||||
: ExerciseCategory.fromJson(json['categories'] as Map<String, dynamic>),
|
||||
)
|
||||
..categoryId = json['category'] as int
|
||||
..musclesIds = (json['muscles'] as List<dynamic>).map((e) => e as int).toList()
|
||||
@@ -35,14 +45,17 @@ ExerciseBase _$ExerciseBaseFromJson(Map<String, dynamic> json) {
|
||||
..equipmentIds = (json['equipment'] as List<dynamic>).map((e) => e as int).toList();
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$ExerciseBaseToJson(ExerciseBase instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$ExerciseToJson(Exercise instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'uuid': instance.uuid,
|
||||
'variations': instance.variationId,
|
||||
'created': instance.created?.toIso8601String(),
|
||||
'last_update': instance.lastUpdate?.toIso8601String(),
|
||||
'last_update_global': instance.lastUpdateGlobal?.toIso8601String(),
|
||||
'category': instance.categoryId,
|
||||
'categories': instance.category?.toJson(),
|
||||
'muscles': instance.musclesIds,
|
||||
'muscles_secondary': instance.musclesSecondaryIds,
|
||||
'musclesSecondary': instance.musclesSecondary.map((e) => e.toJson()).toList(),
|
||||
'equipment': instance.equipmentIds,
|
||||
};
|
||||
50
lib/models/exercises/exercise_api.dart
Normal file
50
lib/models/exercises/exercise_api.dart
Normal file
@@ -0,0 +1,50 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:wger/models/exercises/category.dart';
|
||||
import 'package:wger/models/exercises/equipment.dart';
|
||||
import 'package:wger/models/exercises/image.dart';
|
||||
import 'package:wger/models/exercises/muscle.dart';
|
||||
import 'package:wger/models/exercises/translation.dart';
|
||||
import 'package:wger/models/exercises/video.dart';
|
||||
|
||||
part 'exercise_api.freezed.dart';
|
||||
part 'exercise_api.g.dart';
|
||||
|
||||
/// Model for an exercise as returned from the exercisebaseinfo endpoint
|
||||
///
|
||||
/// Basically this is just used as a convenience to create "real" exercise
|
||||
/// objects and nothing more
|
||||
@freezed
|
||||
class ExerciseApiData with _$ExerciseApiData {
|
||||
factory ExerciseApiData({
|
||||
required int id,
|
||||
required String uuid,
|
||||
// ignore: invalid_annotation_target
|
||||
@Default(null) @JsonKey(name: 'variations') int? variationId,
|
||||
// ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'created') required DateTime created,
|
||||
// ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'last_update') required DateTime lastUpdate,
|
||||
// ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'last_update_global') required DateTime lastUpdateGlobal,
|
||||
required ExerciseCategory category,
|
||||
required List<Muscle> muscles,
|
||||
// ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'muscles_secondary') required List<Muscle> musclesSecondary,
|
||||
// ignore: invalid_annotation_target
|
||||
required List<Equipment> equipment,
|
||||
// ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'exercises') required List<Translation> translations,
|
||||
required List<ExerciseImage> images,
|
||||
required List<Video> videos,
|
||||
// ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'author_history') required List<String> authors,
|
||||
// ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'total_authors_history') required List<String> authorsGlobal,
|
||||
}) = _ExerciseBaseData;
|
||||
|
||||
factory ExerciseApiData.fromString(String input) => _$ExerciseApiDataFromJson(json.decode(input));
|
||||
|
||||
factory ExerciseApiData.fromJson(Map<String, dynamic> json) => _$ExerciseApiDataFromJson(json);
|
||||
}
|
||||
547
lib/models/exercises/exercise_api.freezed.dart
Normal file
547
lib/models/exercises/exercise_api.freezed.dart
Normal file
@@ -0,0 +1,547 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'exercise_api.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
|
||||
|
||||
ExerciseApiData _$ExerciseApiDataFromJson(Map<String, dynamic> json) {
|
||||
return _ExerciseBaseData.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ExerciseApiData {
|
||||
int get id => throw _privateConstructorUsedError;
|
||||
String get uuid => throw _privateConstructorUsedError; // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'variations')
|
||||
int? get variationId => throw _privateConstructorUsedError; // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'created')
|
||||
DateTime get created => throw _privateConstructorUsedError; // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'last_update')
|
||||
DateTime get lastUpdate =>
|
||||
throw _privateConstructorUsedError; // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'last_update_global')
|
||||
DateTime get lastUpdateGlobal => throw _privateConstructorUsedError;
|
||||
ExerciseCategory get category => throw _privateConstructorUsedError;
|
||||
List<Muscle> get muscles =>
|
||||
throw _privateConstructorUsedError; // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'muscles_secondary')
|
||||
List<Muscle> get musclesSecondary =>
|
||||
throw _privateConstructorUsedError; // ignore: invalid_annotation_target
|
||||
List<Equipment> get equipment =>
|
||||
throw _privateConstructorUsedError; // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'exercises')
|
||||
List<Translation> get translations => throw _privateConstructorUsedError;
|
||||
List<ExerciseImage> get images => throw _privateConstructorUsedError;
|
||||
List<Video> get videos => throw _privateConstructorUsedError; // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'author_history')
|
||||
List<String> get authors =>
|
||||
throw _privateConstructorUsedError; // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'total_authors_history')
|
||||
List<String> get authorsGlobal => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$ExerciseApiDataCopyWith<ExerciseApiData> get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ExerciseApiDataCopyWith<$Res> {
|
||||
factory $ExerciseApiDataCopyWith(ExerciseApiData value, $Res Function(ExerciseApiData) then) =
|
||||
_$ExerciseApiDataCopyWithImpl<$Res, ExerciseApiData>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{int id,
|
||||
String uuid,
|
||||
@JsonKey(name: 'variations') int? variationId,
|
||||
@JsonKey(name: 'created') DateTime created,
|
||||
@JsonKey(name: 'last_update') DateTime lastUpdate,
|
||||
@JsonKey(name: 'last_update_global') DateTime lastUpdateGlobal,
|
||||
ExerciseCategory category,
|
||||
List<Muscle> muscles,
|
||||
@JsonKey(name: 'muscles_secondary') List<Muscle> musclesSecondary,
|
||||
List<Equipment> equipment,
|
||||
@JsonKey(name: 'exercises') List<Translation> translations,
|
||||
List<ExerciseImage> images,
|
||||
List<Video> videos,
|
||||
@JsonKey(name: 'author_history') List<String> authors,
|
||||
@JsonKey(name: 'total_authors_history') List<String> authorsGlobal});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ExerciseApiDataCopyWithImpl<$Res, $Val extends ExerciseApiData>
|
||||
implements $ExerciseApiDataCopyWith<$Res> {
|
||||
_$ExerciseApiDataCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? uuid = null,
|
||||
Object? variationId = freezed,
|
||||
Object? created = null,
|
||||
Object? lastUpdate = null,
|
||||
Object? lastUpdateGlobal = null,
|
||||
Object? category = null,
|
||||
Object? muscles = null,
|
||||
Object? musclesSecondary = null,
|
||||
Object? equipment = null,
|
||||
Object? translations = null,
|
||||
Object? images = null,
|
||||
Object? videos = null,
|
||||
Object? authors = null,
|
||||
Object? authorsGlobal = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
uuid: null == uuid
|
||||
? _value.uuid
|
||||
: uuid // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
variationId: freezed == variationId
|
||||
? _value.variationId
|
||||
: variationId // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
created: null == created
|
||||
? _value.created
|
||||
: created // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
lastUpdate: null == lastUpdate
|
||||
? _value.lastUpdate
|
||||
: lastUpdate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
lastUpdateGlobal: null == lastUpdateGlobal
|
||||
? _value.lastUpdateGlobal
|
||||
: lastUpdateGlobal // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
category: null == category
|
||||
? _value.category
|
||||
: category // ignore: cast_nullable_to_non_nullable
|
||||
as ExerciseCategory,
|
||||
muscles: null == muscles
|
||||
? _value.muscles
|
||||
: muscles // ignore: cast_nullable_to_non_nullable
|
||||
as List<Muscle>,
|
||||
musclesSecondary: null == musclesSecondary
|
||||
? _value.musclesSecondary
|
||||
: musclesSecondary // ignore: cast_nullable_to_non_nullable
|
||||
as List<Muscle>,
|
||||
equipment: null == equipment
|
||||
? _value.equipment
|
||||
: equipment // ignore: cast_nullable_to_non_nullable
|
||||
as List<Equipment>,
|
||||
translations: null == translations
|
||||
? _value.translations
|
||||
: translations // ignore: cast_nullable_to_non_nullable
|
||||
as List<Translation>,
|
||||
images: null == images
|
||||
? _value.images
|
||||
: images // ignore: cast_nullable_to_non_nullable
|
||||
as List<ExerciseImage>,
|
||||
videos: null == videos
|
||||
? _value.videos
|
||||
: videos // ignore: cast_nullable_to_non_nullable
|
||||
as List<Video>,
|
||||
authors: null == authors
|
||||
? _value.authors
|
||||
: authors // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
authorsGlobal: null == authorsGlobal
|
||||
? _value.authorsGlobal
|
||||
: authorsGlobal // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ExerciseBaseDataImplCopyWith<$Res> implements $ExerciseApiDataCopyWith<$Res> {
|
||||
factory _$$ExerciseBaseDataImplCopyWith(
|
||||
_$ExerciseBaseDataImpl value, $Res Function(_$ExerciseBaseDataImpl) then) =
|
||||
__$$ExerciseBaseDataImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{int id,
|
||||
String uuid,
|
||||
@JsonKey(name: 'variations') int? variationId,
|
||||
@JsonKey(name: 'created') DateTime created,
|
||||
@JsonKey(name: 'last_update') DateTime lastUpdate,
|
||||
@JsonKey(name: 'last_update_global') DateTime lastUpdateGlobal,
|
||||
ExerciseCategory category,
|
||||
List<Muscle> muscles,
|
||||
@JsonKey(name: 'muscles_secondary') List<Muscle> musclesSecondary,
|
||||
List<Equipment> equipment,
|
||||
@JsonKey(name: 'exercises') List<Translation> translations,
|
||||
List<ExerciseImage> images,
|
||||
List<Video> videos,
|
||||
@JsonKey(name: 'author_history') List<String> authors,
|
||||
@JsonKey(name: 'total_authors_history') List<String> authorsGlobal});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ExerciseBaseDataImplCopyWithImpl<$Res>
|
||||
extends _$ExerciseApiDataCopyWithImpl<$Res, _$ExerciseBaseDataImpl>
|
||||
implements _$$ExerciseBaseDataImplCopyWith<$Res> {
|
||||
__$$ExerciseBaseDataImplCopyWithImpl(
|
||||
_$ExerciseBaseDataImpl _value, $Res Function(_$ExerciseBaseDataImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? uuid = null,
|
||||
Object? variationId = freezed,
|
||||
Object? created = null,
|
||||
Object? lastUpdate = null,
|
||||
Object? lastUpdateGlobal = null,
|
||||
Object? category = null,
|
||||
Object? muscles = null,
|
||||
Object? musclesSecondary = null,
|
||||
Object? equipment = null,
|
||||
Object? translations = null,
|
||||
Object? images = null,
|
||||
Object? videos = null,
|
||||
Object? authors = null,
|
||||
Object? authorsGlobal = null,
|
||||
}) {
|
||||
return _then(_$ExerciseBaseDataImpl(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
uuid: null == uuid
|
||||
? _value.uuid
|
||||
: uuid // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
variationId: freezed == variationId
|
||||
? _value.variationId
|
||||
: variationId // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
created: null == created
|
||||
? _value.created
|
||||
: created // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
lastUpdate: null == lastUpdate
|
||||
? _value.lastUpdate
|
||||
: lastUpdate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
lastUpdateGlobal: null == lastUpdateGlobal
|
||||
? _value.lastUpdateGlobal
|
||||
: lastUpdateGlobal // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
category: null == category
|
||||
? _value.category
|
||||
: category // ignore: cast_nullable_to_non_nullable
|
||||
as ExerciseCategory,
|
||||
muscles: null == muscles
|
||||
? _value._muscles
|
||||
: muscles // ignore: cast_nullable_to_non_nullable
|
||||
as List<Muscle>,
|
||||
musclesSecondary: null == musclesSecondary
|
||||
? _value._musclesSecondary
|
||||
: musclesSecondary // ignore: cast_nullable_to_non_nullable
|
||||
as List<Muscle>,
|
||||
equipment: null == equipment
|
||||
? _value._equipment
|
||||
: equipment // ignore: cast_nullable_to_non_nullable
|
||||
as List<Equipment>,
|
||||
translations: null == translations
|
||||
? _value._translations
|
||||
: translations // ignore: cast_nullable_to_non_nullable
|
||||
as List<Translation>,
|
||||
images: null == images
|
||||
? _value._images
|
||||
: images // ignore: cast_nullable_to_non_nullable
|
||||
as List<ExerciseImage>,
|
||||
videos: null == videos
|
||||
? _value._videos
|
||||
: videos // ignore: cast_nullable_to_non_nullable
|
||||
as List<Video>,
|
||||
authors: null == authors
|
||||
? _value._authors
|
||||
: authors // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
authorsGlobal: null == authorsGlobal
|
||||
? _value._authorsGlobal
|
||||
: authorsGlobal // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$ExerciseBaseDataImpl implements _ExerciseBaseData {
|
||||
_$ExerciseBaseDataImpl(
|
||||
{required this.id,
|
||||
required this.uuid,
|
||||
@JsonKey(name: 'variations') this.variationId = null,
|
||||
@JsonKey(name: 'created') required this.created,
|
||||
@JsonKey(name: 'last_update') required this.lastUpdate,
|
||||
@JsonKey(name: 'last_update_global') required this.lastUpdateGlobal,
|
||||
required this.category,
|
||||
required final List<Muscle> muscles,
|
||||
@JsonKey(name: 'muscles_secondary') required final List<Muscle> musclesSecondary,
|
||||
required final List<Equipment> equipment,
|
||||
@JsonKey(name: 'exercises') required final List<Translation> translations,
|
||||
required final List<ExerciseImage> images,
|
||||
required final List<Video> videos,
|
||||
@JsonKey(name: 'author_history') required final List<String> authors,
|
||||
@JsonKey(name: 'total_authors_history') required final List<String> authorsGlobal})
|
||||
: _muscles = muscles,
|
||||
_musclesSecondary = musclesSecondary,
|
||||
_equipment = equipment,
|
||||
_translations = translations,
|
||||
_images = images,
|
||||
_videos = videos,
|
||||
_authors = authors,
|
||||
_authorsGlobal = authorsGlobal;
|
||||
|
||||
factory _$ExerciseBaseDataImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$ExerciseBaseDataImplFromJson(json);
|
||||
|
||||
@override
|
||||
final int id;
|
||||
@override
|
||||
final String uuid;
|
||||
// ignore: invalid_annotation_target
|
||||
@override
|
||||
@JsonKey(name: 'variations')
|
||||
final int? variationId;
|
||||
// ignore: invalid_annotation_target
|
||||
@override
|
||||
@JsonKey(name: 'created')
|
||||
final DateTime created;
|
||||
// ignore: invalid_annotation_target
|
||||
@override
|
||||
@JsonKey(name: 'last_update')
|
||||
final DateTime lastUpdate;
|
||||
// ignore: invalid_annotation_target
|
||||
@override
|
||||
@JsonKey(name: 'last_update_global')
|
||||
final DateTime lastUpdateGlobal;
|
||||
@override
|
||||
final ExerciseCategory category;
|
||||
final List<Muscle> _muscles;
|
||||
@override
|
||||
List<Muscle> get muscles {
|
||||
if (_muscles is EqualUnmodifiableListView) return _muscles;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_muscles);
|
||||
}
|
||||
|
||||
// ignore: invalid_annotation_target
|
||||
final List<Muscle> _musclesSecondary;
|
||||
// ignore: invalid_annotation_target
|
||||
@override
|
||||
@JsonKey(name: 'muscles_secondary')
|
||||
List<Muscle> get musclesSecondary {
|
||||
if (_musclesSecondary is EqualUnmodifiableListView) return _musclesSecondary;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_musclesSecondary);
|
||||
}
|
||||
|
||||
// ignore: invalid_annotation_target
|
||||
final List<Equipment> _equipment;
|
||||
// ignore: invalid_annotation_target
|
||||
@override
|
||||
List<Equipment> get equipment {
|
||||
if (_equipment is EqualUnmodifiableListView) return _equipment;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_equipment);
|
||||
}
|
||||
|
||||
// ignore: invalid_annotation_target
|
||||
final List<Translation> _translations;
|
||||
// ignore: invalid_annotation_target
|
||||
@override
|
||||
@JsonKey(name: 'exercises')
|
||||
List<Translation> get translations {
|
||||
if (_translations is EqualUnmodifiableListView) return _translations;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_translations);
|
||||
}
|
||||
|
||||
final List<ExerciseImage> _images;
|
||||
@override
|
||||
List<ExerciseImage> get images {
|
||||
if (_images is EqualUnmodifiableListView) return _images;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_images);
|
||||
}
|
||||
|
||||
final List<Video> _videos;
|
||||
@override
|
||||
List<Video> get videos {
|
||||
if (_videos is EqualUnmodifiableListView) return _videos;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_videos);
|
||||
}
|
||||
|
||||
// ignore: invalid_annotation_target
|
||||
final List<String> _authors;
|
||||
// ignore: invalid_annotation_target
|
||||
@override
|
||||
@JsonKey(name: 'author_history')
|
||||
List<String> get authors {
|
||||
if (_authors is EqualUnmodifiableListView) return _authors;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_authors);
|
||||
}
|
||||
|
||||
// ignore: invalid_annotation_target
|
||||
final List<String> _authorsGlobal;
|
||||
// ignore: invalid_annotation_target
|
||||
@override
|
||||
@JsonKey(name: 'total_authors_history')
|
||||
List<String> get authorsGlobal {
|
||||
if (_authorsGlobal is EqualUnmodifiableListView) return _authorsGlobal;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_authorsGlobal);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ExerciseApiData(id: $id, uuid: $uuid, variationId: $variationId, created: $created, lastUpdate: $lastUpdate, lastUpdateGlobal: $lastUpdateGlobal, category: $category, muscles: $muscles, musclesSecondary: $musclesSecondary, equipment: $equipment, translations: $translations, images: $images, videos: $videos, authors: $authors, authorsGlobal: $authorsGlobal)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ExerciseBaseDataImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.uuid, uuid) || other.uuid == uuid) &&
|
||||
(identical(other.variationId, variationId) || other.variationId == variationId) &&
|
||||
(identical(other.created, created) || other.created == created) &&
|
||||
(identical(other.lastUpdate, lastUpdate) || other.lastUpdate == lastUpdate) &&
|
||||
(identical(other.lastUpdateGlobal, lastUpdateGlobal) ||
|
||||
other.lastUpdateGlobal == lastUpdateGlobal) &&
|
||||
(identical(other.category, category) || other.category == category) &&
|
||||
const DeepCollectionEquality().equals(other._muscles, _muscles) &&
|
||||
const DeepCollectionEquality().equals(other._musclesSecondary, _musclesSecondary) &&
|
||||
const DeepCollectionEquality().equals(other._equipment, _equipment) &&
|
||||
const DeepCollectionEquality().equals(other._translations, _translations) &&
|
||||
const DeepCollectionEquality().equals(other._images, _images) &&
|
||||
const DeepCollectionEquality().equals(other._videos, _videos) &&
|
||||
const DeepCollectionEquality().equals(other._authors, _authors) &&
|
||||
const DeepCollectionEquality().equals(other._authorsGlobal, _authorsGlobal));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
id,
|
||||
uuid,
|
||||
variationId,
|
||||
created,
|
||||
lastUpdate,
|
||||
lastUpdateGlobal,
|
||||
category,
|
||||
const DeepCollectionEquality().hash(_muscles),
|
||||
const DeepCollectionEquality().hash(_musclesSecondary),
|
||||
const DeepCollectionEquality().hash(_equipment),
|
||||
const DeepCollectionEquality().hash(_translations),
|
||||
const DeepCollectionEquality().hash(_images),
|
||||
const DeepCollectionEquality().hash(_videos),
|
||||
const DeepCollectionEquality().hash(_authors),
|
||||
const DeepCollectionEquality().hash(_authorsGlobal));
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ExerciseBaseDataImplCopyWith<_$ExerciseBaseDataImpl> get copyWith =>
|
||||
__$$ExerciseBaseDataImplCopyWithImpl<_$ExerciseBaseDataImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$ExerciseBaseDataImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _ExerciseBaseData implements ExerciseApiData {
|
||||
factory _ExerciseBaseData(
|
||||
{required final int id,
|
||||
required final String uuid,
|
||||
@JsonKey(name: 'variations') final int? variationId,
|
||||
@JsonKey(name: 'created') required final DateTime created,
|
||||
@JsonKey(name: 'last_update') required final DateTime lastUpdate,
|
||||
@JsonKey(name: 'last_update_global') required final DateTime lastUpdateGlobal,
|
||||
required final ExerciseCategory category,
|
||||
required final List<Muscle> muscles,
|
||||
@JsonKey(name: 'muscles_secondary') required final List<Muscle> musclesSecondary,
|
||||
required final List<Equipment> equipment,
|
||||
@JsonKey(name: 'exercises') required final List<Translation> translations,
|
||||
required final List<ExerciseImage> images,
|
||||
required final List<Video> videos,
|
||||
@JsonKey(name: 'author_history') required final List<String> authors,
|
||||
@JsonKey(name: 'total_authors_history') required final List<String> authorsGlobal}) =
|
||||
_$ExerciseBaseDataImpl;
|
||||
|
||||
factory _ExerciseBaseData.fromJson(Map<String, dynamic> json) = _$ExerciseBaseDataImpl.fromJson;
|
||||
|
||||
@override
|
||||
int get id;
|
||||
@override
|
||||
String get uuid;
|
||||
@override // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'variations')
|
||||
int? get variationId;
|
||||
@override // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'created')
|
||||
DateTime get created;
|
||||
@override // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'last_update')
|
||||
DateTime get lastUpdate;
|
||||
@override // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'last_update_global')
|
||||
DateTime get lastUpdateGlobal;
|
||||
@override
|
||||
ExerciseCategory get category;
|
||||
@override
|
||||
List<Muscle> get muscles;
|
||||
@override // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'muscles_secondary')
|
||||
List<Muscle> get musclesSecondary;
|
||||
@override // ignore: invalid_annotation_target
|
||||
List<Equipment> get equipment;
|
||||
@override // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'exercises')
|
||||
List<Translation> get translations;
|
||||
@override
|
||||
List<ExerciseImage> get images;
|
||||
@override
|
||||
List<Video> get videos;
|
||||
@override // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'author_history')
|
||||
List<String> get authors;
|
||||
@override // ignore: invalid_annotation_target
|
||||
@JsonKey(name: 'total_authors_history')
|
||||
List<String> get authorsGlobal;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$ExerciseBaseDataImplCopyWith<_$ExerciseBaseDataImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
58
lib/models/exercises/exercise_api.g.dart
Normal file
58
lib/models/exercises/exercise_api.g.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'exercise_api.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$ExerciseBaseDataImpl _$$ExerciseBaseDataImplFromJson(Map<String, dynamic> json) =>
|
||||
_$ExerciseBaseDataImpl(
|
||||
id: json['id'] as int,
|
||||
uuid: json['uuid'] as String,
|
||||
variationId: json['variations'] as int? ?? null,
|
||||
created: DateTime.parse(json['created'] as String),
|
||||
lastUpdate: DateTime.parse(json['last_update'] as String),
|
||||
lastUpdateGlobal: DateTime.parse(json['last_update_global'] as String),
|
||||
category: ExerciseCategory.fromJson(json['category'] as Map<String, dynamic>),
|
||||
muscles: (json['muscles'] as List<dynamic>)
|
||||
.map((e) => Muscle.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
musclesSecondary: (json['muscles_secondary'] as List<dynamic>)
|
||||
.map((e) => Muscle.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
equipment: (json['equipment'] as List<dynamic>)
|
||||
.map((e) => Equipment.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
translations: (json['exercises'] as List<dynamic>)
|
||||
.map((e) => Translation.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
images: (json['images'] as List<dynamic>)
|
||||
.map((e) => ExerciseImage.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
videos: (json['videos'] as List<dynamic>)
|
||||
.map((e) => Video.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
authors: (json['author_history'] as List<dynamic>).map((e) => e as String).toList(),
|
||||
authorsGlobal:
|
||||
(json['total_authors_history'] as List<dynamic>).map((e) => e as String).toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ExerciseBaseDataImplToJson(_$ExerciseBaseDataImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'uuid': instance.uuid,
|
||||
'variations': instance.variationId,
|
||||
'created': instance.created.toIso8601String(),
|
||||
'last_update': instance.lastUpdate.toIso8601String(),
|
||||
'last_update_global': instance.lastUpdateGlobal.toIso8601String(),
|
||||
'category': instance.category,
|
||||
'muscles': instance.muscles,
|
||||
'muscles_secondary': instance.musclesSecondary,
|
||||
'equipment': instance.equipment,
|
||||
'exercises': instance.translations,
|
||||
'images': instance.images,
|
||||
'videos': instance.videos,
|
||||
'author_history': instance.authors,
|
||||
'total_authors_history': instance.authorsGlobal,
|
||||
};
|
||||
@@ -34,7 +34,7 @@ class Muscle extends Equatable {
|
||||
@JsonKey(required: true, name: 'name_en')
|
||||
final String nameEn;
|
||||
|
||||
@JsonKey(name: 'is_front', required: true)
|
||||
@JsonKey(required: true, name: 'is_front')
|
||||
final bool isFront;
|
||||
|
||||
const Muscle({
|
||||
@@ -46,6 +46,7 @@ class Muscle extends Equatable {
|
||||
|
||||
// Boilerplate
|
||||
factory Muscle.fromJson(Map<String, dynamic> json) => _$MuscleFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$MuscleToJson(this);
|
||||
|
||||
@override
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:wger/models/exercises/alias.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/exercises/comment.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/models/exercises/language.dart';
|
||||
|
||||
part 'translation.g.dart';
|
||||
@@ -43,7 +43,7 @@ class Translation extends Equatable {
|
||||
final DateTime? created;
|
||||
|
||||
@JsonKey(required: true, name: 'exercise_base')
|
||||
late int? baseId;
|
||||
late int? exerciseId;
|
||||
|
||||
@JsonKey(required: true)
|
||||
final String name;
|
||||
@@ -51,11 +51,11 @@ class Translation extends Equatable {
|
||||
@JsonKey(required: true)
|
||||
final String description;
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@JsonKey(includeFromJson: true, includeToJson: false)
|
||||
List<Comment> notes = [];
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
List<Alias> alias = [];
|
||||
@JsonKey(includeFromJson: true, includeToJson: false)
|
||||
List<Alias> aliases = [];
|
||||
|
||||
Translation({
|
||||
this.id,
|
||||
@@ -63,11 +63,11 @@ class Translation extends Equatable {
|
||||
this.created,
|
||||
required this.name,
|
||||
required this.description,
|
||||
int? baseId,
|
||||
int? exerciseId,
|
||||
language,
|
||||
}) {
|
||||
if (baseId != null) {
|
||||
baseId = baseId;
|
||||
if (exerciseId != null) {
|
||||
this.exerciseId = exerciseId;
|
||||
}
|
||||
|
||||
if (language != null) {
|
||||
@@ -76,8 +76,8 @@ class Translation extends Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
set base(ExerciseBase base) {
|
||||
baseId = base.id;
|
||||
set exercise(Exercise exercise) {
|
||||
exerciseId = exercise.id;
|
||||
}
|
||||
|
||||
set language(Language language) {
|
||||
@@ -93,7 +93,7 @@ class Translation extends Equatable {
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
baseId,
|
||||
exerciseId,
|
||||
uuid,
|
||||
languageId,
|
||||
created,
|
||||
|
||||
@@ -25,8 +25,15 @@ Translation _$TranslationFromJson(Map<String, dynamic> json) {
|
||||
created: json['created'] == null ? null : DateTime.parse(json['created'] as String),
|
||||
name: json['name'] as String,
|
||||
description: json['description'] as String,
|
||||
baseId: json['exercise_base'] as int?,
|
||||
)..languageId = json['language'] as int;
|
||||
exerciseId: json['exercise_base'] as int?,
|
||||
)
|
||||
..languageId = json['language'] as int
|
||||
..notes = (json['notes'] as List<dynamic>)
|
||||
.map((e) => Comment.fromJson(e as Map<String, dynamic>))
|
||||
.toList()
|
||||
..aliases = (json['aliases'] as List<dynamic>)
|
||||
.map((e) => Alias.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$TranslationToJson(Translation instance) => <String, dynamic>{
|
||||
@@ -34,7 +41,7 @@ Map<String, dynamic> _$TranslationToJson(Translation instance) => <String, dynam
|
||||
'uuid': instance.uuid,
|
||||
'language': instance.languageId,
|
||||
'created': instance.created?.toIso8601String(),
|
||||
'exercise_base': instance.baseId,
|
||||
'exercise_base': instance.exerciseId,
|
||||
'name': instance.name,
|
||||
'description': instance.description,
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
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/exercises/exercise.dart';
|
||||
import 'package:wger/models/workouts/repetition_unit.dart';
|
||||
import 'package:wger/models/workouts/weight_unit.dart';
|
||||
|
||||
@@ -34,7 +34,7 @@ class Log {
|
||||
late int exerciseBaseId;
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
late ExerciseBase exerciseBaseObj;
|
||||
late Exercise exerciseBaseObj;
|
||||
|
||||
@JsonKey(required: true, name: 'workout')
|
||||
late int workoutPlan;
|
||||
@@ -85,7 +85,7 @@ class Log {
|
||||
|
||||
Map<String, dynamic> toJson() => _$LogToJson(this);
|
||||
|
||||
set exerciseBase(ExerciseBase base) {
|
||||
set exerciseBase(Exercise base) {
|
||||
exerciseBaseObj = base;
|
||||
exerciseBaseId = base.id!;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/models/workouts/setting.dart';
|
||||
|
||||
part 'set.g.dart';
|
||||
@@ -42,7 +42,7 @@ class Set {
|
||||
late String comment;
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
List<ExerciseBase> exerciseBasesObj = [];
|
||||
List<Exercise> exerciseBasesObj = [];
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
List<int> exerciseBasesIds = [];
|
||||
@@ -92,7 +92,7 @@ class Set {
|
||||
|
||||
for (final setting in settings) {
|
||||
final foundSettings = out.where(
|
||||
(element) => element.exerciseBaseId == setting.exerciseBaseId,
|
||||
(element) => element.exerciseId == setting.exerciseId,
|
||||
);
|
||||
|
||||
if (foundSettings.isEmpty) {
|
||||
@@ -102,23 +102,23 @@ class Set {
|
||||
return out;
|
||||
}
|
||||
|
||||
void addExerciseBase(ExerciseBase base) {
|
||||
void addExerciseBase(Exercise base) {
|
||||
exerciseBasesObj.add(base);
|
||||
exerciseBasesIds.add(base.id!);
|
||||
}
|
||||
|
||||
void removeExercise(ExerciseBase base) {
|
||||
void removeExercise(Exercise base) {
|
||||
exerciseBasesObj.removeWhere((e) => e.id == base.id);
|
||||
exerciseBasesIds.removeWhere((e) => e == base.id);
|
||||
}
|
||||
|
||||
/// Returns all settings for the given exercise
|
||||
List<Setting> filterSettingsByExercise(ExerciseBase exerciseBase) {
|
||||
return settings.where((element) => element.exerciseBaseId == exerciseBase.id).toList();
|
||||
List<Setting> filterSettingsByExercise(Exercise exerciseBase) {
|
||||
return settings.where((element) => element.exerciseId == exerciseBase.id).toList();
|
||||
}
|
||||
|
||||
/// Returns a list with all repetitions for the given exercise
|
||||
List<String> getSmartRepr(ExerciseBase exerciseBase) {
|
||||
List<String> getSmartRepr(Exercise exerciseBase) {
|
||||
final List<String> out = [];
|
||||
|
||||
final settingList = filterSettingsByExercise(exerciseBase);
|
||||
@@ -141,7 +141,7 @@ class Set {
|
||||
}
|
||||
|
||||
/// Returns a string with all repetitions for the given exercise
|
||||
String getSmartTextRepr(ExerciseBase execiseBase) {
|
||||
String getSmartTextRepr(Exercise execiseBase) {
|
||||
return getSmartRepr(execiseBase).join(' – ');
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
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/exercises/exercise.dart';
|
||||
import 'package:wger/models/workouts/repetition_unit.dart';
|
||||
import 'package:wger/models/workouts/weight_unit.dart';
|
||||
|
||||
@@ -42,10 +42,10 @@ class Setting {
|
||||
late int order;
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
late ExerciseBase exerciseBaseObj;
|
||||
late Exercise exerciseObj;
|
||||
|
||||
@JsonKey(required: true, name: 'exercise_base')
|
||||
late int exerciseBaseId;
|
||||
late int exerciseId;
|
||||
|
||||
@JsonKey(required: true, name: 'repetition_unit')
|
||||
late int repetitionUnitId;
|
||||
@@ -77,7 +77,7 @@ class Setting {
|
||||
this.id,
|
||||
required this.setId,
|
||||
required this.order,
|
||||
required this.exerciseBaseId,
|
||||
required this.exerciseId,
|
||||
required this.repetitionUnitId,
|
||||
required this.reps,
|
||||
required this.weightUnitId,
|
||||
@@ -92,9 +92,9 @@ class Setting {
|
||||
|
||||
Map<String, dynamic> toJson() => _$SettingToJson(this);
|
||||
|
||||
set exerciseBase(ExerciseBase exerciseBase) {
|
||||
exerciseBaseObj = exerciseBase;
|
||||
exerciseBaseId = exerciseBase.id!;
|
||||
set exercise(Exercise exercise) {
|
||||
exerciseObj = exercise;
|
||||
exerciseId = exercise.id!;
|
||||
}
|
||||
|
||||
set weightUnit(WeightUnit weightUnit) {
|
||||
|
||||
@@ -26,7 +26,7 @@ Setting _$SettingFromJson(Map<String, dynamic> json) {
|
||||
id: json['id'] as int?,
|
||||
setId: json['set'] as int,
|
||||
order: json['order'] as int,
|
||||
exerciseBaseId: json['exercise_base'] as int,
|
||||
exerciseId: json['exercise_base'] as int,
|
||||
repetitionUnitId: json['repetition_unit'] as int,
|
||||
reps: json['reps'] as int?,
|
||||
weightUnitId: json['weight_unit'] as int,
|
||||
@@ -39,7 +39,7 @@ Map<String, dynamic> _$SettingToJson(Setting instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'set': instance.setId,
|
||||
'order': instance.order,
|
||||
'exercise_base': instance.exerciseBaseId,
|
||||
'exercise_base': instance.exerciseId,
|
||||
'repetition_unit': instance.repetitionUnitId,
|
||||
'reps': instance.reps,
|
||||
'weight': numToString(instance.weight),
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
import 'package:wger/models/workouts/log.dart';
|
||||
|
||||
@@ -73,7 +73,7 @@ class WorkoutPlan {
|
||||
/// means here that the values are the same, i.e. logs with the same weight,
|
||||
/// reps, etc. are considered equal. Workout ID, Log ID and date are not
|
||||
/// considered.
|
||||
List<Log> filterLogsByExerciseBase(ExerciseBase exerciseBase, {bool unique = false}) {
|
||||
List<Log> filterLogsByExerciseBase(Exercise exerciseBase, {bool unique = false}) {
|
||||
var out = logs.where((element) => element.exerciseBaseId == exerciseBase.id).toList();
|
||||
|
||||
if (unique) {
|
||||
@@ -95,7 +95,7 @@ class WorkoutPlan {
|
||||
if (!out.containsKey(date)) {
|
||||
out[date] = {
|
||||
'session': null,
|
||||
'exercises': <ExerciseBase, List<Log>>{},
|
||||
'exercises': <Exercise, List<Log>>{},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/models/exercises/alias.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/exercises/category.dart';
|
||||
import 'package:wger/models/exercises/equipment.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/models/exercises/language.dart';
|
||||
import 'package:wger/models/exercises/muscle.dart';
|
||||
import 'package:wger/models/exercises/translation.dart';
|
||||
@@ -32,7 +32,7 @@ class AddExerciseProvider with ChangeNotifier {
|
||||
List<String> _alternativeNamesEn = [];
|
||||
List<String> _alternativeNamesTranslation = [];
|
||||
ExerciseCategory? category;
|
||||
List<ExerciseBase> _variations = [];
|
||||
List<Exercise> _variations = [];
|
||||
List<Equipment> _equipment = [];
|
||||
List<Muscle> _primaryMuscles = [];
|
||||
List<Muscle> _secondaryMuscles = [];
|
||||
@@ -93,8 +93,8 @@ class AddExerciseProvider with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
ExerciseBase get base {
|
||||
return ExerciseBase(
|
||||
Exercise get exercise {
|
||||
return Exercise(
|
||||
category: category,
|
||||
equipment: _equipment,
|
||||
muscles: _primaryMuscles,
|
||||
@@ -103,7 +103,7 @@ class AddExerciseProvider with ChangeNotifier {
|
||||
);
|
||||
}
|
||||
|
||||
Translation get exerciseEn {
|
||||
Translation get translationEn {
|
||||
return Translation(
|
||||
name: _nameEn!,
|
||||
description: _descriptionEn!,
|
||||
@@ -111,7 +111,7 @@ class AddExerciseProvider with ChangeNotifier {
|
||||
);
|
||||
}
|
||||
|
||||
Translation get exerciseTranslation {
|
||||
Translation get translation {
|
||||
return Translation(
|
||||
name: _nameTranslation!,
|
||||
description: _descriptionTranslation!,
|
||||
@@ -176,27 +176,27 @@ class AddExerciseProvider with ChangeNotifier {
|
||||
await addVariation();
|
||||
}
|
||||
|
||||
// Create the base
|
||||
final base = await addExerciseBase();
|
||||
// Create the exercise
|
||||
final exercise = await addExerciseBase();
|
||||
|
||||
// Create the base description in English
|
||||
Translation exerciseTranslationEn = exerciseEn;
|
||||
exerciseTranslationEn.base = base;
|
||||
Translation exerciseTranslationEn = translationEn;
|
||||
exerciseTranslationEn.exercise = exercise;
|
||||
exerciseTranslationEn = await addExerciseTranslation(exerciseTranslationEn);
|
||||
for (final alias in _alternativeNamesEn) {
|
||||
if (alias.isNotEmpty) {
|
||||
exerciseTranslationEn.alias.add(await addExerciseAlias(alias, exerciseTranslationEn.id!));
|
||||
exerciseTranslationEn.aliases.add(await addExerciseAlias(alias, exerciseTranslationEn.id!));
|
||||
}
|
||||
}
|
||||
|
||||
// Create the translations
|
||||
if (language != null) {
|
||||
Translation exerciseTranslationLang = exerciseTranslation;
|
||||
exerciseTranslationLang.base = base;
|
||||
Translation exerciseTranslationLang = translation;
|
||||
exerciseTranslationLang.exercise = exercise;
|
||||
exerciseTranslationLang = await addExerciseTranslation(exerciseTranslationLang);
|
||||
for (final alias in _alternativeNamesTranslation) {
|
||||
if (alias.isNotEmpty) {
|
||||
exerciseTranslationLang.alias.add(
|
||||
exerciseTranslationLang.aliases.add(
|
||||
await addExerciseAlias(alias, exerciseTranslationLang.id!),
|
||||
);
|
||||
}
|
||||
@@ -205,20 +205,20 @@ class AddExerciseProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
// Create the images
|
||||
await addImages(base);
|
||||
await addImages(exercise);
|
||||
|
||||
// Clear everything
|
||||
clear();
|
||||
|
||||
// Return exercise ID
|
||||
return base.id!;
|
||||
return exercise.id!;
|
||||
}
|
||||
|
||||
Future<ExerciseBase> addExerciseBase() async {
|
||||
Future<Exercise> addExerciseBase() async {
|
||||
final Uri postUri = baseProvider.makeUrl(_exerciseBaseUrlPath);
|
||||
|
||||
final Map<String, dynamic> newBaseMap = await baseProvider.post(base.toJson(), postUri);
|
||||
final ExerciseBase newExerciseBase = ExerciseBase.fromJson(newBaseMap);
|
||||
final Map<String, dynamic> newBaseMap = await baseProvider.post(exercise.toJson(), postUri);
|
||||
final Exercise newExerciseBase = Exercise.fromJson(newBaseMap);
|
||||
notifyListeners();
|
||||
|
||||
return newExerciseBase;
|
||||
@@ -235,7 +235,7 @@ class AddExerciseProvider with ChangeNotifier {
|
||||
return newVariation;
|
||||
}
|
||||
|
||||
Future<void> addImages(ExerciseBase base) async {
|
||||
Future<void> addImages(Exercise base) async {
|
||||
for (final image in _exerciseImages) {
|
||||
final request = http.MultipartRequest('POST', baseProvider.makeUrl(_imagesUrlPath));
|
||||
request.headers.addAll(baseProvider.getDefaultHeaders(includeAuth: true));
|
||||
|
||||
@@ -20,52 +20,47 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:wger/core/locator.dart';
|
||||
import 'package:wger/database/exercises/exercise_database.dart';
|
||||
import 'package:wger/exceptions/no_such_entry_exception.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/models/exercises/alias.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/exercises/category.dart';
|
||||
import 'package:wger/models/exercises/comment.dart';
|
||||
import 'package:wger/models/exercises/equipment.dart';
|
||||
import 'package:wger/models/exercises/image.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/models/exercises/exercise_api.dart';
|
||||
import 'package:wger/models/exercises/language.dart';
|
||||
import 'package:wger/models/exercises/muscle.dart';
|
||||
import 'package:wger/models/exercises/translation.dart';
|
||||
import 'package:wger/models/exercises/variation.dart';
|
||||
import 'package:wger/models/exercises/video.dart';
|
||||
import 'package:wger/providers/base_provider.dart';
|
||||
|
||||
class ExercisesProvider with ChangeNotifier {
|
||||
final WgerBaseProvider baseProvider;
|
||||
late ExerciseDatabase database;
|
||||
|
||||
ExercisesProvider(this.baseProvider);
|
||||
ExercisesProvider(this.baseProvider, {ExerciseDatabase? database}) {
|
||||
this.database = database ?? locator<ExerciseDatabase>();
|
||||
}
|
||||
|
||||
static const EXERCISE_CACHE_DAYS = 7;
|
||||
static const EXERCISE_FETCH_HOURS = 4;
|
||||
static const CACHE_VERSION = 4;
|
||||
|
||||
static const _exerciseBaseInfoUrlPath = 'exercisebaseinfo';
|
||||
static const _exerciseSearchPath = 'exercise/search';
|
||||
static const exerciseInfoUrlPath = 'exercisebaseinfo';
|
||||
static const exerciseSearchPath = 'exercise/search';
|
||||
|
||||
static const _exerciseVariationsUrlPath = 'variation';
|
||||
static const _categoriesUrlPath = 'exercisecategory';
|
||||
static const _musclesUrlPath = 'muscle';
|
||||
static const _equipmentUrlPath = 'equipment';
|
||||
static const _languageUrlPath = 'language';
|
||||
static const categoriesUrlPath = 'exercisecategory';
|
||||
static const musclesUrlPath = 'muscle';
|
||||
static const equipmentUrlPath = 'equipment';
|
||||
static const languageUrlPath = 'language';
|
||||
|
||||
List<ExerciseBase> _exerciseBases = [];
|
||||
|
||||
set exerciseBases(List<ExerciseBase> exercisesBases) {
|
||||
_exerciseBases = exercisesBases;
|
||||
}
|
||||
List<Exercise> exercises = [];
|
||||
|
||||
List<ExerciseCategory> _categories = [];
|
||||
List<Muscle> _muscles = [];
|
||||
List<Equipment> _equipment = [];
|
||||
List<Language> _languages = [];
|
||||
final List<Variation> _variations = [];
|
||||
|
||||
Filters? _filters;
|
||||
|
||||
@@ -76,31 +71,29 @@ class ExercisesProvider with ChangeNotifier {
|
||||
await findByFilters();
|
||||
}
|
||||
|
||||
List<ExerciseBase> _filteredExerciseBases = [];
|
||||
List<Exercise> _filteredExercises = [];
|
||||
|
||||
List<ExerciseBase> get filteredExerciseBases => _filteredExerciseBases;
|
||||
List<Exercise> get filteredExercises => _filteredExercises;
|
||||
|
||||
set filteredExerciseBases(List<ExerciseBase> newFilteredExercises) {
|
||||
_filteredExerciseBases = newFilteredExercises;
|
||||
set filteredExercises(List<Exercise> newFilteredExercises) {
|
||||
_filteredExercises = newFilteredExercises;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Map<int, List<ExerciseBase>> get exerciseBasesByVariation {
|
||||
final Map<int, List<ExerciseBase>> variations = {};
|
||||
Map<int, List<Exercise>> get exerciseBasesByVariation {
|
||||
final Map<int, List<Exercise>> variations = {};
|
||||
|
||||
for (final base in _exerciseBases.where((e) => e.variationId != null)) {
|
||||
if (!variations.containsKey(base.variationId)) {
|
||||
variations[base.variationId!] = [];
|
||||
for (final exercise in exercises.where((e) => e.variationId != null)) {
|
||||
if (!variations.containsKey(exercise.variationId)) {
|
||||
variations[exercise.variationId!] = [];
|
||||
}
|
||||
|
||||
variations[base.variationId]!.add(base);
|
||||
variations[exercise.variationId]!.add(exercise);
|
||||
}
|
||||
|
||||
return variations;
|
||||
}
|
||||
|
||||
List<ExerciseBase> get bases => [..._exerciseBases];
|
||||
|
||||
List<ExerciseCategory> get categories => [..._categories];
|
||||
|
||||
List<Muscle> get muscles => [..._muscles];
|
||||
@@ -114,7 +107,7 @@ class ExercisesProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
// Initialize filters for exercises search in exercises list
|
||||
void _initFilters() {
|
||||
void initFilters() {
|
||||
if (_muscles.isEmpty || _equipment.isEmpty || _filters != null) {
|
||||
return;
|
||||
}
|
||||
@@ -144,25 +137,25 @@ class ExercisesProvider with ChangeNotifier {
|
||||
Future<void> findByFilters() async {
|
||||
// Filters not initialized
|
||||
if (filters == null) {
|
||||
filteredExerciseBases = [];
|
||||
filteredExercises = [];
|
||||
return;
|
||||
}
|
||||
|
||||
// Filters are initialized and nothing is marked
|
||||
if (filters!.isNothingMarked && filters!.searchTerm.length <= 1) {
|
||||
filteredExerciseBases = _exerciseBases;
|
||||
filteredExercises = exercises;
|
||||
return;
|
||||
}
|
||||
|
||||
filteredExerciseBases = [];
|
||||
filteredExercises = [];
|
||||
|
||||
List<ExerciseBase> filteredItems = _exerciseBases;
|
||||
List<Exercise> filteredItems = exercises;
|
||||
if (filters!.searchTerm.length > 1) {
|
||||
filteredItems = await searchExercise(filters!.searchTerm);
|
||||
}
|
||||
|
||||
// Filter by exercise category and equipment (REPLACE WITH HTTP REQUEST)
|
||||
filteredExerciseBases = filteredItems.where((exercise) {
|
||||
filteredExercises = filteredItems.where((exercise) {
|
||||
final bool isInAnyCategory = filters!.exerciseCategories.selected.contains(exercise.category);
|
||||
|
||||
final bool doesContainAnyEquipment = filters!.equipment.selected.any(
|
||||
@@ -180,25 +173,27 @@ class ExercisesProvider with ChangeNotifier {
|
||||
_muscles = [];
|
||||
_categories = [];
|
||||
_languages = [];
|
||||
_exerciseBases = [];
|
||||
exercises = [];
|
||||
}
|
||||
|
||||
/// Find exercise base by ID
|
||||
ExerciseBase findExerciseBaseById(int id) {
|
||||
return _exerciseBases.firstWhere(
|
||||
///
|
||||
/// Note: prefer using the async `fetchAndSetExercise` method
|
||||
Exercise findExerciseById(int id) {
|
||||
return exercises.firstWhere(
|
||||
(base) => base.id == id,
|
||||
orElse: () => throw NoSuchEntryException(),
|
||||
);
|
||||
}
|
||||
|
||||
/// Find exercise bases by variation IDs
|
||||
/// Find exercises by variation IDs
|
||||
///
|
||||
/// exerciseIdToExclude: the ID of the exercise to exclude from the list of
|
||||
/// returned exercises. Since this is typically called by one exercise, we are
|
||||
/// not interested in seeing that same exercise returned in the list of variations.
|
||||
/// If this parameter is not passed, all exercises are returned.
|
||||
List<ExerciseBase> findExerciseBasesByVariationId(int id, {int? exerciseBaseIdToExclude}) {
|
||||
var out = _exerciseBases.where((base) => base.variationId == id).toList();
|
||||
List<Exercise> findExercisesByVariationId(int id, {int? exerciseBaseIdToExclude}) {
|
||||
var out = exercises.where((base) => base.variationId == id).toList();
|
||||
|
||||
if (exerciseBaseIdToExclude != null) {
|
||||
out = out.where((e) => e.id != exerciseBaseIdToExclude).toList();
|
||||
@@ -238,39 +233,31 @@ class ExercisesProvider with ChangeNotifier {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> fetchAndSetCategories() async {
|
||||
final categories = await baseProvider.fetchPaginated(baseProvider.makeUrl(_categoriesUrlPath));
|
||||
Future<void> fetchAndSetCategoriesFromApi() async {
|
||||
final categories = await baseProvider.fetchPaginated(baseProvider.makeUrl(categoriesUrlPath));
|
||||
for (final category in categories) {
|
||||
_categories.add(ExerciseCategory.fromJson(category));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> fetchAndSetVariations() async {
|
||||
final variations =
|
||||
await baseProvider.fetchPaginated(baseProvider.makeUrl(_exerciseVariationsUrlPath));
|
||||
for (final variation in variations) {
|
||||
_variations.add(Variation.fromJson(variation));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> fetchAndSetMuscles() async {
|
||||
final muscles = await baseProvider.fetchPaginated(baseProvider.makeUrl(_musclesUrlPath));
|
||||
Future<void> fetchAndSetMusclesFromApi() async {
|
||||
final muscles = await baseProvider.fetchPaginated(baseProvider.makeUrl(musclesUrlPath));
|
||||
|
||||
for (final muscle in muscles) {
|
||||
_muscles.add(Muscle.fromJson(muscle));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> fetchAndSetEquipment() async {
|
||||
final equipments = await baseProvider.fetchPaginated(baseProvider.makeUrl(_equipmentUrlPath));
|
||||
Future<void> fetchAndSetEquipmentsFromApi() async {
|
||||
final equipments = await baseProvider.fetchPaginated(baseProvider.makeUrl(equipmentUrlPath));
|
||||
|
||||
for (final equipment in equipments) {
|
||||
_equipment.add(Equipment.fromJson(equipment));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> fetchAndSetLanguages() async {
|
||||
final languageData = await baseProvider.fetchPaginated(baseProvider.makeUrl(_languageUrlPath));
|
||||
Future<void> fetchAndSetLanguagesFromApi() async {
|
||||
final languageData = await baseProvider.fetchPaginated(baseProvider.makeUrl(languageUrlPath));
|
||||
|
||||
for (final language in languageData) {
|
||||
_languages.add(Language.fromJson(language));
|
||||
@@ -280,153 +267,370 @@ class ExercisesProvider with ChangeNotifier {
|
||||
/// Returns the exercise with the given ID
|
||||
///
|
||||
/// If the exercise is not known locally, it is fetched from the server.
|
||||
/// This method is called when a workout is first loaded, after that the
|
||||
/// regular not-async getById method can be used
|
||||
Future<ExerciseBase> fetchAndSetExerciseBase(int exerciseBaseId) async {
|
||||
Future<Exercise> fetchAndSetExercise(int exerciseId) async {
|
||||
try {
|
||||
return findExerciseBaseById(exerciseBaseId);
|
||||
final exercise = findExerciseById(exerciseId);
|
||||
|
||||
// Note: no await since we don't care for the updated data right now. It
|
||||
// will be written to the db whenever the request finishes and we will get
|
||||
// the updated exercise the next time
|
||||
handleUpdateExerciseFromApi(database, exerciseId);
|
||||
|
||||
return exercise;
|
||||
} on NoSuchEntryException {
|
||||
final baseData = await baseProvider.fetch(
|
||||
baseProvider.makeUrl(_exerciseBaseInfoUrlPath, id: exerciseBaseId),
|
||||
);
|
||||
|
||||
final newBase = readExerciseBaseFromBaseInfo(baseData);
|
||||
|
||||
// TODO: save to cache. Since we can't easily generate the JSON, perhaps just reload?
|
||||
_exerciseBases.add(newBase);
|
||||
return newBase;
|
||||
return handleUpdateExerciseFromApi(database, exerciseId);
|
||||
}
|
||||
}
|
||||
|
||||
/// Parses the response from the exercisebaseinfo endpoint and returns
|
||||
/// a full exercise base
|
||||
ExerciseBase readExerciseBaseFromBaseInfo(dynamic baseData) {
|
||||
final category = ExerciseCategory.fromJson(baseData['category']);
|
||||
final musclesPrimary = baseData['muscles'].map((e) => Muscle.fromJson(e)).toList();
|
||||
final musclesSecondary = baseData['muscles_secondary'].map((e) => Muscle.fromJson(e)).toList();
|
||||
final equipment = baseData['equipment'].map((e) => Equipment.fromJson(e)).toList();
|
||||
final images = baseData['images'].map((e) => ExerciseImage.fromJson(e)).toList();
|
||||
final videos = baseData['videos'].map((e) => Video.fromJson(e)).toList();
|
||||
/// Handles updates to exercises from the server to the local database
|
||||
///
|
||||
/// The current logic is:
|
||||
/// Is the exercise known locally:
|
||||
/// -> no: fetch and add to the DB
|
||||
/// -> yes: Do we need to re-fetch?
|
||||
/// -> no: just return what we have in the DB
|
||||
/// -> yes: fetch data and update if necessary
|
||||
Future<Exercise> handleUpdateExerciseFromApi(ExerciseDatabase database, int exerciseId) async {
|
||||
Exercise exercise;
|
||||
final exerciseDb = await (database.select(database.exercises)
|
||||
..where((e) => e.id.equals(exerciseId)))
|
||||
.getSingleOrNull();
|
||||
|
||||
final List<Translation> exercises = [];
|
||||
for (final exerciseData in baseData['exercises']) {
|
||||
final exercise = Translation.fromJson(exerciseData);
|
||||
exercise.alias = exerciseData['aliases']
|
||||
.map((e) => Alias(exerciseId: exercise.id!, alias: e['alias']))
|
||||
.toList()
|
||||
.cast<Alias>();
|
||||
exercise.notes =
|
||||
exerciseData['notes'].map((e) => Comment.fromJson(e)).toList().cast<Comment>();
|
||||
exercise.baseId = baseData['id'];
|
||||
exercise.language = findLanguageById(exerciseData['language']);
|
||||
// Exercise is already known locally
|
||||
if (exerciseDb != null) {
|
||||
final nextFetch = exerciseDb.lastFetched.add(const Duration(hours: EXERCISE_FETCH_HOURS));
|
||||
exercise = Exercise.fromApiDataString(exerciseDb.data, _languages);
|
||||
|
||||
// Fetch and update
|
||||
if (nextFetch.isBefore(DateTime.now())) {
|
||||
final apiData = await baseProvider.fetch(
|
||||
baseProvider.makeUrl(exerciseInfoUrlPath, id: exerciseId),
|
||||
);
|
||||
final exerciseApiData = ExerciseApiData.fromJson(apiData);
|
||||
|
||||
// There have been changes on the server, update
|
||||
if (exerciseApiData.lastUpdateGlobal.isAfter(exerciseDb.lastUpdate)) {
|
||||
exercise = Exercise.fromApiData(exerciseApiData, _languages);
|
||||
|
||||
await (database.update(database.exercises)..where((e) => e.id.equals(exerciseId))).write(
|
||||
ExercisesCompanion(
|
||||
data: Value(jsonEncode(apiData)),
|
||||
lastUpdate: Value(exercise.lastUpdateGlobal!),
|
||||
lastFetched: Value(DateTime.now()),
|
||||
),
|
||||
);
|
||||
// Update last fetched date, otherwise we'll keep hitting the API
|
||||
} else {
|
||||
await (database.update(database.exercises)..where((e) => e.id.equals(exerciseId))).write(
|
||||
ExercisesCompanion(lastFetched: Value(DateTime.now())),
|
||||
);
|
||||
}
|
||||
}
|
||||
// New exercise, fetch and insert to DB
|
||||
} else {
|
||||
final baseData = await baseProvider.fetch(
|
||||
baseProvider.makeUrl(exerciseInfoUrlPath, id: exerciseId),
|
||||
);
|
||||
exercise = Exercise.fromApiDataJson(baseData, _languages);
|
||||
|
||||
if (exerciseDb == null) {
|
||||
await database.into(database.exercises).insert(
|
||||
ExercisesCompanion.insert(
|
||||
id: exercise.id!,
|
||||
data: jsonEncode(baseData),
|
||||
lastUpdate: exercise.lastUpdateGlobal!,
|
||||
lastFetched: DateTime.now()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Either update or add the exercise to local list
|
||||
final index = exercises.indexWhere((element) => element.id == exerciseId);
|
||||
if (index != -1) {
|
||||
exercises[index] = exercise;
|
||||
} else {
|
||||
exercises.add(exercise);
|
||||
}
|
||||
|
||||
final exerciseBase = ExerciseBase(
|
||||
id: baseData['id'],
|
||||
uuid: baseData['uuid'],
|
||||
created: null,
|
||||
//creationDate: toDate(baseData['creation_date']),
|
||||
musclesSecondary: musclesSecondary.cast<Muscle>(),
|
||||
muscles: musclesPrimary.cast<Muscle>(),
|
||||
equipment: equipment.cast<Equipment>(),
|
||||
category: category,
|
||||
images: images.cast<ExerciseImage>(),
|
||||
exercises: exercises,
|
||||
videos: videos.cast<Video>(),
|
||||
);
|
||||
|
||||
return exerciseBase;
|
||||
return exercise;
|
||||
}
|
||||
|
||||
/// Checks the required cache version
|
||||
///
|
||||
/// This is needed since the content of the exercise cache can change and we need
|
||||
/// to invalidate it as a result
|
||||
/// This is needed since the content of the exercise cache (the API response)
|
||||
/// can change and we need to invalidate it as a result
|
||||
Future<void> checkExerciseCacheVersion() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
if (prefs.containsKey(PREFS_EXERCISE_CACHE_VERSION)) {
|
||||
final cacheVersion = prefs.getInt(PREFS_EXERCISE_CACHE_VERSION);
|
||||
final cacheVersion = prefs.getInt(PREFS_EXERCISE_CACHE_VERSION)!;
|
||||
|
||||
// Cache has has a different version, reset
|
||||
if (cacheVersion! != CACHE_VERSION) {
|
||||
await prefs.remove(PREFS_EXERCISES);
|
||||
if (cacheVersion != CACHE_VERSION) {
|
||||
database.delete(database.exercises).go();
|
||||
}
|
||||
await prefs.setInt(PREFS_EXERCISE_CACHE_VERSION, CACHE_VERSION);
|
||||
|
||||
// Cache has no version key, reset
|
||||
// Note: this is only needed for very old apps that update and could probably
|
||||
// be just removed in the future
|
||||
} else {
|
||||
await prefs.remove(PREFS_EXERCISES);
|
||||
database.delete(database.exercises).go();
|
||||
await prefs.setInt(PREFS_EXERCISE_CACHE_VERSION, CACHE_VERSION);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> fetchAndSetExercises() async {
|
||||
Future<void> initCacheTimesLocalPrefs({forceInit = false}) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
// TODO: The exercise data was previously saved in PREFS_EXERCISES. This
|
||||
// can now be deleted. After some time when we can be sure all users
|
||||
// have updated their app, we can also remove this line and the
|
||||
// PREFS_EXERCISES constant
|
||||
if (prefs.containsKey(PREFS_EXERCISES)) {
|
||||
prefs.remove(PREFS_EXERCISES);
|
||||
}
|
||||
|
||||
final initDate = DateTime(2023, 1, 1).toIso8601String();
|
||||
|
||||
if (forceInit || !prefs.containsKey(PREFS_LAST_UPDATED_MUSCLES)) {
|
||||
await prefs.setString(PREFS_LAST_UPDATED_MUSCLES, initDate);
|
||||
}
|
||||
if (forceInit || !prefs.containsKey(PREFS_LAST_UPDATED_EQUIPMENT)) {
|
||||
await prefs.setString(PREFS_LAST_UPDATED_EQUIPMENT, initDate);
|
||||
}
|
||||
if (forceInit || !prefs.containsKey(PREFS_LAST_UPDATED_LANGUAGES)) {
|
||||
await prefs.setString(PREFS_LAST_UPDATED_LANGUAGES, initDate);
|
||||
}
|
||||
if (forceInit || !prefs.containsKey(PREFS_LAST_UPDATED_CATEGORIES)) {
|
||||
await prefs.setString(PREFS_LAST_UPDATED_CATEGORIES, initDate);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> clearAllCachesAndPrefs() async {
|
||||
await database.deleteEverything();
|
||||
await initCacheTimesLocalPrefs(forceInit: true);
|
||||
}
|
||||
|
||||
/// Loads all needed data for the exercises from the local cache, or if not available,
|
||||
/// from the API:
|
||||
/// - Muscles
|
||||
/// - Categories
|
||||
/// - Languages
|
||||
/// - Equipment
|
||||
/// - Exercises (only local cache)
|
||||
Future<void> fetchAndSetInitialData() async {
|
||||
clear();
|
||||
|
||||
// Load exercises from cache, if available
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await initCacheTimesLocalPrefs();
|
||||
await checkExerciseCacheVersion();
|
||||
|
||||
if (prefs.containsKey(PREFS_EXERCISES)) {
|
||||
final cacheData = json.decode(prefs.getString(PREFS_EXERCISES)!);
|
||||
if (DateTime.parse(cacheData['expiresIn']).isAfter(DateTime.now())) {
|
||||
cacheData['equipment'].forEach((e) => _equipment.add(Equipment.fromJson(e)));
|
||||
cacheData['muscles'].forEach((e) => _muscles.add(Muscle.fromJson(e)));
|
||||
cacheData['categories'].forEach((e) => _categories.add(ExerciseCategory.fromJson(e)));
|
||||
cacheData['languages'].forEach((e) => _languages.add(Language.fromJson(e)));
|
||||
cacheData['variations'].forEach((e) => _variations.add(Variation.fromJson(e)));
|
||||
cacheData['bases'].forEach((e) => _exerciseBases.add(readExerciseBaseFromBaseInfo(e)));
|
||||
// Load categories, muscles, equipment and languages
|
||||
await Future.wait([
|
||||
fetchAndSetMuscles(database),
|
||||
fetchAndSetCategories(database),
|
||||
fetchAndSetLanguages(database),
|
||||
fetchAndSetEquipments(database),
|
||||
]);
|
||||
await setExercisesFromDatabase(database);
|
||||
|
||||
_initFilters();
|
||||
log("Read ${_exerciseBases.length} exercises from cache. Valid till ${cacheData['expiresIn']}");
|
||||
initFilters();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Set the available exercises as available in the db
|
||||
Future<void> setExercisesFromDatabase(ExerciseDatabase database,
|
||||
{bool forceDeleteCache = false}) async {
|
||||
if (forceDeleteCache) {
|
||||
await database.delete(database.exercises).go();
|
||||
}
|
||||
|
||||
final exercisesDb = await database.select(database.exercises).get();
|
||||
log('Loaded ${exercisesDb.length} exercises from cache');
|
||||
|
||||
exercises = exercisesDb.map((e) => Exercise.fromApiDataString(e.data, _languages)).toList();
|
||||
}
|
||||
|
||||
/// Updates the exercise database with *all* the exercises from the server
|
||||
Future<void> updateExerciseCache(ExerciseDatabase database) async {
|
||||
final data = await baseProvider.fetch(
|
||||
baseProvider.makeUrl(exerciseInfoUrlPath, query: {'limit': '1000'}),
|
||||
);
|
||||
|
||||
final List<dynamic> exercisesData = data['results'];
|
||||
exercises = exercisesData.map((e) => Exercise.fromApiDataJson(e, _languages)).toList();
|
||||
|
||||
// Insert new entries and update ones that have been edited
|
||||
Future.forEach(exercisesData, (exerciseData) async {
|
||||
final exercise = await (database.select(database.exercises)
|
||||
..where((e) => e.id.equals(exerciseData['id'])))
|
||||
.getSingleOrNull();
|
||||
|
||||
// New exercise, insert
|
||||
if (exercise == null) {
|
||||
database.into(database.exercises).insert(
|
||||
ExercisesCompanion.insert(
|
||||
id: exerciseData['id'],
|
||||
data: jsonEncode(exerciseData),
|
||||
lastUpdate: DateTime.parse(exerciseData['last_update_global']),
|
||||
lastFetched: DateTime.now()),
|
||||
);
|
||||
}
|
||||
|
||||
// If there were updates on the server, update
|
||||
final lastUpdateApi = DateTime.parse(exerciseData['last_update_global']);
|
||||
if (exercise != null && lastUpdateApi.isAfter(exercise.lastUpdate)) {
|
||||
// TODO: timezones 🥳
|
||||
print(
|
||||
'Exercise ${exercise.id}: update API $lastUpdateApi | Update DB: ${exercise.lastUpdate}');
|
||||
(database.update(database.exercises)..where((e) => e.id.equals(exerciseData['id']))).write(
|
||||
ExercisesCompanion(
|
||||
id: Value(exerciseData['id']),
|
||||
data: Value(jsonEncode(exerciseData)),
|
||||
lastUpdate: Value(DateTime.parse(exerciseData['last_update_global'])),
|
||||
lastFetched: Value(DateTime.now()),
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Fetches and sets the available muscles
|
||||
///
|
||||
/// We first try to read from the local DB, and from the API if the data is too old
|
||||
Future<void> fetchAndSetMuscles(ExerciseDatabase database) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
var validTill = DateTime.parse(prefs.getString(PREFS_LAST_UPDATED_MUSCLES)!);
|
||||
|
||||
// Cache still valid, return it
|
||||
if (validTill.isAfter(DateTime.now())) {
|
||||
final muscles = await database.select(database.muscles).get();
|
||||
|
||||
if (muscles.isNotEmpty) {
|
||||
_muscles = muscles.map((e) => e.data).toList();
|
||||
log('Loaded ${_muscles.length} muscles from cache');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Load categories, muscles, equipment and languages
|
||||
final data = await Future.wait<dynamic>([
|
||||
baseProvider.fetch(baseProvider.makeUrl(_exerciseBaseInfoUrlPath, query: {'limit': '1000'})),
|
||||
fetchAndSetCategories(),
|
||||
fetchAndSetMuscles(),
|
||||
fetchAndSetEquipment(),
|
||||
fetchAndSetLanguages(),
|
||||
fetchAndSetVariations(),
|
||||
]);
|
||||
final exerciseBaseData = data[0]['results'];
|
||||
// Fetch from API and save to DB
|
||||
await fetchAndSetMusclesFromApi();
|
||||
await database.delete(database.muscles).go();
|
||||
await Future.forEach(_muscles, (e) async {
|
||||
await database.into(database.muscles).insert(
|
||||
MusclesCompanion.insert(
|
||||
id: e.id,
|
||||
data: e,
|
||||
),
|
||||
);
|
||||
});
|
||||
validTill = DateTime.now().add(const Duration(days: EXERCISE_CACHE_DAYS));
|
||||
await prefs.setString(PREFS_LAST_UPDATED_MUSCLES, validTill.toIso8601String());
|
||||
log('Wrote ${_muscles.length} muscles from cache. Valid till $validTill');
|
||||
}
|
||||
|
||||
_exerciseBases =
|
||||
exerciseBaseData.map((e) => readExerciseBaseFromBaseInfo(e)).toList().cast<ExerciseBase>();
|
||||
/// Fetches and sets the available categories
|
||||
///
|
||||
/// We first try to read from the local DB, and from the API if the data is too old
|
||||
Future<void> fetchAndSetCategories(ExerciseDatabase database) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
var validTill = DateTime.parse(prefs.getString(PREFS_LAST_UPDATED_CATEGORIES)!);
|
||||
|
||||
try {
|
||||
// Save the result to the cache
|
||||
final cacheData = {
|
||||
'date': DateTime.now().toIso8601String(),
|
||||
'expiresIn':
|
||||
DateTime.now().add(const Duration(days: EXERCISE_CACHE_DAYS)).toIso8601String(),
|
||||
'equipment': _equipment.map((e) => e.toJson()).toList(),
|
||||
'categories': _categories.map((e) => e.toJson()).toList(),
|
||||
'muscles': _muscles.map((e) => e.toJson()).toList(),
|
||||
'languages': _languages.map((e) => e.toJson()).toList(),
|
||||
'variations': _variations.map((e) => e.toJson()).toList(),
|
||||
'bases': exerciseBaseData,
|
||||
};
|
||||
log("Saved ${_exerciseBases.length} exercises to cache. Valid till ${cacheData['expiresIn']}");
|
||||
// Cache still valid, return it
|
||||
if (validTill.isAfter(DateTime.now())) {
|
||||
final categories = await database.select(database.categories).get();
|
||||
|
||||
await prefs.setString(PREFS_EXERCISES, json.encode(cacheData));
|
||||
_initFilters();
|
||||
notifyListeners();
|
||||
} on MissingRequiredKeysException catch (error) {
|
||||
log(error.missingKeys.toString());
|
||||
rethrow;
|
||||
if (categories.isNotEmpty) {
|
||||
_categories = categories.map((e) => e.data).toList();
|
||||
log('Loaded ${categories.length} categories from cache');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch from API and save to DB
|
||||
await fetchAndSetCategoriesFromApi();
|
||||
await database.delete(database.categories).go();
|
||||
await Future.forEach(_categories, (e) async {
|
||||
await database.into(database.categories).insert(
|
||||
CategoriesCompanion.insert(
|
||||
id: e.id,
|
||||
data: e,
|
||||
),
|
||||
);
|
||||
});
|
||||
validTill = DateTime.now().add(const Duration(days: EXERCISE_CACHE_DAYS));
|
||||
await prefs.setString(PREFS_LAST_UPDATED_CATEGORIES, validTill.toIso8601String());
|
||||
}
|
||||
|
||||
/// Fetches and sets the available languages
|
||||
///
|
||||
/// We first try to read from the local DB, and from the API if the data is too old
|
||||
Future<void> fetchAndSetLanguages(ExerciseDatabase database) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
var validTill = DateTime.parse(prefs.getString(PREFS_LAST_UPDATED_LANGUAGES)!);
|
||||
|
||||
// Cache still valid, return it
|
||||
if (validTill.isAfter(DateTime.now())) {
|
||||
final languages = await database.select(database.languages).get();
|
||||
|
||||
if (languages.isNotEmpty) {
|
||||
_languages = languages.map((e) => e.data).toList();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch from API and save to DB
|
||||
await fetchAndSetLanguagesFromApi();
|
||||
await database.delete(database.languages).go();
|
||||
await Future.forEach(_languages, (e) async {
|
||||
await database.into(database.languages).insert(
|
||||
LanguagesCompanion.insert(
|
||||
id: e.id,
|
||||
data: e,
|
||||
),
|
||||
);
|
||||
});
|
||||
validTill = DateTime.now().add(const Duration(days: EXERCISE_CACHE_DAYS));
|
||||
await prefs.setString(PREFS_LAST_UPDATED_LANGUAGES, validTill.toIso8601String());
|
||||
}
|
||||
|
||||
/// Fetches and sets the available equipment
|
||||
///
|
||||
/// We first try to read from the local DB, and from the API if the data is too old
|
||||
Future<void> fetchAndSetEquipments(ExerciseDatabase database) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
var validTill = DateTime.parse(prefs.getString(PREFS_LAST_UPDATED_EQUIPMENT)!);
|
||||
|
||||
// Cache still valid, return it
|
||||
if (validTill.isAfter(DateTime.now())) {
|
||||
final equipments = await database.select(database.equipments).get();
|
||||
|
||||
if (equipments.isNotEmpty) {
|
||||
_equipment = equipments.map((e) => e.data).toList();
|
||||
log('Loaded ${equipment.length} equipment from cache');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch from API and save to DB
|
||||
await fetchAndSetEquipmentsFromApi();
|
||||
await database.delete(database.equipments).go();
|
||||
await Future.forEach(_equipment, (e) async {
|
||||
await database.into(database.equipments).insert(
|
||||
EquipmentsCompanion.insert(
|
||||
id: e.id,
|
||||
data: e,
|
||||
),
|
||||
);
|
||||
});
|
||||
validTill = DateTime.now().add(const Duration(days: EXERCISE_CACHE_DAYS));
|
||||
await prefs.setString(PREFS_LAST_UPDATED_EQUIPMENT, validTill.toIso8601String());
|
||||
}
|
||||
|
||||
/// Searches for an exercise
|
||||
///
|
||||
/// We could do this locally, but the server has better text searching capabilities
|
||||
/// with postgresql.
|
||||
Future<List<ExerciseBase>> searchExercise(String name,
|
||||
Future<List<Exercise>> searchExercise(String name,
|
||||
{String languageCode = LANGUAGE_SHORT_ENGLISH, bool searchEnglish = false}) async {
|
||||
if (name.length <= 1) {
|
||||
return [];
|
||||
@@ -440,15 +644,15 @@ class ExercisesProvider with ChangeNotifier {
|
||||
// Send the request
|
||||
final result = await baseProvider.fetch(
|
||||
baseProvider.makeUrl(
|
||||
_exerciseSearchPath,
|
||||
exerciseSearchPath,
|
||||
query: {'term': name, 'language': languages.join(',')},
|
||||
),
|
||||
);
|
||||
|
||||
// Process the response
|
||||
return Future.wait(
|
||||
(result['suggestions'] as List).map<Future<ExerciseBase>>(
|
||||
(entry) => fetchAndSetExerciseBase(entry['data']['base_id']),
|
||||
(result['suggestions'] as List).map<Future<Exercise>>(
|
||||
(entry) => fetchAndSetExercise(entry['data']['base_id']),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
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/exercise.dart';
|
||||
import 'package:wger/models/exercises/translation.dart';
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
import 'package:wger/models/workouts/log.dart';
|
||||
@@ -214,16 +214,15 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
for (final settingEntry in settingData) {
|
||||
final workoutSetting = Setting.fromJson(settingEntry);
|
||||
|
||||
workoutSetting.exerciseBase =
|
||||
await _exercises.fetchAndSetExerciseBase(workoutSetting.exerciseBaseId);
|
||||
workoutSetting.exercise = await _exercises.fetchAndSetExercise(workoutSetting.exerciseId);
|
||||
workoutSetting.weightUnit = _weightUnits.firstWhere(
|
||||
(e) => e.id == workoutSetting.weightUnitId,
|
||||
);
|
||||
workoutSetting.repetitionUnit = _repetitionUnit.firstWhere(
|
||||
(e) => e.id == workoutSetting.repetitionUnitId,
|
||||
);
|
||||
if (!workoutSet.exerciseBasesIds.contains(workoutSetting.exerciseBaseId)) {
|
||||
workoutSet.addExerciseBase(workoutSetting.exerciseBaseObj);
|
||||
if (!workoutSet.exerciseBasesIds.contains(workoutSetting.exerciseId)) {
|
||||
workoutSet.addExerciseBase(workoutSetting.exerciseObj);
|
||||
}
|
||||
|
||||
settings.add(workoutSetting);
|
||||
@@ -248,7 +247,7 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
final log = Log.fromJson(logEntry);
|
||||
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);
|
||||
log.exerciseBase = await _exercises.fetchAndSetExercise(log.exerciseBaseId);
|
||||
plan.logs.add(log);
|
||||
} catch (e) {
|
||||
dev.log('fire! fire!');
|
||||
@@ -291,7 +290,7 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> fetchLogData(WorkoutPlan workout, ExerciseBase base) async {
|
||||
Future<Map<String, dynamic>> fetchLogData(WorkoutPlan workout, Exercise base) async {
|
||||
final data = await baseProvider.fetch(
|
||||
baseProvider.makeUrl(
|
||||
_workoutPlansUrlPath,
|
||||
@@ -504,7 +503,7 @@ class WorkoutPlansProvider with ChangeNotifier {
|
||||
log.id = newLog.id;
|
||||
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);
|
||||
log.exerciseBase = await _exercises.fetchAndSetExercise(log.exerciseBaseId);
|
||||
|
||||
final plan = findById(log.workoutPlan);
|
||||
plan.logs.add(log);
|
||||
|
||||
@@ -74,7 +74,7 @@ class _AddExerciseStepperState extends State<AddExerciseStepper> {
|
||||
final exerciseProvider = context.read<ExercisesProvider>();
|
||||
|
||||
final baseId = await addExerciseProvider.addExercise();
|
||||
final base = await exerciseProvider.fetchAndSetExerciseBase(baseId);
|
||||
final base = await exerciseProvider.fetchAndSetExercise(baseId);
|
||||
final name =
|
||||
base.getExercise(Localizations.localeOf(context).languageCode).name;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/widgets/exercises/exercises.dart';
|
||||
|
||||
class ExerciseDetailScreen extends StatelessWidget {
|
||||
@@ -27,7 +27,7 @@ class ExerciseDetailScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final exerciseBase = ModalRoute.of(context)!.settings.arguments as ExerciseBase;
|
||||
final exerciseBase = ModalRoute.of(context)!.settings.arguments as Exercise;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
import 'package:wger/widgets/core/app_bar.dart';
|
||||
import 'package:wger/widgets/exercises/filter_row.dart';
|
||||
@@ -33,7 +33,7 @@ class _ExercisesScreenState extends State<ExercisesScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//final size = MediaQuery.of(context).size;
|
||||
final exercisesList = Provider.of<ExercisesProvider>(context).filteredExerciseBases;
|
||||
final exercisesList = Provider.of<ExercisesProvider>(context).filteredExercises;
|
||||
|
||||
return Scaffold(
|
||||
appBar: EmptyAppBar(AppLocalizations.of(context).exercises),
|
||||
@@ -62,7 +62,7 @@ class _ExercisesList extends StatelessWidget {
|
||||
required this.exerciseBaseList,
|
||||
});
|
||||
|
||||
final List<ExerciseBase> exerciseBaseList;
|
||||
final List<Exercise> exerciseBaseList;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -90,7 +90,7 @@ class _HomeTabsScreenState extends State<HomeTabsScreen> with SingleTickerProvid
|
||||
userProvider.fetchAndSetProfile(),
|
||||
workoutPlansProvider.fetchAndSetUnits(),
|
||||
nutritionPlansProvider.fetchIngredientsFromCache(),
|
||||
exercisesProvider.fetchAndSetExercises(),
|
||||
exercisesProvider.fetchAndSetInitialData(),
|
||||
]);
|
||||
} catch (e) {
|
||||
log('fire! fire!');
|
||||
|
||||
@@ -58,7 +58,7 @@ class Step2Variations extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
// Exercise bases without variations
|
||||
...exerciseProvider.bases.where((b) => b.variationId == null).map(
|
||||
...exerciseProvider.exercises.where((b) => b.variationId == null).map(
|
||||
(base) => Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
|
||||
@@ -57,16 +57,11 @@ class AboutEntry extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class AboutPage extends StatefulWidget {
|
||||
class AboutPage extends StatelessWidget {
|
||||
static String routeName = '/AboutPage';
|
||||
|
||||
const AboutPage({super.key});
|
||||
|
||||
@override
|
||||
State<AboutPage> createState() => _AboutPageState();
|
||||
}
|
||||
|
||||
class _AboutPageState extends State<AboutPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final deviceSize = MediaQuery.of(context).size;
|
||||
|
||||
@@ -27,6 +27,7 @@ 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/core/settings.dart';
|
||||
import 'package:wger/widgets/user/forms.dart';
|
||||
|
||||
class MainAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
@@ -50,9 +51,7 @@ class MainAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(MaterialLocalizations.of(context).closeButtonLabel),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
],
|
||||
contentPadding: EdgeInsets.zero,
|
||||
@@ -63,22 +62,23 @@ class MainAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
//dense: true,
|
||||
leading: const Icon(Icons.person),
|
||||
title: Text(AppLocalizations.of(context).userProfile),
|
||||
onTap: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).userProfile,
|
||||
UserProfileForm(context.read<UserProvider>().profile!),
|
||||
),
|
||||
);
|
||||
},
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).userProfile,
|
||||
UserProfileForm(context.read<UserProvider>().profile!),
|
||||
),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.settings),
|
||||
onTap: () => Navigator.of(context).pushNamed(SettingsPage.routeName),
|
||||
title: Text(AppLocalizations.of(context).settingsTitle),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.info),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(AboutPage.routeName);
|
||||
},
|
||||
onTap: () => Navigator.of(context).pushNamed(AboutPage.routeName),
|
||||
title: Text(AppLocalizations.of(context).aboutPageTitle),
|
||||
),
|
||||
const Divider(),
|
||||
|
||||
70
lib/widgets/core/settings.dart
Normal file
70
lib/widgets/core/settings.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//import 'package:drift/drift.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
|
||||
class SettingsPage extends StatefulWidget {
|
||||
static String routeName = '/SettingsPage';
|
||||
|
||||
const SettingsPage({super.key});
|
||||
|
||||
@override
|
||||
State<SettingsPage> createState() => _SettingsPageState();
|
||||
}
|
||||
|
||||
class _SettingsPageState extends State<SettingsPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final exerciseProvider = Provider.of<ExercisesProvider>(context, listen: false);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(AppLocalizations.of(context).settingsTitle),
|
||||
),
|
||||
body: ListView(
|
||||
children: [
|
||||
ListTile(
|
||||
// leading: const Icon(Icons.cached),
|
||||
title: Text(AppLocalizations.of(context).settingsCacheTitle),
|
||||
subtitle: Text(AppLocalizations.of(context).settingsCacheDescription),
|
||||
trailing: IconButton(
|
||||
key: const ValueKey('cacheIcon'),
|
||||
icon: const Icon(Icons.delete),
|
||||
onPressed: () async {
|
||||
await exerciseProvider.clearAllCachesAndPrefs();
|
||||
|
||||
if (context.mounted) {
|
||||
final snackBar = SnackBar(
|
||||
content: Text(AppLocalizations.of(context).settingsCacheDeletedSnackbar),
|
||||
);
|
||||
|
||||
// Find the ScaffoldMessenger in the widget tree
|
||||
// and use it to show a SnackBar.
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -498,11 +498,11 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(s.exerciseBaseObj
|
||||
Text(s.exerciseObj
|
||||
.getExercise(Localizations.localeOf(context).languageCode)
|
||||
.name),
|
||||
const SizedBox(width: 10),
|
||||
MutedText(set.getSmartRepr(s.exerciseBaseObj).join('\n')),
|
||||
MutedText(set.getSmartRepr(s.exerciseObj).join('\n')),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
@@ -24,7 +24,7 @@ import 'package:provider/provider.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/helpers/i18n.dart';
|
||||
import 'package:wger/helpers/platform.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/models/exercises/muscle.dart';
|
||||
import 'package:wger/models/exercises/translation.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
@@ -34,7 +34,7 @@ import 'package:wger/widgets/exercises/list_tile.dart';
|
||||
import 'package:wger/widgets/exercises/videos.dart';
|
||||
|
||||
class ExerciseDetail extends StatelessWidget {
|
||||
final ExerciseBase _exerciseBase;
|
||||
final Exercise _exerciseBase;
|
||||
late Translation _exercise;
|
||||
static const PADDING = 9.0;
|
||||
|
||||
@@ -88,7 +88,7 @@ class ExerciseDetail extends StatelessWidget {
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
));
|
||||
Provider.of<ExercisesProvider>(context, listen: false)
|
||||
.findExerciseBasesByVariationId(
|
||||
.findExercisesByVariationId(
|
||||
_exerciseBase.variationId!,
|
||||
exerciseBaseIdToExclude: _exerciseBase.id,
|
||||
)
|
||||
@@ -206,7 +206,7 @@ class ExerciseDetail extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Chip(
|
||||
label: Text(getTranslation(_exerciseBase.category.name, context)),
|
||||
label: Text(getTranslation(_exerciseBase.category!.name, context)),
|
||||
padding: EdgeInsets.zero,
|
||||
backgroundColor: theme.splashColor,
|
||||
),
|
||||
@@ -242,10 +242,10 @@ class ExerciseDetail extends StatelessWidget {
|
||||
|
||||
List<Widget> getAliases(BuildContext context) {
|
||||
final List<Widget> out = [];
|
||||
if (_exercise.alias.isNotEmpty) {
|
||||
if (_exercise.aliases.isNotEmpty) {
|
||||
out.add(MutedText(
|
||||
AppLocalizations.of(context)
|
||||
.alsoKnownAs(_exercise.alias.map((e) => e.alias).toList().join(', ')),
|
||||
.alsoKnownAs(_exercise.aliases.map((e) => e.alias).toList().join(', ')),
|
||||
));
|
||||
out.add(const SizedBox(height: PADDING));
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wger/helpers/i18n.dart';
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/screens/exercise_screen.dart';
|
||||
import 'package:wger/widgets/exercises/images.dart';
|
||||
|
||||
class ExerciseListTile extends StatelessWidget {
|
||||
const ExerciseListTile({super.key, required this.exerciseBase});
|
||||
|
||||
final ExerciseBase exerciseBase;
|
||||
final Exercise exerciseBase;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -57,7 +57,7 @@ class ExerciseListTile extends StatelessWidget {
|
||||
maxLines: 2,
|
||||
),
|
||||
subtitle: Text(
|
||||
'${getTranslation(exerciseBase.category.name, context)} / ${exerciseBase.equipment.map((e) => getTranslation(e.name, context)).toList().join(', ')}',
|
||||
'${getTranslation(exerciseBase.category!.name, context)} / ${exerciseBase.equipment.map((e) => getTranslation(e.name, context)).toList().join(', ')}',
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, ExerciseDetailScreen.routeName, arguments: exerciseBase);
|
||||
|
||||
@@ -50,17 +50,17 @@ class SettingWidget extends StatelessWidget {
|
||||
leading: InkWell(
|
||||
child: SizedBox(
|
||||
width: 45,
|
||||
child: ExerciseImageWidget(image: setting.exerciseBaseObj.getMainImage),
|
||||
child: ExerciseImageWidget(image: setting.exerciseObj.getMainImage),
|
||||
),
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(setting.exerciseBaseObj
|
||||
title: Text(setting.exerciseObj
|
||||
.getExercise(Localizations.localeOf(context).languageCode)
|
||||
.name),
|
||||
content: ExerciseDetail(setting.exerciseBaseObj),
|
||||
content: ExerciseDetail(setting.exerciseObj),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(MaterialLocalizations.of(context).closeButtonLabel),
|
||||
@@ -75,12 +75,12 @@ class SettingWidget extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
setting.exerciseBaseObj.getExercise(Localizations.localeOf(context).languageCode).name,
|
||||
setting.exerciseObj.getExercise(Localizations.localeOf(context).languageCode).name,
|
||||
),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
...set.getSmartRepr(setting.exerciseBaseObj).map((e) => Text(e)),
|
||||
...set.getSmartRepr(setting.exerciseObj).map((e) => Text(e)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -21,7 +21,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
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/exercises/exercise.dart';
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
import 'package:wger/models/workouts/repetition_unit.dart';
|
||||
import 'package:wger/models/workouts/set.dart';
|
||||
@@ -281,14 +281,14 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
final _exercisesController = TextEditingController();
|
||||
|
||||
/// Removes an exercise from the current set
|
||||
void removeExerciseBase(ExerciseBase base) {
|
||||
void removeExerciseBase(Exercise base) {
|
||||
setState(() {
|
||||
widget._set.removeExercise(base);
|
||||
});
|
||||
}
|
||||
|
||||
/// Adds an exercise to the current set
|
||||
void addExercise(ExerciseBase base) {
|
||||
void addExercise(Exercise base) {
|
||||
setState(() {
|
||||
widget._set.addExerciseBase(base);
|
||||
addSettings();
|
||||
@@ -306,7 +306,7 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
for (int loop = 0; loop < widget._set.sets; loop++) {
|
||||
final Setting setting = Setting.empty();
|
||||
setting.order = order;
|
||||
setting.exerciseBase = exercise;
|
||||
setting.exercise = exercise;
|
||||
setting.weightUnit = workoutProvider.defaultWeightUnit;
|
||||
setting.repetitionUnit = workoutProvider.defaultRepetitionUnit;
|
||||
|
||||
@@ -363,7 +363,7 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
Card(
|
||||
child: Column(
|
||||
children: [
|
||||
TypeAheadFormField<ExerciseBase>(
|
||||
TypeAheadFormField<Exercise>(
|
||||
key: const Key('field-typeahead'),
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
controller: _exercisesController,
|
||||
@@ -408,7 +408,7 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
searchEnglish: _searchEnglish,
|
||||
);
|
||||
},
|
||||
itemBuilder: (BuildContext context, ExerciseBase exerciseSuggestion) {
|
||||
itemBuilder: (BuildContext context, Exercise exerciseSuggestion) {
|
||||
return ListTile(
|
||||
leading: SizedBox(
|
||||
width: 45,
|
||||
@@ -420,7 +420,7 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
.name,
|
||||
),
|
||||
subtitle: Text(
|
||||
'${exerciseSuggestion.category.name} / ${exerciseSuggestion.equipment.map((e) => e.name).join(', ')}',
|
||||
'${exerciseSuggestion.category!.name} / ${exerciseSuggestion.equipment.map((e) => e.name).join(', ')}',
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -444,7 +444,7 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
transitionBuilder: (context, suggestionsBox, controller) {
|
||||
return suggestionsBox;
|
||||
},
|
||||
onSuggestionSelected: (ExerciseBase exerciseSuggestion) {
|
||||
onSuggestionSelected: (Exercise exerciseSuggestion) {
|
||||
addExercise(exerciseSuggestion);
|
||||
_exercisesController.text = '';
|
||||
},
|
||||
@@ -502,9 +502,8 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
final index = entry.key;
|
||||
final exercise = entry.value;
|
||||
final showSupersetInfo = (index + 1) < widget._set.exerciseBasesObj.length;
|
||||
final settings = widget._set.settings
|
||||
.where((e) => e.exerciseBaseObj.id == exercise.id)
|
||||
.toList();
|
||||
final settings =
|
||||
widget._set.settings.where((e) => e.exerciseObj.id == exercise.id).toList();
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
@@ -578,7 +577,7 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
}
|
||||
|
||||
class ExerciseSetting extends StatelessWidget {
|
||||
final ExerciseBase _exerciseBase;
|
||||
final Exercise _exerciseBase;
|
||||
late final int _numberOfSets;
|
||||
final bool _detailed;
|
||||
final Function removeExercise;
|
||||
@@ -681,7 +680,7 @@ class ExerciseSetting extends StatelessWidget {
|
||||
_exerciseBase.getExercise(Localizations.localeOf(context).languageCode).name,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
subtitle: Text(_exerciseBase.category.name),
|
||||
subtitle: Text(_exerciseBase.category!.name),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: ExerciseImageWidget(image: _exerciseBase.getMainImage),
|
||||
trailing: IconButton(
|
||||
|
||||
@@ -29,7 +29,7 @@ import 'package:wger/helpers/i18n.dart';
|
||||
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/exercises/exercise.dart';
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
import 'package:wger/models/workouts/log.dart';
|
||||
import 'package:wger/models/workouts/session.dart';
|
||||
@@ -59,7 +59,7 @@ class _GymModeState extends State<GymMode> {
|
||||
var _totalElements = 1;
|
||||
|
||||
/// Map with the first (navigation) page for each exercise
|
||||
final Map<ExerciseBase, int> _exercisePages = {};
|
||||
final Map<Exercise, int> _exercisePages = {};
|
||||
final PageController _controller = PageController(
|
||||
initialPage: 0,
|
||||
);
|
||||
@@ -86,7 +86,7 @@ class _GymModeState extends State<GymMode> {
|
||||
var firstPage = true;
|
||||
for (final setting in set.settingsComputed) {
|
||||
final exerciseBase = Provider.of<ExercisesProvider>(context, listen: false)
|
||||
.findExerciseBaseById(setting.exerciseBaseId);
|
||||
.findExerciseById(setting.exerciseId);
|
||||
|
||||
if (firstPage) {
|
||||
_exercisePages[exerciseBase] = currentPage;
|
||||
@@ -114,7 +114,7 @@ class _GymModeState extends State<GymMode> {
|
||||
var firstPage = true;
|
||||
for (final setting in set.settingsComputed) {
|
||||
final ratioCompleted = currentElement / _totalElements;
|
||||
final exerciseBase = exerciseProvider.findExerciseBaseById(setting.exerciseBaseId);
|
||||
final exerciseBase = exerciseProvider.findExerciseById(setting.exerciseId);
|
||||
currentElement++;
|
||||
|
||||
if (firstPage) {
|
||||
@@ -169,7 +169,7 @@ class _GymModeState extends State<GymMode> {
|
||||
class StartPage extends StatelessWidget {
|
||||
final PageController _controller;
|
||||
final Day _day;
|
||||
final Map<ExerciseBase, int> _exercisePages;
|
||||
final Map<Exercise, int> _exercisePages;
|
||||
|
||||
const StartPage(this._controller, this._day, this._exercisePages);
|
||||
|
||||
@@ -194,12 +194,12 @@ class StartPage extends StatelessWidget {
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
s.exerciseBaseObj
|
||||
s.exerciseObj
|
||||
.getExercise(Localizations.localeOf(context).languageCode)
|
||||
.name,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
...set.getSmartRepr(s.exerciseBaseObj).map((e) => Text(e)),
|
||||
...set.getSmartRepr(s.exerciseObj).map((e) => Text(e)),
|
||||
const SizedBox(height: 15),
|
||||
],
|
||||
);
|
||||
@@ -232,10 +232,10 @@ class LogPage extends StatefulWidget {
|
||||
final PageController _controller;
|
||||
final Setting _setting;
|
||||
final Set _set;
|
||||
final ExerciseBase _exerciseBase;
|
||||
final Exercise _exerciseBase;
|
||||
final WorkoutPlan _workoutPlan;
|
||||
final double _ratioCompleted;
|
||||
final Map<ExerciseBase, int> _exercisePages;
|
||||
final Map<Exercise, int> _exercisePages;
|
||||
final Log _log = Log.empty();
|
||||
|
||||
LogPage(
|
||||
@@ -662,9 +662,9 @@ class _LogPageState extends State<LogPage> {
|
||||
|
||||
class ExerciseOverview extends StatelessWidget {
|
||||
final PageController _controller;
|
||||
final ExerciseBase _exerciseBase;
|
||||
final Exercise _exerciseBase;
|
||||
final double _ratioCompleted;
|
||||
final Map<ExerciseBase, int> _exercisePages;
|
||||
final Map<Exercise, int> _exercisePages;
|
||||
|
||||
const ExerciseOverview(
|
||||
this._controller,
|
||||
@@ -688,7 +688,8 @@ class ExerciseOverview extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||
children: [
|
||||
Text(
|
||||
getTranslation(_exerciseBase.category.name, context),
|
||||
getTranslation(_exerciseBase.category!.name, context),
|
||||
semanticsLabel: getTranslation(_exerciseBase.category!.name, context),
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
@@ -725,7 +726,7 @@ class SessionPage extends StatefulWidget {
|
||||
final WorkoutPlan _workoutPlan;
|
||||
final PageController _controller;
|
||||
final TimeOfDay _start;
|
||||
final Map<ExerciseBase, int> _exercisePages;
|
||||
final Map<Exercise, int> _exercisePages;
|
||||
|
||||
const SessionPage(
|
||||
this._workoutPlan,
|
||||
@@ -932,7 +933,7 @@ class _SessionPageState extends State<SessionPage> {
|
||||
class TimerWidget extends StatefulWidget {
|
||||
final PageController _controller;
|
||||
final double _ratioCompleted;
|
||||
final Map<ExerciseBase, int> _exercisePages;
|
||||
final Map<Exercise, int> _exercisePages;
|
||||
|
||||
const TimerWidget(
|
||||
this._controller,
|
||||
@@ -1063,7 +1064,7 @@ class NavigationFooter extends StatelessWidget {
|
||||
class NavigationHeader extends StatelessWidget {
|
||||
final PageController _controller;
|
||||
final String _title;
|
||||
final Map<ExerciseBase, int> exercisePages;
|
||||
final Map<Exercise, int> exercisePages;
|
||||
|
||||
const NavigationHeader(
|
||||
this._title,
|
||||
|
||||
@@ -21,7 +21,7 @@ import 'package:intl/intl.dart';
|
||||
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/exercises/exercise.dart';
|
||||
import 'package:wger/models/workouts/log.dart';
|
||||
import 'package:wger/models/workouts/session.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
@@ -29,7 +29,7 @@ import 'package:wger/widgets/measurements/charts.dart';
|
||||
import 'package:wger/widgets/workouts/charts.dart';
|
||||
|
||||
class ExerciseLogChart extends StatelessWidget {
|
||||
final ExerciseBase _base;
|
||||
final Exercise _base;
|
||||
final DateTime _currentDate;
|
||||
|
||||
const ExerciseLogChart(this._base, this._currentDate);
|
||||
@@ -89,7 +89,7 @@ class ExerciseLogChart extends StatelessWidget {
|
||||
class DayLogWidget extends StatefulWidget {
|
||||
final DateTime _date;
|
||||
final WorkoutSession? _session;
|
||||
final Map<ExerciseBase, List<Log>> _exerciseData;
|
||||
final Map<Exercise, List<Log>> _exerciseData;
|
||||
|
||||
const DayLogWidget(this._date, this._exerciseData, this._session);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import 'package:flutter/material.dart';
|
||||
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/exercises/exercise.dart';
|
||||
import 'package:wger/models/workouts/log.dart';
|
||||
import 'package:wger/models/workouts/session.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
@@ -96,7 +96,7 @@ class _WorkoutLogsState extends State<WorkoutLogs> {
|
||||
class WorkoutLogEvent {
|
||||
final DateTime dateTime;
|
||||
final WorkoutSession? session;
|
||||
final Map<ExerciseBase, List<Log>> exercises;
|
||||
final Map<Exercise, List<Log>> exercises;
|
||||
|
||||
WorkoutLogEvent(this.dateTime, this.session, this.exercises);
|
||||
}
|
||||
|
||||
@@ -7,12 +7,16 @@
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <file_selector_linux/file_selector_plugin.h>
|
||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
||||
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
||||
g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin");
|
||||
sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar);
|
||||
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
file_selector_linux
|
||||
sqlite3_flutter_libs
|
||||
url_launcher_linux
|
||||
)
|
||||
|
||||
|
||||
@@ -7,16 +7,20 @@ import Foundation
|
||||
|
||||
import file_selector_macos
|
||||
import package_info_plus
|
||||
import path_provider_foundation
|
||||
import rive_common
|
||||
import shared_preferences_foundation
|
||||
import sqlite3_flutter_libs
|
||||
import url_launcher_macos
|
||||
import video_player_avfoundation
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
RivePlugin.register(with: registry.registrar(forPlugin: "RivePlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin"))
|
||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
|
||||
}
|
||||
|
||||
126
pubspec.lock
126
pubspec.lock
@@ -17,6 +17,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.2.0"
|
||||
analyzer_plugin:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer_plugin
|
||||
sha256: "9661b30b13a685efaee9f02e5d01ed9f2b423bd889d28a304d02d704aee69161"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.11.3"
|
||||
android_metadata:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -185,6 +193,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
checked_yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -201,6 +217,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.5"
|
||||
cli_util:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: cli_util
|
||||
sha256: c05b7406fdabc7a49a3929d4af76bcaccbbffcbcdcf185b082e1ae07da323d19
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.4.1"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -273,6 +297,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.4"
|
||||
drift:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: drift
|
||||
sha256: "05363b695885c72036ed5c76287125bfc6f1deda20cb3aa044a09fe22792f81b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.14.1"
|
||||
drift_dev:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: drift_dev
|
||||
sha256: "50c14b8248d133d36b41c1b08ceed138be869b5b98ccaf3af16c9b88c7adc54e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.14.1"
|
||||
equatable:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -522,6 +562,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.6.0"
|
||||
freezed:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: freezed
|
||||
sha256: "6c5031daae12c7072b3a87eff98983076434b4889ef2a44384d0cae3f82372ba"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.6"
|
||||
freezed_annotation:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: freezed_annotation
|
||||
sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.1"
|
||||
frontend_server_client:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -535,6 +591,14 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
get_it:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: get_it
|
||||
sha256: d0b88dc35a7f97fd91fec0cf8f165abd97a57977968d8fc02ba0bc92e14ba07e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.6.6"
|
||||
glob:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -603,10 +667,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_android
|
||||
sha256: "39f2bfe497e495450c81abcd44b62f56c2a36a37a175da7d137b4454977b51b1"
|
||||
sha256: "1a27bf4cc0330389cebe465bab08fe6dec97e44015b4899637344bb7297759ec"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.8.9+3"
|
||||
version: "0.8.9+2"
|
||||
image_picker_for_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -829,7 +893,7 @@ packages:
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
path:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path
|
||||
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
|
||||
@@ -844,6 +908,30 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
path_provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path_provider
|
||||
sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
path_provider_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_android
|
||||
sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.2"
|
||||
path_provider_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_foundation
|
||||
sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -948,6 +1036,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.3"
|
||||
recase:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: recase
|
||||
sha256: e4eb4ec2dcdee52dcf99cb4ceabaffc631d7424ee55e56f280bc039737f89213
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.1.0"
|
||||
rfc_6901:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1081,6 +1177,30 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
sqlite3:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sqlite3
|
||||
sha256: c4a4c5a4b2a32e2d0f6837b33d7c91a67903891a5b7dbe706cf4b1f6b0c798c5
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.0"
|
||||
sqlite3_flutter_libs:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: sqlite3_flutter_libs
|
||||
sha256: "3e3583b77cf888a68eae2e49ee4f025f66b86623ef0d83c297c8d903daa14871"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.18"
|
||||
sqlparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sqlparser
|
||||
sha256: "877fcefabb725d120e31f54fa669a98c002db0feeaca6cea5354543f03b5e906"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.33.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
10
pubspec.yaml
10
pubspec.yaml
@@ -59,8 +59,14 @@ dependencies:
|
||||
flutter_svg: ^2.0.5
|
||||
fl_chart: ^0.66.0
|
||||
flutter_zxing: ^1.5.2
|
||||
drift: ^2.13.1
|
||||
path: ^1.8.3
|
||||
path_provider: ^2.1.1
|
||||
sqlite3_flutter_libs: ^0.5.18
|
||||
get_it: ^7.6.4
|
||||
flex_seed_scheme: ^1.4.0
|
||||
flex_color_scheme: ^7.3.1
|
||||
freezed_annotation: ^2.4.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
@@ -68,11 +74,13 @@ dev_dependencies:
|
||||
integration_test:
|
||||
sdk: flutter
|
||||
build_runner: ^2.3.3
|
||||
json_serializable: ^6.6.2
|
||||
json_serializable: ^6.7.1
|
||||
mockito: ^5.4.4
|
||||
network_image_mock: ^2.1.1
|
||||
flutter_lints: ^3.0.1
|
||||
cider: ^0.2.4
|
||||
drift_dev: ^2.13.1
|
||||
freezed: ^2.4.5
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
1
schema.json
Normal file
1
schema.json
Normal file
@@ -0,0 +1 @@
|
||||
{"_meta":{"description":"This file contains a serialized version of schema entities for drift.","version":"1.1.0"},"options":{"store_date_time_values_as_text":false},"entities":[{"id":0,"references":[],"type":"table","data":{"name":"exercise_table_items","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"exercisebase","getter_name":"exercisebase","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const ExerciseBaseConverter()","dart_type_name":"ExerciseBase"}},{"name":"muscle","getter_name":"muscle","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const MuscleConverter()","dart_type_name":"Muscle"}},{"name":"category","getter_name":"category","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const ExerciseCategoryConverter()","dart_type_name":"ExerciseCategory"}},{"name":"variation","getter_name":"variation","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const VariationConverter()","dart_type_name":"Variation"}},{"name":"language","getter_name":"language","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const LanguageConverter()","dart_type_name":"Language"}},{"name":"equipment","getter_name":"equipment","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const EquipmentConverter()","dart_type_name":"Equipment"}},{"name":"expires_in","getter_name":"expiresIn","moor_type":"dateTime","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}}]}
|
||||
54
test/core/settings_test.dart
Normal file
54
test/core/settings_test.dart
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
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/providers/exercises.dart';
|
||||
import 'package:wger/widgets/core/settings.dart';
|
||||
|
||||
import 'settings_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([ExercisesProvider])
|
||||
void main() {
|
||||
final mockExerciseProvider = MockExercisesProvider();
|
||||
|
||||
Widget createSettingsScreen({locale = 'en'}) {
|
||||
return ChangeNotifierProvider<ExercisesProvider>(
|
||||
create: (context) => mockExerciseProvider,
|
||||
child: MaterialApp(
|
||||
locale: Locale(locale),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: const SettingsPage()),
|
||||
);
|
||||
}
|
||||
|
||||
group('Cache', () {
|
||||
testWidgets('Test the widgets on the gym mode screen', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createSettingsScreen());
|
||||
await tester.tap(find.byKey(const ValueKey('cacheIcon')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
verify(mockExerciseProvider.clearAllCachesAndPrefs());
|
||||
});
|
||||
});
|
||||
}
|
||||
578
test/core/settings_test.mocks.dart
Normal file
578
test/core/settings_test.mocks.dart
Normal file
@@ -0,0 +1,578 @@
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/core/settings_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i10;
|
||||
import 'dart:ui' as _i11;
|
||||
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:wger/database/exercises/exercise_database.dart' as _i3;
|
||||
import 'package:wger/models/exercises/category.dart' as _i5;
|
||||
import 'package:wger/models/exercises/equipment.dart' as _i6;
|
||||
import 'package:wger/models/exercises/exercise.dart' as _i4;
|
||||
import 'package:wger/models/exercises/language.dart' as _i8;
|
||||
import 'package:wger/models/exercises/muscle.dart' as _i7;
|
||||
import 'package:wger/providers/base_provider.dart' as _i2;
|
||||
import 'package:wger/providers/exercises.dart' as _i9;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
// ignore_for_file: unnecessary_parenthesis
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeExerciseDatabase_1 extends _i1.SmartFake implements _i3.ExerciseDatabase {
|
||||
_FakeExerciseDatabase_1(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeExercise_2 extends _i1.SmartFake implements _i4.Exercise {
|
||||
_FakeExercise_2(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeExerciseCategory_3 extends _i1.SmartFake implements _i5.ExerciseCategory {
|
||||
_FakeExerciseCategory_3(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeEquipment_4 extends _i1.SmartFake implements _i6.Equipment {
|
||||
_FakeEquipment_4(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeMuscle_5 extends _i1.SmartFake implements _i7.Muscle {
|
||||
_FakeMuscle_5(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeLanguage_6 extends _i1.SmartFake implements _i8.Language {
|
||||
_FakeLanguage_6(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
/// A class which mocks [ExercisesProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockExercisesProvider extends _i1.Mock implements _i9.ExercisesProvider {
|
||||
MockExercisesProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_i2.WgerBaseProvider get baseProvider => (super.noSuchMethod(
|
||||
Invocation.getter(#baseProvider),
|
||||
returnValue: _FakeWgerBaseProvider_0(
|
||||
this,
|
||||
Invocation.getter(#baseProvider),
|
||||
),
|
||||
) as _i2.WgerBaseProvider);
|
||||
|
||||
@override
|
||||
_i3.ExerciseDatabase get database => (super.noSuchMethod(
|
||||
Invocation.getter(#database),
|
||||
returnValue: _FakeExerciseDatabase_1(
|
||||
this,
|
||||
Invocation.getter(#database),
|
||||
),
|
||||
) as _i3.ExerciseDatabase);
|
||||
|
||||
@override
|
||||
set database(_i3.ExerciseDatabase? _database) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#database,
|
||||
_database,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i4.Exercise> get exercises => (super.noSuchMethod(
|
||||
Invocation.getter(#exercises),
|
||||
returnValue: <_i4.Exercise>[],
|
||||
) as List<_i4.Exercise>);
|
||||
|
||||
@override
|
||||
set exercises(List<_i4.Exercise>? _exercises) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#exercises,
|
||||
_exercises,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i4.Exercise> get filteredExercises => (super.noSuchMethod(
|
||||
Invocation.getter(#filteredExercises),
|
||||
returnValue: <_i4.Exercise>[],
|
||||
) as List<_i4.Exercise>);
|
||||
|
||||
@override
|
||||
set filteredExercises(List<_i4.Exercise>? newFilteredExercises) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#filteredExercises,
|
||||
newFilteredExercises,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<int, List<_i4.Exercise>> get exerciseBasesByVariation => (super.noSuchMethod(
|
||||
Invocation.getter(#exerciseBasesByVariation),
|
||||
returnValue: <int, List<_i4.Exercise>>{},
|
||||
) as Map<int, List<_i4.Exercise>>);
|
||||
|
||||
@override
|
||||
List<_i5.ExerciseCategory> get categories => (super.noSuchMethod(
|
||||
Invocation.getter(#categories),
|
||||
returnValue: <_i5.ExerciseCategory>[],
|
||||
) as List<_i5.ExerciseCategory>);
|
||||
|
||||
@override
|
||||
List<_i7.Muscle> get muscles => (super.noSuchMethod(
|
||||
Invocation.getter(#muscles),
|
||||
returnValue: <_i7.Muscle>[],
|
||||
) as List<_i7.Muscle>);
|
||||
|
||||
@override
|
||||
List<_i6.Equipment> get equipment => (super.noSuchMethod(
|
||||
Invocation.getter(#equipment),
|
||||
returnValue: <_i6.Equipment>[],
|
||||
) as List<_i6.Equipment>);
|
||||
|
||||
@override
|
||||
List<_i8.Language> get languages => (super.noSuchMethod(
|
||||
Invocation.getter(#languages),
|
||||
returnValue: <_i8.Language>[],
|
||||
) as List<_i8.Language>);
|
||||
|
||||
@override
|
||||
set languages(List<_i8.Language>? languages) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#languages,
|
||||
languages,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
bool get hasListeners => (super.noSuchMethod(
|
||||
Invocation.getter(#hasListeners),
|
||||
returnValue: false,
|
||||
) as bool);
|
||||
|
||||
@override
|
||||
_i10.Future<void> setFilters(_i9.Filters? newFilters) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#setFilters,
|
||||
[newFilters],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
void initFilters() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#initFilters,
|
||||
[],
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
_i10.Future<void> findByFilters() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findByFilters,
|
||||
[],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
void clear() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#clear,
|
||||
[],
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
_i4.Exercise findExerciseById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findExerciseById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _FakeExercise_2(
|
||||
this,
|
||||
Invocation.method(
|
||||
#findExerciseById,
|
||||
[id],
|
||||
),
|
||||
),
|
||||
) as _i4.Exercise);
|
||||
|
||||
@override
|
||||
List<_i4.Exercise> findExercisesByVariationId(
|
||||
int? id, {
|
||||
int? exerciseBaseIdToExclude,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findExercisesByVariationId,
|
||||
[id],
|
||||
{#exerciseBaseIdToExclude: exerciseBaseIdToExclude},
|
||||
),
|
||||
returnValue: <_i4.Exercise>[],
|
||||
) as List<_i4.Exercise>);
|
||||
|
||||
@override
|
||||
_i5.ExerciseCategory findCategoryById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findCategoryById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _FakeExerciseCategory_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#findCategoryById,
|
||||
[id],
|
||||
),
|
||||
),
|
||||
) as _i5.ExerciseCategory);
|
||||
|
||||
@override
|
||||
_i6.Equipment findEquipmentById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findEquipmentById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _FakeEquipment_4(
|
||||
this,
|
||||
Invocation.method(
|
||||
#findEquipmentById,
|
||||
[id],
|
||||
),
|
||||
),
|
||||
) as _i6.Equipment);
|
||||
|
||||
@override
|
||||
_i7.Muscle findMuscleById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findMuscleById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _FakeMuscle_5(
|
||||
this,
|
||||
Invocation.method(
|
||||
#findMuscleById,
|
||||
[id],
|
||||
),
|
||||
),
|
||||
) as _i7.Muscle);
|
||||
|
||||
@override
|
||||
_i8.Language findLanguageById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findLanguageById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _FakeLanguage_6(
|
||||
this,
|
||||
Invocation.method(
|
||||
#findLanguageById,
|
||||
[id],
|
||||
),
|
||||
),
|
||||
) as _i8.Language);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetCategoriesFromApi() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetCategoriesFromApi,
|
||||
[],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetMusclesFromApi() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetMusclesFromApi,
|
||||
[],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetEquipmentsFromApi() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetEquipmentsFromApi,
|
||||
[],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetLanguagesFromApi() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetLanguagesFromApi,
|
||||
[],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<_i4.Exercise> fetchAndSetExercise(int? exerciseId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetExercise,
|
||||
[exerciseId],
|
||||
),
|
||||
returnValue: _i10.Future<_i4.Exercise>.value(_FakeExercise_2(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchAndSetExercise,
|
||||
[exerciseId],
|
||||
),
|
||||
)),
|
||||
) as _i10.Future<_i4.Exercise>);
|
||||
|
||||
@override
|
||||
_i10.Future<_i4.Exercise> handleUpdateExerciseFromApi(
|
||||
_i3.ExerciseDatabase? database,
|
||||
int? exerciseId,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#handleUpdateExerciseFromApi,
|
||||
[
|
||||
database,
|
||||
exerciseId,
|
||||
],
|
||||
),
|
||||
returnValue: _i10.Future<_i4.Exercise>.value(_FakeExercise_2(
|
||||
this,
|
||||
Invocation.method(
|
||||
#handleUpdateExerciseFromApi,
|
||||
[
|
||||
database,
|
||||
exerciseId,
|
||||
],
|
||||
),
|
||||
)),
|
||||
) as _i10.Future<_i4.Exercise>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> checkExerciseCacheVersion() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#checkExerciseCacheVersion,
|
||||
[],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> initCacheTimesLocalPrefs({dynamic forceInit = false}) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#initCacheTimesLocalPrefs,
|
||||
[],
|
||||
{#forceInit: forceInit},
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> clearAllCachesAndPrefs() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#clearAllCachesAndPrefs,
|
||||
[],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetInitialData() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetInitialData,
|
||||
[],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> setExercisesFromDatabase(
|
||||
_i3.ExerciseDatabase? database, {
|
||||
bool? forceDeleteCache = false,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#setExercisesFromDatabase,
|
||||
[database],
|
||||
{#forceDeleteCache: forceDeleteCache},
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> updateExerciseCache(_i3.ExerciseDatabase? database) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#updateExerciseCache,
|
||||
[database],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetMuscles(_i3.ExerciseDatabase? database) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetMuscles,
|
||||
[database],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetCategories(_i3.ExerciseDatabase? database) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetCategories,
|
||||
[database],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetLanguages(_i3.ExerciseDatabase? database) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetLanguages,
|
||||
[database],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetEquipments(_i3.ExerciseDatabase? database) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetEquipments,
|
||||
[database],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<List<_i4.Exercise>> searchExercise(
|
||||
String? name, {
|
||||
String? languageCode = r'en',
|
||||
bool? searchEnglish = false,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#searchExercise,
|
||||
[name],
|
||||
{
|
||||
#languageCode: languageCode,
|
||||
#searchEnglish: searchEnglish,
|
||||
},
|
||||
),
|
||||
returnValue: _i10.Future<List<_i4.Exercise>>.value(<_i4.Exercise>[]),
|
||||
) as _i10.Future<List<_i4.Exercise>>);
|
||||
|
||||
@override
|
||||
void addListener(_i11.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addListener,
|
||||
[listener],
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#removeListener,
|
||||
[listener],
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#dispose,
|
||||
[],
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void notifyListeners() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#notifyListeners,
|
||||
[],
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
}
|
||||
@@ -76,7 +76,7 @@ void main() {
|
||||
when(mockExerciseProvider.muscles).thenReturn(testMuscles);
|
||||
when(mockExerciseProvider.equipment).thenReturn(testEquipment);
|
||||
when(mockExerciseProvider.exerciseBasesByVariation).thenReturn({});
|
||||
when(mockExerciseProvider.bases).thenReturn(getTestExerciseBases());
|
||||
when(mockExerciseProvider.exercises).thenReturn(getTestExerciseBases());
|
||||
when(mockExerciseProvider.languages).thenReturn(testLanguages);
|
||||
|
||||
when(mockAddExerciseProvider.equipment).thenReturn([]);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/exercises/contribute_exercise_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -9,9 +9,9 @@ import 'dart:ui' as _i14;
|
||||
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:wger/models/exercises/alias.dart' as _i6;
|
||||
import 'package:wger/models/exercises/base.dart' as _i3;
|
||||
import 'package:wger/models/exercises/category.dart' as _i9;
|
||||
import 'package:wger/models/exercises/equipment.dart' as _i11;
|
||||
import 'package:wger/models/exercises/exercise.dart' as _i3;
|
||||
import 'package:wger/models/exercises/language.dart' as _i8;
|
||||
import 'package:wger/models/exercises/muscle.dart' as _i12;
|
||||
import 'package:wger/models/exercises/translation.dart' as _i4;
|
||||
@@ -25,6 +25,8 @@ import 'package:wger/providers/user.dart' as _i15;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
@@ -42,8 +44,8 @@ class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvi
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeExerciseBase_1 extends _i1.SmartFake implements _i3.ExerciseBase {
|
||||
_FakeExerciseBase_1(
|
||||
class _FakeExercise_1 extends _i1.SmartFake implements _i3.Exercise {
|
||||
_FakeExercise_1(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
@@ -217,29 +219,29 @@ class MockAddExerciseProvider extends _i1.Mock implements _i7.AddExerciseProvide
|
||||
);
|
||||
|
||||
@override
|
||||
_i3.ExerciseBase get base => (super.noSuchMethod(
|
||||
Invocation.getter(#base),
|
||||
returnValue: _FakeExerciseBase_1(
|
||||
_i3.Exercise get exercise => (super.noSuchMethod(
|
||||
Invocation.getter(#exercise),
|
||||
returnValue: _FakeExercise_1(
|
||||
this,
|
||||
Invocation.getter(#base),
|
||||
Invocation.getter(#exercise),
|
||||
),
|
||||
) as _i3.ExerciseBase);
|
||||
) as _i3.Exercise);
|
||||
|
||||
@override
|
||||
_i4.Translation get exerciseEn => (super.noSuchMethod(
|
||||
Invocation.getter(#exerciseEn),
|
||||
_i4.Translation get translationEn => (super.noSuchMethod(
|
||||
Invocation.getter(#translationEn),
|
||||
returnValue: _FakeTranslation_2(
|
||||
this,
|
||||
Invocation.getter(#exerciseEn),
|
||||
Invocation.getter(#translationEn),
|
||||
),
|
||||
) as _i4.Translation);
|
||||
|
||||
@override
|
||||
_i4.Translation get exerciseTranslation => (super.noSuchMethod(
|
||||
Invocation.getter(#exerciseTranslation),
|
||||
_i4.Translation get translation => (super.noSuchMethod(
|
||||
Invocation.getter(#translation),
|
||||
returnValue: _FakeTranslation_2(
|
||||
this,
|
||||
Invocation.getter(#exerciseTranslation),
|
||||
Invocation.getter(#translation),
|
||||
),
|
||||
) as _i4.Translation);
|
||||
|
||||
@@ -334,19 +336,19 @@ class MockAddExerciseProvider extends _i1.Mock implements _i7.AddExerciseProvide
|
||||
) as _i13.Future<int>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.ExerciseBase> addExerciseBase() => (super.noSuchMethod(
|
||||
_i13.Future<_i3.Exercise> addExerciseBase() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addExerciseBase,
|
||||
[],
|
||||
),
|
||||
returnValue: _i13.Future<_i3.ExerciseBase>.value(_FakeExerciseBase_1(
|
||||
returnValue: _i13.Future<_i3.Exercise>.value(_FakeExercise_1(
|
||||
this,
|
||||
Invocation.method(
|
||||
#addExerciseBase,
|
||||
[],
|
||||
),
|
||||
)),
|
||||
) as _i13.Future<_i3.ExerciseBase>);
|
||||
) as _i13.Future<_i3.Exercise>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i5.Variation> addVariation() => (super.noSuchMethod(
|
||||
@@ -364,7 +366,7 @@ class MockAddExerciseProvider extends _i1.Mock implements _i7.AddExerciseProvide
|
||||
) as _i13.Future<_i5.Variation>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> addImages(_i3.ExerciseBase? base) => (super.noSuchMethod(
|
||||
_i13.Future<void> addImages(_i3.Exercise? base) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addImages,
|
||||
[base],
|
||||
|
||||
507
test/exercises/exercise_provider_db_test.dart
Normal file
507
test/exercises/exercise_provider_db_test.dart
Normal file
@@ -0,0 +1,507 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:wger/database/exercises/exercise_database.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/helpers/misc.dart';
|
||||
import 'package:wger/models/exercises/exercise_api.dart';
|
||||
import 'package:wger/models/exercises/muscle.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
|
||||
import '../../test_data/exercises.dart';
|
||||
import '../fixtures/fixture_reader.dart';
|
||||
import '../measurements/measurement_provider_test.mocks.dart';
|
||||
|
||||
void main() {
|
||||
late MockWgerBaseProvider mockBaseProvider;
|
||||
late ExercisesProvider provider;
|
||||
late ExerciseDatabase database;
|
||||
|
||||
const String categoryUrl = 'exercisecategory';
|
||||
const String exerciseBaseInfoUrl = 'exercisebaseinfo';
|
||||
const String muscleUrl = 'muscle';
|
||||
const String equipmentUrl = 'equipment';
|
||||
const String languageUrl = 'language';
|
||||
|
||||
final Uri tCategoryEntriesUri = Uri(
|
||||
scheme: 'http',
|
||||
host: 'localhost',
|
||||
path: 'api/v2/$categoryUrl/',
|
||||
);
|
||||
|
||||
final Uri tExerciseInfoUri = Uri(
|
||||
scheme: 'http',
|
||||
host: 'localhost',
|
||||
path: 'api/v2/$exerciseBaseInfoUrl/',
|
||||
);
|
||||
|
||||
final Uri tExerciseInfoDetailUri = Uri(
|
||||
scheme: 'http',
|
||||
host: 'localhost',
|
||||
path: 'api/v2/$exerciseBaseInfoUrl/9/',
|
||||
);
|
||||
|
||||
final Uri tMuscleEntriesUri = Uri(
|
||||
scheme: 'http',
|
||||
host: 'localhost',
|
||||
path: 'api/v2/$muscleUrl/',
|
||||
);
|
||||
|
||||
final Uri tEquipmentEntriesUri = Uri(
|
||||
scheme: 'http',
|
||||
host: 'localhost',
|
||||
path: 'api/v2/$equipmentUrl/',
|
||||
);
|
||||
|
||||
final Uri tLanguageEntriesUri = Uri(
|
||||
scheme: 'http',
|
||||
host: 'localhost',
|
||||
path: 'api/v2/$languageUrl/',
|
||||
);
|
||||
|
||||
const muscle1 = Muscle(id: 1, name: 'Biceps brachii', nameEn: 'Biceps', isFront: true);
|
||||
const muscle2 = Muscle(id: 2, name: 'Anterior deltoid', nameEn: 'Biceps', isFront: true);
|
||||
const muscle3 = Muscle(id: 4, name: 'Biceps femoris', nameEn: 'Hamstrings', isFront: false);
|
||||
|
||||
final Map<String, dynamic> tCategoryMap = jsonDecode(
|
||||
fixture('exercises/category_entries.json'),
|
||||
);
|
||||
final Map<String, dynamic> tMuscleMap = jsonDecode(
|
||||
fixture('exercises/muscles_entries.json'),
|
||||
);
|
||||
final Map<String, dynamic> tEquipmentMap = jsonDecode(
|
||||
fixture('exercises/equipment_entries.json'),
|
||||
);
|
||||
final Map<String, dynamic> tLanguageMap = jsonDecode(
|
||||
fixture('exercises/language_entries.json'),
|
||||
);
|
||||
final Map<String, dynamic> tExerciseBaseInfoMap = jsonDecode(
|
||||
fixture('exercises/exercisebaseinfo_response.json'),
|
||||
);
|
||||
|
||||
setUp(() {
|
||||
mockBaseProvider = MockWgerBaseProvider();
|
||||
provider = ExercisesProvider(
|
||||
mockBaseProvider,
|
||||
database: ExerciseDatabase.inMemory(NativeDatabase.memory()),
|
||||
);
|
||||
database = ExerciseDatabase.inMemory(NativeDatabase.memory());
|
||||
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
|
||||
// Mock categories
|
||||
when(mockBaseProvider.makeUrl(categoryUrl)).thenReturn(tCategoryEntriesUri);
|
||||
when(mockBaseProvider.fetchPaginated(tCategoryEntriesUri))
|
||||
.thenAnswer((_) => Future.value(tCategoryMap['results']));
|
||||
|
||||
// Mock muscles
|
||||
when(mockBaseProvider.makeUrl(muscleUrl)).thenReturn(tMuscleEntriesUri);
|
||||
when(mockBaseProvider.fetchPaginated(tMuscleEntriesUri))
|
||||
.thenAnswer((_) => Future.value(tMuscleMap['results']));
|
||||
|
||||
// Mock equipment
|
||||
when(mockBaseProvider.makeUrl(equipmentUrl)).thenReturn(tEquipmentEntriesUri);
|
||||
when(mockBaseProvider.fetchPaginated(tEquipmentEntriesUri))
|
||||
.thenAnswer((_) => Future.value(tEquipmentMap['results']));
|
||||
|
||||
// Mock languages
|
||||
when(mockBaseProvider.makeUrl(languageUrl, query: anyNamed('query')))
|
||||
.thenReturn(tLanguageEntriesUri);
|
||||
when(mockBaseProvider.fetchPaginated(tLanguageEntriesUri)).thenAnswer(
|
||||
(_) => Future.value(tLanguageMap['results']),
|
||||
);
|
||||
|
||||
// Mock base info response
|
||||
when(mockBaseProvider.makeUrl(exerciseBaseInfoUrl)).thenReturn(tExerciseInfoUri);
|
||||
when(mockBaseProvider.fetch(tExerciseInfoUri)).thenAnswer(
|
||||
(_) => Future.value(tExerciseBaseInfoMap),
|
||||
);
|
||||
|
||||
when(mockBaseProvider.makeUrl(exerciseBaseInfoUrl, id: 9)).thenReturn(tExerciseInfoDetailUri);
|
||||
when(mockBaseProvider.fetch(tExerciseInfoDetailUri)).thenAnswer(
|
||||
(_) => Future.value(tExerciseBaseInfoMap),
|
||||
);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await database.close();
|
||||
});
|
||||
|
||||
group('Muscles', () {
|
||||
test('that fetched data from the API is written to the DB', () async {
|
||||
// Arrange
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await provider.initCacheTimesLocalPrefs();
|
||||
|
||||
// Act
|
||||
await provider.fetchAndSetMuscles(database);
|
||||
|
||||
// Assert
|
||||
final updateTime = DateTime.parse(prefs.getString(PREFS_LAST_UPDATED_MUSCLES)!);
|
||||
final valid = DateTime.now().add(const Duration(days: ExercisesProvider.EXERCISE_CACHE_DAYS));
|
||||
expect(updateTime.isSameDayAs(valid), true);
|
||||
|
||||
final muscles = await database.select(database.muscles).get();
|
||||
|
||||
verify(mockBaseProvider.fetchPaginated(any));
|
||||
|
||||
expect(muscles[0].id, 2);
|
||||
expect(muscles[0].data, muscle2);
|
||||
|
||||
expect(muscles[1].id, 1);
|
||||
expect(muscles[1].data, muscle1);
|
||||
|
||||
expect(muscles[2].id, 4);
|
||||
expect(muscles[2].data, muscle3);
|
||||
|
||||
expect(provider.muscles.length, 3);
|
||||
expect(provider.muscles[0], muscle2);
|
||||
expect(provider.muscles[1], muscle1);
|
||||
expect(provider.muscles[2], muscle3);
|
||||
});
|
||||
|
||||
test('that if there is already valid data in the DB, the API is not hit', () async {
|
||||
// Arrange
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await provider.initCacheTimesLocalPrefs();
|
||||
|
||||
final valid = DateTime.now().add(const Duration(days: 1));
|
||||
prefs.setString(PREFS_LAST_UPDATED_MUSCLES, valid.toIso8601String());
|
||||
|
||||
await database
|
||||
.into(database.muscles)
|
||||
.insert(MusclesCompanion.insert(id: muscle1.id, data: muscle1));
|
||||
await database
|
||||
.into(database.muscles)
|
||||
.insert(MusclesCompanion.insert(id: muscle2.id, data: muscle2));
|
||||
|
||||
// Act
|
||||
await provider.fetchAndSetMuscles(database);
|
||||
|
||||
// Assert
|
||||
final updateTime = DateTime.parse(prefs.getString(PREFS_LAST_UPDATED_MUSCLES)!);
|
||||
expect(updateTime.isSameDayAs(valid), true);
|
||||
|
||||
expect(provider.muscles.length, 2);
|
||||
expect(provider.muscles[0], muscle1);
|
||||
expect(provider.muscles[1], muscle2);
|
||||
|
||||
verifyNever(mockBaseProvider.fetchPaginated(any));
|
||||
});
|
||||
});
|
||||
|
||||
group('Languages', () {
|
||||
test('that fetched data from the API is written to the DB', () async {
|
||||
// Arrange
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await provider.initCacheTimesLocalPrefs();
|
||||
|
||||
// Act
|
||||
await provider.fetchAndSetLanguages(database);
|
||||
|
||||
// Assert
|
||||
final updateTime = DateTime.parse(prefs.getString(PREFS_LAST_UPDATED_LANGUAGES)!);
|
||||
final valid = DateTime.now().add(const Duration(days: ExercisesProvider.EXERCISE_CACHE_DAYS));
|
||||
expect(updateTime.isSameDayAs(valid), true);
|
||||
|
||||
final languages = await database.select(database.languages).get();
|
||||
|
||||
verify(mockBaseProvider.fetchPaginated(any));
|
||||
|
||||
expect(languages[0].id, tLanguage1.id);
|
||||
expect(languages[0].data, tLanguage1);
|
||||
|
||||
expect(languages[1].id, tLanguage2.id);
|
||||
expect(languages[1].data, tLanguage2);
|
||||
|
||||
expect(languages[2].id, tLanguage4.id);
|
||||
expect(languages[2].data, tLanguage4);
|
||||
|
||||
expect(languages[3].id, tLanguage3.id);
|
||||
expect(languages[3].data, tLanguage3);
|
||||
|
||||
expect(provider.languages.length, 5);
|
||||
expect(provider.languages[0], tLanguage1);
|
||||
expect(provider.languages[1], tLanguage2);
|
||||
expect(provider.languages[2], tLanguage4);
|
||||
expect(provider.languages[3], tLanguage3);
|
||||
});
|
||||
|
||||
test('that if there is already valid data in the DB, the API is not hit', () async {
|
||||
// Arrange
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await provider.initCacheTimesLocalPrefs();
|
||||
|
||||
final valid = DateTime.now().add(const Duration(days: 1));
|
||||
prefs.setString(PREFS_LAST_UPDATED_LANGUAGES, valid.toIso8601String());
|
||||
|
||||
await database
|
||||
.into(database.languages)
|
||||
.insert(LanguagesCompanion.insert(id: tLanguage1.id, data: tLanguage1));
|
||||
await database
|
||||
.into(database.languages)
|
||||
.insert(LanguagesCompanion.insert(id: tLanguage2.id, data: tLanguage2));
|
||||
|
||||
// Act
|
||||
await provider.fetchAndSetLanguages(database);
|
||||
|
||||
// Assert
|
||||
final updateTime = DateTime.parse(prefs.getString(PREFS_LAST_UPDATED_LANGUAGES)!);
|
||||
expect(updateTime.isSameDayAs(valid), true);
|
||||
|
||||
expect(provider.languages.length, 2);
|
||||
expect(provider.languages[0], tLanguage1);
|
||||
expect(provider.languages[1], tLanguage2);
|
||||
|
||||
verifyNever(mockBaseProvider.fetchPaginated(any));
|
||||
});
|
||||
});
|
||||
group('Categories', () {
|
||||
test('that fetched data from the API is written to the DB', () async {
|
||||
// Arrange
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await provider.initCacheTimesLocalPrefs();
|
||||
|
||||
// Act
|
||||
await provider.fetchAndSetCategories(database);
|
||||
|
||||
// Assert
|
||||
final updateTime = DateTime.parse(prefs.getString(PREFS_LAST_UPDATED_CATEGORIES)!);
|
||||
final valid = DateTime.now().add(const Duration(days: ExercisesProvider.EXERCISE_CACHE_DAYS));
|
||||
expect(updateTime.isSameDayAs(valid), true);
|
||||
|
||||
final categories = await database.select(database.categories).get();
|
||||
|
||||
verify(mockBaseProvider.fetchPaginated(any));
|
||||
|
||||
expect(categories[0].id, tCategory1.id);
|
||||
expect(categories[0].data, tCategory1);
|
||||
|
||||
expect(categories[1].id, tCategory2.id);
|
||||
expect(categories[1].data, tCategory2);
|
||||
|
||||
expect(provider.categories.length, 2);
|
||||
expect(provider.categories[0], tCategory1);
|
||||
expect(provider.categories[1], tCategory2);
|
||||
});
|
||||
|
||||
test('that if there is already valid data in the DB, the API is not hit', () async {
|
||||
// Arrange
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await provider.initCacheTimesLocalPrefs();
|
||||
|
||||
final valid = DateTime.now().add(const Duration(days: 1));
|
||||
prefs.setString(PREFS_LAST_UPDATED_CATEGORIES, valid.toIso8601String());
|
||||
|
||||
await database
|
||||
.into(database.categories)
|
||||
.insert(CategoriesCompanion.insert(id: tCategory1.id, data: tCategory1));
|
||||
await database
|
||||
.into(database.categories)
|
||||
.insert(CategoriesCompanion.insert(id: tCategory2.id, data: tCategory2));
|
||||
|
||||
// Act
|
||||
await provider.fetchAndSetCategories(database);
|
||||
|
||||
// Assert
|
||||
final updateTime = DateTime.parse(prefs.getString(PREFS_LAST_UPDATED_CATEGORIES)!);
|
||||
expect(updateTime.isSameDayAs(valid), true);
|
||||
|
||||
expect(provider.categories.length, 2);
|
||||
expect(provider.categories[0], tCategory1);
|
||||
expect(provider.categories[1], tCategory2);
|
||||
|
||||
verifyNever(mockBaseProvider.fetchPaginated(any));
|
||||
});
|
||||
});
|
||||
|
||||
group('Equipment', () {
|
||||
test('that fetched data from the API is written to the DB', () async {
|
||||
// Arrange
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await provider.initCacheTimesLocalPrefs();
|
||||
|
||||
// Act
|
||||
await provider.fetchAndSetEquipments(database);
|
||||
|
||||
// Assert
|
||||
final updateTime = DateTime.parse(prefs.getString(PREFS_LAST_UPDATED_EQUIPMENT)!);
|
||||
final valid = DateTime.now().add(const Duration(days: ExercisesProvider.EXERCISE_CACHE_DAYS));
|
||||
expect(updateTime.isSameDayAs(valid), true);
|
||||
|
||||
final equipmentList = await database.select(database.equipments).get();
|
||||
|
||||
verify(mockBaseProvider.fetchPaginated(any));
|
||||
|
||||
expect(equipmentList[0].id, tEquipment1.id);
|
||||
expect(equipmentList[0].data, tEquipment1);
|
||||
|
||||
expect(equipmentList[1].id, tEquipment2.id);
|
||||
expect(equipmentList[1].data, tEquipment2);
|
||||
|
||||
expect(provider.equipment.length, 4);
|
||||
expect(provider.equipment[0], tEquipment1);
|
||||
expect(provider.equipment[1], tEquipment2);
|
||||
expect(provider.equipment[2], tEquipment3);
|
||||
expect(provider.equipment[3], tEquipment4);
|
||||
});
|
||||
|
||||
test('that if there is already valid data in the DB, the API is not hit', () async {
|
||||
// Arrange
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await provider.initCacheTimesLocalPrefs();
|
||||
|
||||
final valid = DateTime.now().add(const Duration(days: 1));
|
||||
prefs.setString(PREFS_LAST_UPDATED_EQUIPMENT, valid.toIso8601String());
|
||||
|
||||
await database
|
||||
.into(database.equipments)
|
||||
.insert(EquipmentsCompanion.insert(id: tEquipment1.id, data: tEquipment1));
|
||||
await database
|
||||
.into(database.equipments)
|
||||
.insert(EquipmentsCompanion.insert(id: tCategory2.id, data: tEquipment2));
|
||||
|
||||
// Act
|
||||
await provider.fetchAndSetEquipments(database);
|
||||
|
||||
// Assert
|
||||
final updateTime = DateTime.parse(prefs.getString(PREFS_LAST_UPDATED_EQUIPMENT)!);
|
||||
expect(updateTime.isSameDayAs(valid), true);
|
||||
|
||||
expect(provider.equipment.length, 2);
|
||||
expect(provider.equipment[0], tEquipment1);
|
||||
expect(provider.equipment[1], tEquipment2);
|
||||
|
||||
verifyNever(mockBaseProvider.fetchPaginated(any));
|
||||
});
|
||||
});
|
||||
|
||||
group('Exercises', () {
|
||||
test('that if there is already valid data in the DB, the API is not hit', () async {
|
||||
// Arrange
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await provider.initCacheTimesLocalPrefs();
|
||||
final valid = DateTime.now().add(const Duration(days: 1));
|
||||
prefs.setString(PREFS_LAST_UPDATED_LANGUAGES, valid.toIso8601String());
|
||||
|
||||
await database.into(database.exercises).insert(
|
||||
ExercisesCompanion.insert(
|
||||
id: tExerciseBaseInfoMap['id'],
|
||||
data: json.encode(tExerciseBaseInfoMap),
|
||||
lastUpdate: DateTime.parse(tExerciseBaseInfoMap['last_update_global']),
|
||||
lastFetched: DateTime.now(),
|
||||
),
|
||||
);
|
||||
await database
|
||||
.into(database.languages)
|
||||
.insert(LanguagesCompanion.insert(id: tLanguage1.id, data: tLanguage1));
|
||||
await database
|
||||
.into(database.languages)
|
||||
.insert(LanguagesCompanion.insert(id: tLanguage2.id, data: tLanguage2));
|
||||
await database
|
||||
.into(database.languages)
|
||||
.insert(LanguagesCompanion.insert(id: tLanguage3.id, data: tLanguage3));
|
||||
|
||||
// Act
|
||||
await provider.fetchAndSetLanguages(database);
|
||||
await provider.setExercisesFromDatabase(database);
|
||||
|
||||
// Assert
|
||||
expect(provider.exercises.length, 1);
|
||||
expect(provider.exercises.first.id, 9);
|
||||
expect(provider.exercises.first.uuid, '1b020b3a-3732-4c7e-92fd-a0cec90ed69b');
|
||||
verifyNever(mockBaseProvider.fetchPaginated(any));
|
||||
});
|
||||
|
||||
test('fetching a known exercise - no API refresh', () async {
|
||||
// Arrange
|
||||
provider.languages = testLanguages;
|
||||
await database.into(database.exercises).insert(
|
||||
ExercisesCompanion.insert(
|
||||
id: tExerciseBaseInfoMap['id'],
|
||||
data: json.encode(tExerciseBaseInfoMap),
|
||||
lastUpdate: DateTime.parse(tExerciseBaseInfoMap['last_update_global']),
|
||||
lastFetched: DateTime.now().subtract(const Duration(hours: 1)),
|
||||
),
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(provider.exercises.length, 0);
|
||||
|
||||
// Act
|
||||
await provider.handleUpdateExerciseFromApi(database, 9);
|
||||
|
||||
// Assert
|
||||
expect(provider.exercises.length, 1);
|
||||
expect(provider.exercises.first.id, 9);
|
||||
expect(provider.exercises.first.uuid, '1b020b3a-3732-4c7e-92fd-a0cec90ed69b');
|
||||
verifyNever(mockBaseProvider.fetch(any));
|
||||
});
|
||||
|
||||
test('fetching a known exercise - needed API refresh - no new data', () async {
|
||||
// Arrange
|
||||
provider.languages = testLanguages;
|
||||
await database.into(database.exercises).insert(
|
||||
ExercisesCompanion.insert(
|
||||
id: tExerciseBaseInfoMap['id'],
|
||||
data: json.encode(tExerciseBaseInfoMap),
|
||||
lastUpdate: DateTime.parse(tExerciseBaseInfoMap['last_update_global']),
|
||||
lastFetched: DateTime.now().subtract(const Duration(days: 10)),
|
||||
),
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(provider.exercises.length, 0);
|
||||
|
||||
// Act
|
||||
await provider.handleUpdateExerciseFromApi(database, 9);
|
||||
final exerciseDb = await (database.select(database.exercises)..where((e) => e.id.equals(9)))
|
||||
.getSingleOrNull();
|
||||
|
||||
// Assert
|
||||
verify(mockBaseProvider.fetch(any));
|
||||
expect(provider.exercises.length, 1);
|
||||
expect(provider.exercises.first.id, 9);
|
||||
expect(provider.exercises.first.uuid, '1b020b3a-3732-4c7e-92fd-a0cec90ed69b');
|
||||
expect(exerciseDb!.lastFetched.isSameDayAs(DateTime.now()), true);
|
||||
});
|
||||
|
||||
test('fetching a known exercise - needed API refresh - new data from API', () async {
|
||||
// Arrange
|
||||
provider.languages = testLanguages;
|
||||
final newData = Map.from(tExerciseBaseInfoMap);
|
||||
newData['uuid'] = 'bf6d5557-1c49-48fd-922e-75d11f81d4eb';
|
||||
|
||||
await database.into(database.exercises).insert(
|
||||
ExercisesCompanion.insert(
|
||||
id: newData['id'],
|
||||
data: json.encode(newData),
|
||||
lastUpdate: DateTime(2023, 1, 1),
|
||||
lastFetched: DateTime.now().subtract(const Duration(days: 10)),
|
||||
),
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(provider.exercises.length, 0);
|
||||
|
||||
// Act
|
||||
await provider.handleUpdateExerciseFromApi(database, 9);
|
||||
final exerciseDb = await (database.select(database.exercises)..where((e) => e.id.equals(9)))
|
||||
.getSingleOrNull();
|
||||
final exerciseData = ExerciseApiData.fromString(exerciseDb!.data);
|
||||
|
||||
// Assert
|
||||
verify(mockBaseProvider.fetch(any));
|
||||
expect(provider.exercises.length, 1);
|
||||
expect(provider.exercises.first.id, 9);
|
||||
expect(provider.exercises.first.uuid, '1b020b3a-3732-4c7e-92fd-a0cec90ed69b');
|
||||
expect(exerciseDb.lastFetched.isSameDayAs(DateTime.now()), true);
|
||||
expect(exerciseData.uuid, '1b020b3a-3732-4c7e-92fd-a0cec90ed69b');
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:wger/core/locator.dart';
|
||||
import 'package:wger/database/exercises/exercise_database.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
|
||||
import '../../test_data/exercises.dart';
|
||||
@@ -20,37 +26,60 @@ void main() {
|
||||
path: 'api/v2/$exerciseBaseInfoUrl/9/',
|
||||
);
|
||||
|
||||
final Map<String, dynamic> tExerciseBaseInfoMap = jsonDecode(
|
||||
final Uri tExerciseBaseInfoUri2 = Uri(
|
||||
scheme: 'http',
|
||||
host: 'localhost',
|
||||
path: 'api/v2/$exerciseBaseInfoUrl/1/',
|
||||
);
|
||||
|
||||
final Map<String, dynamic> tExerciseInfoMap = jsonDecode(
|
||||
fixture('exercises/exercisebaseinfo_response.json'),
|
||||
);
|
||||
|
||||
setUp(() {
|
||||
setUpAll(() async {
|
||||
// Needs to be configured here, setUp runs on every test, setUpAll only once
|
||||
await ServiceLocator().configure();
|
||||
});
|
||||
|
||||
setUp(() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
driftRuntimeOptions.dontWarnAboutMultipleDatabases = true;
|
||||
|
||||
mockBaseProvider = MockWgerBaseProvider();
|
||||
provider = ExercisesProvider(mockBaseProvider);
|
||||
provider.exerciseBases = getTestExerciseBases();
|
||||
provider = ExercisesProvider(
|
||||
mockBaseProvider,
|
||||
database: ExerciseDatabase.inMemory(NativeDatabase.memory()),
|
||||
);
|
||||
provider.exercises = getTestExerciseBases();
|
||||
provider.languages = [tLanguage1, tLanguage2, tLanguage3];
|
||||
|
||||
// Mock base info response
|
||||
when(
|
||||
mockBaseProvider.makeUrl(exerciseBaseInfoUrl, id: 9),
|
||||
).thenReturn(tExerciseBaseInfoUri);
|
||||
when(
|
||||
mockBaseProvider.makeUrl(exerciseBaseInfoUrl, id: 1),
|
||||
).thenReturn(tExerciseBaseInfoUri2);
|
||||
|
||||
when(mockBaseProvider.fetch(tExerciseBaseInfoUri))
|
||||
.thenAnswer((_) => Future.value(tExerciseBaseInfoMap));
|
||||
.thenAnswer((_) => Future.value(tExerciseInfoMap));
|
||||
when(mockBaseProvider.fetch(tExerciseBaseInfoUri2))
|
||||
.thenAnswer((_) => Future.value(tExerciseInfoMap));
|
||||
});
|
||||
|
||||
group('Correctly loads and parses data from the server', () {
|
||||
test('test that fetchAndSetExerciseBase finds an existing base', () async {
|
||||
// arrange and act
|
||||
final base = await provider.fetchAndSetExerciseBase(1);
|
||||
final base = await provider.fetchAndSetExercise(1);
|
||||
|
||||
// assert
|
||||
verifyNever(provider.baseProvider.fetch(tExerciseBaseInfoUri));
|
||||
verifyNever(provider.baseProvider.fetch(tExerciseBaseInfoUri2));
|
||||
expect(base.id, 1);
|
||||
});
|
||||
|
||||
test('test that fetchAndSetExerciseBase fetches a new base', () async {
|
||||
// arrange and act
|
||||
final base = await provider.fetchAndSetExerciseBase(9);
|
||||
final base = await provider.fetchAndSetExercise(9);
|
||||
|
||||
// assert
|
||||
verify(provider.baseProvider.fetch(tExerciseBaseInfoUri));
|
||||
@@ -61,40 +90,44 @@ void main() {
|
||||
// arrange
|
||||
|
||||
// arrange and act
|
||||
final base = provider.readExerciseBaseFromBaseInfo(tExerciseBaseInfoMap);
|
||||
final exercise = Exercise.fromApiDataJson(
|
||||
tExerciseInfoMap,
|
||||
const [tLanguage1, tLanguage2, tLanguage3],
|
||||
);
|
||||
|
||||
// assert
|
||||
expect(base.id, 9);
|
||||
expect(base.uuid, '1b020b3a-3732-4c7e-92fd-a0cec90ed69b');
|
||||
expect(base.categoryId, 10);
|
||||
expect(base.equipment.map((e) => e.name), ['Kettlebell']);
|
||||
expect(base.muscles.map((e) => e.name), [
|
||||
expect(exercise.id, 9);
|
||||
expect(exercise.uuid, '1b020b3a-3732-4c7e-92fd-a0cec90ed69b');
|
||||
expect(exercise.categoryId, 10);
|
||||
expect(exercise.equipment.map((e) => e.name), ['Kettlebell']);
|
||||
expect(exercise.muscles.map((e) => e.name), [
|
||||
'Biceps femoris',
|
||||
'Brachialis',
|
||||
'Obliquus externus abdominis',
|
||||
]);
|
||||
expect(base.musclesSecondary.map((e) => e.name), [
|
||||
'Anterior deltoid',
|
||||
'Trapezius',
|
||||
expect(exercise.musclesSecondary.map((e) => e.name), [
|
||||
'Biceps femoris',
|
||||
'Brachialis',
|
||||
'Obliquus externus abdominis',
|
||||
]);
|
||||
expect(base.images.map((e) => e.uuid), [
|
||||
expect(exercise.images.map((e) => e.uuid), [
|
||||
'1f5d2b2f-d4ea-4eeb-9377-56176465e08d',
|
||||
'ab645585-26ef-4992-a9ec-15425687ece9',
|
||||
'd8aa5990-bb47-4111-9823-e2fbd98fe07f',
|
||||
'49a159e1-1e00-409a-81c9-b4d4489fbd67'
|
||||
]);
|
||||
expect(base.videos.map((v) => v.uuid), ['63e996e9-a772-4ca5-9d09-8b4be03f6be4']);
|
||||
expect(exercise.videos.map((v) => v.uuid), ['63e996e9-a772-4ca5-9d09-8b4be03f6be4']);
|
||||
|
||||
final exercise1 = base.translations[0];
|
||||
expect(exercise1.name, '2 Handed Kettlebell Swing');
|
||||
expect(exercise1.languageObj.shortName, 'en');
|
||||
expect(exercise1.notes[0].comment, "it's important to do the exercise correctly");
|
||||
expect(exercise1.notes[1].comment, 'put a lot of effort into this exercise');
|
||||
expect(exercise1.notes[2].comment, 'have fun');
|
||||
expect(exercise1.alias[0].alias, 'double handed kettlebell');
|
||||
expect(exercise1.alias[1].alias, 'Kettlebell russian style');
|
||||
expect(base.translations[1].name, 'Kettlebell Con Dos Manos');
|
||||
expect(base.translations[2].name, 'Zweihändiges Kettlebell');
|
||||
final translation1 = exercise.translations[0];
|
||||
expect(translation1.name, '2 Handed Kettlebell Swing');
|
||||
expect(translation1.languageObj.shortName, 'en');
|
||||
expect(translation1.notes[0].comment, "it's important to do the exercise correctly");
|
||||
expect(translation1.notes[1].comment, 'put a lot of effort into this exercise');
|
||||
expect(translation1.notes[2].comment, 'have fun');
|
||||
expect(translation1.aliases[0].alias, 'double handed kettlebell');
|
||||
expect(translation1.aliases[1].alias, 'Kettlebell russian style');
|
||||
expect(exercise.translations[1].name, 'Kettlebell Con Dos Manos');
|
||||
expect(exercise.translations[2].name, 'Zweihändiges Kettlebell');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:wger/database/exercises/exercise_database.dart';
|
||||
import 'package:wger/exceptions/no_such_entry_exception.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/models/exercises/category.dart';
|
||||
import 'package:wger/models/exercises/equipment.dart';
|
||||
import 'package:wger/models/exercises/language.dart';
|
||||
import 'package:wger/models/exercises/muscle.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
|
||||
import '../../test_data/exercises.dart' as data;
|
||||
import '../../test_data/exercises.dart';
|
||||
import '../fixtures/fixture_reader.dart';
|
||||
import '../measurements/measurement_provider_test.mocks.dart';
|
||||
|
||||
@@ -31,10 +35,10 @@ void main() {
|
||||
path: 'api/v2/$categoryUrl/',
|
||||
);
|
||||
|
||||
final Uri texerciseBaseInfoUri = Uri(
|
||||
final Uri tExerciseInfoUri = Uri(
|
||||
scheme: 'http',
|
||||
host: 'localhost',
|
||||
path: 'api/v2/$exerciseBaseInfoUrl/',
|
||||
path: 'api/v2/$exerciseBaseInfoUrl/1/',
|
||||
);
|
||||
|
||||
final Uri tMuscleEntriesUri = Uri(
|
||||
@@ -63,8 +67,6 @@ void main() {
|
||||
|
||||
const category1 = ExerciseCategory(id: 1, name: 'Arms');
|
||||
const muscle1 = Muscle(id: 1, name: 'Biceps brachii', nameEn: 'Biceps', isFront: true);
|
||||
const equipment1 = Equipment(id: 1, name: 'Barbell');
|
||||
const language1 = Language(id: 1, shortName: 'de', fullName: 'Deutsch');
|
||||
|
||||
final Map<String, dynamic> tCategoryMap = jsonDecode(
|
||||
fixture('exercises/category_entries.json'),
|
||||
@@ -82,9 +84,21 @@ void main() {
|
||||
fixture('exercises/exercisebaseinfo_response.json'),
|
||||
);
|
||||
|
||||
setUpAll(() async {
|
||||
// Needs to be configured here, setUp runs on every test, setUpAll only once
|
||||
//await ServiceLocator().configure();
|
||||
});
|
||||
|
||||
setUp(() {
|
||||
mockBaseProvider = MockWgerBaseProvider();
|
||||
provider = ExercisesProvider(mockBaseProvider);
|
||||
provider = ExercisesProvider(
|
||||
mockBaseProvider,
|
||||
database: ExerciseDatabase.inMemory(NativeDatabase.memory()),
|
||||
);
|
||||
provider.languages = [...testLanguages];
|
||||
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
driftRuntimeOptions.dontWarnAboutMultipleDatabases = true;
|
||||
|
||||
// Mock categories
|
||||
when(mockBaseProvider.makeUrl(categoryUrl)).thenReturn(tCategoryEntriesUri);
|
||||
@@ -108,15 +122,16 @@ void main() {
|
||||
.thenAnswer((_) => Future.value(tLanguageMap['results']));
|
||||
|
||||
// Mock base info response
|
||||
when(mockBaseProvider.makeUrl(exerciseBaseInfoUrl)).thenReturn(texerciseBaseInfoUri);
|
||||
when(mockBaseProvider.fetch(texerciseBaseInfoUri))
|
||||
when(mockBaseProvider.makeUrl(exerciseBaseInfoUrl, id: 1)).thenReturn(tExerciseInfoUri);
|
||||
when(mockBaseProvider.makeUrl(exerciseBaseInfoUrl, id: 2)).thenReturn(tExerciseInfoUri);
|
||||
when(mockBaseProvider.fetch(tExerciseInfoUri))
|
||||
.thenAnswer((_) => Future.value(tExerciseBaseInfoMap));
|
||||
});
|
||||
|
||||
group('findCategoryById()', () {
|
||||
test('should return a category for an id', () async {
|
||||
// arrange
|
||||
await provider.fetchAndSetCategories();
|
||||
await provider.fetchAndSetCategoriesFromApi();
|
||||
|
||||
// act
|
||||
final result = provider.findCategoryById(1);
|
||||
@@ -134,7 +149,7 @@ void main() {
|
||||
group('findMuscleById()', () {
|
||||
test('should return a muscle for an id', () async {
|
||||
// arrange
|
||||
await provider.fetchAndSetMuscles();
|
||||
await provider.fetchAndSetMusclesFromApi();
|
||||
|
||||
// act
|
||||
final result = provider.findMuscleById(1);
|
||||
@@ -152,13 +167,13 @@ void main() {
|
||||
group('findEquipmentById()', () {
|
||||
test('should return an equipment for an id', () async {
|
||||
// arrange
|
||||
await provider.fetchAndSetEquipment();
|
||||
await provider.fetchAndSetEquipmentsFromApi();
|
||||
|
||||
// act
|
||||
final result = provider.findEquipmentById(1);
|
||||
|
||||
// assert
|
||||
expect(result, equipment1);
|
||||
expect(result, tEquipment1);
|
||||
});
|
||||
|
||||
test('should throw a NoResultException if no equipment is found', () {
|
||||
@@ -170,13 +185,13 @@ void main() {
|
||||
group('findLanguageById()', () {
|
||||
test('should return a language for an id', () async {
|
||||
// arrange
|
||||
await provider.fetchAndSetLanguages();
|
||||
await provider.fetchAndSetLanguagesFromApi();
|
||||
|
||||
// act
|
||||
final result = provider.findLanguageById(1);
|
||||
|
||||
// assert
|
||||
expect(result, language1);
|
||||
expect(result, tLanguage1);
|
||||
});
|
||||
|
||||
test('should throw a NoResultException if no equipment is found', () {
|
||||
@@ -195,7 +210,7 @@ void main() {
|
||||
|
||||
// assert
|
||||
verifyNever(provider.baseProvider.fetch(tSearchByNameUri));
|
||||
expect(provider.filteredExerciseBases, isEmpty);
|
||||
expect(provider.filteredExercises, isEmpty);
|
||||
});
|
||||
|
||||
group('Filters are not null', () {
|
||||
@@ -208,7 +223,7 @@ void main() {
|
||||
equipment: FilterCategory<Equipment>(title: 'Equipment', items: {}),
|
||||
);
|
||||
|
||||
provider.exerciseBases = data.getTestExerciseBases();
|
||||
provider.exercises = data.getTestExerciseBases();
|
||||
});
|
||||
|
||||
test('Nothing is selected with no search term', () async {
|
||||
@@ -222,7 +237,7 @@ void main() {
|
||||
verifyNever(provider.baseProvider.fetch(tSearchByNameUri));
|
||||
|
||||
expect(
|
||||
provider.filteredExerciseBases,
|
||||
provider.filteredExercises,
|
||||
data.getTestExerciseBases(),
|
||||
);
|
||||
});
|
||||
@@ -238,7 +253,7 @@ void main() {
|
||||
|
||||
// assert
|
||||
verifyNever(provider.baseProvider.fetch(tSearchByNameUri));
|
||||
expect(provider.filteredExerciseBases, [data.getTestExerciseBases()[0]]);
|
||||
expect(provider.filteredExercises, [data.getTestExerciseBases()[0]]);
|
||||
});
|
||||
|
||||
test('A muscle is selected with no search term. Should not find results', () async {
|
||||
@@ -252,7 +267,7 @@ void main() {
|
||||
|
||||
// assert
|
||||
verifyNever(provider.baseProvider.fetch(tSearchByNameUri));
|
||||
expect(provider.filteredExerciseBases, isEmpty);
|
||||
expect(provider.filteredExercises, isEmpty);
|
||||
});
|
||||
|
||||
test('An equipment is selected with no search term. Should find results', () async {
|
||||
@@ -266,7 +281,7 @@ void main() {
|
||||
|
||||
// assert
|
||||
verifyNever(provider.baseProvider.fetch(tSearchByNameUri));
|
||||
expect(provider.filteredExerciseBases, [data.getTestExerciseBases()[0]]);
|
||||
expect(provider.filteredExercises, [data.getTestExerciseBases()[0]]);
|
||||
});
|
||||
|
||||
test('An equipment is selected with no search term. Should not find results', () async {
|
||||
@@ -280,7 +295,7 @@ void main() {
|
||||
|
||||
// assert
|
||||
verifyNever(provider.baseProvider.fetch(tSearchByNameUri));
|
||||
expect(provider.filteredExerciseBases, isEmpty);
|
||||
expect(provider.filteredExercises, isEmpty);
|
||||
});
|
||||
|
||||
test('A muscle and equipment is selected and there is a match', () async {
|
||||
@@ -295,14 +310,14 @@ void main() {
|
||||
|
||||
// assert
|
||||
verifyNever(provider.baseProvider.fetch(tSearchByNameUri));
|
||||
expect(provider.filteredExerciseBases, [data.getTestExerciseBases()[1]]);
|
||||
expect(provider.filteredExercises, [data.getTestExerciseBases()[1]]);
|
||||
});
|
||||
|
||||
test('A muscle and equipment is selected but no match', () async {
|
||||
// arrange
|
||||
final Filters tFilters = filters.copyWith(
|
||||
exerciseCategories: filters.exerciseCategories.copyWith(items: {data.tCategory2: true}),
|
||||
equipment: filters.equipment.copyWith(items: {equipment1: true}),
|
||||
equipment: filters.equipment.copyWith(items: {tEquipment1: true}),
|
||||
);
|
||||
|
||||
// act
|
||||
@@ -310,7 +325,7 @@ void main() {
|
||||
|
||||
// assert
|
||||
verifyNever(provider.baseProvider.fetch(tSearchByNameUri));
|
||||
expect(provider.filteredExerciseBases, isEmpty);
|
||||
expect(provider.filteredExercises, isEmpty);
|
||||
});
|
||||
|
||||
group('Search term', () {
|
||||
@@ -349,7 +364,7 @@ void main() {
|
||||
// assert
|
||||
verify(provider.baseProvider.fetch(tSearchByNameUri)).called(1);
|
||||
expect(
|
||||
provider.filteredExerciseBases,
|
||||
provider.filteredExercises,
|
||||
[data.getTestExerciseBases()[0], data.getTestExerciseBases()[1]],
|
||||
);
|
||||
});
|
||||
@@ -365,9 +380,67 @@ void main() {
|
||||
|
||||
// assert
|
||||
verify(provider.baseProvider.fetch(tSearchByNameUri)).called(1);
|
||||
expect(provider.filteredExerciseBases, isEmpty);
|
||||
expect(provider.filteredExercises, isEmpty);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
group('local prefs', () {
|
||||
test('initCacheTimesLocalPrefs correctly initalises the cache values', () async {
|
||||
// arrange
|
||||
const initValue = '2023-01-01T00:00:00.000';
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
// act
|
||||
await provider.initCacheTimesLocalPrefs();
|
||||
|
||||
// assert
|
||||
expect(prefs.getString(PREFS_LAST_UPDATED_MUSCLES), initValue);
|
||||
expect(prefs.getString(PREFS_LAST_UPDATED_EQUIPMENT), initValue);
|
||||
expect(prefs.getString(PREFS_LAST_UPDATED_CATEGORIES), initValue);
|
||||
expect(prefs.getString(PREFS_LAST_UPDATED_LANGUAGES), initValue);
|
||||
});
|
||||
|
||||
test('calling initCacheTimesLocalPrefs again does nothing', () async {
|
||||
// arrange
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
const newValue = '2023-10-10T01:18:35.000';
|
||||
|
||||
// act
|
||||
await provider.initCacheTimesLocalPrefs();
|
||||
prefs.setString(PREFS_LAST_UPDATED_MUSCLES, newValue);
|
||||
prefs.setString(PREFS_LAST_UPDATED_EQUIPMENT, newValue);
|
||||
prefs.setString(PREFS_LAST_UPDATED_CATEGORIES, newValue);
|
||||
prefs.setString(PREFS_LAST_UPDATED_LANGUAGES, newValue);
|
||||
await provider.initCacheTimesLocalPrefs();
|
||||
|
||||
// Assert
|
||||
expect(prefs.getString(PREFS_LAST_UPDATED_MUSCLES), newValue);
|
||||
expect(prefs.getString(PREFS_LAST_UPDATED_EQUIPMENT), newValue);
|
||||
expect(prefs.getString(PREFS_LAST_UPDATED_CATEGORIES), newValue);
|
||||
expect(prefs.getString(PREFS_LAST_UPDATED_LANGUAGES), newValue);
|
||||
});
|
||||
|
||||
test('calling initCacheTimesLocalPrefs with forceInit replaces the date', () async {
|
||||
// arrange
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
const initValue = '2023-01-01T00:00:00.000';
|
||||
const newValue = '2023-10-10T01:18:35.000';
|
||||
|
||||
// act
|
||||
await provider.initCacheTimesLocalPrefs();
|
||||
prefs.setString(PREFS_LAST_UPDATED_MUSCLES, newValue);
|
||||
prefs.setString(PREFS_LAST_UPDATED_EQUIPMENT, newValue);
|
||||
prefs.setString(PREFS_LAST_UPDATED_CATEGORIES, newValue);
|
||||
prefs.setString(PREFS_LAST_UPDATED_LANGUAGES, newValue);
|
||||
await provider.initCacheTimesLocalPrefs(forceInit: true);
|
||||
|
||||
// Assert
|
||||
expect(prefs.getString(PREFS_LAST_UPDATED_MUSCLES), initValue);
|
||||
expect(prefs.getString(PREFS_LAST_UPDATED_EQUIPMENT), initValue);
|
||||
expect(prefs.getString(PREFS_LAST_UPDATED_CATEGORIES), initValue);
|
||||
expect(prefs.getString(PREFS_LAST_UPDATED_LANGUAGES), initValue);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
76
test/exercises/model_exercise_test.dart
Normal file
76
test/exercises/model_exercise_test.dart
Normal file
@@ -0,0 +1,76 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
|
||||
import '../../test_data/exercises.dart';
|
||||
import '../fixtures/fixture_reader.dart';
|
||||
|
||||
void main() {
|
||||
final Map<String, dynamic> tExerciseInfoMap = jsonDecode(
|
||||
fixture('exercises/exercisebaseinfo_response.json'),
|
||||
);
|
||||
|
||||
group('Model tests', () {
|
||||
test('test getExercise', () async {
|
||||
// arrange and act
|
||||
final base = getTestExerciseBases()[1];
|
||||
|
||||
// assert
|
||||
expect(base.getExercise('en').id, 5);
|
||||
expect(base.getExercise('en-UK').id, 5);
|
||||
expect(base.getExercise('de').id, 4);
|
||||
expect(base.getExercise('de-AT').id, 4);
|
||||
expect(base.getExercise('fr').id, 3);
|
||||
expect(base.getExercise('fr-FR').id, 3);
|
||||
expect(base.getExercise('pt').id, 5); // English again
|
||||
});
|
||||
|
||||
test('Load the readExerciseBaseFromBaseInfo parse method', () {
|
||||
// arrange
|
||||
|
||||
// arrange and act
|
||||
final exercise = Exercise.fromApiDataJson(
|
||||
tExerciseInfoMap,
|
||||
const [tLanguage1, tLanguage2, tLanguage3],
|
||||
);
|
||||
|
||||
// assert
|
||||
expect(exercise.id, 9);
|
||||
expect(exercise.uuid, '1b020b3a-3732-4c7e-92fd-a0cec90ed69b');
|
||||
expect(exercise.categoryId, 10);
|
||||
expect(exercise.variationId, 25);
|
||||
expect(exercise.authors, ["Foo Bar"]);
|
||||
expect(exercise.authorsGlobal, ["Foo Bar", "tester McTestface", "Mr. X"]);
|
||||
expect(exercise.equipment.map((e) => e.name), ['Kettlebell']);
|
||||
expect(exercise.muscles.map((e) => e.name), [
|
||||
'Biceps femoris',
|
||||
'Brachialis',
|
||||
'Obliquus externus abdominis',
|
||||
]);
|
||||
expect(exercise.musclesSecondary.map((e) => e.name), [
|
||||
'Biceps femoris',
|
||||
'Brachialis',
|
||||
'Obliquus externus abdominis',
|
||||
]);
|
||||
expect(exercise.images.map((e) => e.uuid), [
|
||||
'1f5d2b2f-d4ea-4eeb-9377-56176465e08d',
|
||||
'ab645585-26ef-4992-a9ec-15425687ece9',
|
||||
'd8aa5990-bb47-4111-9823-e2fbd98fe07f',
|
||||
'49a159e1-1e00-409a-81c9-b4d4489fbd67'
|
||||
]);
|
||||
expect(exercise.videos.map((v) => v.uuid), ['63e996e9-a772-4ca5-9d09-8b4be03f6be4']);
|
||||
|
||||
final translation1 = exercise.translations[0];
|
||||
expect(translation1.name, '2 Handed Kettlebell Swing');
|
||||
expect(translation1.languageObj.shortName, 'en');
|
||||
expect(translation1.notes[0].comment, "it's important to do the exercise correctly");
|
||||
expect(translation1.notes[1].comment, 'put a lot of effort into this exercise');
|
||||
expect(translation1.notes[2].comment, 'have fun');
|
||||
expect(translation1.aliases[0].alias, 'double handed kettlebell');
|
||||
expect(translation1.aliases[1].alias, 'Kettlebell russian style');
|
||||
expect(exercise.translations[1].name, 'Kettlebell Con Dos Manos');
|
||||
expect(exercise.translations[2].name, 'Zweihändiges Kettlebell');
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../test_data/exercises.dart';
|
||||
|
||||
void main() {
|
||||
group('Model tests', () {
|
||||
test('test getExercise', () async {
|
||||
// arrange and act
|
||||
final base = getTestExerciseBases()[1];
|
||||
|
||||
// assert
|
||||
expect(base.getExercise('en').id, 5);
|
||||
expect(base.getExercise('en-UK').id, 5);
|
||||
expect(base.getExercise('de').id, 4);
|
||||
expect(base.getExercise('de-AT').id, 4);
|
||||
expect(base.getExercise('fr').id, 3);
|
||||
expect(base.getExercise('fr-FR').id, 3);
|
||||
expect(base.getExercise('pt').id, 5); // English again
|
||||
});
|
||||
});
|
||||
}
|
||||
16
test/fixtures/exercises/category_entries.json
vendored
16
test/fixtures/exercises/category_entries.json
vendored
@@ -3,13 +3,13 @@
|
||||
"next": null,
|
||||
"previous": null,
|
||||
"results": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Arms"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Abs"
|
||||
}
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Arms"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Legs"
|
||||
}
|
||||
]
|
||||
}
|
||||
12
test/fixtures/exercises/equipment_entries.json
vendored
12
test/fixtures/exercises/equipment_entries.json
vendored
@@ -5,18 +5,18 @@
|
||||
"results": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Barbell"
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"name": "Bench"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"id": 2,
|
||||
"name": "Dumbbell"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"id": 3,
|
||||
"name": "Bench"
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"name": "Gym mat"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -158,7 +158,15 @@
|
||||
"created": "2015-08-03T18:22:54.909478+02:00",
|
||||
"language": 2,
|
||||
"license": 2,
|
||||
"license_author": "deusinvictus"
|
||||
"license_author": "deusinvictus",
|
||||
"license_title": "",
|
||||
"license_object_url": "",
|
||||
"license_author_url": "",
|
||||
"license_derivative_source_url": "",
|
||||
"author_history": [
|
||||
"deusinvictus",
|
||||
"Foo Bar"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 856,
|
||||
@@ -187,7 +195,14 @@
|
||||
"created": "2022-03-14T18:22:54.909478+02:00",
|
||||
"language": 3,
|
||||
"license": 2,
|
||||
"license_author": "tester McTestface"
|
||||
"license_author": "tester McTestface",
|
||||
"license_title": "",
|
||||
"license_object_url": "",
|
||||
"license_author_url": "",
|
||||
"license_derivative_source_url": "",
|
||||
"author_history": [
|
||||
"tester McTestface"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 855,
|
||||
@@ -205,9 +220,25 @@
|
||||
],
|
||||
"created": "2022-03-14T18:22:54.909478+02:00",
|
||||
"language": 1,
|
||||
"license": 2,
|
||||
"license_author": "tester McTestface"
|
||||
"license": 1,
|
||||
"license_title": "",
|
||||
"license_object_url": "",
|
||||
"license_author": "GrosseHund",
|
||||
"license_author_url": "",
|
||||
"license_derivative_source_url": "",
|
||||
"author_history": [
|
||||
"GrosseHund",
|
||||
"Wunschcoach"
|
||||
]
|
||||
}
|
||||
],
|
||||
"variations": 25
|
||||
"variations": 25,
|
||||
"author_history": [
|
||||
"Foo Bar"
|
||||
],
|
||||
"total_authors_history": [
|
||||
"Foo Bar",
|
||||
"tester McTestface",
|
||||
"Mr. X"
|
||||
]
|
||||
}
|
||||
@@ -14,19 +14,19 @@
|
||||
"full_name": "English"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"id": 12,
|
||||
"short_name": "es",
|
||||
"full_name": "Español"
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"id": 3,
|
||||
"short_name": "fr",
|
||||
"full_name": "Français"
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"short_name": "it",
|
||||
"full_name": "Italian"
|
||||
"full_name": "Italiano"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/gallery/gallery_form_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -17,6 +17,8 @@ import 'package:wger/providers/gallery.dart' as _i4;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/gallery/gallery_screen_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -17,6 +17,8 @@ import 'package:wger/providers/gallery.dart' as _i4;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/measurements/measurement_categories_screen_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -16,6 +16,8 @@ import 'package:wger/providers/measurement.dart' as _i4;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/measurements/measurement_provider_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -14,6 +14,8 @@ import 'package:wger/providers/base_provider.dart' as _i4;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/nutrition/nutritional_meal_form_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -18,6 +18,8 @@ import 'package:wger/providers/nutrition.dart' as _i7;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/nutrition/nutritional_plan_form_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -18,6 +18,8 @@ import 'package:wger/providers/nutrition.dart' as _i7;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/nutrition/nutritional_plan_screen_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i5;
|
||||
import 'dart:convert' as _i8;
|
||||
import 'dart:typed_data' as _i9;
|
||||
import 'dart:ui' as _i7;
|
||||
import 'dart:convert' as _i9;
|
||||
import 'dart:typed_data' as _i10;
|
||||
import 'dart:ui' as _i8;
|
||||
|
||||
import 'package:http/http.dart' as _i3;
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:mockito/src/dummies.dart' as _i7;
|
||||
import 'package:package_info_plus/package_info_plus.dart' as _i6;
|
||||
import 'package:wger/providers/auth.dart' as _i2;
|
||||
import 'package:wger/providers/base_provider.dart' as _i4;
|
||||
@@ -18,6 +19,8 @@ import 'package:wger/providers/base_provider.dart' as _i4;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
@@ -431,7 +434,13 @@ class MockAuthProvider extends _i1.Mock implements _i2.AuthProvider {
|
||||
#getServerUrlFromPrefs,
|
||||
[],
|
||||
),
|
||||
returnValue: _i5.Future<String>.value(''),
|
||||
returnValue: _i5.Future<String>.value(_i7.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#getServerUrlFromPrefs,
|
||||
[],
|
||||
),
|
||||
)),
|
||||
) as _i5.Future<String>);
|
||||
|
||||
@override
|
||||
@@ -460,11 +469,17 @@ class MockAuthProvider extends _i1.Mock implements _i2.AuthProvider {
|
||||
#getAppNameHeader,
|
||||
[],
|
||||
),
|
||||
returnValue: '',
|
||||
returnValue: _i7.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#getAppNameHeader,
|
||||
[],
|
||||
),
|
||||
),
|
||||
) as String);
|
||||
|
||||
@override
|
||||
void addListener(_i7.VoidCallback? listener) => super.noSuchMethod(
|
||||
void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addListener,
|
||||
[listener],
|
||||
@@ -473,7 +488,7 @@ class MockAuthProvider extends _i1.Mock implements _i2.AuthProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i7.VoidCallback? listener) => super.noSuchMethod(
|
||||
void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#removeListener,
|
||||
[listener],
|
||||
@@ -555,7 +570,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
|
||||
Uri? url, {
|
||||
Map<String, String>? headers,
|
||||
Object? body,
|
||||
_i8.Encoding? encoding,
|
||||
_i9.Encoding? encoding,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -586,7 +601,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
|
||||
Uri? url, {
|
||||
Map<String, String>? headers,
|
||||
Object? body,
|
||||
_i8.Encoding? encoding,
|
||||
_i9.Encoding? encoding,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -617,7 +632,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
|
||||
Uri? url, {
|
||||
Map<String, String>? headers,
|
||||
Object? body,
|
||||
_i8.Encoding? encoding,
|
||||
_i9.Encoding? encoding,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -648,7 +663,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
|
||||
Uri? url, {
|
||||
Map<String, String>? headers,
|
||||
Object? body,
|
||||
_i8.Encoding? encoding,
|
||||
_i9.Encoding? encoding,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -685,11 +700,18 @@ class MockClient extends _i1.Mock implements _i3.Client {
|
||||
[url],
|
||||
{#headers: headers},
|
||||
),
|
||||
returnValue: _i5.Future<String>.value(''),
|
||||
returnValue: _i5.Future<String>.value(_i7.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#read,
|
||||
[url],
|
||||
{#headers: headers},
|
||||
),
|
||||
)),
|
||||
) as _i5.Future<String>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i9.Uint8List> readBytes(
|
||||
_i5.Future<_i10.Uint8List> readBytes(
|
||||
Uri? url, {
|
||||
Map<String, String>? headers,
|
||||
}) =>
|
||||
@@ -699,8 +721,8 @@ class MockClient extends _i1.Mock implements _i3.Client {
|
||||
[url],
|
||||
{#headers: headers},
|
||||
),
|
||||
returnValue: _i5.Future<_i9.Uint8List>.value(_i9.Uint8List(0)),
|
||||
) as _i5.Future<_i9.Uint8List>);
|
||||
returnValue: _i5.Future<_i10.Uint8List>.value(_i10.Uint8List(0)),
|
||||
) as _i5.Future<_i10.Uint8List>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i3.StreamedResponse> send(_i3.BaseRequest? request) => (super.noSuchMethod(
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/nutrition/nutritional_plans_screen_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i5;
|
||||
import 'dart:convert' as _i8;
|
||||
import 'dart:typed_data' as _i9;
|
||||
import 'dart:ui' as _i6;
|
||||
import 'dart:convert' as _i9;
|
||||
import 'dart:typed_data' as _i10;
|
||||
import 'dart:ui' as _i7;
|
||||
|
||||
import 'package:http/http.dart' as _i2;
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:mockito/src/dummies.dart' as _i6;
|
||||
import 'package:package_info_plus/package_info_plus.dart' as _i4;
|
||||
import 'package:wger/providers/auth.dart' as _i3;
|
||||
import 'package:wger/providers/base_provider.dart' as _i7;
|
||||
import 'package:wger/providers/base_provider.dart' as _i8;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
@@ -270,7 +273,13 @@ class MockAuthProvider extends _i1.Mock implements _i3.AuthProvider {
|
||||
#getServerUrlFromPrefs,
|
||||
[],
|
||||
),
|
||||
returnValue: _i5.Future<String>.value(''),
|
||||
returnValue: _i5.Future<String>.value(_i6.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#getServerUrlFromPrefs,
|
||||
[],
|
||||
),
|
||||
)),
|
||||
) as _i5.Future<String>);
|
||||
|
||||
@override
|
||||
@@ -299,11 +308,17 @@ class MockAuthProvider extends _i1.Mock implements _i3.AuthProvider {
|
||||
#getAppNameHeader,
|
||||
[],
|
||||
),
|
||||
returnValue: '',
|
||||
returnValue: _i6.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#getAppNameHeader,
|
||||
[],
|
||||
),
|
||||
),
|
||||
) as String);
|
||||
|
||||
@override
|
||||
void addListener(_i6.VoidCallback? listener) => super.noSuchMethod(
|
||||
void addListener(_i7.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addListener,
|
||||
[listener],
|
||||
@@ -312,7 +327,7 @@ class MockAuthProvider extends _i1.Mock implements _i3.AuthProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i6.VoidCallback? listener) => super.noSuchMethod(
|
||||
void removeListener(_i7.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#removeListener,
|
||||
[listener],
|
||||
@@ -342,7 +357,7 @@ class MockAuthProvider extends _i1.Mock implements _i3.AuthProvider {
|
||||
/// A class which mocks [WgerBaseProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockWgerBaseProvider extends _i1.Mock implements _i7.WgerBaseProvider {
|
||||
class MockWgerBaseProvider extends _i1.Mock implements _i8.WgerBaseProvider {
|
||||
MockWgerBaseProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
@@ -555,7 +570,7 @@ class MockClient extends _i1.Mock implements _i2.Client {
|
||||
Uri? url, {
|
||||
Map<String, String>? headers,
|
||||
Object? body,
|
||||
_i8.Encoding? encoding,
|
||||
_i9.Encoding? encoding,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -586,7 +601,7 @@ class MockClient extends _i1.Mock implements _i2.Client {
|
||||
Uri? url, {
|
||||
Map<String, String>? headers,
|
||||
Object? body,
|
||||
_i8.Encoding? encoding,
|
||||
_i9.Encoding? encoding,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -617,7 +632,7 @@ class MockClient extends _i1.Mock implements _i2.Client {
|
||||
Uri? url, {
|
||||
Map<String, String>? headers,
|
||||
Object? body,
|
||||
_i8.Encoding? encoding,
|
||||
_i9.Encoding? encoding,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -648,7 +663,7 @@ class MockClient extends _i1.Mock implements _i2.Client {
|
||||
Uri? url, {
|
||||
Map<String, String>? headers,
|
||||
Object? body,
|
||||
_i8.Encoding? encoding,
|
||||
_i9.Encoding? encoding,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -685,11 +700,18 @@ class MockClient extends _i1.Mock implements _i2.Client {
|
||||
[url],
|
||||
{#headers: headers},
|
||||
),
|
||||
returnValue: _i5.Future<String>.value(''),
|
||||
returnValue: _i5.Future<String>.value(_i6.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#read,
|
||||
[url],
|
||||
{#headers: headers},
|
||||
),
|
||||
)),
|
||||
) as _i5.Future<String>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i9.Uint8List> readBytes(
|
||||
_i5.Future<_i10.Uint8List> readBytes(
|
||||
Uri? url, {
|
||||
Map<String, String>? headers,
|
||||
}) =>
|
||||
@@ -699,8 +721,8 @@ class MockClient extends _i1.Mock implements _i2.Client {
|
||||
[url],
|
||||
{#headers: headers},
|
||||
),
|
||||
returnValue: _i5.Future<_i9.Uint8List>.value(_i9.Uint8List(0)),
|
||||
) as _i5.Future<_i9.Uint8List>);
|
||||
returnValue: _i5.Future<_i10.Uint8List>.value(_i10.Uint8List(0)),
|
||||
) as _i5.Future<_i10.Uint8List>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) => (super.noSuchMethod(
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/other/base_provider_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i3;
|
||||
import 'dart:convert' as _i4;
|
||||
import 'dart:typed_data' as _i5;
|
||||
import 'dart:typed_data' as _i6;
|
||||
|
||||
import 'package:http/http.dart' as _i2;
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:mockito/src/dummies.dart' as _i5;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
@@ -226,11 +229,18 @@ class MockClient extends _i1.Mock implements _i2.Client {
|
||||
[url],
|
||||
{#headers: headers},
|
||||
),
|
||||
returnValue: _i3.Future<String>.value(''),
|
||||
returnValue: _i3.Future<String>.value(_i5.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#read,
|
||||
[url],
|
||||
{#headers: headers},
|
||||
),
|
||||
)),
|
||||
) as _i3.Future<String>);
|
||||
|
||||
@override
|
||||
_i3.Future<_i5.Uint8List> readBytes(
|
||||
_i3.Future<_i6.Uint8List> readBytes(
|
||||
Uri? url, {
|
||||
Map<String, String>? headers,
|
||||
}) =>
|
||||
@@ -240,8 +250,8 @@ class MockClient extends _i1.Mock implements _i2.Client {
|
||||
[url],
|
||||
{#headers: headers},
|
||||
),
|
||||
returnValue: _i3.Future<_i5.Uint8List>.value(_i5.Uint8List(0)),
|
||||
) as _i3.Future<_i5.Uint8List>);
|
||||
returnValue: _i3.Future<_i6.Uint8List>.value(_i6.Uint8List(0)),
|
||||
) as _i3.Future<_i6.Uint8List>);
|
||||
|
||||
@override
|
||||
_i3.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) => (super.noSuchMethod(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/user/provider_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -14,6 +14,8 @@ import 'package:wger/providers/base_provider.dart' as _i4;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/weight/weight_provider_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -14,6 +14,8 @@ import 'package:wger/providers/base_provider.dart' as _i4;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/weight/weight_screen_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -15,6 +15,8 @@ import 'package:wger/providers/body_weight.dart' as _i4;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
@@ -75,8 +75,8 @@ void main() {
|
||||
}
|
||||
|
||||
testWidgets('Test the widgets on the gym mode screen', (WidgetTester tester) async {
|
||||
when(mockExerciseProvider.findExerciseBaseById(1)).thenReturn(bases[0]);
|
||||
when(mockExerciseProvider.findExerciseBaseById(6)).thenReturn(bases[5]);
|
||||
when(mockExerciseProvider.findExerciseById(1)).thenReturn(bases[0]);
|
||||
when(mockExerciseProvider.findExerciseById(6)).thenReturn(bases[5]);
|
||||
|
||||
await tester.pumpWidget(createHomeScreen());
|
||||
await tester.tap(find.byType(TextButton));
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/workout/gym_mode_screen_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i10;
|
||||
import 'dart:ui' as _i12;
|
||||
import 'dart:async' as _i11;
|
||||
import 'dart:ui' as _i13;
|
||||
|
||||
import 'package:http/http.dart' as _i3;
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:wger/models/exercises/base.dart' as _i5;
|
||||
import 'package:wger/models/exercises/category.dart' as _i6;
|
||||
import 'package:wger/models/exercises/equipment.dart' as _i7;
|
||||
import 'package:wger/models/exercises/language.dart' as _i9;
|
||||
import 'package:wger/models/exercises/muscle.dart' as _i8;
|
||||
import 'package:wger/database/exercises/exercise_database.dart' as _i5;
|
||||
import 'package:wger/models/exercises/category.dart' as _i7;
|
||||
import 'package:wger/models/exercises/equipment.dart' as _i8;
|
||||
import 'package:wger/models/exercises/exercise.dart' as _i6;
|
||||
import 'package:wger/models/exercises/language.dart' as _i10;
|
||||
import 'package:wger/models/exercises/muscle.dart' as _i9;
|
||||
import 'package:wger/providers/auth.dart' as _i2;
|
||||
import 'package:wger/providers/base_provider.dart' as _i4;
|
||||
import 'package:wger/providers/exercises.dart' as _i11;
|
||||
import 'package:wger/providers/exercises.dart' as _i12;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
@@ -78,8 +81,8 @@ class _FakeWgerBaseProvider_4 extends _i1.SmartFake implements _i4.WgerBaseProvi
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeExerciseBase_5 extends _i1.SmartFake implements _i5.ExerciseBase {
|
||||
_FakeExerciseBase_5(
|
||||
class _FakeExerciseDatabase_5 extends _i1.SmartFake implements _i5.ExerciseDatabase {
|
||||
_FakeExerciseDatabase_5(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
@@ -88,8 +91,8 @@ class _FakeExerciseBase_5 extends _i1.SmartFake implements _i5.ExerciseBase {
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeExerciseCategory_6 extends _i1.SmartFake implements _i6.ExerciseCategory {
|
||||
_FakeExerciseCategory_6(
|
||||
class _FakeExercise_6 extends _i1.SmartFake implements _i6.Exercise {
|
||||
_FakeExercise_6(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
@@ -98,8 +101,8 @@ class _FakeExerciseCategory_6 extends _i1.SmartFake implements _i6.ExerciseCateg
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeEquipment_7 extends _i1.SmartFake implements _i7.Equipment {
|
||||
_FakeEquipment_7(
|
||||
class _FakeExerciseCategory_7 extends _i1.SmartFake implements _i7.ExerciseCategory {
|
||||
_FakeExerciseCategory_7(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
@@ -108,8 +111,8 @@ class _FakeEquipment_7 extends _i1.SmartFake implements _i7.Equipment {
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeMuscle_8 extends _i1.SmartFake implements _i8.Muscle {
|
||||
_FakeMuscle_8(
|
||||
class _FakeEquipment_8 extends _i1.SmartFake implements _i8.Equipment {
|
||||
_FakeEquipment_8(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
@@ -118,8 +121,18 @@ class _FakeMuscle_8 extends _i1.SmartFake implements _i8.Muscle {
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeLanguage_9 extends _i1.SmartFake implements _i9.Language {
|
||||
_FakeLanguage_9(
|
||||
class _FakeMuscle_9 extends _i1.SmartFake implements _i9.Muscle {
|
||||
_FakeMuscle_9(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeLanguage_10 extends _i1.SmartFake implements _i10.Language {
|
||||
_FakeLanguage_10(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
@@ -214,25 +227,25 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
) as Uri);
|
||||
|
||||
@override
|
||||
_i10.Future<Map<String, dynamic>> fetch(Uri? uri) => (super.noSuchMethod(
|
||||
_i11.Future<Map<String, dynamic>> fetch(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i10.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i10.Future<Map<String, dynamic>>);
|
||||
returnValue: _i11.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i11.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i10.Future<List<dynamic>> fetchPaginated(Uri? uri) => (super.noSuchMethod(
|
||||
_i11.Future<List<dynamic>> fetchPaginated(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchPaginated,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i10.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
) as _i10.Future<List<dynamic>>);
|
||||
returnValue: _i11.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
) as _i11.Future<List<dynamic>>);
|
||||
|
||||
@override
|
||||
_i10.Future<Map<String, dynamic>> post(
|
||||
_i11.Future<Map<String, dynamic>> post(
|
||||
Map<String, dynamic>? data,
|
||||
Uri? uri,
|
||||
) =>
|
||||
@@ -244,11 +257,11 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i10.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i10.Future<Map<String, dynamic>>);
|
||||
returnValue: _i11.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i11.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i10.Future<Map<String, dynamic>> patch(
|
||||
_i11.Future<Map<String, dynamic>> patch(
|
||||
Map<String, dynamic>? data,
|
||||
Uri? uri,
|
||||
) =>
|
||||
@@ -260,11 +273,11 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i10.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i10.Future<Map<String, dynamic>>);
|
||||
returnValue: _i11.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i11.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i10.Future<_i3.Response> deleteRequest(
|
||||
_i11.Future<_i3.Response> deleteRequest(
|
||||
String? url,
|
||||
int? id,
|
||||
) =>
|
||||
@@ -276,7 +289,7 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
id,
|
||||
],
|
||||
),
|
||||
returnValue: _i10.Future<_i3.Response>.value(_FakeResponse_3(
|
||||
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#deleteRequest,
|
||||
@@ -286,13 +299,13 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
],
|
||||
),
|
||||
)),
|
||||
) as _i10.Future<_i3.Response>);
|
||||
) as _i11.Future<_i3.Response>);
|
||||
}
|
||||
|
||||
/// A class which mocks [ExercisesProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
class MockExercisesProvider extends _i1.Mock implements _i12.ExercisesProvider {
|
||||
MockExercisesProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
@@ -307,67 +320,85 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
) as _i4.WgerBaseProvider);
|
||||
|
||||
@override
|
||||
set exerciseBases(List<_i5.ExerciseBase>? exercisesBases) => super.noSuchMethod(
|
||||
_i5.ExerciseDatabase get database => (super.noSuchMethod(
|
||||
Invocation.getter(#database),
|
||||
returnValue: _FakeExerciseDatabase_5(
|
||||
this,
|
||||
Invocation.getter(#database),
|
||||
),
|
||||
) as _i5.ExerciseDatabase);
|
||||
|
||||
@override
|
||||
set database(_i5.ExerciseDatabase? _database) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#exerciseBases,
|
||||
exercisesBases,
|
||||
#database,
|
||||
_database,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i5.ExerciseBase> get filteredExerciseBases => (super.noSuchMethod(
|
||||
Invocation.getter(#filteredExerciseBases),
|
||||
returnValue: <_i5.ExerciseBase>[],
|
||||
) as List<_i5.ExerciseBase>);
|
||||
List<_i6.Exercise> get exercises => (super.noSuchMethod(
|
||||
Invocation.getter(#exercises),
|
||||
returnValue: <_i6.Exercise>[],
|
||||
) as List<_i6.Exercise>);
|
||||
|
||||
@override
|
||||
set filteredExerciseBases(List<_i5.ExerciseBase>? newFilteredExercises) => super.noSuchMethod(
|
||||
set exercises(List<_i6.Exercise>? _exercises) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#filteredExerciseBases,
|
||||
#exercises,
|
||||
_exercises,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i6.Exercise> get filteredExercises => (super.noSuchMethod(
|
||||
Invocation.getter(#filteredExercises),
|
||||
returnValue: <_i6.Exercise>[],
|
||||
) as List<_i6.Exercise>);
|
||||
|
||||
@override
|
||||
set filteredExercises(List<_i6.Exercise>? newFilteredExercises) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#filteredExercises,
|
||||
newFilteredExercises,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<int, List<_i5.ExerciseBase>> get exerciseBasesByVariation => (super.noSuchMethod(
|
||||
Map<int, List<_i6.Exercise>> get exerciseBasesByVariation => (super.noSuchMethod(
|
||||
Invocation.getter(#exerciseBasesByVariation),
|
||||
returnValue: <int, List<_i5.ExerciseBase>>{},
|
||||
) as Map<int, List<_i5.ExerciseBase>>);
|
||||
returnValue: <int, List<_i6.Exercise>>{},
|
||||
) as Map<int, List<_i6.Exercise>>);
|
||||
|
||||
@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(
|
||||
List<_i7.ExerciseCategory> get categories => (super.noSuchMethod(
|
||||
Invocation.getter(#categories),
|
||||
returnValue: <_i6.ExerciseCategory>[],
|
||||
) as List<_i6.ExerciseCategory>);
|
||||
returnValue: <_i7.ExerciseCategory>[],
|
||||
) as List<_i7.ExerciseCategory>);
|
||||
|
||||
@override
|
||||
List<_i8.Muscle> get muscles => (super.noSuchMethod(
|
||||
List<_i9.Muscle> get muscles => (super.noSuchMethod(
|
||||
Invocation.getter(#muscles),
|
||||
returnValue: <_i8.Muscle>[],
|
||||
) as List<_i8.Muscle>);
|
||||
returnValue: <_i9.Muscle>[],
|
||||
) as List<_i9.Muscle>);
|
||||
|
||||
@override
|
||||
List<_i7.Equipment> get equipment => (super.noSuchMethod(
|
||||
List<_i8.Equipment> get equipment => (super.noSuchMethod(
|
||||
Invocation.getter(#equipment),
|
||||
returnValue: <_i7.Equipment>[],
|
||||
) as List<_i7.Equipment>);
|
||||
returnValue: <_i8.Equipment>[],
|
||||
) as List<_i8.Equipment>);
|
||||
|
||||
@override
|
||||
List<_i9.Language> get languages => (super.noSuchMethod(
|
||||
List<_i10.Language> get languages => (super.noSuchMethod(
|
||||
Invocation.getter(#languages),
|
||||
returnValue: <_i9.Language>[],
|
||||
) as List<_i9.Language>);
|
||||
returnValue: <_i10.Language>[],
|
||||
) as List<_i10.Language>);
|
||||
|
||||
@override
|
||||
set languages(List<_i9.Language>? languages) => super.noSuchMethod(
|
||||
set languages(List<_i10.Language>? languages) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#languages,
|
||||
languages,
|
||||
@@ -382,24 +413,33 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
) as bool);
|
||||
|
||||
@override
|
||||
_i10.Future<void> setFilters(_i11.Filters? newFilters) => (super.noSuchMethod(
|
||||
_i11.Future<void> setFilters(_i12.Filters? newFilters) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#setFilters,
|
||||
[newFilters],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> findByFilters() => (super.noSuchMethod(
|
||||
void initFilters() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#initFilters,
|
||||
[],
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
_i11.Future<void> findByFilters() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findByFilters,
|
||||
[],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
void clear() => super.noSuchMethod(
|
||||
@@ -411,196 +451,282 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
_i5.ExerciseBase findExerciseBaseById(int? id) => (super.noSuchMethod(
|
||||
_i6.Exercise findExerciseById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findExerciseBaseById,
|
||||
#findExerciseById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _FakeExerciseBase_5(
|
||||
returnValue: _FakeExercise_6(
|
||||
this,
|
||||
Invocation.method(
|
||||
#findExerciseBaseById,
|
||||
#findExerciseById,
|
||||
[id],
|
||||
),
|
||||
),
|
||||
) as _i5.ExerciseBase);
|
||||
) as _i6.Exercise);
|
||||
|
||||
@override
|
||||
List<_i5.ExerciseBase> findExerciseBasesByVariationId(
|
||||
List<_i6.Exercise> findExercisesByVariationId(
|
||||
int? id, {
|
||||
int? exerciseBaseIdToExclude,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findExerciseBasesByVariationId,
|
||||
#findExercisesByVariationId,
|
||||
[id],
|
||||
{#exerciseBaseIdToExclude: exerciseBaseIdToExclude},
|
||||
),
|
||||
returnValue: <_i5.ExerciseBase>[],
|
||||
) as List<_i5.ExerciseBase>);
|
||||
returnValue: <_i6.Exercise>[],
|
||||
) as List<_i6.Exercise>);
|
||||
|
||||
@override
|
||||
_i6.ExerciseCategory findCategoryById(int? id) => (super.noSuchMethod(
|
||||
_i7.ExerciseCategory findCategoryById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findCategoryById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _FakeExerciseCategory_6(
|
||||
returnValue: _FakeExerciseCategory_7(
|
||||
this,
|
||||
Invocation.method(
|
||||
#findCategoryById,
|
||||
[id],
|
||||
),
|
||||
),
|
||||
) as _i6.ExerciseCategory);
|
||||
) as _i7.ExerciseCategory);
|
||||
|
||||
@override
|
||||
_i7.Equipment findEquipmentById(int? id) => (super.noSuchMethod(
|
||||
_i8.Equipment findEquipmentById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findEquipmentById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _FakeEquipment_7(
|
||||
returnValue: _FakeEquipment_8(
|
||||
this,
|
||||
Invocation.method(
|
||||
#findEquipmentById,
|
||||
[id],
|
||||
),
|
||||
),
|
||||
) as _i7.Equipment);
|
||||
) as _i8.Equipment);
|
||||
|
||||
@override
|
||||
_i8.Muscle findMuscleById(int? id) => (super.noSuchMethod(
|
||||
_i9.Muscle findMuscleById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findMuscleById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _FakeMuscle_8(
|
||||
returnValue: _FakeMuscle_9(
|
||||
this,
|
||||
Invocation.method(
|
||||
#findMuscleById,
|
||||
[id],
|
||||
),
|
||||
),
|
||||
) as _i8.Muscle);
|
||||
) as _i9.Muscle);
|
||||
|
||||
@override
|
||||
_i9.Language findLanguageById(int? id) => (super.noSuchMethod(
|
||||
_i10.Language findLanguageById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findLanguageById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _FakeLanguage_9(
|
||||
returnValue: _FakeLanguage_10(
|
||||
this,
|
||||
Invocation.method(
|
||||
#findLanguageById,
|
||||
[id],
|
||||
),
|
||||
),
|
||||
) as _i9.Language);
|
||||
) as _i10.Language);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetCategories() => (super.noSuchMethod(
|
||||
_i11.Future<void> fetchAndSetCategoriesFromApi() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetCategories,
|
||||
#fetchAndSetCategoriesFromApi,
|
||||
[],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetVariations() => (super.noSuchMethod(
|
||||
_i11.Future<void> fetchAndSetMusclesFromApi() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetVariations,
|
||||
#fetchAndSetMusclesFromApi,
|
||||
[],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetMuscles() => (super.noSuchMethod(
|
||||
_i11.Future<void> fetchAndSetEquipmentsFromApi() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetMuscles,
|
||||
#fetchAndSetEquipmentsFromApi,
|
||||
[],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetEquipment() => (super.noSuchMethod(
|
||||
_i11.Future<void> fetchAndSetLanguagesFromApi() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetEquipment,
|
||||
#fetchAndSetLanguagesFromApi,
|
||||
[],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetLanguages() => (super.noSuchMethod(
|
||||
_i11.Future<_i6.Exercise> fetchAndSetExercise(int? exerciseId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetLanguages,
|
||||
[],
|
||||
#fetchAndSetExercise,
|
||||
[exerciseId],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<_i5.ExerciseBase> fetchAndSetExerciseBase(int? exerciseBaseId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetExerciseBase,
|
||||
[exerciseBaseId],
|
||||
),
|
||||
returnValue: _i10.Future<_i5.ExerciseBase>.value(_FakeExerciseBase_5(
|
||||
returnValue: _i11.Future<_i6.Exercise>.value(_FakeExercise_6(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchAndSetExerciseBase,
|
||||
[exerciseBaseId],
|
||||
#fetchAndSetExercise,
|
||||
[exerciseId],
|
||||
),
|
||||
)),
|
||||
) as _i10.Future<_i5.ExerciseBase>);
|
||||
) as _i11.Future<_i6.Exercise>);
|
||||
|
||||
@override
|
||||
_i5.ExerciseBase readExerciseBaseFromBaseInfo(dynamic baseData) => (super.noSuchMethod(
|
||||
_i11.Future<_i6.Exercise> handleUpdateExerciseFromApi(
|
||||
_i5.ExerciseDatabase? database,
|
||||
int? exerciseId,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#readExerciseBaseFromBaseInfo,
|
||||
[baseData],
|
||||
#handleUpdateExerciseFromApi,
|
||||
[
|
||||
database,
|
||||
exerciseId,
|
||||
],
|
||||
),
|
||||
returnValue: _FakeExerciseBase_5(
|
||||
returnValue: _i11.Future<_i6.Exercise>.value(_FakeExercise_6(
|
||||
this,
|
||||
Invocation.method(
|
||||
#readExerciseBaseFromBaseInfo,
|
||||
[baseData],
|
||||
#handleUpdateExerciseFromApi,
|
||||
[
|
||||
database,
|
||||
exerciseId,
|
||||
],
|
||||
),
|
||||
),
|
||||
) as _i5.ExerciseBase);
|
||||
)),
|
||||
) as _i11.Future<_i6.Exercise>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> checkExerciseCacheVersion() => (super.noSuchMethod(
|
||||
_i11.Future<void> checkExerciseCacheVersion() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#checkExerciseCacheVersion,
|
||||
[],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<void> fetchAndSetExercises() => (super.noSuchMethod(
|
||||
_i11.Future<void> initCacheTimesLocalPrefs({dynamic forceInit = false}) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetExercises,
|
||||
#initCacheTimesLocalPrefs,
|
||||
[],
|
||||
{#forceInit: forceInit},
|
||||
),
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
_i11.Future<void> clearAllCachesAndPrefs() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#clearAllCachesAndPrefs,
|
||||
[],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
_i10.Future<List<_i5.ExerciseBase>> searchExercise(
|
||||
_i11.Future<void> fetchAndSetInitialData() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetInitialData,
|
||||
[],
|
||||
),
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
_i11.Future<void> setExercisesFromDatabase(
|
||||
_i5.ExerciseDatabase? database, {
|
||||
bool? forceDeleteCache = false,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#setExercisesFromDatabase,
|
||||
[database],
|
||||
{#forceDeleteCache: forceDeleteCache},
|
||||
),
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
_i11.Future<void> updateExerciseCache(_i5.ExerciseDatabase? database) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#updateExerciseCache,
|
||||
[database],
|
||||
),
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
_i11.Future<void> fetchAndSetMuscles(_i5.ExerciseDatabase? database) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetMuscles,
|
||||
[database],
|
||||
),
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
_i11.Future<void> fetchAndSetCategories(_i5.ExerciseDatabase? database) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetCategories,
|
||||
[database],
|
||||
),
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
_i11.Future<void> fetchAndSetLanguages(_i5.ExerciseDatabase? database) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetLanguages,
|
||||
[database],
|
||||
),
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
_i11.Future<void> fetchAndSetEquipments(_i5.ExerciseDatabase? database) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetEquipments,
|
||||
[database],
|
||||
),
|
||||
returnValue: _i11.Future<void>.value(),
|
||||
returnValueForMissingStub: _i11.Future<void>.value(),
|
||||
) as _i11.Future<void>);
|
||||
|
||||
@override
|
||||
_i11.Future<List<_i6.Exercise>> searchExercise(
|
||||
String? name, {
|
||||
String? languageCode = r'en',
|
||||
bool? searchEnglish = false,
|
||||
@@ -614,11 +740,11 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
#searchEnglish: searchEnglish,
|
||||
},
|
||||
),
|
||||
returnValue: _i10.Future<List<_i5.ExerciseBase>>.value(<_i5.ExerciseBase>[]),
|
||||
) as _i10.Future<List<_i5.ExerciseBase>>);
|
||||
returnValue: _i11.Future<List<_i6.Exercise>>.value(<_i6.Exercise>[]),
|
||||
) as _i11.Future<List<_i6.Exercise>>);
|
||||
|
||||
@override
|
||||
void addListener(_i12.VoidCallback? listener) => super.noSuchMethod(
|
||||
void addListener(_i13.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addListener,
|
||||
[listener],
|
||||
@@ -627,7 +753,7 @@ class MockExercisesProvider extends _i1.Mock implements _i11.ExercisesProvider {
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod(
|
||||
void removeListener(_i13.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#removeListener,
|
||||
[listener],
|
||||
|
||||
@@ -41,7 +41,7 @@ void main() {
|
||||
final setting1 = Setting(
|
||||
setId: 1,
|
||||
order: 1,
|
||||
exerciseBaseId: 1,
|
||||
exerciseId: 1,
|
||||
repetitionUnitId: 1,
|
||||
reps: 2,
|
||||
weightUnitId: 1,
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/workout/repetition_unit_form_widget_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i12;
|
||||
import 'dart:ui' as _i15;
|
||||
import 'dart:ui' as _i16;
|
||||
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:wger/models/exercises/base.dart' as _i13;
|
||||
import 'package:mockito/src/dummies.dart' as _i15;
|
||||
import 'package:wger/models/exercises/exercise.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;
|
||||
@@ -24,6 +25,8 @@ import 'package:wger/providers/workout_plans.dart' as _i11;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
@@ -328,7 +331,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
@override
|
||||
_i12.Future<Map<String, dynamic>> fetchLogData(
|
||||
_i5.WorkoutPlan? workout,
|
||||
_i13.ExerciseBase? base,
|
||||
_i13.Exercise? base,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -480,7 +483,16 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
exercise,
|
||||
],
|
||||
),
|
||||
returnValue: _i12.Future<String>.value(''),
|
||||
returnValue: _i12.Future<String>.value(_i15.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchSmartText,
|
||||
[
|
||||
workoutSet,
|
||||
exercise,
|
||||
],
|
||||
),
|
||||
)),
|
||||
) as _i12.Future<String>);
|
||||
|
||||
@override
|
||||
@@ -558,7 +570,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
) as _i12.Future<void>);
|
||||
|
||||
@override
|
||||
void addListener(_i15.VoidCallback? listener) => super.noSuchMethod(
|
||||
void addListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addListener,
|
||||
[listener],
|
||||
@@ -567,7 +579,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod(
|
||||
void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#removeListener,
|
||||
[listener],
|
||||
|
||||
@@ -42,7 +42,7 @@ void main() {
|
||||
final setting1 = Setting(
|
||||
setId: 1,
|
||||
order: 1,
|
||||
exerciseBaseId: 1,
|
||||
exerciseId: 1,
|
||||
repetitionUnitId: 1,
|
||||
reps: 2,
|
||||
weightUnitId: 1,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/workout/weight_unit_form_widget_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -15,6 +15,8 @@ import 'package:wger/providers/body_weight.dart' as _i4;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/workout/workout_day_form_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i12;
|
||||
import 'dart:ui' as _i15;
|
||||
import 'dart:ui' as _i16;
|
||||
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:wger/models/exercises/base.dart' as _i13;
|
||||
import 'package:mockito/src/dummies.dart' as _i15;
|
||||
import 'package:wger/models/exercises/exercise.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;
|
||||
@@ -24,6 +25,8 @@ import 'package:wger/providers/workout_plans.dart' as _i11;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
@@ -328,7 +331,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
@override
|
||||
_i12.Future<Map<String, dynamic>> fetchLogData(
|
||||
_i5.WorkoutPlan? workout,
|
||||
_i13.ExerciseBase? base,
|
||||
_i13.Exercise? base,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -480,7 +483,16 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
exercise,
|
||||
],
|
||||
),
|
||||
returnValue: _i12.Future<String>.value(''),
|
||||
returnValue: _i12.Future<String>.value(_i15.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchSmartText,
|
||||
[
|
||||
workoutSet,
|
||||
exercise,
|
||||
],
|
||||
),
|
||||
)),
|
||||
) as _i12.Future<String>);
|
||||
|
||||
@override
|
||||
@@ -558,7 +570,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
) as _i12.Future<void>);
|
||||
|
||||
@override
|
||||
void addListener(_i15.VoidCallback? listener) => super.noSuchMethod(
|
||||
void addListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addListener,
|
||||
[listener],
|
||||
@@ -567,7 +579,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod(
|
||||
void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#removeListener,
|
||||
[listener],
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/workout/workout_form_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i12;
|
||||
import 'dart:ui' as _i15;
|
||||
import 'dart:ui' as _i16;
|
||||
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:wger/models/exercises/base.dart' as _i13;
|
||||
import 'package:mockito/src/dummies.dart' as _i15;
|
||||
import 'package:wger/models/exercises/exercise.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;
|
||||
@@ -24,6 +25,8 @@ import 'package:wger/providers/workout_plans.dart' as _i11;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
@@ -328,7 +331,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
@override
|
||||
_i12.Future<Map<String, dynamic>> fetchLogData(
|
||||
_i5.WorkoutPlan? workout,
|
||||
_i13.ExerciseBase? base,
|
||||
_i13.Exercise? base,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -480,7 +483,16 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
exercise,
|
||||
],
|
||||
),
|
||||
returnValue: _i12.Future<String>.value(''),
|
||||
returnValue: _i12.Future<String>.value(_i15.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#fetchSmartText,
|
||||
[
|
||||
workoutSet,
|
||||
exercise,
|
||||
],
|
||||
),
|
||||
)),
|
||||
) as _i12.Future<String>);
|
||||
|
||||
@override
|
||||
@@ -558,7 +570,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
) as _i12.Future<void>);
|
||||
|
||||
@override
|
||||
void addListener(_i15.VoidCallback? listener) => super.noSuchMethod(
|
||||
void addListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addListener,
|
||||
[listener],
|
||||
@@ -567,7 +579,7 @@ class MockWorkoutPlansProvider extends _i1.Mock implements _i11.WorkoutPlansProv
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod(
|
||||
void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#removeListener,
|
||||
[listener],
|
||||
|
||||
@@ -16,11 +16,13 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/database/exercises/exercise_database.dart';
|
||||
import 'package:wger/providers/base_provider.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
@@ -32,7 +34,10 @@ import 'workout_plan_screen_test.mocks.dart';
|
||||
@GenerateMocks([WgerBaseProvider])
|
||||
void main() {
|
||||
final mockBaseProvider = MockWgerBaseProvider();
|
||||
final exercisesProvider = ExercisesProvider(mockBaseProvider);
|
||||
final exercisesProvider = ExercisesProvider(
|
||||
mockBaseProvider,
|
||||
database: ExerciseDatabase.inMemory(NativeDatabase.memory()),
|
||||
);
|
||||
Widget createHomeScreen({locale = 'en'}) {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/workout/workout_plan_screen_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -14,6 +14,8 @@ import 'package:wger/providers/base_provider.dart' as _i4;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -23,6 +24,7 @@ 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/database/exercises/exercise_database.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
import 'package:wger/providers/base_provider.dart';
|
||||
import 'package:wger/providers/exercises.dart';
|
||||
@@ -37,7 +39,10 @@ import 'workout_plans_screen_test.mocks.dart';
|
||||
@GenerateMocks([WgerBaseProvider])
|
||||
void main() {
|
||||
var mockBaseProvider = MockWgerBaseProvider();
|
||||
final testExercisesProvider = ExercisesProvider(mockBaseProvider);
|
||||
final testExercisesProvider = ExercisesProvider(
|
||||
mockBaseProvider,
|
||||
database: ExerciseDatabase.inMemory(NativeDatabase.memory()),
|
||||
);
|
||||
|
||||
setUp(() {
|
||||
mockBaseProvider = MockWgerBaseProvider();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/workout/workout_plans_screen_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -14,6 +14,8 @@ import 'package:wger/providers/base_provider.dart' as _i4;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
@@ -24,6 +24,7 @@ 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/core/locator.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';
|
||||
@@ -38,6 +39,11 @@ import 'workout_provider_test.mocks.dart';
|
||||
void main() {
|
||||
final mockBaseProvider = MockWgerBaseProvider();
|
||||
|
||||
setUpAll(() async {
|
||||
// Needs to be configured here, setUp runs on every test, setUpAll only once
|
||||
await ServiceLocator().configure();
|
||||
});
|
||||
|
||||
group('test the workout routine provider', () {
|
||||
test('Test fetching and setting a plan', () async {
|
||||
final exercisesProvider = ExercisesProvider(mockBaseProvider);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Mocks generated by Mockito 5.4.2 from annotations
|
||||
// Mocks generated by Mockito 5.4.4 from annotations
|
||||
// in wger/test/workout/workout_provider_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
@@ -14,6 +14,8 @@ import 'package:wger/providers/base_provider.dart' as _i4;
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,9 +16,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/exercises/category.dart';
|
||||
import 'package:wger/models/exercises/equipment.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/models/exercises/language.dart';
|
||||
import 'package:wger/models/exercises/muscle.dart';
|
||||
import 'package:wger/models/exercises/translation.dart';
|
||||
@@ -28,6 +28,8 @@ import 'screenshots_exercises.dart';
|
||||
const tLanguage1 = Language(id: 1, shortName: 'de', fullName: 'Deutsch');
|
||||
const tLanguage2 = Language(id: 2, shortName: 'en', fullName: 'English');
|
||||
const tLanguage3 = Language(id: 3, shortName: 'fr', fullName: 'Français');
|
||||
const tLanguage4 = Language(id: 12, shortName: 'es', fullName: 'Español');
|
||||
const tLanguage5 = Language(id: 13, shortName: 'it', fullName: 'Italiano');
|
||||
const testLanguages = [tLanguage1, tLanguage2, tLanguage3];
|
||||
|
||||
const tMuscle1 = Muscle(id: 1, name: 'Flutterus maximus', nameEn: 'Glutes', isFront: true);
|
||||
@@ -43,11 +45,12 @@ const tCategory5 = ExerciseCategory(id: 5, name: 'Calves');
|
||||
const testCategories = [tCategory1, tCategory2, tCategory3, tCategory4, tCategory5];
|
||||
|
||||
const tEquipment1 = Equipment(id: 1, name: 'Bench');
|
||||
const tEquipment2 = Equipment(id: 1, name: 'Dumbbell');
|
||||
const tEquipment3 = Equipment(id: 2, name: 'Bench');
|
||||
const tEquipment2 = Equipment(id: 2, name: 'Dumbbell');
|
||||
const tEquipment3 = Equipment(id: 3, name: 'Bench');
|
||||
const tEquipment4 = Equipment(id: 10, name: 'Gym mat');
|
||||
const testEquipment = [tEquipment1, tEquipment2, tEquipment3];
|
||||
|
||||
final benchPress = ExerciseBase(
|
||||
final benchPress = Exercise(
|
||||
id: 1,
|
||||
uuid: '364f196c-881b-4839-8bfc-9e8f651521b6',
|
||||
created: DateTime(2021, 09, 01),
|
||||
@@ -58,7 +61,7 @@ final benchPress = ExerciseBase(
|
||||
musclesSecondary: const [tMuscle3],
|
||||
);
|
||||
|
||||
final crunches = ExerciseBase(
|
||||
final crunches = Exercise(
|
||||
id: 2,
|
||||
uuid: '82415754-fc4c-49ea-8ca7-1516dd36d5a0',
|
||||
created: DateTime(2021, 08, 01),
|
||||
@@ -69,7 +72,7 @@ final crunches = ExerciseBase(
|
||||
musclesSecondary: const [tMuscle2],
|
||||
);
|
||||
|
||||
final deadLift = ExerciseBase(
|
||||
final deadLift = Exercise(
|
||||
id: 3,
|
||||
uuid: 'ca84e2c5-5608-4d6d-ba57-6d4b6b5e7acd',
|
||||
created: DateTime(2021, 08, 01),
|
||||
@@ -80,7 +83,7 @@ final deadLift = ExerciseBase(
|
||||
musclesSecondary: const [tMuscle2],
|
||||
);
|
||||
|
||||
final curls = ExerciseBase(
|
||||
final curls = Exercise(
|
||||
id: 4,
|
||||
uuid: '361f024c-fdf8-4146-b7d7-0c1b67c58141',
|
||||
created: DateTime(2021, 08, 01),
|
||||
@@ -90,7 +93,7 @@ final curls = ExerciseBase(
|
||||
muscles: const [tMuscle1],
|
||||
musclesSecondary: const [tMuscle2],
|
||||
);
|
||||
final squats = ExerciseBase(
|
||||
final squats = Exercise(
|
||||
id: 5,
|
||||
uuid: '361f024c-fdf8-4146-b7d7-0c1b67c58141',
|
||||
created: DateTime(2021, 08, 01),
|
||||
@@ -100,7 +103,7 @@ final squats = ExerciseBase(
|
||||
muscles: const [tMuscle1],
|
||||
musclesSecondary: const [tMuscle2],
|
||||
);
|
||||
final sideRaises = ExerciseBase(
|
||||
final sideRaises = Exercise(
|
||||
id: 6,
|
||||
uuid: '721ff972-c568-41e3-8cf5-cf1e5c5c801c',
|
||||
created: DateTime(2022, 11, 01),
|
||||
@@ -117,7 +120,7 @@ final benchPressDe = Translation(
|
||||
created: DateTime(2021, 1, 15),
|
||||
name: 'Bankdrücken',
|
||||
description: 'add clever text',
|
||||
baseId: benchPress.id,
|
||||
exerciseId: benchPress.id,
|
||||
language: tLanguage1,
|
||||
);
|
||||
final benchPressEn = Translation(
|
||||
@@ -126,7 +129,7 @@ final benchPressEn = Translation(
|
||||
created: DateTime(2021, 1, 15),
|
||||
name: 'Bench press',
|
||||
description: 'add clever text',
|
||||
baseId: benchPress.id,
|
||||
exerciseId: benchPress.id,
|
||||
language: tLanguage1,
|
||||
);
|
||||
|
||||
@@ -136,7 +139,7 @@ final deadLiftEn = Translation(
|
||||
created: DateTime(2021, 1, 15),
|
||||
name: 'Dead Lift',
|
||||
description: 'Lorem ipsum etc',
|
||||
baseId: crunches.id,
|
||||
exerciseId: crunches.id,
|
||||
language: tLanguage2,
|
||||
);
|
||||
|
||||
@@ -146,7 +149,7 @@ final crunchesFr = Translation(
|
||||
created: DateTime(2021, 4, 1),
|
||||
name: 'Crunches',
|
||||
description: 'The man in black fled across the desert, and the gunslinger followed',
|
||||
baseId: deadLift.id,
|
||||
exerciseId: deadLift.id,
|
||||
language: tLanguage3,
|
||||
);
|
||||
|
||||
@@ -156,7 +159,7 @@ final crunchesDe = Translation(
|
||||
created: DateTime(2021, 4, 1),
|
||||
name: 'Crunches',
|
||||
description: 'The story so far: in the beginning, the universe was created',
|
||||
baseId: deadLift.id,
|
||||
exerciseId: deadLift.id,
|
||||
language: tLanguage1,
|
||||
);
|
||||
|
||||
@@ -166,7 +169,7 @@ final crunchesEn = Translation(
|
||||
created: DateTime(2021, 4, 1),
|
||||
name: 'test exercise 5',
|
||||
description: 'I am an invisible man',
|
||||
baseId: deadLift.id,
|
||||
exerciseId: deadLift.id,
|
||||
language: tLanguage2,
|
||||
);
|
||||
|
||||
@@ -176,7 +179,7 @@ final curlsEn = Translation(
|
||||
created: DateTime(2021, 4, 1),
|
||||
name: 'Curls',
|
||||
description: 'It was a bright cold day in April, and the clocks were striking thirteen',
|
||||
baseId: curls.id,
|
||||
exerciseId: curls.id,
|
||||
language: tLanguage2,
|
||||
);
|
||||
|
||||
@@ -186,7 +189,7 @@ final squatsEn = Translation(
|
||||
created: DateTime(2021, 4, 1),
|
||||
name: 'Squats',
|
||||
description: 'It was a bright cold day in April, and the clocks were striking thirteen',
|
||||
baseId: curls.id,
|
||||
exerciseId: curls.id,
|
||||
language: tLanguage2,
|
||||
);
|
||||
|
||||
@@ -196,11 +199,11 @@ final sideRaisesEn = Translation(
|
||||
created: DateTime(2022, 11, 1),
|
||||
name: 'Side raises',
|
||||
description: 'It was a bright cold day in April, and the clocks were striking thirteen',
|
||||
baseId: curls.id,
|
||||
exerciseId: curls.id,
|
||||
language: tLanguage2,
|
||||
);
|
||||
|
||||
List<ExerciseBase> getTestExerciseBases() {
|
||||
List<Exercise> getTestExerciseBases() {
|
||||
benchPress.translations = [benchPressEn, benchPressDe];
|
||||
crunches.translations = [crunchesEn, crunchesDe, crunchesFr];
|
||||
deadLift.translations = [deadLiftEn];
|
||||
@@ -211,7 +214,7 @@ List<ExerciseBase> getTestExerciseBases() {
|
||||
return [benchPress, crunches, deadLift, curls, squats, sideRaises];
|
||||
}
|
||||
|
||||
List<ExerciseBase> getScreenshotExercises() {
|
||||
List<Exercise> getScreenshotExercises() {
|
||||
benchPress.translations = benchPressTranslations;
|
||||
crunches.translations = crunchesTranslations;
|
||||
deadLift.translations = deadLiftTranslations;
|
||||
|
||||
@@ -90,7 +90,7 @@ final squatsPT = Translation(
|
||||
name: 'Agachamento de impulso',
|
||||
description:
|
||||
'''<p>Posição inicial:</p><p>Comece na posição de prancha alta:costas, braços e pernas retos e as mãos afastadas alinhadas aos ombros.</p><p>Passos:</p><ol><li>Pule jogando seus pés para frente entre os braços, mantendo as costas reta.</li><li>Mantendo suas mãos no chão, retorne suas pernas para a posição de prancha altas.</li><li>Repita.</li></ol>''',
|
||||
baseId: 616,
|
||||
exerciseId: 616,
|
||||
language: tLanguage7,
|
||||
);
|
||||
|
||||
@@ -101,7 +101,7 @@ final squatsNL = Translation(
|
||||
name: 'Hurkstoten',
|
||||
description:
|
||||
'''<p>Startpositie:</p><p>Begin in hoge plankpositie:rug, armen en benen recht en handen op schouderbreedte uit elkaar.</p><p>Stap:</p><ol><li>Spring met je voeten naar voren tussen je armen en houd je rug plat.</li><li>Houd je handen op de vloer, spring je benen terug in hoge plank positie.</li><li>Herhalen.</li></ol>''',
|
||||
baseId: 616,
|
||||
exerciseId: 616,
|
||||
language: tLanguage6,
|
||||
);
|
||||
|
||||
@@ -112,7 +112,7 @@ final squatsID = Translation(
|
||||
name: 'Jongkok menyodorkan',
|
||||
description:
|
||||
'''<p>Posisi awal:</p><p>Mulailah dengan posisi papan tinggi:punggung, lengan, dan kaki lurus dan tangan selebar bahu.</p><p>Langkah:</p><ol><li>Lompati kaki Anda ke depan di antara kedua lengan, jaga punggung tetap rata.</li><li>Menjaga tangan Anda di lantai, melompat kaki Anda kembali ke posisi papan tinggi.</li><li>Ulangi.</li></ol>''',
|
||||
baseId: 616,
|
||||
exerciseId: 616,
|
||||
language: tLanguage23,
|
||||
);
|
||||
|
||||
@@ -123,7 +123,7 @@ final squatsDE = Translation(
|
||||
name: 'Kniebeugen',
|
||||
description:
|
||||
'''<p>Ausgangsposition:</p><p>Beginne in der hohen Plank-Position:Rücken, Arme und Beine sind gestreckt, die Hände sind schulterbreit auseinander.</p><p>Schritte:</p><ol><li>Springe mit den Füßen zwischen den Armen nach vorne und halte den Rücken flach.</li><li>Lasse die Hände auf dem Boden und springe mit den Beinen zurück in die hohe Plank-Position.</li><li>Wiederhole die Übung.</li></ol>''',
|
||||
baseId: 616,
|
||||
exerciseId: 616,
|
||||
language: tLanguage1,
|
||||
);
|
||||
|
||||
@@ -133,7 +133,7 @@ final squatsFR = Translation(
|
||||
created: DateTime(2021, 1, 15),
|
||||
name: 'Poussées de squat',
|
||||
description: '''''',
|
||||
baseId: 616,
|
||||
exerciseId: 616,
|
||||
language: tLanguage12,
|
||||
);
|
||||
|
||||
@@ -144,7 +144,7 @@ final squatsIT = Translation(
|
||||
name: 'Spinte squat',
|
||||
description:
|
||||
'''<p>Posizione di partenza:</p><p>Iniziare in posizione di plank alto:schiena, braccia e gambe dritte e mani alla larghezza delle spalle.</p><p>Passi:</p><ol><li>Saltare i piedi in avanti tra le braccia, mantenendo la schiena piatta.</li><li>Tenendo le mani sul pavimento, saltare le gambe indietro in posizione di plank alto.</li><li>Ripetere.</li></ol>''',
|
||||
baseId: 616,
|
||||
exerciseId: 616,
|
||||
language: tLanguage13,
|
||||
);
|
||||
|
||||
@@ -155,7 +155,7 @@ final squatsEN = Translation(
|
||||
name: 'Squat Thrust',
|
||||
description:
|
||||
'''The burpee, or squat thrust, is a full body exercise used in strength training and as an aerobic exercise. The basic movement is performed in four steps and known as a four-count burpee: Begin in a standing position. Move into a squat position with your hands on the ground. (count 1) Kick your feet back into a plank position, while keeping your arms extended. (count 2) Immediately return your feet into squat position. (count 3) Stand up from the squat position (count 4)''',
|
||||
baseId: 616,
|
||||
exerciseId: 616,
|
||||
language: tLanguage2,
|
||||
);
|
||||
|
||||
@@ -166,7 +166,7 @@ final squatsEL = Translation(
|
||||
name: 'Ωθήσεις βαθέος καθίσματος',
|
||||
description:
|
||||
'''<p>Θέση εκκίνησης:</p><p>Εκκίνηση σε θέση υψηλής σανίδας:πλάτη, χέρια και πόδια είναι ίσια, και τα χέρια βρίσκονται στο πλάτος των ώμων.</p><p>Βήματα:</p><ol><li>Πηδήξτε με τα πόδια προς τα εμπρός ανάμεσα στα χέρια, κρατώντας την πλάτη επίπεδη.</li><li>Διατηρώντας τα χέρια στο πάτωμα, πηδήξτε με τα πόδια σας πίσω σε θέση υψηλής σανίδας.</li><li>Επαναλάβετε.</li></ol>''',
|
||||
baseId: 616,
|
||||
exerciseId: 616,
|
||||
language: tLanguage8,
|
||||
);
|
||||
|
||||
@@ -177,7 +177,7 @@ final squatsAR = Translation(
|
||||
name: 'دفعات القرفصاء',
|
||||
description:
|
||||
'''<p>وضع البداية:</p><p>ابدأ في وضع اللوح الخشبي المرتفع:الظهر والذراعين والساقين مستقيمين واليدين متباعدتين بعرض الكتفين.</p><p>الخطوات:</p><ol><li>اقفز قدميك للأمام بين ذراعيك ، مع الحفاظ على ظهرك مسطحًا.</li><li>إبقاء يديك على الأرض ، واقفز رجليك إلى الوراء في وضع اللوح الخشبي العالي.</li><li>كرر.</li></ol>''',
|
||||
baseId: 616,
|
||||
exerciseId: 616,
|
||||
language: tLanguage17,
|
||||
);
|
||||
|
||||
@@ -188,7 +188,7 @@ final squatsZH = Translation(
|
||||
name: '俯卧撑腿屈伸',
|
||||
description:
|
||||
'''<p>起始姿势:以高位平板支撑姿势开始:背部、手臂和腿均伸直,双手分开与肩同宽。</p><p>步骤:</p><ol><li>双脚向双臂的方向向前跳,保持背部平直。</li><li>双手撑地,双腿跳回高位平板支撑位置。</li><li>重复。</li></ol>''',
|
||||
baseId: 616,
|
||||
exerciseId: 616,
|
||||
language: tLanguage24,
|
||||
);
|
||||
|
||||
@@ -218,7 +218,7 @@ final benchPressDE = Translation(
|
||||
<li>breiter Griff: äußere Brustmuskeln</li>
|
||||
<li>enger Griff: innere Brustmuskeln und Trizeps</li>
|
||||
</ul>''',
|
||||
baseId: 73,
|
||||
exerciseId: 73,
|
||||
language: tLanguage1,
|
||||
);
|
||||
|
||||
@@ -235,7 +235,7 @@ final benchPressEN = Translation(
|
||||
<li>wide grip: outer chest muscles</li>
|
||||
<li>narrow grip: inner chest muscles and triceps</li>
|
||||
</ul>''',
|
||||
baseId: 73,
|
||||
exerciseId: 73,
|
||||
language: tLanguage2,
|
||||
);
|
||||
|
||||
@@ -245,7 +245,7 @@ final benchPressIT = Translation(
|
||||
created: DateTime(2021, 1, 15),
|
||||
name: 'Distensione Panca Piana con Bilanciere',
|
||||
description: '''Distensione Panca Piana con BilanciereDistensione Panca Piana con Bilanciere''',
|
||||
baseId: 73,
|
||||
exerciseId: 73,
|
||||
language: tLanguage13,
|
||||
);
|
||||
|
||||
@@ -259,7 +259,7 @@ final deadLiftEN = Translation(
|
||||
description:
|
||||
'''<p>Stand firmly, with your feet slightly more than shoulder wide apart. Stand directly behind the bar where it should barely touch your shin, your feet pointing a bit out. Bend down with a straight back, the knees also pointing somewhat out. Grab the bar with a shoulder wide grip, one underhand, one reverse grip.</p>
|
||||
<p>Pull the weight up. At the highest point make a slight hollow back and pull the bar back. Hold 1 or 2 seconds that position. Go down, making sure the back is not bent. Once down you can either go back again as soon as the weights touch the floor, or make a pause, depending on the weight.</p>''',
|
||||
baseId: 184,
|
||||
exerciseId: 184,
|
||||
language: tLanguage2,
|
||||
);
|
||||
|
||||
@@ -271,7 +271,7 @@ final deadLiftDE = Translation(
|
||||
description:
|
||||
'''<p>Stelle dich mit etwas mehr als schulterbreitem Stand vor der Stange, die Füße zeigen leicht nach außen, die Stange ist direkt darüber und sehr nahe am Schienbein. Beuge die Knie (zeigen ebenfalls etwas nach außen) und neige den Oberkörper (bleibt während der ganzen Übung gerade). Greife die Stange schulterbreit mit einem Unter- und einem Obergriff.</p>
|
||||
<p>Ziehe nun die Stange nach oben. An der höchsten Stelle mache ein leichtes Hohlkreuz und drücke die Schultern nach hinten. Gehe wieder runter, wobei du darauf achtest, dass der Rücken gerade bleibt und sich nicht krümmt. Du kannst unten angekommen eine kleine Pause einlegen oder sofort weitermachen.</p>''',
|
||||
baseId: 184,
|
||||
exerciseId: 184,
|
||||
language: tLanguage1,
|
||||
);
|
||||
|
||||
@@ -284,7 +284,7 @@ final deadLiftPT = Translation(
|
||||
'''Fique firme, com os pés ligeiramente mais afastados do que os ombros. Fique diretamente atrás da barra, onde ela mal deve tocar sua canela, com os pés apontando um pouco para fora. Curve-se com as costas retas, os joelhos também apontando um pouco para fora. Agarre a barra com uma pegada na largura dos ombros, uma pegada por baixo e uma pegada reversa.
|
||||
|
||||
Puxe o peso para cima. No ponto mais alto, faça uma leve depressão para trás e puxe a barra para trás. Segure 1 ou 2 segundos nessa posição. Desça, certificando-se de que as costas não estão dobradas. Depois de descer, você pode voltar assim que os pesos tocarem o chão ou fazer uma pausa, dependendo do peso.''',
|
||||
baseId: 184,
|
||||
exerciseId: 184,
|
||||
language: tLanguage7,
|
||||
);
|
||||
|
||||
@@ -295,7 +295,7 @@ final deadLiftIT = Translation(
|
||||
name: 'Stacco',
|
||||
description: '''StaccoStacco
|
||||
Stacco''',
|
||||
baseId: 184,
|
||||
exerciseId: 184,
|
||||
language: tLanguage13,
|
||||
);
|
||||
|
||||
@@ -308,7 +308,7 @@ final crunchesPT = Translation(
|
||||
name: 'Abdominal',
|
||||
description:
|
||||
'''<ol><li>Deite-se de barriga para cima no chão com os joelhos dobrados.</li><li>Curve os ombros em direção a pélvis. As mãos podem ficar atrás ou do lado do pescoço ou cruzadas sobre o peito.</li><li>Repita</li></ol>''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage7,
|
||||
);
|
||||
|
||||
@@ -319,7 +319,7 @@ final crunchesES = Translation(
|
||||
name: 'Abdominales',
|
||||
description:
|
||||
'''<ol><li>Acuéstese boca arriba en el suelo con las rodillas dobladas.</li><li>Flexione los hombros hacia la pelvis. Las manos pueden estar detrás o al costado del cuello o cruzadas sobre el pecho.</li><li>Repita</li></ol>''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage4,
|
||||
);
|
||||
|
||||
@@ -330,7 +330,7 @@ final crunchesFR = Translation(
|
||||
name: 'Abdominaux',
|
||||
description:
|
||||
'''<ol><li>Allongez-vous sur le sol, face contre terre, genoux pliés.</li><li>Courbez les épaules vers le bassin. Les mains peuvent être derrière ou à côté du cou ou croisées sur la poitrine.</li><li>Répétez</li></ol>''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage12,
|
||||
);
|
||||
|
||||
@@ -341,7 +341,7 @@ final crunchesIT = Translation(
|
||||
name: 'Addominali',
|
||||
description:
|
||||
'''<ol><li>Sdraiati a pancia in su sul pavimento con le ginocchia piegate.</li><li>Solleva il busto verso il bacino, a 30° / 40° dal suolo. Le mani possono essere dietro o accanto al collo o incrociate sul petto.</li><li>Ripeti</li></ol>''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage13,
|
||||
);
|
||||
|
||||
@@ -352,7 +352,7 @@ final crunchesNL = Translation(
|
||||
name: 'Crunch',
|
||||
description:
|
||||
'''<ol><li>Ga op je rug liggen en buig je knieën.</li><li>Draai je schouders richting je bekken. Houd je handen achter of naast je nek of kruislings over je borstkas.</li><li>Herhaal</li></ol>''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage6,
|
||||
);
|
||||
|
||||
@@ -363,7 +363,7 @@ final crunchesID = Translation(
|
||||
name: 'Crunch',
|
||||
description:
|
||||
'''<ol><li>Tiarap di lantai dengan lutut bengkok.</li><li>Ikatkan bahumu ke pinggulnya. Tangan bisa berada di belakang atau di samping leher atau menyeberang di atas dada.</li><li>Ulangi</li></ol>''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage23,
|
||||
);
|
||||
|
||||
@@ -375,7 +375,7 @@ final crunchesDE = Translation(
|
||||
description:
|
||||
'''<p>Lege dich auf eine Matte mit angewinkelten Beinen. Die Füße werden irgendwie festgehalten (Partner, Lanhghantel, o.Ä.) und die Hände werden hinter dem Nacken verschränkt. Aus dieser Position führe den Oberkörper so weit nach oben, bis Kopf oder Ellenbogen die angewinkelten Beine berühren.</p>
|
||||
<p>Es ist wichtig, dass dieser Vorgang mit einer rollenden Bewegung durchgeführt wird: die Wirbelsäule sollte sich Wirbel für Wirbel von der Matte lösen. Ein Hohlkreuz ist stets zu vermeiden.</p>''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage1,
|
||||
);
|
||||
|
||||
@@ -386,7 +386,7 @@ final crunchesEN = Translation(
|
||||
name: 'Crunches',
|
||||
description:
|
||||
'''<p>Lay down on your back a soft surface, the feet are on the floor. Ask a partner or use some other help (barbell, etc.) to keep them fixed, your hands are behind your head. From this position move your upper body up till your head or elbows touch your knees. Do this movement by rolling up your back.</p>''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage2,
|
||||
);
|
||||
|
||||
@@ -397,7 +397,7 @@ final crunchesCS = Translation(
|
||||
name: 'Sedolehy',
|
||||
description:
|
||||
'''<ol><li>Lehni si na zem hlavou nahoru s pokrčenými koleny.Zvedni záda tak, aby se tvá ramena co nejblíže přiblížily ke kolenům. Plosky nohou včetně prstů by měly zůstat na zemi. Ruce mohou být za hlavou nebo přeložené v kříž na hrudi.</li><li>Opakuj</li></ol>''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage9,
|
||||
);
|
||||
|
||||
@@ -407,7 +407,7 @@ final crunchesHR = Translation(
|
||||
created: DateTime(2021, 1, 15),
|
||||
name: 'Trbušnjaci',
|
||||
description: '''''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage22,
|
||||
);
|
||||
|
||||
@@ -418,7 +418,7 @@ final crunchesTR = Translation(
|
||||
name: 'Yarım mekik',
|
||||
description:
|
||||
'''<ol><li>Dizlerinizi bükerek yere sırtüstü yatın.</li><li>Omuzları leğen kemiğine doğru bükün. Eller boynun arkasında veya yanında olabilir ya da göğsün üzerinden geçebilir.</li><li>Tekrarlayın</li></ol>''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage16,
|
||||
);
|
||||
|
||||
@@ -429,7 +429,7 @@ final crunchesEL = Translation(
|
||||
name: 'Κοιλιακοί',
|
||||
description:
|
||||
'''<ol><li>Ξαπλώστε ανάσκελα στο πάτωμα με τα γόνατα λυγισμένα.</li><li>Κυρτώστε τους ώμους προς τη λεκάνη. Τα χέρια μπορεί να είναι πίσω ή δίπλα από τον αυχένα ή σταυρωμένα πάνω από το στήθος.</li><li>Επαναλάβετε</li></ol>''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage8,
|
||||
);
|
||||
|
||||
@@ -439,7 +439,7 @@ final crunchesRU = Translation(
|
||||
created: DateTime(2021, 1, 15),
|
||||
name: 'Скручивания',
|
||||
description: '''''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage5,
|
||||
);
|
||||
|
||||
@@ -449,7 +449,7 @@ final crunchesHE = Translation(
|
||||
created: DateTime(2021, 1, 15),
|
||||
name: 'כפיפות בטן',
|
||||
description: '''''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage21,
|
||||
);
|
||||
|
||||
@@ -460,7 +460,7 @@ final crunchesAR = Translation(
|
||||
name: 'الطحن',
|
||||
description:
|
||||
'''<ol><li>الاستلقاء على الأرض مع ثني الركبتين.</li><li>لف الكتفين نحو الحوض. يمكن أن تكون اليدين خلف العنق أو بجانبه أو متقاطعتين فوق الصدر.</li><li>كرر التمرين</li></ol>''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage17,
|
||||
);
|
||||
|
||||
@@ -471,7 +471,7 @@ final crunchesZH = Translation(
|
||||
name: '仰卧起坐',
|
||||
description:
|
||||
'''<p>起始姿势:膝盖弯曲,脸朝上躺在地板上。</p><p>步骤:</p><ol><li>朝骨盆方向弯曲肩膀。 双手可以放在脖子后面或脖子旁边,也可以交叉在胸前。2.回到初始姿势。</li><li>重复。</li></ol>''',
|
||||
baseId: 167,
|
||||
exerciseId: 167,
|
||||
language: tLanguage24,
|
||||
);
|
||||
|
||||
@@ -502,7 +502,7 @@ final curlsEN = Translation(
|
||||
description:
|
||||
'''<p>Hold two barbells, the arms are streched, the hands are on your side, the palms face inwards. Bend the arms and bring the weight with a fast movement up. At the same time, rotate your arms by 90 degrees at the very beginning of the movement. At the highest point, rotate a little the weights further outwards. Without a pause, bring them down, slowly.</p>
|
||||
<p>Don't allow your body to swing during the exercise, all work is done by the biceps, which are the only mucles that should move (pay attention to the elbows).</p>''',
|
||||
baseId: 92,
|
||||
exerciseId: 92,
|
||||
language: tLanguage2,
|
||||
);
|
||||
|
||||
@@ -514,7 +514,7 @@ final curlsDE = Translation(
|
||||
description:
|
||||
'''<p>Halte zwei Kurzhantel mit ausgestreckten Armen neben dem Körper, die Handflächen zeigen nach innen. Beuge die Arme und brige die Hanteln mit einer schnellen Bewegung nach oben wobei sie gleichzeitig um 90 Grad gedreht werden. Am höchsten Punkt kann man die Hanteln ganz leicht weiter nach außen drehen. Ohne Pause wird das Gewicht nun kontrolliert nach unten gebracht. Beachte, dass die Bewegung nach oben schneller ist als nach unten.</p>
|
||||
<p>Während des Bewegungablaufs darf der Körper nicht mitschwingen. Die Ellenbogen bleiben dabei immer an der Stelle.</p>''',
|
||||
baseId: 92,
|
||||
exerciseId: 92,
|
||||
language: tLanguage1,
|
||||
);
|
||||
|
||||
@@ -525,7 +525,7 @@ final curlsES = Translation(
|
||||
name: 'Curl de bíceps con mancuerna',
|
||||
description:
|
||||
'''Sujeta dos pesas, los brazos estirados, las manos a los lados, las palmas hacia dentro. Flexiona los brazos y sube el peso con un movimiento rápido. Al mismo tiempo, gira los brazos 90 grados al principio del movimiento. En el punto más alto, gira un poco las pesas hacia fuera. Sin pausa, bájalas lentamente.No permitas que tu cuerpo se balancee durante el ejercicio, todo el trabajo lo realizan los bíceps, que son los únicos músculos que deben moverse (presta atención a los codos).''',
|
||||
baseId: 92,
|
||||
exerciseId: 92,
|
||||
language: tLanguage4,
|
||||
);
|
||||
|
||||
@@ -537,7 +537,7 @@ final raisesIT = Translation(
|
||||
created: DateTime(2021, 1, 15),
|
||||
name: 'Alzate Laterali',
|
||||
description: '''Alzate LateraliAlzate Laterali''',
|
||||
baseId: 348,
|
||||
exerciseId: 348,
|
||||
language: tLanguage13,
|
||||
);
|
||||
|
||||
@@ -548,7 +548,7 @@ final raisesEN = Translation(
|
||||
name: 'Lateral Raises',
|
||||
description:
|
||||
'''This exercise works the deltoid muscle of the shoulder. The movement starts with the arms straight, and the hands holding weights at the sides or in front of the body. Body is in a slight forward-leaning position with hips and knees bent a little. Arms are kept straight or slightly bent, and raised through an arc of movement in the coronal plane that terminates when the hands are at approximately shoulder height. Weights are lowered to the starting position, completing one rep. When using a cable machine the individual stands with the coronal plane in line with the pulley, which is at or near the ground.[9] The exercise can be completed one shoulder at a time (with the other hand used to stabilize the body against the weight moved), or with both hands simultaneously if two parallel pulleys are available.''',
|
||||
baseId: 348,
|
||||
exerciseId: 348,
|
||||
language: tLanguage2,
|
||||
);
|
||||
|
||||
@@ -565,7 +565,7 @@ final raisesDE = Translation(
|
||||
<li>Am höchsten Punkt hältst du für 1-2 Sekunden inne und ziehst deine Schulterblätter zusammen.</li>
|
||||
<li>Führe die Hanteln langsam wieder nach unten in die Ausgangsposition und atme ein.</li>
|
||||
</ol>''',
|
||||
baseId: 348,
|
||||
exerciseId: 348,
|
||||
language: tLanguage1,
|
||||
);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:wger/models/exercises/base.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
import 'package:wger/models/workouts/log.dart';
|
||||
import 'package:wger/models/workouts/repetition_unit.dart';
|
||||
@@ -33,7 +33,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({List<ExerciseBase>? exercises}) {
|
||||
WorkoutPlan getWorkout({List<Exercise>? exercises}) {
|
||||
final testBases = exercises ?? getTestExerciseBases();
|
||||
|
||||
final log1 = Log.empty()
|
||||
@@ -72,7 +72,7 @@ WorkoutPlan getWorkout({List<ExerciseBase>? exercises}) {
|
||||
final settingBenchPress = Setting(
|
||||
setId: 1,
|
||||
order: 1,
|
||||
exerciseBaseId: 1,
|
||||
exerciseId: 1,
|
||||
repetitionUnitId: 1,
|
||||
reps: 6,
|
||||
weightUnitId: 1,
|
||||
@@ -81,7 +81,7 @@ WorkoutPlan getWorkout({List<ExerciseBase>? exercises}) {
|
||||
);
|
||||
settingBenchPress.repetitionUnit = repetitionUnit1;
|
||||
settingBenchPress.weightUnit = weightUnit1;
|
||||
settingBenchPress.exerciseBase = testBases[0];
|
||||
settingBenchPress.exercise = testBases[0];
|
||||
settingBenchPress.weight = 80;
|
||||
|
||||
final setBenchPress = Set.withData(
|
||||
@@ -98,7 +98,7 @@ WorkoutPlan getWorkout({List<ExerciseBase>? exercises}) {
|
||||
final settingSquat = Setting(
|
||||
setId: 2,
|
||||
order: 1,
|
||||
exerciseBaseId: 8,
|
||||
exerciseId: 8,
|
||||
repetitionUnitId: 1,
|
||||
reps: 8,
|
||||
weightUnitId: 1,
|
||||
@@ -107,7 +107,7 @@ WorkoutPlan getWorkout({List<ExerciseBase>? exercises}) {
|
||||
);
|
||||
settingSquat.repetitionUnit = repetitionUnit1;
|
||||
settingSquat.weightUnit = weightUnit1;
|
||||
settingSquat.exerciseBase = testBases[4];
|
||||
settingSquat.exercise = testBases[4];
|
||||
settingSquat.weight = 120;
|
||||
|
||||
final setSquat = Set.withData(
|
||||
@@ -123,7 +123,7 @@ WorkoutPlan getWorkout({List<ExerciseBase>? exercises}) {
|
||||
final settingSideRaises = Setting(
|
||||
setId: 2,
|
||||
order: 1,
|
||||
exerciseBaseId: 8,
|
||||
exerciseId: 8,
|
||||
repetitionUnitId: 1,
|
||||
reps: 12,
|
||||
weightUnitId: 1,
|
||||
@@ -132,7 +132,7 @@ WorkoutPlan getWorkout({List<ExerciseBase>? exercises}) {
|
||||
);
|
||||
settingSideRaises.repetitionUnit = repetitionUnit1;
|
||||
settingSideRaises.weightUnit = weightUnit1;
|
||||
settingSideRaises.exerciseBase = testBases[5];
|
||||
settingSideRaises.exercise = testBases[5];
|
||||
settingSideRaises.weight = 6;
|
||||
|
||||
final setSideRaises = Set.withData(
|
||||
|
||||
Reference in New Issue
Block a user