feat: add automatic weight sync from Apple Health and Google Health Connect#1156
Open
JohnWeidner wants to merge 9 commits intowger-project:masterfrom
Open
feat: add automatic weight sync from Apple Health and Google Health Connect#1156JohnWeidner wants to merge 9 commits intowger-project:masterfrom
JohnWeidner wants to merge 9 commits intowger-project:masterfrom
Conversation
…onnect Import body weight data from Apple Health (iOS) and Google Health Connect (Android) into wger when the app is opened. Uses the Flutter `health` package for cross-platform access. Feature is opt-in via a settings toggle. Key changes: - Add HealthSyncNotifier (Riverpod) for sync orchestration - Add HealthSyncSettingsTile in settings page - Add health package dependency and platform permissions - Fix WeightEntry.copyWith parameter type (int? -> num?) - Fix BodyWeightProvider.findByDate() to use calendar-date comparison - Raise Android minSdkVersion to 26 (Health Connect requirement) - Change MainActivity to extend FlutterFragmentActivity Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Show "Weight (kg)" or "Weight (lb)" on the weight entry form based on the user's profile preference - Convert health sync values from kg to lb before POSTing when the user's profile is set to lb - Check/request health permissions on sync to handle app restart - Fix weight form tests to provide UserProvider mock Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
sqlite3_flutter_libs 0.6.0+eol no longer bundles the native SQLite library correctly on newer Android toolchains, causing a DriftRemoteException on startup (dlopen failed: libsqlite3.so not found). Replace it with drift_flutter which is the current recommended package for providing native SQLite to drift databases. Also suppress the StackFrame assertion error from the stack_trace package that was masking the real error. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Pass isMetric to enableSync() so the initial sync from the settings toggle converts kg to lb when the user's profile is set to lb - Refresh BodyWeightProvider after sync from settings tile so the dashboard and weight screen update immediately - Fix DashboardWeightWidget to compute sensibleRange() inside the Consumer builder so it rebuilds when weight data changes - Add permission check in syncOnAppOpen() for app restart scenarios - Add unit tests for weight conversion logic and HealthSyncState Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use existing isSameDayAs() extension in findByDate() instead of manual year/month/day comparison - Build a Set of existing timestamps for O(1) dedup lookups instead of O(n*m) .any() scan per data point - Simplify nullable bool check (_isAvailable != true) - Remove comments that restate the code Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add healthSync, healthSyncDescription, healthSyncSuccess, and health keys to app_en.arb and use AppLocalizations instead of hardcoded English strings in the settings tile and settings page. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove the 30-day lookback limit on initial sync. Pull all available weight data from Health Connect on first enable. Add READ_HEALTH_DATA_HISTORY permission to AndroidManifest to allow reading data older than 30 days. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Call requestHealthDataHistoryAuthorization() on Android after initial permission grant. Without this runtime request, Health Connect limits data access to the last 30 days regardless of the manifest permission. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
51 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
healthpackageDateTimeFieldsince migration 0004)DashboardWeightWidgetto rebuild when weight data changes (pre-existing bug)WeightEntry.copyWithparameter type (int?→num?) (pre-existing bug)BodyWeightProvider.findByDate()to use calendar-date comparison via existingisSameDayAs()extension (pre-existing bug)How it works
BodyWeightProvideris refreshed so the dashboard and weight screen update immediatelyKnown limitations
Platform configuration
READ_WEIGHT,READ_HEALTH_DATA_HISTORY),FlutterFragmentActivity,minSdkVersionraised to 26NSHealthShareUsageDescriptionin Info.plistTest plan
flutter analyzepasses (no new warnings)flutter test— all tests pass (1 pre-existing timezone failure)HealthSyncStatecopyWithandfindByDatebug fixesProviderScopeUserProvidermockcloses: #1153
🤖 Generated with Claude Code