|
18 | 18 |
|
19 | 19 | @interface FLTImagePickerPlugin () <UINavigationControllerDelegate,
|
20 | 20 | UIImagePickerControllerDelegate,
|
21 |
| - PHPickerViewControllerDelegate> |
| 21 | + PHPickerViewControllerDelegate, |
| 22 | + UIAdaptivePresentationControllerDelegate> |
22 | 23 |
|
23 | 24 | @property(copy, nonatomic) FlutterResult result;
|
24 | 25 |
|
@@ -92,6 +93,7 @@ - (void)pickImageWithPHPicker:(int)maxImagesAllowed API_AVAILABLE(ios(14)) {
|
92 | 93 |
|
93 | 94 | _pickerViewController = [[PHPickerViewController alloc] initWithConfiguration:config];
|
94 | 95 | _pickerViewController.delegate = self;
|
| 96 | + _pickerViewController.presentationController.delegate = self; |
95 | 97 |
|
96 | 98 | self.maxImagesAllowed = maxImagesAllowed;
|
97 | 99 |
|
@@ -373,18 +375,28 @@ - (NSNumber *)getDesiredImageQuality:(NSNumber *)imageQuality {
|
373 | 375 | return imageQuality;
|
374 | 376 | }
|
375 | 377 |
|
| 378 | +- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController { |
| 379 | + if (self.result != nil) { |
| 380 | + self.result(nil); |
| 381 | + self.result = nil; |
| 382 | + self->_arguments = nil; |
| 383 | + } |
| 384 | +} |
| 385 | + |
376 | 386 | - (void)picker:(PHPickerViewController *)picker
|
377 | 387 | didFinishPicking:(NSArray<PHPickerResult *> *)results API_AVAILABLE(ios(14)) {
|
378 | 388 | [picker dismissViewControllerAnimated:YES completion:nil];
|
379 |
| - dispatch_queue_t backgroundQueue = |
380 |
| - dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0); |
381 |
| - dispatch_async(backgroundQueue, ^{ |
382 |
| - if (results.count == 0) { |
| 389 | + if (results.count == 0) { |
| 390 | + if (self.result != nil) { |
383 | 391 | self.result(nil);
|
384 | 392 | self.result = nil;
|
385 | 393 | self->_arguments = nil;
|
386 |
| - return; |
387 | 394 | }
|
| 395 | + return; |
| 396 | + } |
| 397 | + dispatch_queue_t backgroundQueue = |
| 398 | + dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0); |
| 399 | + dispatch_async(backgroundQueue, ^{ |
388 | 400 | NSNumber *maxWidth = [self->_arguments objectForKey:@"maxWidth"];
|
389 | 401 | NSNumber *maxHeight = [self->_arguments objectForKey:@"maxHeight"];
|
390 | 402 | NSNumber *imageQuality = [self->_arguments objectForKey:@"imageQuality"];
|
|
0 commit comments