-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
fix: 3018 - instant upload of images #3329
fix: 3018 - instant upload of images #3329
Conversation
New files: * `ocr_widget.dart`: Widget dedicated to OCR, with 3 actions: upload image, extract data, save. Used to be in `edit_ingredients_page.dart` * `transient_file.dart`: Helper class about transient files (= not fully uploaded yet). Impacted files: * `add_basic_details_page.dart`: minor refactoring * `add_new_product_page.dart`: refactored around the class image repository * `app_en.arb`: added 1 label when OCR fails * `app_fr.arb`: added 1 label when OCR fails * `background_task_details.dart`: minor refactoring * `background_task_image.dart`: immediate execution with just one try * `confirm_and_upload_picture.dart`: minor refactoring with new private class `_OutlinedButton` * `edit_ingredients_page.dart`: moved `OcrWidget` code to dedicated new dart file; fixed the extract button - that cannot be reached if the image is not uploaded yet * `image_crop_page.dart`: refactored with more explicit method names * `image_upload_card.dart`: refactored with `TransientFile` * `new_product_page.dart`: minor refactoring * `product_cards_helper.dart`: minor refactoring * `product_image_carousel.dart`: minor refactoring * `product_image_gallery_view.dart`: refactored with new method `confirmAndUploadNewPicture` and new class `TransientFile` * `product_image_viewer.dart`: refactored with new class `TransientFile` * `question_card.dart`: minor refactoring * `smooth_product_image.dart`: refactored with new class `TransientFile`
Codecov Report
@@ Coverage Diff @@
## develop #3329 +/- ##
========================================
Coverage 10.48% 10.49%
========================================
Files 251 253 +2
Lines 12322 12313 -9
========================================
Hits 1292 1292
+ Misses 11030 11021 -9
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
I tried to run it locally , my initial impressions were good , it works
Please approve it if relevant. |
I just had a rough look, looking into more details, will update you soon |
Don't have time today, I'm having a look at it tomorrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @monsieurtanuki especially that you thought about the transient image for ocr. Added some minor comments
|
||
ProductImageData getProductImageData( | ||
final Product product, | ||
final AppLocalizations? appLocalizations, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this nullable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is that ProductImageData
does 2 different things: it computes the image provider or url, and it populates the title and button labels.
In some cases we don't use the labels, therefore we don't need the AppLocalizations
. I just wanted to avoid calling a AppLocalizations.of(context)
just for something I don't care about - or maybe the context
was not available there, don't remember.
Could be refactored later, especially now that I created specific methods for each use-case (button label, title label, url, provider).
@@ -215,3 +166,34 @@ class _ConfirmAndUploadPictureState extends State<ConfirmAndUploadPicture> { | |||
await model.onCreateProduct(barcode); // TODO(monsieurtanuki): a bit fishy | |||
} | |||
} | |||
|
|||
/// Standard button for this page. | |||
class _OutlinedButton extends StatelessWidget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'n not a fan of having different private buttons per page can't we use one we already have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before in this page the same code was repeated 3 times (once for each button), so it's an improvement, isn't it?
That said, feel free to create an issue about uniformisation of buttons in pages: probably not all identical, but at least "classes" of buttons that can be reused.
New files:
ocr_widget.dart
: Widget dedicated to OCR, with 3 actions: upload image, extract data, save. Used to be inedit_ingredients_page.dart
transient_file.dart
: Helper class about transient files (= not fully uploaded yet).Impacted files:
add_basic_details_page.dart
: minor refactoringadd_new_product_page.dart
: refactored around the class image repositoryapp_en.arb
: added 1 label when OCR failsapp_fr.arb
: added 1 label when OCR failsbackground_task_details.dart
: minor refactoringbackground_task_image.dart
: immediate execution with just one tryconfirm_and_upload_picture.dart
: minor refactoring with new private class_OutlinedButton
edit_ingredients_page.dart
: movedOcrWidget
code to dedicated new dart file; fixed the extract button - that cannot be reached if the image is not uploaded yetimage_crop_page.dart
: refactored with more explicit method namesimage_upload_card.dart
: refactored withTransientFile
new_product_page.dart
: minor refactoringproduct_cards_helper.dart
: minor refactoringproduct_image_carousel.dart
: minor refactoringproduct_image_gallery_view.dart
: refactored with new methodconfirmAndUploadNewPicture
and new classTransientFile
product_image_viewer.dart
: refactored with new classTransientFile
question_card.dart
: minor refactoringsmooth_product_image.dart
: refactored with new classTransientFile
What
TransientFile
.Part of