feat(add-meal): suggest a meal type from the current time (#580) - #590
Open
ibrahim-iqbal wants to merge 1 commit into
Open
feat(add-meal): suggest a meal type from the current time (#580)#590ibrahim-iqbal wants to merge 1 commit into
ibrahim-iqbal wants to merge 1 commit into
Conversation
…a#580) Preselect Breakfast/Lunch/Dinner/Snack in the global add-item bottom sheet based on the device's local time. Every tile stays immediately tappable; the suggestion is a visual default rendered as a compact 'Suggested' chip on the matching tile. - MealTypeSuggester.suggestFromTime() centralizes the time -> meal-type ranges so they can be tweaked in one place (04-11 breakfast, 11-15 lunch, 15-17 snack, 17-22 dinner, 22-04 snack). - AddItemBottomSheet accepts a nullable suggestedType. main_screen (the global + FAB) passes MealTypeSuggester.suggestFromTime(DateTime.now()). Flows launched from a specific meal section keep passing null and see no highlight, per the issue's acceptance criteria. - Unit tests cover every range and each boundary hour (04, 11, 15, 17, 22, 00, 03:59) deterministically. Widget tests cover the preselect visual and the null-behavior path. - Adds 'suggestedLabel' to intl_en.arb; other locales inherit the English fallback until they're translated.
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.
Fixes #580.
Summary
Preselect a meal type in the global add-item bottom sheet based on the device's local time. Every tile stays immediately tappable; the suggestion renders as a small
Suggestedchip on the matching tile so nothing changes about the tap flow.Approach
MealTypeSuggester.suggestFromTime(DateTime)inlib/core/utils/centralizes the time-of-day ranges so they can be tweaked in one place:AddItemBottomSheetaccepts a nullablesuggestedType. The global+action inmain_screen.dartpassesMealTypeSuggester.suggestFromTime(DateTime.now()). Flows launched from a specific meal section keep passing nothing and see no highlight, per the acceptance criteria.Suggestedchip usescolorScheme.secondaryContainer/onSecondaryContainerso it inherits both light and dark themes cleanly.Acceptance criteria mapping
MealTypeSuggesterMealTypeSuggester.suggestFromTime(DateTime.now())inmain_screen.dart+—Suggestedchip on the matching tileonTaphandlers)suggestedTypestays null and no chip rendersSemantics(identifier: ...)values — chip hasadd-item-suggested-chip; the existing tile identifiers are untouchedTests
test/core/utils/meal_type_suggester_test.dart— 6 unit tests covering every range and each boundary hourtest/core/presentation/widgets/add_item_bottom_sheet_test.dart— 2 new widget tests: chip renders on the matching tile, no chip renders whensuggestedTypeis nullAll 11 tests in the two files pass;
flutter analyzeclean on the touched files.Localization
Adds
suggestedLabel: "Suggested"tolib/l10n/intl_en.arb. Other locales fall back to English until they're translated.