Replace fork with upstream package

This commit is contained in:
Roland Geider
2026-11-24 15:24:53 +01:00
parent 3ac3abe306
commit fab3af04ec
19 changed files with 565 additions and 377 deletions

View File

@@ -91,7 +91,7 @@
<string>Workout photos</string>
<key>NSHealthShareUsageDescription</key>
<string>wger reads your Apple Health data to import measurements and activity such as weight, body fat, blood pressure, heart rate, blood oxygen, sleep, steps, distance, and active energy into your wger account</string>
<!-- wger only reads from HealthKit, but health_bridge links Apple's write API
<!-- wger only reads from HealthKit, but the health plugin links Apple's write API
(requestAuthorization(toShare:read:), save, delete), so App Store validation
rejects the upload without this key (ITMS-90683). -->
<key>NSHealthUpdateUsageDescription</key>

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:health_bridge/health.dart';
import 'package:health/health.dart';
import 'package:wger/features/measurements/models/measurement_category.dart';
/// Timeline a single platform query covers unless the metric says otherwise,

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:health_bridge/health.dart';
import 'package:health/health.dart';
/// A single reading pulled from a health platform, reduced to the fields the
/// importer needs. Keeps the `health` package's [HealthDataPoint] out of the

View File

@@ -17,7 +17,7 @@
*/
import 'package:collection/collection.dart';
import 'package:health_bridge/health.dart';
import 'package:health/health.dart';
import 'package:logging/logging.dart';
import 'package:powersync/powersync.dart' as ps;
import 'package:wger/features/health/models/daily_windows.dart';

View File

@@ -17,7 +17,7 @@
*/
import 'package:collection/collection.dart';
import 'package:health_bridge/health.dart';
import 'package:health/health.dart';
import 'package:logging/logging.dart';
import 'package:powersync/powersync.dart' as ps;
import 'package:wger/core/network/auth_credentials_storage.dart';

View File

