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: image list gallery #2724

Closed
wants to merge 24 commits into from
Closed

Conversation

VaiTon
Copy link
Member

@VaiTon VaiTon commented Aug 3, 2022

In V1 (at least for android) we had a "Image gallery" page which would display the list of every image related to the product.

Here we have the carousel that gets activated whenever you click on the images (or click on edit images in the edit view) but it's not really a listing of every image related to the product.

That's why, as suggested by @teolemon, with this PR I'm implementing a product image gallery view as a list of clickable items. When a tile is clicked the corresponding image is opened (if existing) to be viewed/edited, or taken.

Below a video representing the flow:

2022-08-05.00-54-25.mp4

Updated screenshot

@VaiTon VaiTon force-pushed the feat/image_gallery branch from 523d7e4 to d748bc6 Compare August 3, 2022 19:31
@codecov-commenter
Copy link

codecov-commenter commented Aug 3, 2022

Codecov Report

Merging #2724 (0b580a3) into develop (2ea0da3) will decrease coverage by 1.82%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           develop   #2724      +/-   ##
==========================================
- Coverage     8.86%   7.04%   -1.83%     
==========================================
  Files          161     223      +62     
  Lines         6623   10679    +4056     
==========================================
+ Hits           587     752     +165     
- Misses        6036    9927    +3891     
Impacted Files Coverage Δ
...kages/smooth_app/lib/widgets/attribute_button.dart 0.00% <0.00%> (-92.00%) ⬇️
...s/smooth_app/lib/data_models/user_preferences.dart 8.73% <0.00%> (-23.57%) ⬇️
packages/smooth_app/lib/themes/smooth_theme.dart 62.26% <0.00%> (-20.72%) ⬇️
...p/lib/generic_lib/dialogs/smooth_alert_dialog.dart 15.11% <0.00%> (-19.10%) ⬇️
...mooth_app/lib/data_models/product_preferences.dart 21.68% <0.00%> (-9.75%) ⬇️
packages/smooth_app/lib/main.dart 14.65% <0.00%> (-3.24%) ⬇️
.../smooth_app/lib/pages/onboarding/welcome_page.dart 0.00% <0.00%> (-3.13%) ⬇️
.../smooth_app/lib/pages/onboarding/scan_example.dart 0.00% <0.00%> (-2.28%) ⬇️
...ackages/smooth_app/lib/pages/scan/scan_header.dart 2.50% <0.00%> (-2.27%) ⬇️
...p/lib/pages/onboarding/consent_analytics_page.dart 0.00% <0.00%> (-1.57%) ⬇️
... and 244 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@VaiTon
Copy link
Member Author

VaiTon commented Aug 4, 2022

@monsieurtanuki @M123-dev @g123k if you could give me an initial code review it would be great!

@monsieurtanuki
Copy link
Contributor

@VaiTon For the record it's a "draft": not something reviewers spend time on spontaneously. Unless instructed to :)

@monsieurtanuki
Copy link
Contributor

@VaiTon I don't mean to be rude but you don't provide any explanation on the PR and any /// comment in the code. We don't know what you do and why you do it. That kind of information can help reviewers.

@VaiTon
Copy link
Member Author

VaiTon commented Aug 4, 2022

@VaiTon I don't mean to be rude but you don't provide any explanation on the PR and any /// comment in the code. We don't know what you do and why you do it. That kind of information can help reviewers.

Sorry! I really thought I put something in the body of the PR while I didn't 😆. For the Draft, I did that on purpose but I'd like your review code wise to continue this path or not.

edit @monsieurtanuki added an explanation and a video!

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 @VaiTon!

Nothing that shocks me in your code, except the ignore_for_file: cast_nullable_to_non_nullable that is definitely NOT a good idea and needs to be removed immediately.

Other suggestions:

  • don't hesitate to put /// comments
  • don't hesitate, instead of lousy Widget _buildBlablabla methods, to create a new widget in a new specific class (with its own /// comments, and maybe in its own specific file) - it's better for clarity and flutter performances

@VaiTon
Copy link
Member Author

VaiTon commented Aug 5, 2022

The main issue I found while coding this is that at the moment we only have like 4 categories displayed instead of every image.

For example the Nutella has lots of images on the website but on the app only 4 are displayed.

@M123-dev
Copy link
Member

M123-dev commented Aug 5, 2022

Do we need to show more then that

@monsieurtanuki
Copy link
Contributor

