Skip to content

App meal creation support#1195

Open
BryceKrispiess wants to merge 9 commits intoCodeWithCJ:mainfrom
BryceKrispiess:AppMeals
Open

App meal creation support#1195
BryceKrispiess wants to merge 9 commits intoCodeWithCJ:mainfrom
BryceKrispiess:AppMeals

Conversation

@BryceKrispiess
Copy link
Copy Markdown
Contributor

Tip

Help us review and merge your PR faster!
Please ensure you have completed the Checklist below.
For Frontend changes, please run pnpm run validate to check for any errors.
PRs that include tests and clear screenshots are highly preferred!
Note: AI-generated descriptions must be manually edited for conciseness. Do not paste raw AI summaries.

Description

What problem does this PR solve?
Allows users to create meals in the app just like they can on the web.

How did you implement the solution?
I added the existing food pickers into a meal-builder mode, and reused the existing backend meal-create endpoint so foods can be added and saved directly from the app.

Linked Issue: #

How to Test

  1. Open app
  2. click library tab
  3. click create meal

PR Type

  • Issue (bug fix)
  • New Feature
  • Refactor
  • Documentation

Checklist

All PRs:

  • [MANDATORY - ALL] Integrity & License: I certify this is my own work, free of malicious code, and I agree to the License terms.

New features only:

  • [MANDATORY for new feature] Alignment: I have raised a GitHub issue and it was reviewed/approved by maintainers or it was approved on Discord.

Frontend changes (SparkyFitnessFrontend/ or src/):

  • [MANDATORY for Frontend changes] Quality: I have run pnpm run validate and it passes.
  • [MANDATORY for Frontend changes] Translations: I have only updated the English (en) translation file.

Backend changes (SparkyFitnessServer/):

  • [MANDATORY for Backend changes] Code Quality: I have run typecheck, lint, and tests. New files use TypeScript, new endpoints have Zod schemas, and new endpoints include tests.
  • [MANDATORY for Backend changes] Database Security: I have updated rls_policies.sql for any new user-specific tables.

UI changes (components, screens, pages):

  • [MANDATORY for UI changes] Screenshots: I have attached Before/After screenshots below.

Screenshots

Click to expand

Before

before

After

image

Notes for Reviewers

Optional — use this for anything that doesn't fit above: known tradeoffs, areas you'd like specific feedback on, qustions you have or context that helps reviewers.

# Conflicts:
#	SparkyFitnessMobile/App.tsx
#	SparkyFitnessMobile/src/hooks/index.ts
#	SparkyFitnessMobile/src/screens/FoodEntryAddScreen.tsx
#	SparkyFitnessMobile/src/screens/FoodFormScreen.tsx
#	SparkyFitnessMobile/src/types/navigation.ts
… and save food logic

- Added support for meal builder mode in FoodFormScreen, allowing users to save food entries as meal ingredients.
- Introduced a new utility function to build meal ingredient drafts from saved food.
- Updated the FoodSearchScreen to improve accessibility and UI consistency.
- Enhanced MealBuilderScreen layout and integrated nutrition macro display.
- Created a new utility file for meal builder draft functions.
# Conflicts:
#	SparkyFitnessMobile/src/screens/FoodEntryAddScreen.tsx
#	SparkyFitnessMobile/src/screens/FoodFormScreen.tsx
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a Meal Builder feature, enabling users to create and save custom meals by combining multiple food ingredients. The implementation includes a new MealBuilderScreen, a useCreateMeal hook, and a NutritionMacroCard component for shared macro visualization. Existing screens for food searching, adding, and scanning were updated with a 'meal-builder' mode to facilitate ingredient selection. Feedback was provided regarding the error handling in FoodEntryAddScreen, where failures during the saving of external foods could result in silent errors.

Comment thread SparkyFitnessMobile/src/screens/FoodEntryAddScreen.tsx Outdated
Copy link
Copy Markdown
Contributor

@apedley apedley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need some tests here. Here's what I'd focus on:

mealbuilderscreen.tsx - mainly handleSaveMeal validation
foodentryaddscreen.tsx - all the additions
foodformscreen.tsx - all the additions
There's also some easy pure unit tests to be written in mealBuilderDraft.ts

The rest is mostly cosmetic so don't worry about testing that stuff.

Comment thread SparkyFitnessMobile/src/screens/MealBuilderScreen.tsx Outdated
…l builder draft utilities

- Created FoodFormScreen.test.tsx to test the FoodFormScreen component, including saving food, logging, and validation.
- Created MealBuilderScreen.test.tsx to test the MealBuilderScreen component, focusing on meal creation, ingredient management, and error handling.
- Added mealBuilderDraft.test.ts to test utility functions for building meal ingredient drafts.
- Refactored MealBuilderScreen to remove BottomSheetModalProvider and streamline the layout.
- Updated MealBuilderScreen to improve ingredient handling and UI responsiveness.
@BryceKrispiess
Copy link
Copy Markdown
Contributor Author

Need some tests here. Here's what I'd focus on:

mealbuilderscreen.tsx - mainly handleSaveMeal validation foodentryaddscreen.tsx - all the additions foodformscreen.tsx - all the additions There's also some easy pure unit tests to be written in mealBuilderDraft.ts

The rest is mostly cosmetic so don't worry about testing that stuff.

These have been added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants