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

feat: Add basic details page UI #1515

Merged
merged 19 commits into from
May 6, 2022
Merged

feat: Add basic details page UI #1515

merged 19 commits into from
May 6, 2022

Conversation

bhattabhi013
Copy link
Contributor

@bhattabhi013 bhattabhi013 commented Apr 7, 2022

What

Created add basic details page UI.

Video

basic_Details_page.mp4

Fixes bug(s)

Part of

@bhattabhi013 bhattabhi013 requested a review from a team as a code owner April 7, 2022 18:17
@bhattabhi013
Copy link
Contributor Author

I've created the UI part and I have some doubts regarding the submission of data entered by the user.
I referred nutrition_page_loaded.dart for this purpose and found that the data is saved in the local database. Do we have to do the same process for this page too? and if we have to send the data to the back-end then how we are supposed to do it? I will be glad if you can provide any reference for the same. Thanks

@M123-dev
Copy link
Member

M123-dev commented Apr 7, 2022

@bhattabhi013 this part should theoretically be not that hard because all querys to open food facts are routed to our other repository openfoodfacts-dart

But actually @monsieurtanuki I'm unsure if the part is already done in off-dart, just did a quick check and we have saveProduct which does a query to the right endpoint (product_jqm2.pl)

But here:

Editing the product
You just have to prefix add_ before the name of the field. Examples:

add_categories
add_labels
add_brands

This adds a new value but doesn't delete the previous ones. Adding values doesn't need authentication but take it into account. Examples:

https://world.openfoodfacts.net/cgi/product_jqm2.pl?code=0048151621226&add_brands=Brand%202
https://world.openfoodfacts.net/cgi/product_jqm2.pl?code=0048151621226&user_id=username&password=*****&add_brands=Brand%203

I'm unsure if we add the add_ prefix

@monsieurtanuki
Copy link
Contributor

@bhattabhi013 nutrition_page_loaded.dart actually saves the data on the back-end with ProductRefresher.
Btw be careful and switch to the dev environment when you code.

@M123-dev I think the calls you're referring to still need to be implemented, cf. openfoodfacts/openfoodfacts-dart#132 - assuming it's what we need here.

@teolemon
Copy link
Member

teolemon commented Apr 9, 2022

We probably don't need the add_ prefix if we do things properly (we check for pre-existing data, and we offer the user the opportunity to correct or augment it)
The add_ prefix is a safety system if for some reason the app does not have a comprehensive editing system.

@teolemon teolemon added Product addition The easier it is to add a product and get Nutri-Score, Eco-Score, the happier the users. ✏️ Editing Many products are incomplete and don't have Nutri-Score, Eco-Score…so editing is important for users labels Apr 9, 2022
@teolemon teolemon linked an issue Apr 9, 2022 that may be closed by this pull request
10 tasks
@monsieurtanuki
Copy link
Contributor

We probably don't need the add_ prefix if we do things properly (we check for pre-existing data, and we offer the user the opportunity to correct or augment it)
The add_ prefix is a safety system if for some reason the app does not have a comprehensive editing system.

@bhattabhi013 Therefore you should use saveProduct, with the barcode and all the values for the field you changed, for instance:

  • brand was "Coca Cola"
  • you want to add "Walmart"
  • you have to save barcode="xxxxx", brand="Coca Cola, Walmart"

@M123-dev
Copy link
Member

Any updated @bhattabhi013

@bhattabhi013
Copy link
Contributor Author

bhattabhi013 commented Apr 20, 2022

Hey @M123-dev,
I'm working on it, I apologize as I was unable to update the ongoing process.
@teolemon @M123-dev, I've got a doubt while using the saveProduct API.
Should I replace the key instead of updating it, for example:

  • Brand was "Coca Cola"
  • I want to add "Walmart"
  • Instead of doing it like brand=" Coca Cola, Walmart" I think of doing it as brand = "Walmart" because I feel having two brands for a single product or 2 product names for a single product doesn't look good.
    I would love to hear your suggestions on this.

@codecov-commenter
Copy link

codecov-commenter commented Apr 23, 2022

Codecov Report

Merging #1515 (995c3b4) into develop (2ea0da3) will decrease coverage by 0.61%.
The diff coverage is 0.66%.

@@            Coverage Diff             @@
##           develop   #1515      +/-   ##
==========================================
- Coverage     8.86%   8.25%   -0.62%     
==========================================
  Files          161     168       +7     
  Lines         6623    7333     +710     
