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

Nutrition input (Tracker) #511

Open
2 of 21 tasks
Tracked by #503 ...
teolemon opened this issue Aug 19, 2021 · 38 comments
Open
2 of 21 tasks
Tracked by #503 ...

Nutrition input (Tracker) #511

teolemon opened this issue Aug 19, 2021 · 38 comments
Labels
✏️ Contribution ✏️ Editing - Nutrition input 🎨 Mockups available Some mockups are available for this issue. Please check everything is ok before starting coding. nutrition facts 🛣️ Road to scores The easier it is to get Nutri-Score, Eco-Score, the happier the users.
Milestone

Comments

@teolemon
Copy link
Member

teolemon commented Aug 19, 2021

Who for

What

Tasks

  1. ✏️ Editing - Nutrition input
  2. 0 of 10
    data quality good first issue nutrition facts ✏️ Editing - Nutrition input 🎯 P1
  3. ✏️ Editing - Nutrition input 🎨 Mockup required 🎯 P1 🤖 Robotoff
  4. nutrition facts ✏️ Editing - Nutrition input 🎨 Mockups available
  5. image upload 🐛 bug
  6. On-device ML 🤳 MLKit
  7. ✏️ Editing - Nutrition input

Tasks

  1. ✏️ Editing - Nutrition input 🎨 Mockups available 🎯 P1 🤖 Robotoff 🤖 blocked on Robotoff
  2. ✏️ Editing - Nutrition input

Mockup

  • image
  • image
  • image
  • image
    Here's a first mockup, which hasn't been discussed yet

Code pointers

Why

Design doc

Part of

@teolemon
Copy link
Member Author

teolemon commented Jan 8, 2022

@monsieurtanuki would you take on Nutrition ?

@monsieurtanuki
Copy link
Contributor

I'm afraid not, I cannot use the camera. The camera is the main item here, isn't it? If it's not, I can work on the input of a nutrient list, and someone else would do the camera side later. Tell me if that makes sense.

@teolemon
Copy link
Member Author

teolemon commented Jan 8, 2022

No, the photo here is an existing nutrition photo. The layout is immersive and scrollable to make it easy to improve nutrition. The photo retaking is for a later iteration.

@teolemon
Copy link
Member Author

teolemon commented Jan 8, 2022

So it's really the input of the nutrients list, with a fancy layout. We can start simpler.

@teolemon
Copy link
Member Author

teolemon commented Jan 8, 2022

But to be clear it's a big chew:

  • Creating a layout for the nutrition input
    • Layout for the fields
      • Units
      • Values
      • Modifiers <>=
    • Layout for the energy fields
      • Values
    • Layout for the portion size
      • Units
      • Values
      • Text
    • Layout for the nutrition table
      • Displaying the current photo of the nutrition table
      • Make it scrollable
  • Building that layout dynamically (using the Nutrient list and order API from openfoodfacts-dart, based on the country selected in the app)
  • Getting existing nutrition values for the product
  • Populating that layout with existing values
  • Gathering all changes made by the users to the fields
  • Sending them to the server
  • Extra refinements
    • the portion/100G thing
    • no nutrition value
    • Allow to add custom nutrients to the nutrition input (using the Nutrient list API from openfoodfacts-dart)

@monsieurtanuki
Copy link
Contributor

OK, I'll do it step by step.

@monsieurtanuki
Copy link
Contributor

@teolemon How are we supposed to open that page? From product page I guess, but where should one click?

@teolemon
Copy link
Member Author

teolemon commented Jan 8, 2022

  • The button you added yesterday is a good entry point when nutrition is not there at all.
  • When there is nutrition info, it could become "update nutrition information"

@monsieurtanuki
Copy link
Contributor

monsieurtanuki commented Jan 8, 2022

Now I have a similar problem as with the Android app: I don't know the meaning of the fields, as the meaning is only displayed as a hint:

@teolemon
Copy link
Member Author

teolemon commented Jan 8, 2022

We need to find the equivalent of the library we used

@teolemon
Copy link
Member Author

teolemon commented Jan 8, 2022

@monsieurtanuki
Copy link
Contributor

monsieurtanuki commented Jan 8, 2022

@teolemon Indeed:

monsieurtanuki added a commit to monsieurtanuki/smooth-app that referenced this issue Jan 9, 2022
New files:
* `nutrition_page.dart`: Preparatory nutrition page where data is loaded.
* `nutrition_page_loaded.dart`: Actual nutrition page, with data already loaded.

Impacted files:
* `app_en.arb`: added 6 related labels
* `app_fr.arb`: added 6 related labels
* `knowledge_panels_builder.dart`: now the nutrition page button is systematic (but with a potentially different label/icon)
* `new_product_page.dart`: minor refactoring
* `product_cards_helper.dart`: minor refactoring
* `smooth_app/pubspec.lock`
* `smooth_ui_library/pubspec.lock`
* `smooth_ui_library/example/pubspec.lock`
monsieurtanuki added a commit to monsieurtanuki/smooth-app that referenced this issue Jan 9, 2022
Impacted files:
* `nutrition_page.dart`: refactored with `ProductQuery`
* `nutrition_page_loaded.dart`: refactored with `ProductQuery`
* `product_query.dart`: new method `getLocaleString`
monsieurtanuki added a commit that referenced this issue Jan 9, 2022
New files:
* `nutrition_page.dart`: Preparatory nutrition page where data is loaded.
* `nutrition_page_loaded.dart`: Actual nutrition page, with data already loaded.

