mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 23:42:00 +01:00
Special handling of externally synchronized categories
This commit is contained in:
@@ -17,6 +17,9 @@ class MeasurementCategory extends Equatable {
|
||||
@JsonKey(required: true)
|
||||
final String name;
|
||||
|
||||
@JsonKey(required: true, name: 'internal_name')
|
||||
final String? internalName;
|
||||
|
||||
@JsonKey(required: true)
|
||||
final String unit;
|
||||
|
||||
@@ -27,19 +30,20 @@ class MeasurementCategory extends Equatable {
|
||||
final List<MeasurementEntry> entries;
|
||||
|
||||
MeasurementCategory({
|
||||
required this.id,
|
||||
this.id,
|
||||
required this.name,
|
||||
required this.unit,
|
||||
this.entries = const [],
|
||||
String? source,
|
||||
this.internalName,
|
||||
this.source = 'manual',
|
||||
String? uuid,
|
||||
}) : uuid = uuid ?? const Uuid().v7(),
|
||||
source = source ?? 'manual';
|
||||
}) : uuid = uuid ?? const Uuid().v7();
|
||||
|
||||
MeasurementCategory copyWith({
|
||||
int? id,
|
||||
String? uuid,
|
||||
String? name,
|
||||
String? internalName,
|
||||
String? unit,
|
||||
String? source,
|
||||
List<MeasurementEntry>? entries,
|
||||
@@ -48,6 +52,7 @@ class MeasurementCategory extends Equatable {
|
||||
id: id ?? this.id,
|
||||
uuid: uuid ?? this.uuid,
|
||||
name: name ?? this.name,
|
||||
internalName: internalName ?? this.internalName,
|
||||
unit: unit ?? this.unit,
|
||||
source: source ?? this.source,
|
||||
entries: entries ?? this.entries,
|
||||
@@ -61,6 +66,10 @@ class MeasurementCategory extends Equatable {
|
||||
);
|
||||
}
|
||||
|
||||
bool get isExternal => source != 'manual';
|
||||
|
||||
bool get isInternal => source == 'manual';
|
||||
|
||||
// Boilerplate
|
||||
factory MeasurementCategory.fromJson(Map<String, dynamic> json) =>
|
||||
_$MeasurementCategoryFromJson(json);
|
||||
|
||||
@@ -7,7 +7,7 @@ part of 'measurement_category.dart';
|
||||
// **************************************************************************
|
||||
|
||||
MeasurementCategory _$MeasurementCategoryFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(json, requiredKeys: const ['id', 'uuid', 'name', 'unit', 'source']);
|
||||
$checkKeys(json, requiredKeys: const ['id', 'uuid', 'name', 'internal_name', 'unit', 'source']);
|
||||
return MeasurementCategory(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
name: json['name'] as String,
|
||||
@@ -17,7 +17,8 @@ MeasurementCategory _$MeasurementCategoryFromJson(Map<String, dynamic> json) {
|
||||
?.map((e) => MeasurementEntry.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[],
|
||||
source: json['source'] as String?,
|
||||
internalName: json['internal_name'] as String?,
|
||||
source: json['source'] as String? ?? 'manual',
|
||||
uuid: json['uuid'] as String?,
|
||||
);
|
||||
}
|
||||
@@ -26,6 +27,7 @@ Map<String, dynamic> _$MeasurementCategoryToJson(MeasurementCategory instance) =
|
||||
'id': instance.id,
|
||||
'uuid': instance.uuid,
|
||||
'name': instance.name,
|
||||
'internal_name': instance.internalName,
|
||||
'unit': instance.unit,
|
||||
'source': instance.source,
|
||||
'entries': MeasurementCategory._nullValue(instance.entries),
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:health/health.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import '../models/measurements/measurement_entry.dart';
|
||||
import '../providers/health_sync_provider.dart';
|
||||
import '../providers/measurement.dart';
|
||||
import 'package:wger/models/measurements/measurement_category.dart';
|
||||
import 'package:wger/models/measurements/measurement_entry.dart';
|
||||
import 'package:wger/providers/health_sync_provider.dart';
|
||||
import 'package:wger/providers/measurement.dart';
|
||||
|
||||
class HealthService {
|
||||
final _logger = Logger('HealthService');
|
||||
@@ -12,19 +14,21 @@ class HealthService {
|
||||
final HealthSyncProvider provider;
|
||||
final MeasurementProvider measurementProvider;
|
||||
|
||||
final types = [
|
||||
HealthDataType.HEART_RATE,
|
||||
HealthDataType.STEPS,
|
||||
HealthDataType.ACTIVE_ENERGY_BURNED,
|
||||
HealthDataType.WEIGHT,
|
||||
HealthDataType.WATER,
|
||||
];
|
||||
|
||||
HealthService(this.provider, this.measurementProvider);
|
||||
|
||||
/// Requests permissions for health data types. Updates provider state accordingly.
|
||||
Future<bool> requestPermissions() async {
|
||||
provider.setLoading(true);
|
||||
provider.setError(null);
|
||||
final types = [
|
||||
HealthDataType.HEART_RATE,
|
||||
HealthDataType.STEPS,
|
||||
HealthDataType.ACTIVE_ENERGY_BURNED,
|
||||
HealthDataType.WEIGHT,
|
||||
HealthDataType.WATER,
|
||||
];
|
||||
|
||||
final permissions = types.map((_) => HealthDataAccess.READ).toList();
|
||||
try {
|
||||
final granted = await health.requestAuthorization(types, permissions: permissions);
|
||||
@@ -55,6 +59,75 @@ class HealthService {
|
||||
}
|
||||
}
|
||||
|
||||
String internalNameForType(HealthDataType type) {
|
||||
return type.toString().split('.').last.toLowerCase();
|
||||
}
|
||||
|
||||
/// Ensures all required categories for the given HealthDataTypes exist in MeasurementProvider
|
||||
Future<void> _ensureCategoriesExist(List<HealthDataType> types) async {
|
||||
// Only run on Android and iOS
|
||||
if (!(Platform.isAndroid || Platform.isIOS)) {
|
||||
return;
|
||||
}
|
||||
await measurementProvider.fetchAndSetCategories();
|
||||
final existingCategories = measurementProvider.categories;
|
||||
|
||||
String displayNameForType(HealthDataType type) {
|
||||
switch (type) {
|
||||
case HealthDataType.HEART_RATE:
|
||||
return 'Heart Rate';
|
||||
case HealthDataType.STEPS:
|
||||
return 'Steps';
|
||||
case HealthDataType.ACTIVE_ENERGY_BURNED:
|
||||
return 'Active Energy Burned';
|
||||
case HealthDataType.SLEEP_ASLEEP:
|
||||
return 'Sleep Asleep';
|
||||
case HealthDataType.DISTANCE_DELTA:
|
||||
return 'Distance';
|
||||
default:
|
||||
return internalNameForType(type);
|
||||
}
|
||||
}
|
||||
|
||||
String unitForType(HealthDataType type) {
|
||||
switch (type) {
|
||||
case HealthDataType.HEART_RATE:
|
||||
return 'bpm';
|
||||
case HealthDataType.STEPS:
|
||||
return 'steps';
|
||||
case HealthDataType.ACTIVE_ENERGY_BURNED:
|
||||
return 'kcal';
|
||||
case HealthDataType.SLEEP_ASLEEP:
|
||||
return 'minutes';
|
||||
case HealthDataType.DISTANCE_DELTA:
|
||||
return 'm';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
String sourceForPlatform() {
|
||||
if (Platform.isAndroid) return 'google_health';
|
||||
if (Platform.isIOS) return 'apple_health';
|
||||
return '';
|
||||
}
|
||||
|
||||
for (final type in types) {
|
||||
final internalName = internalNameForType(type);
|
||||
final exists = existingCategories.any((cat) => cat.internalName == internalName);
|
||||
if (!exists) {
|
||||
await measurementProvider.addCategory(
|
||||
MeasurementCategory(
|
||||
name: displayNameForType(type),
|
||||
internalName: internalName,
|
||||
unit: unitForType(type),
|
||||
source: sourceForPlatform(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Fetch historical health data for the last 30 days
|
||||
Future<void> _syncHistoricalData() async {
|
||||
final now = DateTime.now();
|
||||
@@ -67,13 +140,11 @@ class HealthService {
|
||||
HealthDataType.DISTANCE_DELTA,
|
||||
];
|
||||
|
||||
final Map<HealthDataType, int> categoryMap = {
|
||||
HealthDataType.HEART_RATE: 1,
|
||||
HealthDataType.STEPS: 2,
|
||||
HealthDataType.ACTIVE_ENERGY_BURNED: 3,
|
||||
HealthDataType.SLEEP_ASLEEP: 4,
|
||||
HealthDataType.DISTANCE_DELTA: 5,
|
||||
};
|
||||
// Ensure all required categories exist before syncing
|
||||
await _ensureCategoriesExist(types);
|
||||
await measurementProvider.fetchAndSetCategories();
|
||||
final updatedCategories = measurementProvider.categories;
|
||||
|
||||
try {
|
||||
final dataPoints = await health.getHealthDataFromTypes(
|
||||
startTime: startTime,
|
||||
@@ -101,19 +172,25 @@ class HealthService {
|
||||
default:
|
||||
unit = point.unitString ?? '';
|
||||
}
|
||||
// Kategorie-ID dynamisch suchen
|
||||
final internalName = internalNameForType(point.type);
|
||||
final category = updatedCategories.firstWhere(
|
||||
(cat) => cat.internalName == internalName,
|
||||
orElse: () => throw Exception('No category for $internalName'),
|
||||
);
|
||||
return MeasurementEntry(
|
||||
id: null,
|
||||
category: categoryMap[point.type] ?? 0,
|
||||
category: category.id!,
|
||||
date: point.dateFrom,
|
||||
value: 3,
|
||||
//point.value,
|
||||
// value: point.value,
|
||||
notes: unit,
|
||||
source: point.sourceName ?? 'health_platform',
|
||||
uuid: point.uuid ?? null,
|
||||
created: DateTime.now(),
|
||||
);
|
||||
}).toList();
|
||||
//await measurementProvider.addEntries(entries);
|
||||
await measurementProvider.addEntries(entries);
|
||||
} catch (e) {
|
||||
_logger.warning('Error syncing historical health data: $e');
|
||||
provider.setError('Error syncing historical health data: $e');
|
||||
|
||||
@@ -24,10 +24,7 @@ import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/widgets/measurements/entries.dart';
|
||||
import 'package:wger/widgets/measurements/forms.dart';
|
||||
|
||||
enum MeasurementOptions {
|
||||
edit,
|
||||
delete,
|
||||
}
|
||||
enum MeasurementOptions { edit, delete }
|
||||
|
||||
class MeasurementEntriesScreen extends StatelessWidget {
|
||||
const MeasurementEntriesScreen();
|
||||
@@ -36,6 +33,7 @@ class MeasurementEntriesScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final i18n = AppLocalizations.of(context);
|
||||
final categoryId = ModalRoute.of(context)!.settings.arguments as int;
|
||||
final category = Provider.of<MeasurementProvider>(context).findCategoryById(categoryId);
|
||||
|
||||
@@ -51,10 +49,7 @@ class MeasurementEntriesScreen extends StatelessWidget {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).edit,
|
||||
MeasurementCategoryForm(category),
|
||||
),
|
||||
arguments: FormScreenArguments(i18n.edit, MeasurementCategoryForm(category)),
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -64,24 +59,22 @@ class MeasurementEntriesScreen extends StatelessWidget {
|
||||
builder: (BuildContext contextDialog) {
|
||||
return AlertDialog(
|
||||
content: Text(
|
||||
AppLocalizations.of(context).confirmDelete(category.name),
|
||||
AppLocalizations.of(contextDialog).confirmDelete(category.name),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(MaterialLocalizations.of(context).cancelButtonLabel),
|
||||
child: Text(MaterialLocalizations.of(contextDialog).cancelButtonLabel),
|
||||
onPressed: () => Navigator.of(contextDialog).pop(),
|
||||
),
|
||||
TextButton(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).delete,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
AppLocalizations.of(contextDialog).delete,
|
||||
style: TextStyle(color: Theme.of(contextDialog).colorScheme.error),
|
||||
),
|
||||
onPressed: () {
|
||||
// Confirmed, delete the workout
|
||||
Provider.of<MeasurementProvider>(
|
||||
context,
|
||||
contextDialog,
|
||||
listen: false,
|
||||
).deleteCategory(category.id!);
|
||||
|
||||
@@ -89,10 +82,10 @@ class MeasurementEntriesScreen extends StatelessWidget {
|
||||
Navigator.of(contextDialog).pop();
|
||||
|
||||
// and inform the user
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(contextDialog).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(context).successfullyDeleted,
|
||||
AppLocalizations.of(contextDialog).successfullyDeleted,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
@@ -110,30 +103,29 @@ class MeasurementEntriesScreen extends StatelessWidget {
|
||||
return [
|
||||
PopupMenuItem<MeasurementOptions>(
|
||||
value: MeasurementOptions.edit,
|
||||
child: Text(AppLocalizations.of(context).edit),
|
||||
child: Text(i18n.edit),
|
||||
),
|
||||
PopupMenuItem<MeasurementOptions>(
|
||||
value: MeasurementOptions.delete,
|
||||
child: Text(AppLocalizations.of(context).delete),
|
||||
child: Text(i18n.delete),
|
||||
),
|
||||
];
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.add, color: Colors.white),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).newEntry,
|
||||
MeasurementEntryForm(categoryId),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
floatingActionButton: category.isInternal
|
||||
? FloatingActionButton(
|
||||
child: const Icon(Icons.add, color: Colors.white),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(i18n.newEntry, MeasurementEntryForm(categoryId)),
|
||||
);
|
||||
},
|
||||
)
|
||||
: null,
|
||||
body: SingleChildScrollView(
|
||||
child: Consumer<MeasurementProvider>(
|
||||
builder: (context, provider, child) => EntriesList(category),
|
||||
|
||||
@@ -28,19 +28,16 @@ class CategoriesCard extends StatelessWidget {
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 5),
|
||||
child: Text(
|
||||
currentCategory.name,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
child: Text(currentCategory.name, style: Theme.of(context).textTheme.titleLarge),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 5),
|
||||
child: Text('Externally synchronized', style: Theme.of(context).textTheme.titleSmall),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
height: 220,
|
||||
child: MeasurementChartWidgetFl(
|
||||
entriesAll,
|
||||
currentCategory.unit,
|
||||
avgs: entries7dAvg,
|
||||
),
|
||||
child: MeasurementChartWidgetFl(entriesAll, currentCategory.unit, avgs: entries7dAvg),
|
||||
),
|
||||
if (entries7dAvg.isNotEmpty)
|
||||
MeasurementOverallChangeWidget(
|
||||
@@ -62,19 +59,20 @@ class CategoriesCard extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
await Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).newEntry,
|
||||
MeasurementEntryForm(currentCategory.id!),
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.add),
|
||||
),
|
||||
if (currentCategory.isInternal)
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
await Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).newEntry,
|
||||
MeasurementEntryForm(currentCategory.id!),
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.add),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
@@ -53,7 +53,7 @@ dependencies:
|
||||
http: ^1.5.0
|
||||
image_picker: ^1.2.0
|
||||
intl: ^0.20.0
|
||||
json_annotation: ^4.8.1
|
||||
json_annotation: ^4.9.0
|
||||
multi_select_flutter: ^4.1.3
|
||||
package_info_plus: ^9.0.0
|
||||
path: ^1.9.0
|
||||
|
||||
@@ -28,23 +28,13 @@ import 'package:wger/providers/measurement.dart' as _i4;
|
||||
// ignore_for_file: invalid_use_of_internal_member
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
_FakeWgerBaseProvider_0(Object parent, Invocation parentInvocation)
|
||||
: super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeMeasurementCategory_1 extends _i1.SmartFake implements _i3.MeasurementCategory {
|
||||
_FakeMeasurementCategory_1(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
_FakeMeasurementCategory_1(Object parent, Invocation parentInvocation)
|
||||
: super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
/// A class which mocks [MeasurementProvider].
|
||||
@@ -56,145 +46,117 @@ class MockMeasurementProvider extends _i1.Mock implements _i4.MeasurementProvide
|
||||
}
|
||||
|
||||
@override
|
||||
_i2.WgerBaseProvider get baseProvider => (super.noSuchMethod(
|
||||
Invocation.getter(#baseProvider),
|
||||
returnValue: _FakeWgerBaseProvider_0(
|
||||
this,
|
||||
Invocation.getter(#baseProvider),
|
||||
),
|
||||
) as _i2.WgerBaseProvider);
|
||||
|
||||
@override
|
||||
List<_i3.MeasurementCategory> get categories => (super.noSuchMethod(
|
||||
Invocation.getter(#categories),
|
||||
returnValue: <_i3.MeasurementCategory>[],
|
||||
) as List<_i3.MeasurementCategory>);
|
||||
|
||||
@override
|
||||
bool get hasListeners => (super.noSuchMethod(
|
||||
Invocation.getter(#hasListeners),
|
||||
returnValue: false,
|
||||
) as bool);
|
||||
|
||||
@override
|
||||
void clear() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#clear,
|
||||
[],
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
_i3.MeasurementCategory findCategoryById(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#findCategoryById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _FakeMeasurementCategory_1(
|
||||
this,
|
||||
Invocation.method(
|
||||
#findCategoryById,
|
||||
[id],
|
||||
),
|
||||
),
|
||||
) as _i3.MeasurementCategory);
|
||||
|
||||
@override
|
||||
_i5.Future<void> fetchAndSetCategories() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetCategories,
|
||||
[],
|
||||
),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> fetchAndSetCategoryEntries(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetCategoryEntries,
|
||||
[id],
|
||||
),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> fetchAndSetAllCategoriesAndEntries() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchAndSetAllCategoriesAndEntries,
|
||||
[],
|
||||
),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> addCategory(_i3.MeasurementCategory? category) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addCategory,
|
||||
[category],
|
||||
),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> deleteCategory(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteCategory,
|
||||
[id],
|
||||
),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> editCategory(
|
||||
int? id,
|
||||
String? newName,
|
||||
String? newUnit,
|
||||
) =>
|
||||
_i2.WgerBaseProvider get baseProvider =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#editCategory,
|
||||
[
|
||||
id,
|
||||
newName,
|
||||
newUnit,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
Invocation.getter(#baseProvider),
|
||||
returnValue: _FakeWgerBaseProvider_0(this, Invocation.getter(#baseProvider)),
|
||||
)
|
||||
as _i2.WgerBaseProvider);
|
||||
|
||||
@override
|
||||
_i5.Future<void> addEntry(_i6.MeasurementEntry? entry) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addEntry,
|
||||
[entry],
|
||||
),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
List<_i3.MeasurementCategory> get categories =>
|
||||
(super.noSuchMethod(Invocation.getter(#categories), returnValue: <_i3.MeasurementCategory>[])
|
||||
as List<_i3.MeasurementCategory>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> deleteEntry(
|
||||
int? id,
|
||||
int? categoryId,
|
||||
) =>
|
||||
bool get hasListeners =>
|
||||
(super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool);
|
||||
|
||||
@override
|
||||
void clear() =>
|
||||
super.noSuchMethod(Invocation.method(#clear, []), returnValueForMissingStub: null);
|
||||
|
||||
@override
|
||||
_i3.MeasurementCategory findCategoryById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteEntry,
|
||||
[
|
||||
id,
|
||||
categoryId,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
Invocation.method(#findCategoryById, [id]),
|
||||
returnValue: _FakeMeasurementCategory_1(
|
||||
this,
|
||||
Invocation.method(#findCategoryById, [id]),
|
||||
),
|
||||
)
|
||||
as _i3.MeasurementCategory);
|
||||
|
||||
@override
|
||||
_i5.Future<void> fetchAndSetCategories() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetCategories, []),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
)
|
||||
as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> fetchAndSetCategoryEntries(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetCategoryEntries, [id]),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
)
|
||||
as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> fetchAndSetAllCategoriesAndEntries() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllCategoriesAndEntries, []),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
)
|
||||
as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> addCategory(_i3.MeasurementCategory? category) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addCategory, [category]),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
)
|
||||
as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> deleteCategory(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteCategory, [id]),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
)
|
||||
as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> editCategory(int? id, String? newName, String? newUnit) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editCategory, [id, newName, newUnit]),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
)
|
||||
as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> addEntry(_i6.MeasurementEntry? entry, {bool? notify = true}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addEntry, [entry], {#notify: notify}),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
)
|
||||
as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> addEntries(List<_i6.MeasurementEntry>? entries) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addEntries, [entries]),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
)
|
||||
as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> deleteEntry(int? id, int? categoryId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteEntry, [id, categoryId]),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
)
|
||||
as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
_i5.Future<void> editEntry(
|
||||
@@ -205,53 +167,29 @@ class MockMeasurementProvider extends _i1.Mock implements _i4.MeasurementProvide
|
||||
DateTime? newDate,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#editEntry,
|
||||
[
|
||||
id,
|
||||
categoryId,
|
||||
newValue,
|
||||
newNotes,
|
||||
newDate,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
Invocation.method(#editEntry, [id, categoryId, newValue, newNotes, newDate]),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
)
|
||||
as _i5.Future<void>);
|
||||
|
||||
@override
|
||||
void addListener(_i7.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addListener,
|
||||
[listener],
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
Invocation.method(#addListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i7.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#removeListener,
|
||||
[listener],
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
Invocation.method(#removeListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#dispose,
|
||||
[],
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
void dispose() =>
|
||||
super.noSuchMethod(Invocation.method(#dispose, []), returnValueForMissingStub: null);
|
||||
|
||||
@override
|
||||
void notifyListeners() => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#notifyListeners,
|
||||
[],
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
void notifyListeners() =>
|
||||
super.noSuchMethod(Invocation.method(#notifyListeners, []), returnValueForMissingStub: null);
|
||||
}
|
||||
|
||||
@@ -26,43 +26,19 @@ import 'package:wger/providers/base_provider.dart' as _i4;
|
||||
// ignore_for_file: invalid_use_of_internal_member
|
||||
|
||||
class _FakeAuthProvider_0 extends _i1.SmartFake implements _i2.AuthProvider {
|
||||
_FakeAuthProvider_0(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
_FakeAuthProvider_0(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeClient_1 extends _i1.SmartFake implements _i3.Client {
|
||||
_FakeClient_1(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
_FakeClient_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeUri_2 extends _i1.SmartFake implements Uri {
|
||||
_FakeUri_2(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
_FakeUri_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response {
|
||||
_FakeResponse_3(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
_FakeResponse_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
/// A class which mocks [WgerBaseProvider].
|
||||
@@ -74,154 +50,95 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
}
|
||||
|
||||
@override
|
||||
_i2.AuthProvider get auth => (super.noSuchMethod(
|
||||
Invocation.getter(#auth),
|
||||
returnValue: _FakeAuthProvider_0(
|
||||
this,
|
||||
Invocation.getter(#auth),
|
||||
),
|
||||
) as _i2.AuthProvider);
|
||||
|
||||
@override
|
||||
_i3.Client get client => (super.noSuchMethod(
|
||||
Invocation.getter(#client),
|
||||
returnValue: _FakeClient_1(
|
||||
this,
|
||||
Invocation.getter(#client),
|
||||
),
|
||||
) as _i3.Client);
|
||||
|
||||
@override
|
||||
set auth(_i2.AuthProvider? value) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#auth,
|
||||
value,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set client(_i3.Client? value) => super.noSuchMethod(
|
||||
Invocation.setter(
|
||||
#client,
|
||||
value,
|
||||
),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getDefaultHeaders,
|
||||
[],
|
||||
{#includeAuth: includeAuth},
|
||||
),
|
||||
returnValue: <String, String>{},
|
||||
) as Map<String, String>);
|
||||
|
||||
@override
|
||||
Uri makeUrl(
|
||||
String? path, {
|
||||
int? id,
|
||||
String? objectMethod,
|
||||
Map<String, dynamic>? query,
|
||||
}) =>
|
||||
_i2.AuthProvider get auth =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#makeUrl,
|
||||
[path],
|
||||
{
|
||||
#id: id,
|
||||
#objectMethod: objectMethod,
|
||||
#query: query,
|
||||
},
|
||||
),
|
||||
returnValue: _FakeUri_2(
|
||||
this,
|
||||
Invocation.method(
|
||||
#makeUrl,
|
||||
[path],
|
||||
{
|
||||
#id: id,
|
||||
#objectMethod: objectMethod,
|
||||
#query: query,
|
||||
},
|
||||
),
|
||||
),
|
||||
) as Uri);
|
||||
Invocation.getter(#auth),
|
||||
returnValue: _FakeAuthProvider_0(this, Invocation.getter(#auth)),
|
||||
)
|
||||
as _i2.AuthProvider);
|
||||
|
||||
@override
|
||||
_i5.Future<dynamic> fetch(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetch,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<dynamic>.value(),
|
||||
) as _i5.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchPaginated,
|
||||
[uri],
|
||||
),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
) as _i5.Future<List<dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> post(
|
||||
Map<String, dynamic>? data,
|
||||
Uri? uri,
|
||||
) =>
|
||||
_i3.Client get client =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#post,
|
||||
[
|
||||
data,
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
Invocation.getter(#client),
|
||||
returnValue: _FakeClient_1(this, Invocation.getter(#client)),
|
||||
)
|
||||
as _i3.Client);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> patch(
|
||||
Map<String, dynamic>? data,
|
||||
Uri? uri,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#patch,
|
||||
[
|
||||
data,
|
||||
uri,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
) as _i5.Future<Map<String, dynamic>>);
|
||||
set auth(_i2.AuthProvider? value) =>
|
||||
super.noSuchMethod(Invocation.setter(#auth, value), returnValueForMissingStub: null);
|
||||
|
||||
@override
|
||||
_i5.Future<_i3.Response> deleteRequest(
|
||||
String? url,
|
||||
int? id,
|
||||
) =>
|
||||
set client(_i3.Client? value) =>
|
||||
super.noSuchMethod(Invocation.setter(#client, value), returnValueForMissingStub: null);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteRequest,
|
||||
[
|
||||
url,
|
||||
id,
|
||||
],
|
||||
),
|
||||
returnValue: _i5.Future<_i3.Response>.value(_FakeResponse_3(
|
||||
this,
|
||||
Invocation.method(
|
||||
#deleteRequest,
|
||||
[
|
||||
url,
|
||||
id,
|
||||
],
|
||||
),
|
||||
)),
|
||||
) as _i5.Future<_i3.Response>);
|
||||
Invocation.method(#getDefaultHeaders, [], {#includeAuth: includeAuth}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
as Map<String, String>);
|
||||
|
||||
@override
|
||||
Uri makeUrl(String? path, {int? id, String? objectMethod, Map<String, dynamic>? query}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#makeUrl,
|
||||
[path],
|
||||
{#id: id, #objectMethod: objectMethod, #query: query},
|
||||
),
|
||||
returnValue: _FakeUri_2(
|
||||
this,
|
||||
Invocation.method(
|
||||
#makeUrl,
|
||||
[path],
|
||||
{#id: id, #objectMethod: objectMethod, #query: query},
|
||||
),
|
||||
),
|
||||
)
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<dynamic> fetch(Uri? uri) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
returnValue: _i5.Future<dynamic>.value(),
|
||||
)
|
||||
as _i5.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i5.Future<List<dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> post(Map<String, dynamic>? data, Uri? uri) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#post, [data, uri]),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
)
|
||||
as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> patch(Map<String, dynamic>? data, Uri? uri) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#patch, [data, uri]),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
|
||||
)
|
||||
as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i3.Response> deleteRequest(String? url, int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteRequest, [url, id]),
|
||||
returnValue: _i5.Future<_i3.Response>.value(
|
||||
_FakeResponse_3(this, Invocation.method(#deleteRequest, [url, id])),
|
||||
),
|
||||
)
|
||||
as _i5.Future<_i3.Response>);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user