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: 3332 - refactored the new crop page UI and added a camera #3402

Merged
merged 10 commits into from
Dec 8, 2022

Conversation

monsieurtanuki
Copy link
Contributor

New file:

  • may_exit_page_helper.dart: Helper class about the "You're leaving the page with unsaved changes" case.

Impacted files:

  • image_crop_page.dart: made method pickImageFile public
  • new_crop_image.dart: added "camera" button to app bar, moved "rotate" button on app bar, moved "ok" button as FAB, added "exit without saving" dialog feature
  • simple_input_page.dart: now using new class MayExitPageHelper

What

  • This is a new step for Simplify adding photos by removing 2 of the 4 steps #3332: adding a camera button to the new crop page.
  • That meant 3 buttons on bottom bar, which collided visually with the 3 bottom navigation tabs - I changed the UI to avoid the collision (cf. screenshot). I'm open to other suggestions.
  • A new "exit without saving?" dialog feature has been introduced on this page, similar to what was in SimpleInputPage
  • Of course it's still a bit clumsy - as we still have the old crop page as an option, it's not possible to remove the previous "camera", "edit", "confirm" page. We have to click on "OK" on the crop page to save our changes, and then to "confirm" them on the other page to save the changes to the server. That problem is already mentioned in Simplify adding photos by removing 2 of the 4 steps #3332 - to be solved when we get rid of the old crop page option.

Screenshots

light dark
Capture d’écran 2022-12-02 à 19 07 44 Capture d’écran 2022-12-02 à 19 08 10

Part of

New file:
* `may_exit_page_helper.dart`: Helper class about the "You're leaving the page with unsaved changes" case.

Impacted files:
* `image_crop_page.dart`: made method `pickImageFile` public
* `new_crop_image.dart`: added "camera" button to app bar, moved "rotate" button on app bar, moved "ok" button as FAB, added "exit without saving" dialog feature
* `simple_input_page.dart`: now using new class `MayExitPageHelper`
@monsieurtanuki
Copy link
Contributor Author

@omkarChend1kar Would you please review it?

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.

image

@omkarChend1kar
Copy link
Contributor

@omkarChend1kar Would you please review it?

@monsieurtanuki Sure, Maybe after the requested changes.

@monsieurtanuki
Copy link
Contributor Author

Hi @teolemon!

You're right, my suggested UI does not go towards your mockup.

In your mockup

  • there are 4 features that are not supported now (unselect, select, change language, change field)
  • the "OK" is not confusing there, because there's no "OK" button at all

If I implement something that goes towards your mockup, it will also look a lot like the page before the crop page, that we cannot get rid of as long as we keep the old crop tool "just in case".
For the record, page before the crop page:
Capture d’écran 2022-12-03 à 07 26 11

As for do we need labels on buttons, that's probably a matter of taste. A matter of space too, especially with localizations.
In "my" solution, it's definitely not an issue as I land on a crop page with a "camera" button, a "rotation" button, and an "OK" button. The logos are explicit, standard, and even if they're not the user has only 3 buttons to try in a very specific context.

That said, I'm going to implement your suggested changes (aka buttons with labels), that will make it more obvious that we need to get rid of the old crop page and the additional "edit image" page.

@teolemon
Copy link
Member

teolemon commented Dec 3, 2022

The big differences:

  • it's one screen
  • there's no "validate/ok" button
  • no proeminent crop/rotate, especially since we don't have server side operations (it justs reuploads the same image, cropped, and the next user can't uncrop, correct mistakes, or even restart from the uncropped image)

Also, one question, is that supposed to be the rotate button ?
image

@teolemon
Copy link
Member

teolemon commented Dec 3, 2022

If all other features are off the table, here's one version that:

  • does not jeopardize the vision where you can take quick actions (such as unselecting, reporting)
  • prepares the table for multilingual images
  • reduces rotation time, and makes it clearer it is rotation
  • The rotation buttons rotate the whole image

image

Impacted file:
* `new_crop_image.dart`: moved "camera" button to bottom center, moved "rotate" button to top right, removed "ok" button
@monsieurtanuki
Copy link
Contributor Author

Thank you @teolemon for your suggestions!

This is a screenshot from my latest commit:
Capture d’écran 2022-12-03 à 08 41 24

For the record, according to flutter it did use a decent rotate right icon (but your icon choice is definitely more explicit):
Capture d’écran 2022-12-03 à 08 16 38

@codecov-commenter
Copy link

codecov-commenter commented Dec 3, 2022

Codecov Report

Merging #3402 (e57f610) into develop (282884a) will increase coverage by 0.02%.
The diff coverage is 0.00%.

@@             Coverage Diff             @@
##           develop    #3402      +/-   ##
===========================================
+ Coverage    10.32%   10.35%   +0.02%     
===========================================
  Files          260      259       -1     
  Lines        12595    12550      -45     
===========================================
- Hits          1301     1300       -1     
+ Misses       11294    11250      -44     
Impacted Files Coverage Δ
packages/smooth_app/lib/pages/image_crop_page.dart 0.00% <0.00%> (-1.36%) ⬇️
...b/pages/preferences/user_preferences_dev_mode.dart 0.00% <0.00%> (ø)
...th_app/lib/pages/product/may_exit_page_helper.dart 0.00% <0.00%> (ø)
...th_app/lib/pages/product/product_image_viewer.dart 0.00% <0.00%> (ø)
...mooth_app/lib/pages/product/simple_input_page.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%> (ø)
...ckages/smooth_app/lib/tmp_crop_image/rotation.dart 2.50% <0.00%> (-0.36%) ⬇️

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

@teolemon
Copy link
Member

teolemon commented Dec 3, 2022