Impacted files:
* `app_en.arb`: added 6 related labels
* `app_fr.arb`: added 6 related labels
* `knowledge_panels_builder.dart`: now the nutrition page button is systematic (but with a potentially different label/icon)
* `new_product_page.dart`: minor refactoring
* `product_cards_helper.dart`: minor refactoring
* `product_query.dart`: new method `getLocaleString`
* `smooth_app/pubspec.lock`
* `smooth_ui_library/pubspec.lock`
* `smooth_ui_library/example/pubspec.lock`
@monsieurtanuki
Copy link
Contributor

@teolemon Still some questions/remarks:

  1. "Modifiers <>=" - what's the point as we cannot save anything but '='
  2. "energy" - potential confusion here, as we have "energy-kj", "energy-kcal" and "energy". 3 of them: it's too much! We should display only "energy-kj" and "energy-kcal", populating one of them with the "energy" value if needed, right?
  3. "portion size" needs to be added
  4. "cancel" / "save" buttons needs to be added
  5. what if both per 100g and per serving fields are populated: should we save both?
  6. for the moment, except for energy, I considered that all nutrients were weights (g, mg, µg). How can I know which nutrients are not weights? (e.g. alcohol in %age)

@teolemon
Copy link
Member Author

teolemon commented Jan 9, 2022

  1. "Modifiers <>=" - you pass the modifier directly in the value (concatenate)
  2. "energy-kj", "energy-kcal": those 2 only. We do automatic conversion, but we want users to be able to input both values, as indicated on the packaging
    5.show the matching values in each section, as toggled by the portion/100g switch ? Perhaps a warning that this product has values for both ?
  3. Default units should be exposed by the dart package normally

@teolemon
Copy link
Member Author

teolemon commented Jan 9, 2022

Weird spinner on opening the view

@monsieurtanuki
Copy link
Contributor

Already mentioned by @M123-dev in the code review.

My answer was:

  1. I know
  2. the target is to pre-load the nutrient list at app init time, not querying the API each time we edit the nutrients. So, in a near future, that will disappear.

@teolemon
Copy link
Member Author

teolemon commented Jan 9, 2022

perfect, sorry for my inattention 😅

@monsieurtanuki
Copy link
Contributor

"Modifiers <>=" - you pass the modifier directly in the value (concatenate)

Maybe that's possible on the server side, but that's not possible for the moment in off-dart:

double? vitaminB12Serving
double? vitaminB12;
Unit? vitaminB12Unit;

@monsieurtanuki
Copy link
Contributor

Default units should be exposed by the dart package normally

I'm afraid not.

@teolemon
Copy link
Member Author

teolemon commented Jan 9, 2022

monsieurtanuki added a commit to monsieurtanuki/smooth-app that referenced this issue Jan 9, 2022
Impacted file:
* `nutrition_page_loaded.dart`
  * explicit labels for units
  * removed "energy" line and computed "energy-kj" and "energy-kcal" accordingly
  * unit conversion (e.g. x 1000 for mg from g)
  * new small default nutrient unit repository
@monsieurtanuki
Copy link
Contributor

Mhhh I understand the thoughts behind the button to the next page where it can be added per portion but I think it's rather confusing and maybe looks like you have to add both for 100g and per portion

Maybe if we put it at the bottom of the page, like "Advanced: nutrition facts per portion"?

what about two radio buttons in a row

That would be similar to the Switch.

@M123-dev
Copy link
Member

I don't know how it is labeled on products, does every product has both

Also can we generate the product data

5g sugar per 100g; portion=50g so 2,5g sugar per portion. If so it doesn't make sense to put it at the bottom

@monsieurtanuki
Copy link
Contributor

@M123-dev Indeed, that could be a solution:

  • letting the user enter all the data for 100g
  • add a button "enter serving size"
    • that button would open a dialog where the serving size can be entered
      • when clicking on "ok" on that dialog, we compute the ratio from the serving size text and ask the end-user to confirm if the energy-kj we computed is correct compared to the data printed on the product

I mean, it's not because we have the possibility to enter that many data that it makes sense the ask the end-user to do so, especially:

  • on a small device
  • potentially in a hostile environment - e.g. supermarket on Saturday
  • when we want to make data input a rewarding experience - and typing a second column that is simply a ratio of another column is not a rewarding experience

monsieurtanuki added a commit that referenced this issue Jan 13, 2022
… API (#910)

Impacted files:
* `app_en.arb`: added 3 labels
* `app_fr.arb`: added 3 labels
* `knowledge_panels_builder.dart`: added TODO comment
* `nutrition_page_loaded.dart`: now validates and (almost) saves the form with the API
@teolemon teolemon added the 🛣️ Road to scores The easier it is to get Nutri-Score, Eco-Score, the happier the users. label Jan 15, 2022
@teolemon teolemon moved this to Todo in Road to Scores Feb 11, 2022
@teolemon teolemon added the 🎨 Mockups available Some mockups are available for this issue. Please check everything is ok before starting coding. label Mar 9, 2022
@teolemon teolemon added this to the V1 milestone Apr 11, 2022
@teolemon teolemon changed the title Nutrition input Nutrition input (Tracker) May 24, 2022
@teolemon teolemon modified the milestones: V1, V1.1 May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✏️ Contribution ✏️ Editing - Nutrition input 🎨 Mockups available Some mockups are available for this issue. Please check everything is ok before starting coding. nutrition facts 🛣️ Road to scores The easier it is to get Nutri-Score, Eco-Score, the happier the users.
Projects
Status: Todo
Status: 💬 To discuss and validate
Development

No branches or pull requests

4 participants