diff --git a/lib/database/powersync/database.g.dart b/lib/database/powersync/database.g.dart index c01662f61..f2e624c68 100644 --- a/lib/database/powersync/database.g.dart +++ b/lib/database/powersync/database.g.dart @@ -5192,7 +5192,7 @@ class $MeasurementEntryTableTable extends MeasurementEntryTable false, type: DriftSqlType.string, requiredDuringInsert: false, - defaultValue: const Constant('manual'), + defaultValue: const Constant('user'), ); static const VerificationMeta _externalIdMeta = const VerificationMeta( 'externalId', diff --git a/lib/database/powersync/tables/measurements.dart b/lib/database/powersync/tables/measurements.dart index cd16325a6..6b3b922fa 100644 --- a/lib/database/powersync/tables/measurements.dart +++ b/lib/database/powersync/tables/measurements.dart @@ -71,9 +71,9 @@ class MeasurementEntryTable extends Table { RealColumn get value => real()(); TextColumn get notes => text()(); - /// Where the reading came from: `manual` or a health platform - /// (`apple_health`, `health_connect`). - TextColumn get source => text().withDefault(const Constant('manual'))(); + /// Where the reading came from; one of the server's `source` values: + /// `user` for manual entries or a health platform (`apple`, `google`). + TextColumn get source => text().withDefault(const Constant('user'))(); /// Platform record UUID, used to deduplicate re-imports. `null` for manual /// entries. diff --git a/lib/features/account/widgets/settings.dart b/lib/features/account/widgets/settings.dart index d430f6cc0..39957dfed 100644 --- a/lib/features/account/widgets/settings.dart +++ b/lib/features/account/widgets/settings.dart @@ -54,9 +54,6 @@ class SettingsPage extends StatelessWidget { ), ), const SettingsDataPrivacy(), - ListTile( - title: Text(i18n.health, style: Theme.of(context).textTheme.headlineSmall), - ), const HealthSyncSettingsTile(), ListTile(title: Text(i18n.others, style: Theme.of(context).textTheme.headlineSmall)), const SettingsTheme(), diff --git a/lib/features/account/widgets/settings/health_sync.dart b/lib/features/account/widgets/settings/health_sync.dart index 91d3528d2..de20858b1 100644 --- a/lib/features/account/widgets/settings/health_sync.dart +++ b/lib/features/account/widgets/settings/health_sync.dart @@ -47,7 +47,8 @@ class _HealthSyncSettingsTileState extends ConsumerState @override Widget build(BuildContext context) { - // Hide entirely if platform check hasn't completed or is unavailable + // Hide entirely (including the section header) if the platform check + // hasn't completed or no health platform is available if (_isAvailable != true) { return const SizedBox.shrink(); } @@ -56,27 +57,34 @@ class _HealthSyncSettingsTileState extends ConsumerState final i18n = AppLocalizations.of(context); - return SwitchListTile( - title: Text(i18n.healthSync), - subtitle: Text(i18n.healthSyncDescription), - value: syncState.isEnabled, - onChanged: syncState.isSyncing - ? null - : (enabled) async { - final notifier = ref.read(healthSyncProvider.notifier); - if (enabled) { - final count = await notifier.enableSync(); - // Imported entries land in the local Drift DB and surface through - // the measurement stream automatically, so no manual refresh is needed. - if (context.mounted && count > 0) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text(i18n.healthSyncSuccess(count))), - ); - } - } else { - await notifier.disableSync(); - } - }, + return Column( + children: [ + ListTile( + title: Text(i18n.health, style: Theme.of(context).textTheme.headlineSmall), + ), + SwitchListTile( + title: Text(i18n.healthSync), + subtitle: Text(i18n.healthSyncDescription), + value: syncState.isEnabled, + onChanged: syncState.isSyncing + ? null + : (enabled) async { + final notifier = ref.read(healthSyncProvider.notifier); + if (enabled) { + final count = await notifier.enableSync(); + // Imported entries land in the local Drift DB and surface through + // the measurement stream automatically, so no manual refresh is needed. + if (context.mounted && count > 0) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text(i18n.healthSyncSuccess(count))), + ); + } + } else { + await notifier.disableSync(); + } + }, + ), + ], ); } } diff --git a/lib/features/health/providers/health_sync.g.dart b/lib/features/health/providers/health_sync.g.dart index 686cde9b1..8410b9c61 100644 --- a/lib/features/health/providers/health_sync.g.dart +++ b/lib/features/health/providers/health_sync.g.dart @@ -56,7 +56,7 @@ final class HealthSyncNotifierProvider } } -String _$healthSyncNotifierHash() => r'9c7a678e7740bfa32db7638bd227d64da3bfef09'; +String _$healthSyncNotifierHash() => r'bc23c2f6013f731414a7aa1ac98c618d1937c711'; /// Imports body metrics from Apple Health / Health Connect into measurement /// categories. Read-only: reads the platform (via [HealthRepository]), writes to diff --git a/lib/features/measurements/providers/measurement_notifier.g.dart b/lib/features/measurements/providers/measurement_notifier.g.dart index 561817c74..5897b64f6 100644 --- a/lib/features/measurements/providers/measurement_notifier.g.dart +++ b/lib/features/measurements/providers/measurement_notifier.g.dart @@ -33,7 +33,7 @@ final class MeasurementNotifierProvider MeasurementNotifier create() => MeasurementNotifier(); } -String _$measurementNotifierHash() => r'2072d9a5dd3b0c64830913541d236f5dfe28fbbc'; +String _$measurementNotifierHash() => r'd21ed9e3cba86b2395e6df78d51fceb523e7c4fb'; abstract class _$MeasurementNotifier extends $StreamNotifier> { Stream> build(); diff --git a/test/core/validators_test.mocks.dart b/test/core/validators_test.mocks.dart index ac8462028..92ef67ae0 100644 --- a/test/core/validators_test.mocks.dart +++ b/test/core/validators_test.mocks.dart @@ -2030,6 +2030,17 @@ class MockAppLocalizations extends _i1.Mock implements _i2.AppLocalizations { ) as String); + @override + String get reorderCategories => + (super.noSuchMethod( + Invocation.getter(#reorderCategories), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#reorderCategories), + ), + ) + as String); + @override String get metricCustom => (super.noSuchMethod(