Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[image_picker] Implement methods for picking both images and videos simultaneously. #4676

Closed
wants to merge 22 commits into from

Conversation

BeMacized
Copy link
Member

@BeMacized BeMacized commented Jan 18, 2022

This PR implements both pickImageOrVideo and pickMultiImageAndVideo pickMedia on both Android and iOS.

This PR is still in draft mode due to the lack of unit tests, as well as the dependency on the changes to the platform interface: #4675. I will be adding tests later.

Relevant issue:

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [relevant style guides] and ran [the auto-formatter]. (Unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the [CLA].
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy], or this PR is [exempt from version changes].
  • I updated CHANGELOG.md to add a description of the change, [following repository CHANGELOG style].
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

Comment on lines +77 to +118
- (void)processImage API_AVAILABLE(ios(14)) {
[self.result.itemProvider
loadObjectOfClass:[UIImage class]
completionHandler:^(__kindof id<NSItemProviderReading> _Nullable data,
NSError *_Nullable error) {
if ([data isKindOfClass:[UIImage class]]) {
__block UIImage *localImage = data;
PHAsset *originalAsset = [self getAssetFromPHPickerResult:self.result];
if (self.maxWidth != (id)[NSNull null] || self.maxHeight != (id)[NSNull null]) {
localImage = [FLTImagePickerImageUtil scaledImage:localImage
maxWidth:self.maxWidth
maxHeight:self.maxHeight
isMetadataAvailable:originalAsset != nil];
}
__block NSString *savedPath;
if (!originalAsset) {
// Image picked without an original asset (e.g. User picked an image without
// permission).
savedPath = [self saveImageWithPickerInfo:nil
image:localImage
imageQuality:self.desiredImageQuality];
[self completeOperationWithPath:savedPath];
} else {
[[PHImageManager defaultManager]
requestImageDataForAsset:originalAsset
options:nil
resultHandler:^(NSData *_Nullable imageData, NSString *_Nullable dataUTI,
UIImageOrientation orientation,
NSDictionary *_Nullable info) {
// maxWidth and maxHeight are used only for GIF images.
savedPath =
[self saveImageWithOriginalImageData:imageData
image:localImage
maxWidth:self.maxWidth
maxHeight:self.maxHeight
imageQuality:self.desiredImageQuality];
[self completeOperationWithPath:savedPath];
}];
}
}
}];
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This method was already in here, it's simply moved over from FLTPHPickerSaveImageToPathOperation.

@Hixie
Copy link
Contributor

Hixie commented Mar 29, 2022

It sounds like this is obsolete with #4675 now, so I'm going to close this PR. Please don't hesitate to submit it again if I'm wrong about this.

@Hixie Hixie closed this Mar 29, 2022
@BeMacized
Copy link
Member Author

Reopening this as I've picked this (and #4675) back up again.

@BeMacized BeMacized reopened this Apr 1, 2022
@Hixie
Copy link
Contributor

Hixie commented May 31, 2022

@BeMacized Is this PR read for review?

@BeMacized
Copy link
Member Author

No, it's not (also because the changes to the platform interface have not been merged yet).

It will be superceded by two new PRs that I'll submit in a moment. Closing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants