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: New image cropper (pure Flutter) #1063

Merged
merged 8 commits into from
Feb 3, 2022
Merged

feat: New image cropper (pure Flutter) #1063

merged 8 commits into from
Feb 3, 2022

Conversation

M123-dev
Copy link
Member

@M123-dev M123-dev commented Feb 2, 2022

Fixes: #1038

CI failing because of: #1062

@M123-dev M123-dev added the images label Feb 2, 2022
@github-actions github-actions bot added Android 🌐 l10n Product addition The easier it is to add a product and get Nutri-Score, Eco-Score, the happier the users. 🥫 Product page labels Feb 2, 2022
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 @M123-dev!
That was a good idea to get rid of additional lines in AndroidManifest.xml thank to the new solution: wasn't there something related on the iOS side too?
My main concern here is an easy one: the code would be easier to read if you create a Crop StatelessWidget instead of hiding your widget into a method. I'm a Java boy, sorry about that, I like files and classes...


final Directory tempDir = await getTemporaryDirectory();
final String tempPath = tempDir.path;
final String filePath = '$tempPath/upload_img_file_01.tmp';
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably be deleted after the upload, though I understand that it will overridden by the next image.
Btw it's always just one upload at a time?

Copy link
Member Author

@M123-dev M123-dev Feb 2, 2022

Choose a reason for hiding this comment

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

I just checked we cannot delete the file directly, otherwise it will fail uploading, becouse it can't finde the file. I think that with the file object we only pass some kind of pointer. But since it's in the temp directory it won't be a problem

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.

It's better, but I still don't like it at 100%. Please read my comments, and feel free to ignore them and merge if you are in a hurry.
About the file deletion, again I wouldn't want to prevent you from merging quickly important code, but I don't see why you cannot delete the file after the upload. If really you cannot, that may be the symptom of something else like a hidden bug.

Comment on lines 34 to 39
return FutureBuilder<Uint8List?>(
future: pickImage(),
builder: (
BuildContext context,
AsyncSnapshot<Uint8List?> snap,
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly I have problems with this syntax, but I don't blame you in particular because it's not the only place in the project where it's coded that way - and maybe it's not your problem if I have a problem with that :)

In short, I don't think it makes sense to open a page/Scaffold on a Future when the Future is a dialog or a file picker. Besides, this class is called ImageCropPage and therefore should crop an image (in this case a Uint8List), and that's it.
Step 1 the caller calls a file picker, step 2 it calls ImageCropPage on the file picker result. ImageCropPage could be called from anywhere, not necessarily from a Future that necessarily opens a file picker.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for your review @monsieurtanuki the Scaffold before the FutureBuilder makes sense, and for the File, from the comments on the file implementation:

/// A reference to a file on the file system.
///
/// A File holds a [path] on which operations can be performed.
/// You can get the parent directory of the file using [parent],
/// a property inherited from [FileSystemEntity].

Se would have to remove it after sending, not in the cropper. But thats not in the scope of this PR,

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually no, just added it 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android images 🌐 l10n Product addition The easier it is to add a product and get Nutri-Score, Eco-Score, the happier the users. 🥫 Product page
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build fails because of `Theme.AppCompat.Light.NoActionBar not foundà
2 participants