Skip to content

Commit

Permalink
feat: 5621 - "road to scores" label now depends on OxF (openfoodfacts…
Browse files Browse the repository at this point in the history
…#5772)

Impacted files:
* `app_en.arb`: added labels for OxF versions
* `product_incomplete_card.dart`: button label depends on OxF
* `product_query.dart`: new `getRoadToScoreLabel` method
  • Loading branch information
monsieurtanuki authored Nov 1, 2024
1 parent 767fccb commit 66a3492
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,9 @@
"description": "Button at the end of new product page, that takes you to completed product"
},
"hey_incomplete_product_message": "Tap to answer 3 questions NOW to compute Nutri-Score, Eco-Score & Ultra-processing (NOVA)!",
"hey_incomplete_product_message_beauty": "Tap now to answer 2 questions to help analyze this cosmetic!",
"hey_incomplete_product_message_pet_food": "Tap now to answer 3 questions to help analyze this pet food product!",
"hey_incomplete_product_message_product": "Tap now to help complete this product!",
"nutritional_facts_photo_uploaded": "Nutrition facts photo uploaded",
"@nutritional_facts_photo_uploaded": {},
"recycling_photo_button_label": "Recycling photo",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:smooth_app/helpers/analytics_helper.dart';
import 'package:smooth_app/pages/product/add_new_product_page.dart';
import 'package:smooth_app/pages/product/product_field_editor.dart';
import 'package:smooth_app/pages/product/simple_input_page_helpers.dart';
import 'package:smooth_app/query/product_query.dart';

/// "Incomplete product!" card to be displayed in product summary, if relevant.
///
Expand Down Expand Up @@ -99,7 +100,11 @@ class ProductIncompleteCard extends StatelessWidget {
child: ElevatedButton.icon(
label: Padding(
padding: const EdgeInsets.symmetric(vertical: SMALL_SPACE),
child: Text(appLocalizations.hey_incomplete_product_message),
child: Text(
(product.productType ?? ProductType.food).getRoadToScoreLabel(
appLocalizations,
),
),
),
icon: const Icon(
Icons.bolt,
Expand Down
11 changes: 11 additions & 0 deletions packages/smooth_app/lib/query/product_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,15 @@ extension ProductTypeExtension on ProductType {
ProductType.petFood => appLocalizations.product_type_label_pet_food,
ProductType.product => appLocalizations.product_type_label_product,
};

String getRoadToScoreLabel(final AppLocalizations appLocalizations) =>
switch (this) {
ProductType.food => appLocalizations.hey_incomplete_product_message,
ProductType.beauty =>
appLocalizations.hey_incomplete_product_message_beauty,
ProductType.petFood =>
appLocalizations.hey_incomplete_product_message_pet_food,
ProductType.product =>
appLocalizations.hey_incomplete_product_message_product,
};
}

0 comments on commit 66a3492

Please sign in to comment.