==========================================
+ Hits           587     605      +18     
- Misses        6036    6728     +692     
Impacted Files Coverage Δ
...h_app/lib/cards/category_cards/abstract_cache.dart 0.00% <0.00%> (ø)
...p/lib/cards/category_cards/asset_cache_helper.dart 0.00% <0.00%> (ø)
...p/lib/cards/category_cards/raster_async_asset.dart 0.00% <0.00%> (ø)
...oth_app/lib/cards/category_cards/raster_cache.dart 0.00% <0.00%> (ø)
..._app/lib/cards/category_cards/svg_async_asset.dart 0.00% <0.00%> (ø)
...smooth_app/lib/cards/category_cards/svg_cache.dart 0.00% <0.00%> (ø)
...t_cards/knowledge_panels/knowledge_panel_card.dart 0.00% <0.00%> (ø)
...t_cards/knowledge_panels/knowledge_panel_page.dart 0.00% <0.00%> (ø)
...knowledge_panels/knowledge_panel_summary_card.dart 0.00% <ø> (ø)
...s/knowledge_panels/knowledge_panel_table_card.dart 0.00% <0.00%> (ø)
... and 60 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f11488e...995c3b4. Read the comment docs.

@bhattabhi013
Copy link
Contributor Author

bhattabhi013 commented Apr 23, 2022

Hi everyone,
Here is the video after the latest development:
https://user-images.githubusercontent.com/47862474/164913355-c94f391b-2e9e-43fe-85f9-9e11ee800ca0.mp4

Please let me know your thoughts on this and provide your input.

@teolemon
Copy link
Member

@bhattabhi013 Could you add some margin left and right so that the fields do not look stuck to the edges of the screen ?
image

@bhattabhi013
Copy link
Contributor Author

Sure @teolemon,
Here is an updated screenshot.
image

@teolemon
Copy link
Member

The carousel can stay edge to edge, since it's intended to be scrolled

@bhattabhi013
Copy link
Contributor Author

Hi @teolemon,
Here is the updated screenshot.
image

@teolemon
Copy link
Member

teolemon commented May 3, 2022

LGTM visually 👍

@teolemon
Copy link
Member

teolemon commented May 3, 2022

@monsieurtanuki @M123-dev what about code-wise ?

Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bhattabhi013!
Many comments for you, lucky you :)

if (widget.product.barcode != null)
Padding(
padding: EdgeInsets.symmetric(horizontal: size.width * 0.05),
child: Column(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if adding a Column inside a ListView is a good idea. What about ListView children?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used padding widget to add some extra padding for the textfields.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a Column inside a ListView adds complexity and possible side-effects. I strongly suggest that you use either a Column or a ListView, but not both.

],
),
),
Row(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how you put the buttons cleanly at the bottom of the page. Here they are just after the rest, aren't they?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used Row to horizontally align the buttons and used MainAxisAlignment.spaceAround value in mainAxisAlignment for spacing purposes. Please suggest if you have something else in your mind.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern is about the vertical position of the Row. Let's keep it that way.

@bhattabhi013
Copy link
Contributor Author

Hi @bhattabhi013! Many comments for you, lucky you :)

Indeed 😁.

Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bhattabhi013!
Still not convinced by the ListView / Column combination. But that's good enough I guess.

if (widget.product.barcode != null)
Padding(
padding: EdgeInsets.symmetric(horizontal: size.width * 0.05),
child: Column(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a Column inside a ListView adds complexity and possible side-effects. I strongly suggest that you use either a Column or a ListView, but not both.

],
),
),
Row(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern is about the vertical position of the Row. Let's keep it that way.

@M123-dev
Copy link
Member

M123-dev commented May 6, 2022

We need to update the branch for it to be mergable

@bhattabhi013
Copy link
Contributor Author

Hi @M123-dev,
I'll update the branch once #1772 is merged.

@M123-dev M123-dev merged commit 9518e2e into openfoodfacts:develop May 6, 2022
@M123-dev
Copy link
Member

M123-dev commented May 6, 2022

Perfect, thanks @bhattabhi013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✏️ Contribution ✏️ Editing Many products are incomplete and don't have Nutri-Score, Eco-Score…so editing is important for users Product addition The easier it is to add a product and get Nutri-Score, Eco-Score, the happier the users.
Development

Successfully merging this pull request may close these issues.

Add the ability to add basic details if they are not available
5 participants