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: Extract ingredients/packaging: loading / loaded / extracting states #5384

Merged
merged 4 commits into from
Jun 16, 2024

Conversation

g123k
Copy link
Collaborator

@g123k g123k commented Jun 15, 2024

Hi everyone,

Extract ingredients and packaging share the same screen.
However, there are two issues:

  • We don't clearly understand what's happening with the progress bar
  • There is an empty container when we extract the data

I've made things clearer, that you can see in this video:

Untitled.mov

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 78 lines in your changes missing coverage. Please review.

Project coverage is 7.32%. Comparing base (4d9c7fc) to head (d854301).
Report is 196 commits behind head on develop.

Files Patch % Lines
...es/smooth_app/lib/pages/product/edit_ocr_page.dart 0.00% 69 Missing ⚠️
..._app/lib/pages/product/ocr_ingredients_helper.dart 0.00% 5 Missing ⚠️
...th_app/lib/pages/product/ocr_packaging_helper.dart 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           develop   #5384      +/-   ##
==========================================
- Coverage     9.54%   7.32%   -2.23%     
==========================================
  Files          325     386      +61     
  Lines        16411   19847    +3436     
==========================================
- Hits          1567    1454     -113     
- Misses       14844   18393    +3549     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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 @g123k!
LGTM, and this page did need some action!
Regarding the code, there are a couple of issues that bother me: changing translation tags, and not catching an exception.
The others are minor comments, feel free to ignore them.

@@ -1448,18 +1448,34 @@
"completed_basic_details_btn_text": "Complete basic details",
"not_implemented_snackbar_text": "Not implemented yet",
"category_picker_page_appbar_text": "Categories",
"edit_ingredients_extrait_ingredients_btn_text": "Extract ingredients",
"@edit_ingredients_extrait_ingredients_btn_text": {
"edit_ingredients_extract_ingredients_btn_text": "Extract ingredients from the photo",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm really not convinced it's such a brillant idea to change translation tags, as I fear it wipes out all the previous translations. For a very limited added-value: fixing an invisible useless typo.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, it's now merged :/
@teleomon Is-it somehow possible to move an old translation to a new one?

Comment on lines +379 to +390
OcrState _extractState(TransientFile transientFile) {
if (_extractingData) {
return OcrState.EXTRACTING_DATA;
} else if (transientFile.isServerImage()) {
return OcrState.IMAGE_LOADED;
} else if (transientFile.isImageAvailable()) {
return OcrState.IMAGE_LOADING;
} else {
return OcrState.OTHER;
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks brillant!

Comment on lines +505 to +512
const CircularProgressIndicator.adaptive(),
Expanded(
child: Text(
helper.getActionExtractingData(appLocalizations),
textAlign: TextAlign.center,
),
),
const CircularProgressIndicator.adaptive(),
Copy link
Contributor

Choose a reason for hiding this comment

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

2 progress indicators? A bit too much, isn't it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You can see it, on the video, with the Shimmer effect, actually it's OK.
To be honest, I've not checked on Android and in that case, I will remove the first one on non-Apple devices

),
const Icon(
Icons.download,
semanticLabel: '',
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that worth it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, otherwise, the screen reader tries to say the character in font (that's the default behavior)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, otherwise, the screen reader tries to say the character in font (that's the default behavior)

Hmm, I guess that wouldn't hurt to say "download".
If I've understood well, that also means that we're supposed to give each Icon we use in the app that meaningless semanticLabel: '' parameter, which is not nice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's not needed, because we have the text just before.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know it's your way of coding, putting several classes in the same file, and my way of coding is rather one class per file.
Beyond those differences, you may consider that 600 lines of code is a bit too much for a single file, and create additional files, e.g. one per button.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, I will move _EditOcrMainAction in a separate file, but sub widgets are just a way to prevent of giant Widget

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm ok with subwidgets, I just don't like big files - and giant widgets ;)

} catch (e) {
//
}
} catch (_) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

So you're not resetting _extractingData to false when there's an exception in getExtractedText?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice catch 😆
I will fix that

Copy link
Member

@teolemon teolemon left a comment

Choose a reason for hiding this comment

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

I would potentially add the language the photo is in, and the language it's extracting to in the loading message.
Alternatively we can shift to a tab based UI instead of dropdowns

image

@teolemon teolemon merged commit 65ce9c4 into openfoodfacts:develop Jun 16, 2024
6 checks passed
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.

4 participants