openfoodfacts / openfoodfacts-dart

Open Food Facts API Wrapper
https://pub.dev/packages/openfoodfacts
Apache License 2.0
164 stars 66 forks source link

Add an Eco-Score helper #191

Open teolemon opened 3 years ago

teolemon commented 3 years ago

What

image I specced a system to help 3rd party apps ask for relevant Eco-Score data. How about creating the logic within openfoodfacts-dart so that it can be reused easily ?

Eco-Score for 3rd party apps

A similar system for Eco-Score, and another one for Ingredient related analysis (NOVA, allergens, gluten…) would unlock more reuses, and more data for Open Food Facts

Will unlock

monsieurtanuki commented 3 years ago

My suggestion would be to:

  1. create an enum with all the possible message cases (ProductImprovement?)
  2. for each message case, provide a (default) message in English
  3. add a method in Product that returns a List<ProductImprovement>
  4. the developer would then be able to ignore those possible improvements (same as today), to display them with the default English message, or to localize them according to their own user target and their own UI/UX

Same method for #193 of course.

@teolemon Does that make sense?

teolemon commented 3 years ago

That looks like a rather good plan. I would also try to mutualize translations, or possibly move them to something on the server (a file the plugin could query ?)

monsieurtanuki commented 3 years ago

@teolemon Are you sure about the 'en:labels-to-be-completed' string? In the unit tests I could not find a product with something similar. I found something like that for product.statesTags:

stephanegigandet commented 3 years ago

There's no label to be completed state because some products don't have labels.

monsieurtanuki commented 3 years ago

@stephanegigandet I've just removed ProductImprovement.LABELS_TO_BE_COMPLETED from #217.

monsieurtanuki commented 3 years ago

Product improvements are now computed in product.getProductImprovements() (#217). Beyond the enum values, I don't know how the translations are supposed to be integrated, and how.