wger-project / flutter

Flutter fitness/workout app for wger
GNU Affero General Public License v3.0
572 stars 245 forks source link

Allow users to submit new ingredients or corrections to OFF #83

Open rolandgeider opened 3 years ago

rolandgeider commented 3 years ago

Use case

Ideally users could spot errors in the ingredients and submit corrections or even completely new ones.

Proposal

Take a look at the Open Food Facts package, and if this is not possible/too hard add a link to the OFF website

https://pub.dev/packages/openfoodfacts

albertoazinar commented 3 years ago

Hi. Can u assign it to me? I wanna try

rolandgeider commented 3 years ago

Sure!

You can identify the ingredients with the "code" field (the ones that don't have any are not from OFF)

albertoazinar commented 3 years ago

hi @rolandgeider

I didn't even run the app. I was just reading the code first. understading the app structure and classes.

but when I ran the app, an error appeared and I tried to find the specified line but no sucess. I attached the error down below, maybe u can help.

rolandgeider commented 3 years ago

Ah that one, one of the dependencies is not compatible with flutter 2.5. You can either downgrade to 2.2 or add this worakound in pibspec.yaml (just don't commit it):

charts_flutter:
    git:
      url: https://github.com/google/charts
      path: charts_flutter
albertoazinar commented 3 years ago

okey @rolandgeider. I prefer downgrading it. thanks

u really fast answering. appreciate that

rolandgeider commented 3 years ago

I try ๐Ÿ˜… (I also know how frustrating it is when you're waiting for days for an answer)

albertoazinar commented 3 years ago

import 'package:flutter_gen/gen_l10n/app_localizations.dart';

@rolandgeider, does this file exist?

rolandgeider commented 3 years ago

It's generated when you build the app. sometimes my ide doesn't recognize it and marks it but the app builds just fine

albertoazinar commented 3 years ago

it does not work for me. I did even try to run flutter gen-l10n to see if it could solve the problem. but it does not. but i'm gonna do some researches to see if i can find a solution

rolandgeider commented 3 years ago

Strange. So it doesn't even compile?

albertoazinar commented 3 years ago

the compiler says the URI doesn't exist. so when I run the program it promps this errors "Error when reading '.dart_tool/flutter_gen/gen_l10n/app_localizations.dart': The system cannot find the file specified." for every files the call that path file.

ib/main.dart:136:35: Error: The getter 'AppLocalizations' isn't defined for the class 'MyApp'.

it is really strange

rolandgeider commented 3 years ago

Indeed. If you find a fix let me know, then we can document this if it happens to others

albertoazinar commented 3 years ago

Of course.

albertoazinar commented 3 years ago

hi @rolandgeider

I solved the first error shared with you by adding that lines to my pubspec.yaml. there was a problem on the url, there was missing the ".git" extension. after that, I head to change the variable body1 to bodyText1 of the file in the directory C:\src\flutter.pub-cache\hosted\pub.dartlang.org\charts_flutter-0.9.0\lib\src\behaviors\legend\legend_entry_layout.

There's still something I noticed. the app_localizations.dart file is not generated in the specified directory, but in the other one witch is .dart_tools/flutter_gen/genl10n.

rolandgeider commented 3 years ago

Hi! The charting library recently released a new version that is compatible with 2.5, if you pull master you won't need the workaround anymore.

And as for the localizations, that is the place where flutter should place the synthetic package. Perhaps you can try flutter clean and try again (perhaps with 2.5?). From my experience, sometimes the IDE doesn't recognise the package, but that's not the problem you are having

albertoazinar commented 3 years ago

Hi sorry for taking along. the app is already running. I think the problem was the compatibility with my Flutter. now with Flutter 2.5 I just had to

that error was a big deal. thankiu

rolandgeider commented 3 years ago

don't worry man, glad this works now! BTW since you need a backend, you can register on the testserver (just click on custom server before loggin in) https://wger-master.rge.uber.space/

albertoazinar commented 3 years ago

Ops, I was working on the default server. already registered on that.

I have a doubt related to this issue (the way the feature has to work, just to be clear).

by clicking at the added ingredient item of the meal (on the plan details screen), it can open a new screen with the options to add new ingredients of that OFF product right?

rolandgeider commented 3 years ago

oh sure, use the the regular server, no problems.

To give you a bit of background, the ingredients we have currently in the database come mostly from open food facts and a couple of others from the US department of agriculture. You can think of OFF as a wikipedia for food products where everybody can contribute. Some of the ingredients/products from OFF are imported to wger every couple of months or so, so they can be used in for meals etc. The idea would be that if a user doesn't find the product they are searching, it would be possible to add them to the OFF database (so that everybody can benefit). I'm not sure how the process to add them works or what kind of authentication we need (do the users need to register or is it enough if there is some kind of wger user and we use that one in their behalf) but I think @M123-dev can help us with that.

albertoazinar commented 3 years ago

I needed that background about the US department of agriculture. thanks About the OFF database, I was reading the documentation early, to edit an existing product there's no need to be authenticated (to add an ingredient of a product for instance). The thing I'm not sure is about adding a new product(I think it can be done with or without authenticated user).

If u want to take a look, u can check it up here https://wiki.openfoodfacts.org/API/Write#Posting_a_new_product

rolandgeider commented 3 years ago

I'm also thinking, directly adding a new product might not be the best idea, we don't have the complete OFF database and just because we can't find a product in our DB, it might still exist. If we had scanned it (#5 ) we could be sure that it really is not known

albertoazinar commented 3 years ago

so the feature will be just to update the ingredients? for example, the coca-cola zero from OFF it has the following ingredients: carbonated water, colour: e150d, acidifiers: phosphoric acid, sodium citrate, sweeteners: aspartame, acesulfame k, natural aromas (including caffeine) contains a source of phenylalanine

then a wger user notice that there is missing one more ingredient. he can update the date from the OFF database.

tell me if I'm lost.

rolandgeider commented 3 years ago

we don't save the ingredients of a product on wger (and I see this is also a bit cofusing, what we call "ingredient" in wger is a "product" on OFF). But in general yes, if a user sees that some product infos has some errors, it should be possible to correct it.

albertoazinar commented 3 years ago

ahh, yes! the name of the issue got me (made me think about the ingredients of OFF product). what is saved by the user in wger is just the name of the product and the nutricional values only right?

So, what has to be done in this issue, is just the feature of submiting the correction of fields (used in wger like name and nutritional values).

disregarding the option of submiting a new ingredient because of the bar code scanner that is being created in the other side right?

rolandgeider commented 3 years ago

sorry, forgot to answer you. Yes, we would just need to submit a correction of the nutritional values

albertoazinar commented 3 years ago

no worries man๐Ÿ˜… okey, I'll work on that.

derkrasseleo commented 5 months ago

Any updates on this?

albertoazinar commented 5 months ago

Hi, Nope.