Claude Terminal
Loading...
✏️ Mark your custom foods
Adds a way to identify foods you've edited so you know which ones have your custom changes.
> Technical Details
Add a new dataset food type to distinguish dataset foods that have been modified by the user before saving, and update the UI to display this modified state differently in the food cell's source icon within the item editor.
Currently, the FoodDataset enum (located at /Users/pxlshpr/Developer/NutriKit/Packages/FoodCore/Sources/FoodCore/Enums/FoodDataset.swift) defines three dataset types:
- ●
.usda- USDA database foods - ●
.ausnut2011_2013- AUSNUT database foods - ●
.openFoodFacts- Open Food Facts database foods
The FoodSource enum (located at /Users/pxlshpr/Developer/NutriKit/Packages/FoodCore/Sources/FoodCore/Enums/FoodSource.swift) defines four source types including .dataset which uses a mint-colored checkmark.seal.fill icon.
When a user selects a dataset food and modifies it before saving (e.g., adjusting nutritional values, changing name/details), we need to track this modified state and display it differently to indicate the food has been customized from its original dataset values.
1. Data Model Changes
Add a new case to the FoodDataset enum or create a separate mechanism to track when a dataset food has been user-modified. Consider the following approaches:
Option A: Add a new FoodSource case like .datasetModified
- ●System image: Use a variant that indicates modification (e.g., "checkmark.seal.fill" with a badge or different icon like "pencil.and.outline")
- ●Color: Use a distinct color to differentiate from standard
.dataset(consider using a variation of mint or a complementary color like cyan or teal)
Option B: Add metadata to track modification state on the Food model itself
- ●This would require changes to the Food struct to include a
isModifiedboolean or similar - ●The
FoodSourcewould remain.datasetbut the display logic would vary based on modification state
2. UI Changes
Update the FoodCell view (located at /Users/pxlshpr/Developer/NutriKit/NutriKit/Refactor Inbox/FoodsUI/Views/FoodCell.swift) to handle the modified dataset food display:
- ●In the
sourceIconcomputed property (line 134-137), add logic to:- ●Detect when a food is a modified dataset food
- ●Display a visually distinct icon that communicates "this was from a dataset but has been customized"
- ●Ensure the icon is easily distinguishable from regular dataset foods at a glance
Consider using:
- ●A different SF Symbol (e.g., "checkmark.seal.fill" with a pencil overlay, or "doc.badge.gearshape.fill")
- ●A different color (distinct from the standard mint color used for
.dataset) - ●Potentially an icon that combines both "verified dataset" and "user edited" concepts
3. Item Editor Integration
Ensure the modified state is properly set when:
- ●A user selects a dataset food in the item editor
- ●Makes any changes to the food's properties (name, details, nutritional values, etc.)
- ●Saves the modified food
The source icon should update to reflect this modified state when displayed in food cells using .sourceIcon accessory type.
Key Files:
- ●
/Users/pxlshpr/Developer/NutriKit/Packages/FoodCore/Sources/FoodCore/Enums/FoodDataset.swift- Dataset enum definition - ●
/Users/pxlshpr/Developer/NutriKit/Packages/FoodCore/Sources/FoodCore/Enums/FoodSource.swift- Source enum with icon/color definitions - ●
/Users/pxlshpr/Developer/NutriKit/NutriKit/Refactor Inbox/FoodsUI/Views/FoodCell.swift- Food cell UI with source icon display
Current Source Icon Implementation:
var sourceIcon: some View {
Image(systemName: food.source.systemImage)
.foregroundStyle(food.source.color)
}
Existing FoodSource Cases:
- ●
.dataset- mint color, checkmark.seal.fill icon - ●
.private- purple color, person.fill icon - ●
.public- blue color, checkmark.seal.fill icon - ●
.openFoodFacts- orange color, network.fill icon
- ● New dataset type or modification tracking mechanism is added to distinguish user-modified dataset foods
- ● Modified dataset foods display a visually distinct source icon in
FoodCellwhen using.sourceIconaccessory type - ● Icon clearly communicates that the food originated from a dataset but has been customized
- ● Visual distinction is clear and consistent with existing design language
- ● Changes are properly propagated when a dataset food is modified in the item editor
- ● No regressions to existing food source display for unmodified dataset foods
- ●Choose an icon that balances "authoritative source" (dataset) with "user customization" (edited)
- ●Ensure color choice works well in both light and dark mode
- ●Consider user mental model: they should understand at a glance that this food came from a trusted dataset but has been personalized
- ●Maintain visual consistency with other source types
Build instruction: Use -destination 'platform=iOS Simulator,name=iPhone 17 Pro' when building this project