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

fix: #1538 - new crop tool (cf. dev mode) #2872

Merged
merged 6 commits into from
Sep 7, 2022

Conversation

monsieurtanuki
Copy link
Contributor

New files:

  • crop_grid.dart: heavily inspired from package crop_image - ideally we should put it back there.
  • crop_helper.dart: Crop Helper - which crop tool do we use, and the method to use it.
  • new_crop_page.dart: Page dedicated to image cropping. Pops the resulting file path if relevant.
  • rotated_crop_controller.dart: heavily inspired from package crop_image BUT with the rotation feature - ideally we should put it back there.
  • rotated_crop_image.dart: heavily inspired from package crop_image BUT with the rotation feature - ideally we should put it back there.
  • rotation.dart: 90 degree rotations - ideally we should put it in package crop_image

Impacted files:

  • image_crop_page.dart: now relying on new class CropHelper in order to get the appropriate crop tool (e.g. old or new)
  • pubspec.lock: wtf
  • pubspec.yaml: added package image for good performances regarding image saving
  • user_preferences_dev_mode.dart: added a "Use new crop tool" switch (default is false)

What

  • I've just added a new crop tool, which can be turned on through dev mode (off by default).
  • This crop tool is a very simple adaptation of an existing package crop_image, that unfortunately did not support rotations (we do).
  • We may be able to integrate the code to the existing package, and then rely only on crop_image.
  • The display and features are the same on Android and iOS. We'll be able to support the "initial crop" parameter and the "crop area" result, which was not the case with the previous tool.
  • There may be performance issues at strategic moments (when we save the cropped image to a file)- feel free to test
  • I've noticed little issues regarding the product refresh. For instance, when we crop an image and save it, it's perfect on the website, but not necessarily refreshed on all pages of the app. The problem was probably there before and should be solved, like The app should refresh sub-knowledge panels after category addition #2833, but in another issue/PR.

Screenshot

"old" crop tool new crop tool
Capture d’écran 2022-08-30 à 17 31 41 Capture d’écran 2022-08-30 à 17 32 17

Fixes bug(s)

New files:
* `crop_grid.dart`: heavily inspired from package `crop_image` - ideally we should put it back there.
* `crop_helper.dart`: Crop Helper - which crop tool do we use, and the method to use it.
* `new_crop_page.dart`: Page dedicated to image cropping. Pops the resulting file path if relevant.
* `rotated_crop_controller.dart`: heavily inspired from package `crop_image` BUT with the rotation feature - ideally we should put it back there.
* `rotated_crop_image.dart`: heavily inspired from package `crop_image` BUT with the rotation feature - ideally we should put it back there.
* `rotation.dart`: 90 degree rotations - ideally we should put it back in package `crop_image`

Impacted files:
* `image_crop_page.dart`: now relying on new class `CropHelper` in order to get the appropriate crop tool (e.g. old or new)
* `pubspec.lock`: wtf
* `pubspec.yaml`: added package `image` for good performances regarding image encoding
* `user_preferences_dev_mode.dart`: added a "Use new crop tool" switch (default is `false`)
@codecov-commenter
Copy link

codecov-commenter commented Aug 30, 2022

Codecov Report

Merging #2872 (e03f062) into develop (e9e538f) will decrease coverage by 0.27%.
The diff coverage is 0.40%.

@@            Coverage Diff             @@
##           develop   #2872      +/-   ##
==========================================
- Coverage     6.94%   6.67%   -0.28%     
==========================================
  Files          229     235       +6     
  Lines        11155   11646     +491     
==========================================
+ Hits           775     777       +2     
- Misses       10380   10869     +489     
Impacted Files Coverage Δ
packages/smooth_app/lib/pages/crop_helper.dart 0.00% <0.00%> (ø)
packages/smooth_app/lib/pages/image_crop_page.dart 2.12% <0.00%> (+0.20%) ⬆️
...b/pages/preferences/user_preferences_dev_mode.dart 0.38% <0.00%> (-0.01%) ⬇️
...kages/smooth_app/lib/tmp_crop_image/crop_grid.dart 0.00% <0.00%> (ø)
...s/smooth_app/lib/tmp_crop_image/new_crop_page.dart 0.00% <0.00%> (ø)
...pp/lib/tmp_crop_image/rotated_crop_controller.dart 0.00% <0.00%> (ø)
...oth_app/lib/tmp_crop_image/rotated_crop_image.dart 0.53% <0.53%> (ø)
...ckages/smooth_app/lib/tmp_crop_image/rotation.dart 2.85% <2.85%> (ø)

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

@VaiTon
Copy link
Member

VaiTon commented Sep 4, 2022

@monsieurtanuki could we please add a padding so that gestures do not interfere with the actual cropping?

@monsieurtanuki
Copy link
Contributor Author

@monsieurtanuki could we please add a padding so that gestures do not interfere with the actual cropping?

I'm not against an evolution but I don't understand what bothers you here. The only gestures I see here are linked to the 4 corners of the crop tool, and the rotate and OK buttons. I don't see the interference: in which cases would that be?

@teolemon
Copy link
Member

teolemon commented Sep 4, 2022

System edge swipe on Android, which will change the foreground app

@monsieurtanuki
Copy link
Contributor Author

@teolemon You mean from the bottom? I assumed that the "action bar" (rotate + ok) was enough, but I can add a padding, fair enough.

@VaiTon
Copy link
Member

VaiTon commented Sep 6, 2022

@monsieurtanuki thank you! It's also from the left and the right sides, because with system gestures we get the "go back" action if sliding from the left or right side

@monsieurtanuki
Copy link
Contributor Author

@monsieurtanuki thank you! It's also from the left and the right sides, because with system gestures we get the "go back" action if sliding from the left or right side

@VaiTon I'm not sure about that: the crop tool is considered as a (full size) modal dialog.
Anyway, just tell me how big a safe padding would be, and I'll fix the code accordingly.
For the record system gestures didn't seem to be a problem with the previous (= current) version of the crop tool.

@monsieurtanuki
Copy link
Contributor Author

@VaiTon For the record I'm not replacing the previous crop tool, I only make another crop tool available: users would have to go to dev mode in order to select the new crop tool.
If this PR is merged, there is no direct impact on "normal people", and "developers" can test the new crop tool and check its collisions (or not) with system gestures.

@VaiTon
Copy link
Member

VaiTon commented Sep 7, 2022

@monsieurtanuki that's good! Let's merge and I'll tell you if it interferes with navigation gestures :)

Copy link
Member

@M123-dev M123-dev left a comment

Choose a reason for hiding this comment

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

Nothing that shocks me here when scimming over it, I agree with @VaiTon lets merge and test, thanks @monsieurtanuki

@monsieurtanuki monsieurtanuki merged commit 535cddc into openfoodfacts:develop Sep 7, 2022
@monsieurtanuki
Copy link
Contributor Author

Thank you @M123-dev @VaiTon!

@monsieurtanuki
Copy link
Contributor Author

@VaiTon Don't hesitate to test the new crop tool!
cf. Dev mode, "Use new crop tool => true"

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

Successfully merging this pull request may close these issues.

Impossible to zoom out after rotating photo in the cropper
5 participants