Ok now we're back to interaction issues for saving, which was handled by the "OK" button (which added an extra step).

V1 autosaves new images, and subsequent crop/rotation is saved manually on a separate screen. On V1 We had a separate initial photo upload screen (with instant upload) with (client-side) cropping embedded, and a subsequent image manipulation screen with instant upload and server-side cropping/rotation… Crop/rotation happening server-side is to avoid loosing pictures, to generate training data for cropping, reduce server storage drain… We're trying to have the same screen optimize for 2 things.

  • Initial: taking/uploading photo and cropping as quickly as possible. (What I'd like for V2 of the app is also multilingual support eventually)
  • Subsequent photo editing: more operations (including multilingual, crop, unselection…)

At this point, and to go from first principles to this PR:

  • Are changes instantly applied on upload ? crop ? on rotate ? or on closing the view ? what happens if clicking the navigation bar ?
  • Here a solution is to save on view exit. We can a "Save" button in the top bar or below the take new photo button
  • What about not showing the app navigation bar to reduce complexity ?

image

Honestly, I took 20 min writing this text, and I'm not happy with it, since it grossly misrepresents things. I'm not into writing novels for each feature/PR. Live and Collaborative fast iteration on images/mockups or a visio are worth a thousand words, and verbal iteration on what happens in each subcase, potential user reactions…

@monsieurtanuki
Copy link
Contributor Author

Are changes instantly applied on upload ? crop ? on rotate ? or on closing the view ?

No server change is really applied on that screen. When we exit the screen, we provide the resulting file to the caller. That's the caller that decides to upload that file (with the "confirm" button).
The target would be to have the current screen uploading the file when clicking on "save" (or going back and being reminded that there are pending changes).

Again, this is due to the "old crop tool" / "new custom crop tool" dilemma. If we get rid of the old crop tool, we'll have a clearer view.
It looks like the new crop tool is not malfunctioning, so I'm in favor of discarding the old one altogether (especially given that we could not customize the old one at all, like adding buttons or uploading).

what happens if clicking the navigation bar ?

Good question, I haven't checked that one. It's probably not detected by WillPopScope as it's not a "back" gesture/click.

Here a solution is to save on view exit. We can a "Save" button in the top bar or below the take new photo button

That was more or less the purpose of the "OK" button. BUT, as said before, for historical reasons when we clicked on OK that would bring us back to the previous page with its "confirm" button.

What about not showing the app navigation bar to reduce complexity ?

#3337

@monsieurtanuki
Copy link
Contributor Author

Honestly, I took 20 min writing this text, and I'm not happy with it, since it grossly misrepresents things. I'm not into writing novels for each feature/PR. Live and Collaborative fast iteration on images/mockups or a visio are worth a thousand words, and verbal iteration on what happens in each subcase, potential user reactions…

@teolemon In the visual approach, you simply ignore all the potential algorithm questions and contradictions that we coders have to deal with, like "When should we save to the server?", "What if the users forget to click on the save button?" or "What if the server rejects the cropped image?". That's not rendered on figma, is it?
Even in figma the visual questions like "what if the localizations make texts too big or too small", the aspect ratio on small / tall / big screens and the scrolling are not dealt with.
We need both a good UX and a good code underneath. You care more about the visual aspect, I care more about the code and the algorithms. Nothing wrong with that.

In the specific case of this PR, my initial point was just to add a working "camera" button. It became obvious that just adding the "camera" icon would create confusion with 2 rows of 3 icons on the bottom of the screen, and I had to change the UI accordingly. My point was not to say "This is the new UI direction!", my point was "I had to change the UI, change it as you wish but don't spend too much time on it as new features/new buttons/new UX/UI will come soon".

We're zig-zaging, but in the right direction.

That said, there are methods like Model–view–controller in order to separate the UI from the actual code.

Impacted files:
* `crop_helper.dart`: removed the old crop tool
* `image_crop_page.dart`: removed the old crop tool
* `new_crop_page.dart`: added a "rotate left" button; added a "confirm" button; refactored
* `Podfile.lock`: wtf
* `pubspec.lock`: wtf
* `pubspec.yaml`: removed the old crop tool
* `rotated_crop_controller.dart`: added a "rotate left" method
* `rotation.dart`: added a "rotate left" method
* `user_preferences_dev_mode.dart`: removed the choice of "old crop tool"
@monsieurtanuki
Copy link
Contributor Author

Latest commit screenshot:
Capture d’écran 2022-12-05 à 08 56 41

TODO: remove "the previous page", which is very similar to the crop page without added value:
Capture d’écran 2022-12-05 à 08 58 45

Deleted files:
* `confirm_and_upload_picture.dart`
* `crop_helper.dart`

Impacted files:
* `image_crop_page.dart`: simplified with fewer steps
* `new_crop_page.dart`: now uploads
* `product_image_viewer.dart`: minor refactoring - going directly to `CropPage`
@monsieurtanuki
Copy link
Contributor Author

Screenshot with the latest commit.
As far as #3332 went, the PR is complete.
Feel free to review and add suggestions.

product page after a click on whatever picture
Capture d’écran 2022-12-05 à 10 49 44 Capture d’écran 2022-12-05 à 10 50 06
after a click on ingredient picture after a click on edit
Capture d’écran 2022-12-05 à 10 54 21 Capture d’écran 2022-12-05 à 10 54 53

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.

Thank you very much @monsieurtanuki for the changes. We're improving the photo situation, bit by bit.

@monsieurtanuki monsieurtanuki merged commit d3aea55 into openfoodfacts:develop Dec 8, 2022
@monsieurtanuki
Copy link
Contributor Author

Thank you @teolemon for your feedbacks!

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.

4 participants