I don't know what we're supposed to display in Smoothie, but this is the data we get from the server (https://world.openfoodfacts.org/cgi/search.pl?code=3017620425035&json=1&search_terms=):

"image_front_small_url": "https://images.openfoodfacts.org/images/products/301/762/042/5035/front_en.381.200.jpg",
"image_front_thumb_url": "https://images.openfoodfacts.org/images/products/301/762/042/5035/front_en.381.100.jpg",
"image_front_url": "https://images.openfoodfacts.org/images/products/301/762/042/5035/front_en.381.400.jpg",
"image_ingredients_small_url": "https://images.openfoodfacts.org/images/products/301/762/042/5035/ingredients_en.379.200.jpg",
"image_ingredients_thumb_url": "https://images.openfoodfacts.org/images/products/301/762/042/5035/ingredients_en.379.100.jpg",
"image_ingredients_url": "https://images.openfoodfacts.org/images/products/301/762/042/5035/ingredients_en.379.400.jpg",
"image_nutrition_small_url": "https://images.openfoodfacts.org/images/products/301/762/042/5035/nutrition_en.368.200.jpg",
"image_nutrition_thumb_url": "https://images.openfoodfacts.org/images/products/301/762/042/5035/nutrition_en.368.100.jpg",
"image_nutrition_url": "https://images.openfoodfacts.org/images/products/301/762/042/5035/nutrition_en.368.400.jpg",
"image_packaging_small_url": "https://images.openfoodfacts.org/images/products/301/762/042/5035/packaging_en.369.200.jpg",
"image_packaging_thumb_url": "https://images.openfoodfacts.org/images/products/301/762/042/5035/packaging_en.369.100.jpg",
"image_packaging_url": "https://images.openfoodfacts.org/images/products/301/762/042/5035/packaging_en.369.400.jpg",
"image_small_url": "https://images.openfoodfacts.org/images/products/301/762/042/5035/front_en.381.200.jpg",
"image_thumb_url": "https://images.openfoodfacts.org/images/products/301/762/042/5035/front_en.381.100.jpg",
"image_url": "https://images.openfoodfacts.org/images/products/301/762/042/5035/front_en.381.400.jpg",

@teolemon
Copy link
Member

teolemon commented Aug 6, 2022

@VaiTon
Copy link
Member Author

VaiTon commented Aug 6, 2022

@monsieurtanuki the query that we do in the Android app is:

/**
 * Returns images for the current product
 *
 * @param barcode barcode for the current product
 */
@GET("$API_P/product/{barcode}.json?fields=images")
suspend fun getProductImages(@Path("barcode") barcode: String): ObjectNode

@monsieurtanuki
Copy link
Contributor

@VaiTon Add ProductField.images to ProductQuery.fields, and find the results in Product.images.

@VaiTon
Copy link
Member Author

VaiTon commented Aug 6, 2022

@VaiTon Add ProductField.images to ProductQuery.fields, and find the results in Product.images.

Where should I do this? The idea was to query for all the images only in the gallery view

@monsieurtanuki
Copy link
Contributor

Where should I do this? The idea was to query for all the images only in the gallery view

Either you do that always for all products, and add ProductField.images to ProductQuery.fields.

Or you want specifically to extract those images only if the user goes to a specific page: then you have to asyncly download only the ProductField.images for that product. Something similar to what is coded in BarcodeProductQuery, like:

  Future<List<ProductImage>?> getFetchedProduct() async {
    final ProductQueryConfiguration configuration = ProductQueryConfiguration(
      barcode,
      fields: [ProductQuery.IMAGES],
      language: ProductQuery.getLanguage(),
      country: ProductQuery.getCountry(),
    );

    final ProductResult result;
    try {
      result = await OpenFoodAPIClient.getProduct(configuration);
    } catch (e) {
      return null;
    }

    if (result.status == 1) {
      final Product? product = result.product;
      if (product != null) {
        return product.images;
      }
    }
    return null;
  }

But then you probably have to cache the results somehow...

@VaiTon
Copy link
Member Author

VaiTon commented Aug 6, 2022

@monsieurtanuki thanks! I think that we maybe could do without caching for now, as editing images requires an internet connection to download them (as far as I understand)

@M123-dev
Copy link
Member

M123-dev commented Aug 7, 2022

/**
 * Returns images for the current product
 *
 * @param barcode barcode for the current product
 */
@GET("$API_P/product/{barcode}.json?fields=images")
suspend fun getProductImages(@Path("barcode") barcode: String): ObjectNode

Ohh luckily I don't know kotlin if you have to suspend fun in it 😆

@VaiTon
Copy link
Member Author

VaiTon commented Aug 7, 2022

Now it should display every image. I'm not understanding why they're not opening in full screen anymore though..

# Conflicts:
#	packages/smooth_app/lib/pages/product/edit_product_page.dart
@VaiTon VaiTon force-pushed the feat/image_gallery branch from ad2384f to dbcd334 Compare August 16, 2022 15:09
@VaiTon
Copy link
Member Author

VaiTon commented Aug 16, 2022

Updated screenshot

immagine

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 @VaiTon: the SmoothBackButton is cool, but I have other comments too.

import 'package:smooth_app/generic_lib/widgets/smooth_product_image_container.dart';
import 'package:smooth_app/themes/constant_icons.dart';

class SmoothListTileCard extends StatelessWidget {
Copy link
Contributor

Choose a reason for hiding this comment

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

The big misunderstanding is that I never imagined that you would display an image inside a "normal" ListTile. I expected something similar to the website: tons of pictures in a grid.

I don't know if there were explicit expectations regarding UX/UI, but I must say I'm not a big fan of:

  • all the waste space with no added value (the "title")
  • the cropped image
  • the image ratio

We should start from there: how is it supposed to look? @teolemon Are you OK with the latest screenshots?

@VaiTon VaiTon requested a review from monsieurtanuki August 16, 2022 16:10
@teolemon
Copy link
Member

thanks 👍
I was indeed expecting a grid of squares for unselected images, like in v1 (for extreme cases, and also because you shouldn't be able to do all the same operations on an unselected image as on a selected one, eg client or server side cropping, rotation, unless you're explicitely mapping them to a field first (and server side operations would be preferable)

@VaiTon
Copy link
Member Author

VaiTon commented Aug 16, 2022

thanks +1 I was indeed expecting a grid of squares for unselected images, like in v1 (for extreme cases, and also because you shouldn't be able to do all the same operations on an unselected image as on a selected one, eg client or server side cropping, rotation, unless you're explicitely mapping them to a field first (and server side operations would be preferable)

So we can keep the list for the selected images and a grid for the unselected images? Even keeping a list we would be able to make some actions doable only for selected images

@monsieurtanuki
Copy link
Contributor

I don't know the V1, but from what I see in the website it's a bit by chapter: front, ingredients, ...

Let's imagine what we should display for each chapter (selected image with special power, and all the images).

Something like that:

FRONT
selected:
 000000
 000000
 000000

select another image:
 123456
 ABCDEF
 GHIJKL

Take another picture

Btw @VaiTon I would happily (not happily, but seriously) review your code once we agree on the display and your generated screenshots.

@teolemon
Copy link
Member

@VaiTon @monsieurtanuki here's what I have in Figma
image
image

@VaiTon
Copy link
Member Author

VaiTon commented Aug 16, 2022

@monsieurtanuki would that be in a single page? Because unselected images do not have a field so we should display every unselected image for every field

@VaiTon
Copy link
Member Author

VaiTon commented Aug 16, 2022

@teolemon which is what we have on android.

I don't think that's really what we want because it does not separate the selected images from the unselected ones.

@teolemon
Copy link
Member

So we could use that in 2 places:

  • one as a server side photo picker (where it makes sense)
  • and as a variation below the list of selected images, that could stay tiles, like it currently is.

@monsieurtanuki
Copy link
Contributor

Personally I had no expectations, except a grid, so I'm not really the person to ask.
@VaiTon You seem to be right regarding "unknown" pictures: on the website there are tons of pictures in a grid, and the same ton for each "chapter". In French we say "vrac", which is a dutch word that sounds perfect to say that pictures are just put somewhere.

@VaiTon
Copy link
Member Author

VaiTon commented Aug 16, 2022

@teolemon what about

immagine

@VaiTon
Copy link
Member Author

VaiTon commented Aug 16, 2022

@openfoodfacts/smooth-app any comments? Otherwise I'm implementing this one in a different PR. (50+ comments on this one)

@monsieurtanuki
Copy link
Contributor

@VaiTon Your latest screenshot looks good, except that I would not display images with different aspect ratio for "selected" and "unselected" images. As in your screenshot you put 4 "unselected" images in a row, I guess you could put 2 "selected" images in a row with the same aspect ratio.
If it's more convenient for you to create a new PR, please do. And don't forget to display screenshots first, so that we can assess the UI/UX before starting reviewing the code itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants