feat: comprehensive micronutrient tracking (#237)#314
Open
erikpt wants to merge 53 commits intosimonoppowa:developfrom
Open
feat: comprehensive micronutrient tracking (#237)#314erikpt wants to merge 53 commits intosimonoppowa:developfrom
erikpt wants to merge 53 commits intosimonoppowa:developfrom
Conversation
…gative macro values Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
…ation Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
…ility Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
… functionality Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
… Add height/weight validation and prevent negative values Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
…ity and name validation Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
… for FDC imports Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
… UX improvements - next key, error message, and recent list extension Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
…ve indicator Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
Fix critical bugs, input validation, and data quality: 23 issues including data loss, negative values, keyboard focus, custom meal search, FDC import validation, duplicate warnings, and UX improvements
Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
simonoppowa#212, simonoppowa#213, simonoppowa#215 Co-authored-by: erikpt <4423348+erikpt@users.noreply.github.com>
Comprehensive analysis and categorization of 136 open issues into prioritized task list with code verification
Fix diary showing zero intake for days at date range boundaries
Fix FDC import: prefer Atwater Specific Factors and validate nutritional data
Revert "Fix FDC import: prefer Atwater Specific Factors and validate nutritional data"
- Add INDEX.md for navigation hub with role-based reading paths - Add README.md with documentation overview and recommendations - Add QUICK-REFERENCE.md for quick status checks and decisions - Add UPDATES.md summarizing all documentation changes - Add 07-BRANCH-REORGANIZATION-2025-12-03.md detailing branch cleanup - Update 00-OVERALL-PLAN.md to reflect accurate branch status * Clarify 17 issues on main, 3 pending on bugfixes branch * Add repository status section * Update completion counts This ensures documentation reflects the current state after moving PRs #3, #4, #5 from main to erikpt/bugfixes branch.
- Update QUICK-REFERENCE.md to show bugfixes as main working branch - Update README.md to clarify development workflow - Update 00-OVERALL-PLAN.md with working branch context - Update INDEX.md with working branch notice - Update UPDATES.md with revision history This clarifies that erikpt/bugfixes is the primary development branch with 20 completed issues, while main (17 issues) is the stable upstream.
…owa#154) - Add optional dayToRefresh parameter to RefreshCalendarDayEvent - Update CalendarDayBloc to use provided date instead of _currentDay - Pass selected date when refreshing calendar after meal addition When adding a meal for a future date, the diary now stays on that date instead of navigating back to today. Previously, the calendar always refreshed to DateTime.now() causing the view to jump to the current date. This fix allows the meal_detail_bottom_sheet to pass the selected date when refreshing the calendar, preserving the user's position in the UI. Fixes simonoppowa#154
fix: preserve diary date selection when adding meal entries (simonoppowa#154)
- Fix LoadCalendarDayEvent props to include day parameter - Previously: List<Object?> get props => []; - Now: List<Object?> get props => [day]; This fixes a critical bug where Equatable comparison fails because the day field is not included in the props list. Events with different dates would be incorrectly considered equal, leading to duplicate event processing bugs. - Add technical debt documentation (09-TECHNICAL-DEBT-FIXES.md) - Identifies dummy user data handling - Documents rating enum refactoring opportunity - Tracks all identified technical debt Impact: HIGH - Fixes Equatable equality comparison Severity: CRITICAL - Affects event deduplication logic
- Create new DayRating enum with good/poor values - Add color methods to enum (getCalendarColor, getTextColor, getTextBackgroundColor) - Refactor TrackedDayEntity to use rating getter - Rename private method to _isWithinAcceptableCalorieDifference for clarity - Remove TODO comment as it's now implemented - Update technical debt documentation - Pin Flutter SDK to 3.27.0 via FVM for consistent builds
- Add missing l10n strings: warningLabel, duplicateMealDialogContent - Update meal_detail_bottom_sheet to use proper l10n keys - Remove unused intl import from tracked_day_data_source.dart - Remove unused variable in tracked_day_data_source_test.dart - Regenerate localization files with intl_translation - Add intl_translation as dev dependency for l10n generation All errors resolved - only info-level lints remain (pre-existing)
- Mark simonoppowa#229 (API rate limiting) as COMPLETE - Mark simonoppowa#125 (Search quality) as COMPLETE - Mark simonoppowa#212 (Duplicate meal detection) as COMPLETE - Mark DayRating enum as COMPLETE - Add 10-STATUS-UPDATE-2025-12-04.md with session summary - Update INDEX.md with new documents - Update QUICK-REFERENCE.md with current status - Update 02-REMAINING-TASKS.md with completed items
fix: resolve technical debt - props bug, DayRating enum, analyzer errors
- Correct 02-INPUT-VALIDATION.md: all items verified complete except simonoppowa#222 (reverted) - Flag 5 use_build_context_synchronously violations in meal_detail_bottom_sheet.dart - Correct simonoppowa#229/simonoppowa#125 status: code not found, likely reverted in PR #5 - Document hardcoded validation strings (not localized) as tech debt - Update QUICK-REFERENCE.md: current branch, active bug, corrected priorities - UPDATES.md: add March 2026 review session entry
- simonoppowa#213: validate macro values in edit_meal_screen before saving - each macro must not exceed base quantity - total macros must not exceed base quantity (5% tolerance) - kcal must not exceed 9 kcal/g * base quantity - docs: consolidate .copilot/workitems — remove 10 stale session/PR docs, update remaining 5 files to reflect current branch state (2026-03-11) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…simonoppowa#277) - simonoppowa#235: Show macros (carbs/fat/protein) per meal section header and per intake item card on home screen - simonoppowa#277: Add 'Show Activity Tracking' toggle in Settings; persisted via ConfigDBO.showActivityTracking (HiveField 9); ActivityVerticalList conditionally rendered on home page based on setting Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a 'Per Xg/ml' / 'Total' toggle above the nutritional fields in the edit meal screen. In Total mode, users enter absolute values for the specified meal quantity; values are converted to per-base-qty before validation and saving. Meal quantity must be set to use Total mode. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
, simonoppowa#174) Custom meals are now saved to a dedicated CustomMealBox (Box<MealDBO>) when the user finishes the edit-meal flow. RecentMealBloc merges these templates with recent intakes so custom meals appear in the 'Recently Added' tab even before they are logged for the first time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…a#182) - DayInfoWidget now computes calories/macros from actual intake lists instead of the stale TrackedDayDBO cache, so 0 kcal never shows when food was logged - CalendarDayBloc reconciles the cache on each day load: if actual kcal differs from cached by >0.5, it overwrites the stored values, fixing calendar dot colors over time as the user browses past days Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…oppowa#267/simonoppowa#174 complete Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds 17 new micronutrient fields to the meal data model and displays them in the meal detail screen behind a Settings toggle. Data model: - MealNutrimentsDBO: HiveFields 7-23 for mono/polyunsaturated fat, trans fat, cholesterol, sodium, potassium, magnesium, calcium, iron, zinc, phosphorus, vitamins A/C/D/B6/B12, and niacin (all nullable, backward-compatible with existing Hive records) - ConfigDBO: HiveField 9 for showMicronutrients preference - MealNutrimentsEntity: mirrors DBO fields + hasMicronutrientData getter - OFF DTO: new @JsonKey-mapped fields for hyphenated OFF JSON keys - FDC constants: nutrient IDs 318/401/328/415/418/406/307/306/304/ 301/303/309/305/645/646/605/601 Display: - ExpansionTile in MealDetailNutrimentsTable auto-expands when any micronutrient data is present; section hidden when empty and showMicronutrients is false - Settings SwitchListTile persists the preference via ConfigDBO l10n: - 20 new keys added to EN/DE/TR ARB files and generated message maps Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…imonoppowa#237) Covers fromFDCNutriments (ID mapping, Atwater fallback chain, absent fields), fromOffNutriments (double/int/string dynamic types, null DTO), and hasMicronutrientData computed getter. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ssal fix: resolve a large collection of issues and bugs (PR simonoppowa#313 mirror)
Remove all completed items; add new open issues 281/284/290/292/297/298/312. Reflect fork main as source of truth and PR #8/simonoppowa#314 status for micronutrients. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
, simonoppowa#292, simonoppowa#297, simonoppowa#298, simonoppowa#312 simonoppowa#292: Extend diary calendar and data query range from 356 days to 5 years so entries older than ~1 year are no longer invisible. simonoppowa#290: Update physical activity data source to 2024 Compendium of Physical Activities — updated MET values (yoga, running, tai chi) and added new activities: pilates, stretching, rowing machine, elliptical trainer, stair-treadmill, treadmill running, pickleball, active video games, Nordic walking, cross-country skiing, snowshoeing, resistance training. simonoppowa#281: Add QuickWeightWidget to the home screen — shows current weight with an edit button that opens SetWeightDialog and updates TDEE on save. simonoppowa#297: Add direct text input fields to CalculationsDialog alongside sliders for kcal adjustment and macro percentages. Total percentage shown as hint. Normalization to 100% is deferred to save time. simonoppowa#284: Add weekly weight rate goal to UserDBO/UserEntity (HiveField 6, nullable double, kg/week). CalorieGoalCalc uses this rate (1100 kcal/day per kg/week) when set, otherwise falls back to the existing lose/maintain/ gain enum. Profile page shows a new "Weekly rate" tile with a slider dialog. simonoppowa#298: Fix nutrient field labels in edit_meal_screen — replace broken string concatenation (which produced "kcal per100 g/ml" in EN and doubled the unit in DE) with clean labelText + helperText layout. Localize the Per/Total toggle labels via new mealNutrientsPerQtyLabel and mealNutrientsTotalLabel keys. Updated EN, DE, TR ARB files and generated message files. simonoppowa#312: Add daily meal reminder notifications using flutter_local_notifications. NotificationService schedules a daily exact alarm at a user-chosen time. Settings screen adds a SwitchListTile to enable/disable reminders and a time picker for the reminder time. Notification preference (enabled, hour, minute) stored in ConfigDBO as HiveFields 10–12. Android permissions and receivers added to AndroidManifest.xml. Notifications restored at startup. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…or iOS 26 simulator support - Pin FVM to stable channel (Flutter 3.41.4) to support iOS 26 simulator - Upgrade mobile_scanner 6→7 (drops GoogleMLKit, uses Apple Vision framework) - Bump intl constraint to ^0.20.2 to match Flutter SDK requirement - Downgrade build_runner to ^2.4.13 and remove mockito to resolve dep conflicts - Update Podfile.lock and pubspec.lock accordingly Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…292-297-298-312 feat: implement issues simonoppowa#281, simonoppowa#284, simonoppowa#290, simonoppowa#292, simonoppowa#297, simonoppowa#298, simonoppowa#312
…licts Merges all changes from main (PRs #9, #10): - Keeps showActivityTracking (field 9), notificationsEnabled (10), notificationHour (11), notificationMinute (12) from main - Adds showMicronutrients at HiveField 13 (renumbered from 9 to avoid collision) - Merges all l10n keys from both branches in messages_en/de/tr.dart - Flutter upgraded to stable (3.41.4), mobile_scanner 6→7 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Resolved conflicts by: - Taking upstream develop version for all fork-only features (notifications, activity tracking toggle, weekly weight goals, water intake, etc.) - Keeping only the micronutrient-specific changes: 17 new MealNutrimentsDBO fields, MealNutrimentsEntity updates, showMicronutrients config toggle, meal_detail_nutriments_table, OFF/FDC data parsing, l10n keys (EN/DE/TR) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…a#314 Remove notification service, weekly weight goal dialog, quick weight widget, custom meal data source, day_rating entity, and revert fork-specific changes to AndroidManifest, calorie_goal_calc, tracked_day_repository, add_tracked_day_usecase, diary files, and edit_meal_bloc. PR simonoppowa#314 scope is micronutrient tracking only (simonoppowa#237). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Closes #237
Summary
Implements full micronutrient tracking for 17 nutrients across the lipid, mineral, and vitamin categories. Data is sourced from both OpenFoodFacts (OFF) and FoodData Central (FDC), persisted in Hive, and displayed in the meal detail screen behind a user-controlled toggle in Settings.
Why this was needed
The existing nutriments model only tracked 7 fields: energy, carbs, fat, protein, sugars, saturated fat, and fiber. Nutrition labels routinely include much more — sodium, cholesterol, vitamins, minerals — and users have long requested this data be visible in the app.
What was added
17 new nutrient fields
Data layer
MealNutrimentsDBO— 17 new@HiveFields (indices 7–23), all nullable. New fields use append-only indices so existing Hive records deserialize cleanly without migration (missing fields resolve tonull).MealNutrimentsDBO.g.dart— manually updated (build_runner cannot run due to a pre-existingintlversion conflict in the project); write count bumped from 7 → 24.ConfigDBO—@HiveField(9) bool? showMicronutrientsadded for the settings toggle. Null defaults tofalse(backward-compatible).ConfigDBO.g.dart— manually updated; write count bumped from 9 → 10.Domain layer
MealNutrimentsEntity— mirrors all 17 new DBO fields plus ahasMicronutrientDatacomputed getter (returnstrueif any micronutrient field is non-null).ConfigEntity—showMicronutrientsfield added, defaultfalse.AddConfigUsecase/ConfigRepository/ConfigDataSource—setConfigShowMicronutrients(bool)plumbed through the full stack.Data sources
OpenFoodFacts (OFF)
OFFProductNutrimentsDTOgains 17 newdynamicfields. Fields that use hyphenated JSON keys (e.g.monounsaturated-fat_100g,vitamin-a_100g) are mapped via@JsonKey. All new fields are optional in the constructor so products with incomplete data continue to parse correctly.OFFProductNutrimentsDTO.g.dartmanually updated.FoodData Central (FDC)
FDCConst(e.g. sodium = 307, vitamin C = 401).MealNutrimentsEntity.fromFDCNutrimentsuses a localfdcAmount(int id)helper to look up each nutrient by ID from the API response list.Settings
SettingsBloc/SettingsState—showMicronutrientsstate threaded through.SettingsScreen— newSwitchListTile("Show micronutrients") between the theme and export tiles. Toggling it persists the value and reloads bloc state.Meal detail display
MealDetailNutrimentsTable— newshowMicronutrientsparameter. AnExpansionTilecontaining aTableof all 17 rows is appended below the existing macros table.hasMicronutrientData).—for null values when the section is visible (e.g. toggle on but a specific nutrient wasn't reported by the source).MealDetailScreen— loads theshowMicronutrientspreference asynchronously ininitStateviaGetConfigUsecase.Localization
20 new l10n keys added to EN/DE/TR ARB files and the manually-maintained generated files (
lib/generated/l10n.dart,messages_en/de/tr.dart):monounsaturatedFatLabel,polyunsaturatedFatLabel,transFatLabel,cholesterolLabel,sodiumLabel,potassiumLabel,magnesiumLabel,calciumLabel,ironLabel,zincLabel,phosphorusLabel,vitaminALabel,vitaminCLabel,vitaminDLabel,vitaminB6Label,vitaminB12Label,niacinLabel,micronutrientsLabel,settingsShowMicronutrientsLabelTests
test/unit_test/meal_nutriments_entity_test.dart— 11 new unit tests:fromFDCNutriments: core macro mapping, Atwater energy fallback chain (1008 → 957 → 958), all 17 micronutrient ID mappings, absent fields → nullfromOffNutriments: core macro mapping, dynamic type coercion (double / int / string), all 17 micronutrient mappings, absent fields → null, null DTO → empty entityhasMicronutrientData: all-null → false, one non-null → true, empty entity → falseTest plan
—for missing values🤖 Generated with Claude Code