Skip to content

Commit

Permalink
fix: 5665 - display "add nutrition facts" button only for relevant ty…
Browse files Browse the repository at this point in the history
…pes (#5674)

Impacted files:
* `add_nutrition_button.dart`: new method to check if nutrition facts are relevant for this product type
* `knowledge_panel_action_card.dart`: checks if the product type matches before displaying the nutrition facts button
* `knowledge_panels_builder.dart`: checks if the product type matches before displaying the nutrition facts button
* `pubspec.lock`: upgrade to flutter `3.24`
  • Loading branch information
monsieurtanuki authored Oct 20, 2024
1 parent 3698965 commit 3185c72
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
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"

0 comments on commit 3185c72

Please sign in to comment.