@@ -21,7 +21,7 @@ import 'dart:io';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/services.dart' show PlatformException;
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:health_bridge/health.dart';
import 'package:health/health.dart';
import 'package:logging/logging.dart';
import 'package:wger/features/health/models/health_metric.dart';
import 'package:wger/features/health/models/health_reading.dart';
@@ -101,15 +101,15 @@ class HealthRepository {
/// The subset of [types] the platform lets us read, without ever showing a
/// permission dialog.
///
/// Asked per type on purpose. Both platforms hand out access per data type,
/// and Health Connect's dialog invites the user to untick individual ones,
/// so a single declined type must cost only its own metric its import.
/// (`hasPermissions` answers for the whole list at once, which turned one
/// declined type into a full stop.)
/// Asked one type per call on purpose. Both platforms hand out access per
/// data type, and Health Connect's dialog invites the user to untick
/// individual ones, so a single declined type must cost only its own metric
/// its import. (`hasPermissions` with the whole list is only true when every
/// type is granted, which turned one declined type into a full stop.)
///
/// Only Android answers exactly. HealthKit does not disclose read access, so
/// the types it maps come back as `requestedOrUnknown` and count as
/// readable; a denial there only shows up when the read fails, see
/// `hasPermissions` returns null there and the type counts as readable; a
/// denial there only shows up when the read fails, see
/// [isAuthorizationMissing].
Future<Set<HealthDataType>> readableTypes(List<HealthDataType> types) async {
if (types.isEmpty) {
@@ -117,30 +117,23 @@ class HealthRepository {
}
await _health.configure();
try {
final snapshot = await _health.getAuthorizationSnapshot(types.toSet().toList());
if (!snapshot.available) {
return {};
final readable = <HealthDataType>{};
for (final type in types.toSet()) {
try {
if (await _health.hasPermissions([type]) != false) {
readable.add(type);
}
} catch (e) {
// The check only refines what we try: without it the type is read and
// fails on its own if the platform refuses it, which is the behaviour
// this method improves on, not one it depends on
_logger.warning('Could not check the permission for ${type.name}, trying it anyway: $e');
readable.add(type);
}
return {
for (final entry in snapshot.types)
if (_isReadable(entry.read)) entry.type,
};
} catch (e) {
// The snapshot only refines what we try: without it every type is read
// and the ones the platform refuses fail individually, which is the
// behaviour this method improves on, not one it depends on
_logger.warning('Could not read the authorization snapshot, trying every type: $e');
return types.toSet();
}
return readable;
}
static bool _isReadable(HealthAuthorizationState state) => switch (state) {
// iOS never reports more than "was requested at some point"
HealthAuthorizationState.authorized || HealthAuthorizationState.requestedOrUnknown => true,
_ => false,
};
/// Whether [error] is the platform refusing a read for lack of permissions.
///
/// HealthKit throws this when authorization for a type was never requested
@@ -201,9 +194,9 @@ class HealthRepository {
/// record). Adding up the raw records instead counts those twice. The value
/// is in the platform's raw unit (count, meters, kcal), like a raw read.
///
/// Null on iOS, on failure, or when the platform returned nothing, so the
/// caller can fall back to the raw sum. A range without data from the
/// user's priority list comes back as 0, not null.
/// Null on iOS, on failure, or when the platform returned nothing (it omits
/// a range without data from the user's priority list), so the caller can
/// fall back to the raw sum.
Future<double?> platformTotal(HealthDataType type, DateTime start, DateTime end) async {
if (!hasPlatformTotals || !end.isAfter(start)) {
return null;

View File

@@ -193,6 +193,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.1.2"
carp_serializable:
dependency: transitive
description:
name: carp_serializable
sha256: efeac6afbc85c3763fac382647cec6395368cf4c3ecfea4d2d10f95d99c03705
url: "https://pub.dev"
source: hosted
version: "3.0.2"
change:
dependency: transitive
description:
@@ -759,15 +767,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.2"
health_bridge:
health:
dependency: "direct main"
description:
path: "."
ref: "v2.1.0"
resolved-ref: "05515122beb1ac6e93a3b558b5468af16c3e5aaf"
url: "https://github.com/ytsni/health_bridge.git"
source: git
version: "2.1.0"
name: health
sha256: "683d15fdde49a942bacce871faf3090bda3c1f5dad995725337aeb1dfd348e6d"
url: "https://pub.dev"
source: hosted
version: "14.0.0"
hooks:
dependency: transitive
description:

View File

@@ -54,13 +54,7 @@ dependencies:
flutter_zxing: ^3.1.1
font_awesome_flutter: ^11.0.0
freezed_annotation: ^3.1.0
# A maintained fork of `health` 13.3.1. We need its per-type authorization
# snapshot (see HealthRepository.readableTypes) plus its Health Connect and
# iOS crash fixes, none of which upstream has picked up.
health_bridge:
git:
url: https://github.com/ytsni/health_bridge.git
ref: v2.1.0
health: ^14.0.0
http: ^1.6.0
image_picker: ^1.2.3
intl: ^0.20.2

View File

@@ -19,7 +19,7 @@
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:health_bridge/health.dart';
import 'package:health/health.dart';
import 'package:wger/database/powersync/powersync.dart';
import 'package:wger/features/health/models/health_metric.dart';

View File

@@ -17,7 +17,7 @@
*/
import 'package:flutter_test/flutter_test.dart';
import 'package:health_bridge/health.dart';
import 'package:health/health.dart';
import 'package:wger/features/health/models/daily_windows.dart';
import 'package:wger/features/health/models/health_metric.dart';
import 'package:wger/features/health/models/health_reading.dart';

View File

@@ -17,7 +17,7 @@
*/
import 'package:flutter_test/flutter_test.dart';
import 'package:health_bridge/health.dart';
import 'package:health/health.dart';
import 'package:wger/features/health/models/health_metric.dart';
import 'package:wger/features/measurements/models/measurement_category.dart';

View File

@@ -17,7 +17,7 @@
*/
import 'package:flutter_test/flutter_test.dart';
import 'package:health_bridge/health.dart';
import 'package:health/health.dart';
import 'package:wger/features/health/models/health_reading.dart';
HealthDataPoint dataPoint({String uuid = 'abc-123', HealthValue? value}) {

View File

@@ -19,7 +19,7 @@
import 'package:collection/collection.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:health_bridge/health.dart';
import 'package:health/health.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:powersync/powersync.dart' as ps;

View File

@@ -6,7 +6,7 @@
import 'dart:async' as _i4;
import 'package:health_bridge/health.dart' as _i5;
import 'package:health/health.dart' as _i5;
import 'package:mockito/mockito.dart' as _i1;
import 'package:mockito/src/dummies.dart' as _i3;
import 'package:wger/core/network/auth_credentials_storage.dart' as _i11;

View File

@@ -17,7 +17,7 @@
*/
import 'package:flutter_test/flutter_test.dart';
import 'package:health_bridge/health.dart';
import 'package:health/health.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:wger/features/health/models/health_metric.dart';
@@ -363,4 +363,39 @@ void main() {
);
});
});
group('readableTypes', () {
test('a declined type costs only itself', () async {
// Asked for both at once, the platform says false as soon as one is
// missing, which would drop the granted type too
when(health.hasPermissions(any)).thenAnswer((invocation) async {
final types = invocation.positionalArguments.first as List<HealthDataType>;
return !types.contains(HealthDataType.HEART_RATE);
});
final readable = await repository.readableTypes([
HealthDataType.WEIGHT,
HealthDataType.HEART_RATE,
]);
expect(readable, {HealthDataType.WEIGHT});
});
test('an undisclosed read access counts as readable', () async {
// HealthKit never tells whether reading was granted
when(health.hasPermissions(any)).thenAnswer((_) async => null);
final readable = await repository.readableTypes([HealthDataType.WEIGHT]);
expect(readable, {HealthDataType.WEIGHT});
});
test('a failing check still tries the type', () async {
when(health.hasPermissions(any)).thenThrow(Exception('boom'));
final readable = await repository.readableTypes([HealthDataType.WEIGHT]);
expect(readable, {HealthDataType.WEIGHT});
});
});
}

View File

@@ -6,7 +6,7 @@
import 'dart:async' as _i4;
import 'package:health_bridge/health.dart' as _i2;
import 'package:health/health.dart' as _i2;
import 'package:mockito/mockito.dart' as _i1;
import 'package:mockito/src/dummies.dart' as _i3;
@@ -34,6 +34,17 @@ class MockHealth extends _i1.Mock implements _i2.Health {
_i1.throwOnMissingStub(this);
}
@override
_i2.HealthIsolateMode get isolateMode =>
(super.noSuchMethod(
Invocation.getter(#isolateMode),
returnValue: _i2.HealthIsolateMode.auto,
)
as _i2.HealthIsolateMode);
@override
int get pageSize => (super.noSuchMethod(Invocation.getter(#pageSize), returnValue: 0) as int);
@override
_i2.HealthConnectSdkStatus get healthConnectSdkStatus =>
(super.noSuchMethod(
@@ -61,6 +72,18 @@ class MockHealth extends _i1.Mock implements _i2.Health {
)
as String);
@override
set isolateMode(_i2.HealthIsolateMode? value) => super.noSuchMethod(
Invocation.setter(#isolateMode, value),
returnValueForMissingStub: null,
);
@override
set pageSize(int? value) => super.noSuchMethod(
Invocation.setter(#pageSize, value),
returnValueForMissingStub: null,
);
@override
_i4.Future<void> configure() =>
(super.noSuchMethod(
@@ -78,45 +101,6 @@ class MockHealth extends _i1.Mock implements _i2.Health {
)
as bool);
@override
_i4.Future<bool?> hasPermissions(
List<_i2.HealthDataType>? types, {
List<_i2.HealthDataAccess>? permissions,
}) =>
(super.noSuchMethod(
Invocation.method(
#hasPermissions,
[types],
{#permissions: permissions},
),
returnValue: _i4.Future<bool?>.value(),
)
as _i4.Future<bool?>);
@override
_i4.Future<_i2.HealthAuthorizationSnapshot> getAuthorizationSnapshot(
List<_i2.HealthDataType>? types,
) =>
(super.noSuchMethod(
Invocation.method(#getAuthorizationSnapshot, [types]),
returnValue: _i4.Future<_i2.HealthAuthorizationSnapshot>.value(
_i3.dummyValue<_i2.HealthAuthorizationSnapshot>(
this,
Invocation.method(#getAuthorizationSnapshot, [types]),
),
),
)
as _i4.Future<_i2.HealthAuthorizationSnapshot>);
@override
_i4.Future<void> revokePermissions() =>
(super.noSuchMethod(
Invocation.method(#revokePermissions, []),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
)
as _i4.Future<void>);
@override
_i4.Future<_i2.HealthConnectSdkStatus?> getHealthConnectSdkStatus() =>
(super.noSuchMethod(
@@ -125,6 +109,186 @@ class MockHealth extends _i1.Mock implements _i2.Health {
)
as _i4.Future<_i2.HealthConnectSdkStatus?>);
@override
_i4.Future<bool> writeHealthData({
required double? value,
_i2.HealthDataUnit? unit,
required _i2.HealthDataType? type,
required DateTime? startTime,
String? clientRecordId,
double? clientRecordVersion,
DateTime? endTime,
_i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
}) =>
(super.noSuchMethod(
Invocation.method(#writeHealthData, [], {
#value: value,
#unit: unit,
#type: type,
#startTime: startTime,
#clientRecordId: clientRecordId,
#clientRecordVersion: clientRecordVersion,
#endTime: endTime,
#recordingMethod: recordingMethod,
}),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<bool>);
@override
_i4.Future<_i2.HealthDataPoint?> getHealthDataByUUID({
required String? uuid,
required _i2.HealthDataType? type,
}) =>
(super.noSuchMethod(
Invocation.method(#getHealthDataByUUID, [], {
#uuid: uuid,
#type: type,
}),
returnValue: _i4.Future<_i2.HealthDataPoint?>.value(),
)
as _i4.Future<_i2.HealthDataPoint?>);
@override
_i4.Future<List<_i2.HealthDataPoint>> getHealthDataFromTypes({
required List<_i2.HealthDataType>? types,
Map<_i2.HealthDataType, _i2.HealthDataUnit>? preferredUnits,
required DateTime? startTime,
required DateTime? endTime,
List<_i2.RecordingMethod>? recordingMethodsToFilter = const [],
int? limit,
}) =>
(super.noSuchMethod(
Invocation.method(#getHealthDataFromTypes, [], {
#types: types,
#preferredUnits: preferredUnits,
#startTime: startTime,
#endTime: endTime,
#recordingMethodsToFilter: recordingMethodsToFilter,
#limit: limit,
}),
returnValue: _i4.Future<List<_i2.HealthDataPoint>>.value(
<_i2.HealthDataPoint>[],
),
)
as _i4.Future<List<_i2.HealthDataPoint>>);
@override
_i4.Stream<_i2.HealthDataPage> getHealthDataPages({
required List<_i2.HealthDataType>? types,
required DateTime? startTime,
required DateTime? endTime,
Map<_i2.HealthDataType, _i2.HealthDataUnit>? preferredUnits,
List<_i2.RecordingMethod>? recordingMethodsToFilter = const [],
int? pageSize,
}) =>
(super.noSuchMethod(
Invocation.method(#getHealthDataPages, [], {
#types: types,
#startTime: startTime,
#endTime: endTime,
#preferredUnits: preferredUnits,
#recordingMethodsToFilter: recordingMethodsToFilter,
#pageSize: pageSize,
}),
returnValue: _i4.Stream<_i2.HealthDataPage>.empty(),
)
as _i4.Stream<_i2.HealthDataPage>);
@override
List<_i2.HealthDataPoint> removeDuplicates(
List<_i2.HealthDataPoint>? points,
) =>
(super.noSuchMethod(
Invocation.method(#removeDuplicates, [points]),
returnValue: <_i2.HealthDataPoint>[],
)
as List<_i2.HealthDataPoint>);
@override
_i4.Future<List<_i2.HealthDataPoint>> getHealthIntervalDataFromTypes({
required DateTime? startDate,
required DateTime? endDate,
required List<_i2.HealthDataType>? types,
required int? interval,
List<_i2.RecordingMethod>? recordingMethodsToFilter = const [],
}) =>
(super.noSuchMethod(
Invocation.method(#getHealthIntervalDataFromTypes, [], {
#startDate: startDate,
#endDate: endDate,
#types: types,
#interval: interval,
#recordingMethodsToFilter: recordingMethodsToFilter,
}),
returnValue: _i4.Future<List<_i2.HealthDataPoint>>.value(
<_i2.HealthDataPoint>[],
),
)
as _i4.Future<List<_i2.HealthDataPoint>>);
@override
_i4.Future<List<_i2.HealthDataPoint>> getHealthAggregateDataFromTypes({
required List<_i2.HealthDataType>? types,
required DateTime? startDate,
required DateTime? endDate,
int? activitySegmentDuration = 1,
bool? includeManualEntry = true,
}) =>
(super.noSuchMethod(
Invocation.method(#getHealthAggregateDataFromTypes, [], {
#types: types,
#startDate: startDate,
#endDate: endDate,
#activitySegmentDuration: activitySegmentDuration,
#includeManualEntry: includeManualEntry,
}),
returnValue: _i4.Future<List<_i2.HealthDataPoint>>.value(
<_i2.HealthDataPoint>[],
),
)
as _i4.Future<List<_i2.HealthDataPoint>>);
@override
_i4.Future<int> getTotalStepsInInterval(
DateTime? startTime,
DateTime? endTime, {
bool? includeManualEntry = true,
}) =>
(super.noSuchMethod(
Invocation.method(
#getTotalStepsInInterval,
[startTime, endTime],
{#includeManualEntry: includeManualEntry},
),
returnValue: _i4.Future<int>.value(0),
)
as _i4.Future<int>);
@override
_i4.Future<String?> getChangesToken({
required List<_i2.HealthDataType>? types,
}) =>
(super.noSuchMethod(
Invocation.method(#getChangesToken, [], {#types: types}),
returnValue: _i4.Future<String?>.value(),
)
as _i4.Future<String?>);
@override
_i4.Future<_i2.HealthChangesResponse?> getChanges({
required String? changesToken,
bool? includeSelf = false,
}) =>
(super.noSuchMethod(
Invocation.method(#getChanges, [], {
#changesToken: changesToken,
#includeSelf: includeSelf,
}),
returnValue: _i4.Future<_i2.HealthChangesResponse?>.value(),
)
as _i4.Future<_i2.HealthChangesResponse?>);
@override
_i4.Future<bool> isHealthConnectAvailable() =>
(super.noSuchMethod(
@@ -198,6 +362,37 @@ class MockHealth extends _i1.Mock implements _i2.Health {
)
as _i4.Future<bool>);
@override
_i4.Future<bool> isMindfulnessSessionAvailable() =>
(super.noSuchMethod(
Invocation.method(#isMindfulnessSessionAvailable, []),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<bool>);
@override
_i4.Future<bool> isActivityIntensityAvailable() =>
(super.noSuchMethod(
Invocation.method(#isActivityIntensityAvailable, []),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<bool>);
@override
_i4.Future<bool?> hasPermissions(
List<_i2.HealthDataType>? types, {
List<_i2.HealthDataAccess>? permissions,
}) =>
(super.noSuchMethod(
Invocation.method(
#hasPermissions,
[types],
{#permissions: permissions},
),
returnValue: _i4.Future<bool?>.value(),
)
as _i4.Future<bool?>);
@override
_i4.Future<bool> requestAuthorization(
List<_i2.HealthDataType>? types, {
@@ -214,7 +409,31 @@ class MockHealth extends _i1.Mock implements _i2.Health {
as _i4.Future<bool>);
@override
_i4.Future<String?> writeHealthData({
_i4.Future<_i2.HealthAuthorizationRequestStatus?> getRequestStatusForAuthorization(
List<_i2.HealthDataType>? types, {
List<_i2.HealthDataAccess>? permissions,
}) =>
(super.noSuchMethod(
Invocation.method(
#getRequestStatusForAuthorization,
[types],
{#permissions: permissions},
),
returnValue: _i4.Future<_i2.HealthAuthorizationRequestStatus?>.value(),
)
as _i4.Future<_i2.HealthAuthorizationRequestStatus?>);
@override
_i4.Future<void> revokePermissions() =>
(super.noSuchMethod(
Invocation.method(#revokePermissions, []),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
)
as _i4.Future<void>);
@override
_i4.Future<String?> writeHealthDataUUID({
required double? value,
_i2.HealthDataUnit? unit,
required _i2.HealthDataType? type,
@@ -225,7 +444,7 @@ class MockHealth extends _i1.Mock implements _i2.Health {
_i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
}) =>
(super.noSuchMethod(
Invocation.method(#writeHealthData, [], {
Invocation.method(#writeHealthDataUUID, [], {
#value: value,
#unit: unit,
#type: type,
@@ -239,71 +458,6 @@ class MockHealth extends _i1.Mock implements _i2.Health {
)
as _i4.Future<String?>);
@override
_i4.Future<bool> writeActivityIntensity({
required _i2.ActivityIntensityLevel? intensityLevel,
required DateTime? startTime,
DateTime? endTime,
_i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
String? clientRecordId,
double? clientRecordVersion,
}) =>
(super.noSuchMethod(
Invocation.method(#writeActivityIntensity, [], {
#intensityLevel: intensityLevel,
#startTime: startTime,
#endTime: endTime,
#recordingMethod: recordingMethod,
#clientRecordId: clientRecordId,
#clientRecordVersion: clientRecordVersion,
}),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<bool>);
@override
_i4.Future<bool> delete({
required _i2.HealthDataType? type,
required DateTime? startTime,
DateTime? endTime,
}) =>
(super.noSuchMethod(
Invocation.method(#delete, [], {
#type: type,
#startTime: startTime,
#endTime: endTime,
}),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<bool>);
@override
_i4.Future<bool> deleteByUUID({
required String? uuid,
_i2.HealthDataType? type,
}) =>
(super.noSuchMethod(
Invocation.method(#deleteByUUID, [], {#uuid: uuid, #type: type}),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<bool>);
@override
_i4.Future<bool> deleteByClientRecordId({
required _i2.HealthDataType? dataTypeKey,
required String? clientRecordId,
String? recordId,
}) =>
(super.noSuchMethod(
Invocation.method(#deleteByClientRecordId, [], {
#dataTypeKey: dataTypeKey,
#clientRecordId: clientRecordId,
#recordId: recordId,
}),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<bool>);
@override
_i4.Future<bool> writeBloodPressure({
required int? systolic,
@@ -346,6 +500,110 @@ class MockHealth extends _i1.Mock implements _i2.Health {
)
as _i4.Future<bool>);
@override
_i4.Future<bool> writeMenstruationFlow({
required _i2.MenstrualFlow? flow,
required DateTime? startTime,
required DateTime? endTime,
required bool? isStartOfCycle,
_i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
}) =>
(super.noSuchMethod(
Invocation.method(#writeMenstruationFlow, [], {
#flow: flow,
#startTime: startTime,
#endTime: endTime,
#isStartOfCycle: isStartOfCycle,
#recordingMethod: recordingMethod,
}),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<bool>);
@override
_i4.Future<bool> writeSexualActivity({
_i2.SexualActivityProtection? protectionUsed = _i2.SexualActivityProtection.unknown,
required DateTime? startTime,
DateTime? endTime,
_i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
String? clientRecordId,
double? clientRecordVersion,
}) =>
(super.noSuchMethod(
Invocation.method(#writeSexualActivity, [], {
#protectionUsed: protectionUsed,
#startTime: startTime,
#endTime: endTime,
#recordingMethod: recordingMethod,
#clientRecordId: clientRecordId,
#clientRecordVersion: clientRecordVersion,
}),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<bool>);
@override
_i4.Future<bool> writeAudiogram({
required List<double>? frequencies,
required List<double>? leftEarSensitivities,
required List<double>? rightEarSensitivities,
required DateTime? startTime,
DateTime? endTime,
Map<String, dynamic>? metadata,
}) =>
(super.noSuchMethod(
Invocation.method(#writeAudiogram, [], {
#frequencies: frequencies,
#leftEarSensitivities: leftEarSensitivities,
#rightEarSensitivities: rightEarSensitivities,
#startTime: startTime,
#endTime: endTime,
#metadata: metadata,
}),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<bool>);
@override
_i4.Future<bool> writeInsulinDelivery(
double? units,
_i2.InsulinDeliveryReason? reason,
DateTime? startTime,
DateTime? endTime,
) =>
(super.noSuchMethod(
Invocation.method(#writeInsulinDelivery, [
units,
reason,
startTime,
endTime,
]),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<bool>);
@override
_i4.Future<bool> writeActivityIntensity({
required _i2.ActivityIntensityLevel? intensityLevel,
required DateTime? startTime,
DateTime? endTime,
_i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
String? clientRecordId,
double? clientRecordVersion,
}) =>
(super.noSuchMethod(
Invocation.method(#writeActivityIntensity, [], {
#intensityLevel: intensityLevel,
#startTime: startTime,
#endTime: endTime,
#recordingMethod: recordingMethod,
#clientRecordId: clientRecordId,
#clientRecordVersion: clientRecordVersion,
}),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<bool>);
@override
_i4.Future<bool> writeMeal({
required _i2.MealType? mealType,
@@ -453,19 +711,21 @@ class MockHealth extends _i1.Mock implements _i2.Health {
as _i4.Future<bool>);
@override
_i4.Future<bool> writeMenstruationFlow({
required _i2.MenstrualFlow? flow,
_i4.Future<bool> writeSleepSession({
required DateTime? startTime,
required DateTime? endTime,
required bool? isStartOfCycle,
List<_i2.SleepSessionStage>? stages = const [],
String? title,
String? notes,
_i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
}) =>
(super.noSuchMethod(
Invocation.method(#writeMenstruationFlow, [], {
#flow: flow,
Invocation.method(#writeSleepSession, [], {
#startTime: startTime,
#endTime: endTime,
#isStartOfCycle: isStartOfCycle,
#stages: stages,
#title: title,
#notes: notes,
#recordingMethod: recordingMethod,
}),
returnValue: _i4.Future<bool>.value(false),
@@ -473,254 +733,153 @@ class MockHealth extends _i1.Mock implements _i2.Health {
as _i4.Future<bool>);
@override
_i4.Future<bool> writeAudiogram({
required List<double>? frequencies,
required List<double>? leftEarSensitivities,
required List<double>? rightEarSensitivities,
required DateTime? startTime,
DateTime? endTime,
Map<String, dynamic>? metadata,
}) =>
(super.noSuchMethod(
Invocation.method(#writeAudiogram, [], {
#frequencies: frequencies,
#leftEarSensitivities: leftEarSensitivities,
#rightEarSensitivities: rightEarSensitivities,
#startTime: startTime,
#endTime: endTime,
#metadata: metadata,
}),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<bool>);
@override
_i4.Future<bool> writeInsulinDelivery(
double? units,
_i2.InsulinDeliveryReason? reason,
DateTime? startTime,
DateTime? endTime,
) =>
(super.noSuchMethod(
Invocation.method(#writeInsulinDelivery, [
units,
reason,
startTime,
endTime,
]),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<bool>);
@override
_i4.Future<_i2.HealthDataPoint?> getHealthDataByUUID({
required String? uuid,
required _i2.HealthDataType? type,
}) =>
(super.noSuchMethod(
Invocation.method(#getHealthDataByUUID, [], {
#uuid: uuid,
#type: type,
}),
returnValue: _i4.Future<_i2.HealthDataPoint?>.value(),
)
as _i4.Future<_i2.HealthDataPoint?>);
@override
_i4.Future<List<_i2.HealthDataPoint>> getHealthDataFromTypes({
required List<_i2.HealthDataType>? types,
Map<_i2.HealthDataType, _i2.HealthDataUnit>? preferredUnits,
_i4.Future<bool> writeMindfulnessSession({
required DateTime? startTime,
required DateTime? endTime,
List<_i2.RecordingMethod>? recordingMethodsToFilter = const [],
_i2.MindfulnessSessionType? sessionType = _i2.MindfulnessSessionType.UNKNOWN,
String? title,
String? notes,
_i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
}) =>
(super.noSuchMethod(
Invocation.method(#getHealthDataFromTypes, [], {
#types: types,
#preferredUnits: preferredUnits,
Invocation.method(#writeMindfulnessSession, [], {
#startTime: startTime,
#endTime: endTime,
#recordingMethodsToFilter: recordingMethodsToFilter,
#sessionType: sessionType,
#title: title,
#notes: notes,
#recordingMethod: recordingMethod,
}),
returnValue: _i4.Future<List<_i2.HealthDataPoint>>.value(
<_i2.HealthDataPoint>[],
),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<List<_i2.HealthDataPoint>>);
as _i4.Future<bool>);
@override
_i4.Future<List<_i2.HealthDataPoint>> getHealthIntervalDataFromTypes({
required DateTime? startDate,
required DateTime? endDate,
required List<_i2.HealthDataType>? types,
required int? interval,
List<_i2.RecordingMethod>? recordingMethodsToFilter = const [],
_i4.Future<bool> delete({
required _i2.HealthDataType? type,
required DateTime? startTime,
DateTime? endTime,
}) =>
(super.noSuchMethod(
Invocation.method(#getHealthIntervalDataFromTypes, [], {
#startDate: startDate,
#endDate: endDate,
#types: types,
#interval: interval,
#recordingMethodsToFilter: recordingMethodsToFilter,
Invocation.method(#delete, [], {
#type: type,
#startTime: startTime,
#endTime: endTime,
}),
returnValue: _i4.Future<List<_i2.HealthDataPoint>>.value(
<_i2.HealthDataPoint>[],
),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<List<_i2.HealthDataPoint>>);
as _i4.Future<bool>);
@override
_i4.Future<List<_i2.HealthDataPoint>> getHealthAggregateDataFromTypes({
required List<_i2.HealthDataType>? types,
required DateTime? startDate,
required DateTime? endDate,
int? activitySegmentDuration = 1,
bool? includeManualEntry = true,
_i4.Future<bool> deleteByUUID({
required String? uuid,
_i2.HealthDataType? type,
}) =>
(super.noSuchMethod(
Invocation.method(#getHealthAggregateDataFromTypes, [], {
#types: types,
#startDate: startDate,
#endDate: endDate,
#activitySegmentDuration: activitySegmentDuration,
#includeManualEntry: includeManualEntry,
Invocation.method(#deleteByUUID, [], {#uuid: uuid, #type: type}),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<bool>);
@override
_i4.Future<bool> deleteByClientRecordId({
required _i2.HealthDataType? dataTypeKey,
required String? clientRecordId,
String? recordId,
}) =>
(super.noSuchMethod(
Invocation.method(#deleteByClientRecordId, [], {
#dataTypeKey: dataTypeKey,
#clientRecordId: clientRecordId,
#recordId: recordId,
}),
returnValue: _i4.Future<List<_i2.HealthDataPoint>>.value(
<_i2.HealthDataPoint>[],
),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<List<_i2.HealthDataPoint>>);
as _i4.Future<bool>);
@override
_i4.Future<String?> getChangesToken({
required List<_i2.HealthDataType>? types,
}) =>
(super.noSuchMethod(
Invocation.method(#getChangesToken, [], {#types: types}),
returnValue: _i4.Future<String?>.value(),
)
as _i4.Future<String?>);
@override
_i4.Future<_i2.HealthChangesResponse?> getChanges({
required String? changesToken,
bool? includeSelf = false,
}) =>
(super.noSuchMethod(
Invocation.method(#getChanges, [], {
#changesToken: changesToken,
#includeSelf: includeSelf,
}),
returnValue: _i4.Future<_i2.HealthChangesResponse?>.value(),
)
as _i4.Future<_i2.HealthChangesResponse?>);
@override
List<_i2.HealthDataPoint> removeDuplicates(
List<_i2.HealthDataPoint>? points,
) =>
(super.noSuchMethod(
Invocation.method(#removeDuplicates, [points]),
returnValue: <_i2.HealthDataPoint>[],
)
as List<_i2.HealthDataPoint>);
@override
_i4.Future<int?> getTotalStepsInInterval(
DateTime? startTime,
DateTime? endTime, {
bool? includeManualEntry = true,
}) =>
(super.noSuchMethod(
Invocation.method(
#getTotalStepsInInterval,
[startTime, endTime],
{#includeManualEntry: includeManualEntry},
),
returnValue: _i4.Future<int?>.value(),
)
as _i4.Future<int?>);
@override
_i4.Future<_i2.HealthWorkoutWriteResult> writeWorkoutData({
required String? workoutClientRecordId,
String? energyClientRecordId,
required int? clientRecordVersion,
_i4.Future<bool> writeWorkoutData({
required _i2.HealthWorkoutActivityType? activityType,
required DateTime? start,
required DateTime? end,
required int? startZoneOffsetSeconds,
required int? endZoneOffsetSeconds,
double? activeEnergyKcal,
required String? title,
required _i2.HealthRecordingProvenance? recordingProvenance,
required _i2.HealthRecordingDevice? recordingDevice,
int? totalEnergyBurned,
_i2.HealthDataUnit? totalEnergyBurnedUnit = _i2.HealthDataUnit.KILOCALORIE,
int? totalDistance,
_i2.HealthDataUnit? totalDistanceUnit = _i2.HealthDataUnit.METER,
String? title,
_i2.WorkoutMetadata? metadata,
_i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
String? clientRecordId,
double? clientRecordVersion,
Duration? startZoneOffset,
Duration? endZoneOffset,
_i2.SwimmingDetails? swimming,
int? totalSwimmingStrokeCount,
}) =>
(super.noSuchMethod(
Invocation.method(#writeWorkoutData, [], {
#workoutClientRecordId: workoutClientRecordId,
#energyClientRecordId: energyClientRecordId,
#clientRecordVersion: clientRecordVersion,
#activityType: activityType,
#start: start,
#end: end,
#startZoneOffsetSeconds: startZoneOffsetSeconds,
#endZoneOffsetSeconds: endZoneOffsetSeconds,
#activeEnergyKcal: activeEnergyKcal,
#totalEnergyBurned: totalEnergyBurned,
#totalEnergyBurnedUnit: totalEnergyBurnedUnit,
#totalDistance: totalDistance,
#totalDistanceUnit: totalDistanceUnit,
#title: title,
#recordingProvenance: recordingProvenance,
#recordingDevice: recordingDevice,
#metadata: metadata,
#recordingMethod: recordingMethod,
#clientRecordId: clientRecordId,
#clientRecordVersion: clientRecordVersion,
#startZoneOffset: startZoneOffset,
#endZoneOffset: endZoneOffset,
#swimming: swimming,
#totalSwimmingStrokeCount: totalSwimmingStrokeCount,
}),
returnValue: _i4.Future<_i2.HealthWorkoutWriteResult>.value(
_i3.dummyValue<_i2.HealthWorkoutWriteResult>(
this,
Invocation.method(#writeWorkoutData, [], {
#workoutClientRecordId: workoutClientRecordId,
#energyClientRecordId: energyClientRecordId,
#clientRecordVersion: clientRecordVersion,
#activityType: activityType,
#start: start,
#end: end,
#startZoneOffsetSeconds: startZoneOffsetSeconds,
#endZoneOffsetSeconds: endZoneOffsetSeconds,
#activeEnergyKcal: activeEnergyKcal,
#title: title,
#recordingProvenance: recordingProvenance,
#recordingDevice: recordingDevice,
}),
),
),
returnValue: _i4.Future<bool>.value(false),
)
as _i4.Future<_i2.HealthWorkoutWriteResult>);
as _i4.Future<bool>);
@override
_i4.Future<_i2.HealthWorkoutLookupResult> lookupWorkoutData({
required String? workoutClientRecordId,
String? energyClientRecordId,
_i4.Future<String?> writeWorkoutDataUUID({
required _i2.HealthWorkoutActivityType? activityType,
required DateTime? start,
required DateTime? end,
int? totalEnergyBurned,
_i2.HealthDataUnit? totalEnergyBurnedUnit = _i2.HealthDataUnit.KILOCALORIE,
int? totalDistance,
_i2.HealthDataUnit? totalDistanceUnit = _i2.HealthDataUnit.METER,
String? title,
_i2.WorkoutMetadata? metadata,
_i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
String? clientRecordId,
double? clientRecordVersion,
Duration? startZoneOffset,
Duration? endZoneOffset,
_i2.SwimmingDetails? swimming,
int? totalSwimmingStrokeCount,
}) =>
(super.noSuchMethod(
Invocation.method(#lookupWorkoutData, [], {
#workoutClientRecordId: workoutClientRecordId,
#energyClientRecordId: energyClientRecordId,
Invocation.method(#writeWorkoutDataUUID, [], {
#activityType: activityType,
#start: start,
#end: end,
#totalEnergyBurned: totalEnergyBurned,
#totalEnergyBurnedUnit: totalEnergyBurnedUnit,
#totalDistance: totalDistance,
#totalDistanceUnit: totalDistanceUnit,
#title: title,
#metadata: metadata,
#recordingMethod: recordingMethod,
#clientRecordId: clientRecordId,
#clientRecordVersion: clientRecordVersion,
#startZoneOffset: startZoneOffset,
#endZoneOffset: endZoneOffset,
#swimming: swimming,
#totalSwimmingStrokeCount: totalSwimmingStrokeCount,
}),
returnValue: _i4.Future<_i2.HealthWorkoutLookupResult>.value(
_i3.dummyValue<_i2.HealthWorkoutLookupResult>(
this,
Invocation.method(#lookupWorkoutData, [], {
#workoutClientRecordId: workoutClientRecordId,
#energyClientRecordId: energyClientRecordId,
#start: start,
#end: end,
}),
),
),
returnValue: _i4.Future<String?>.value(),
)
as _i4.Future<_i2.HealthWorkoutLookupResult>);
as _i4.Future<String?>);
@override
_i4.Future<String> startWorkoutRoute() =>

View File

@@ -20,7 +20,7 @@ import 'dart:async';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:health_bridge/health.dart';
import 'package:health/health.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';

View File

@@ -6,7 +6,7 @@
import 'dart:async' as _i4;
import 'package:health_bridge/health.dart' as _i5;
import 'package:health/health.dart' as _i5;
import 'package:mockito/mockito.dart' as _i1;
import 'package:mockito/src/dummies.dart' as _i3;
import 'package:wger/core/network/auth_credentials_storage.dart' as _i11;

View File

@@ -6,7 +6,7 @@
import 'dart:async' as _i11;
import 'package:health_bridge/health.dart' as _i44;
import 'package:health/health.dart' as _i44;
import 'package:image_picker/image_picker.dart' as _i12;
import 'package:mockito/mockito.dart' as _i1;
import 'package:mockito/src/dummies.dart' as _i32;