Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 5665 - display "add nutrition facts" button only for relevant types #5674

Merged
merged 6 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ class KnowledgePanelActionCard extends StatelessWidget {
);
}
if (kpAction == KnowledgePanelAction.addNutritionFacts) {
return AddNutritionButton(product);
if (AddNutritionButton.acceptsNutritionFacts(product)) {
return AddNutritionButton(product);
}
}
Logs.e('unhandled knowledge panel action: $action');
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ class KnowledgePanelsBuilder {
ProductState.NUTRITION_FACTS_COMPLETED.toBeCompletedTag) ??
false;
if (nutritionAddOrUpdate) {
children.add(AddNutritionButton(product));
if (AddNutritionButton.acceptsNutritionFacts(product)) {
children.add(AddNutritionButton(product));
}
}

final bool needEditIngredients = context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class AddNutritionButton extends StatelessWidget {

final Product product;

static bool acceptsNutritionFacts(final Product product) =>
product.productType != ProductType.product &&
product.productType != ProductType.beauty;

@override
Widget build(BuildContext context) => addPanelButton(
AppLocalizations.of(context).score_add_missing_nutrition_facts,
Expand Down
2 changes: 1 addition & 1 deletion packages/smooth_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1853,4 +1853,4 @@ packages:
version: "3.1.2"
sdks:
dart: ">=3.5.3 <4.0.0"
flutter: ">=3.22.0"
flutter: ">=3.24.0"
Loading