Fixes conditional imports for backwards compatibility with Xcode 11

This commit is contained in:
Miguel Ruivo 2020-09-25 15:24:12 +01:00
parent ba19a7eccf
commit 9aa951b4ad
4 changed files with 16 additions and 6 deletions

View File

@ -1,3 +1,6 @@
## 2.0.2+1
iOS: Fixes conditional import for backwards compatibility with Xcode 11.
## 2.0.2
Web: Adds mobile Safari support and other minor improvements.
iOS: Adds conditional import for backwards compatibility with Xcode 11.

View File

@ -4,12 +4,13 @@
#import <Photos/Photos.h>
#import <MobileCoreServices/MobileCoreServices.h>
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0
#if __has_include(<PhotosUI/PHPicker.h>) || __has_include("PHPicker.h")
#define PHPicker
#import <PhotosUI/PHPicker.h>
#endif
@interface FilePickerPlugin : NSObject<FlutterPlugin, FlutterStreamHandler, UIDocumentPickerDelegate, UITabBarDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0
@interface FilePickerPlugin : NSObject<FlutterPlugin, FlutterStreamHandler, UIDocumentPickerDelegate, UITabBarDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIImagePickerControllerDelegate, MPMediaPickerControllerDelegate
#ifdef PHPicker
, PHPickerViewControllerDelegate
#endif
>

View File

@ -4,7 +4,7 @@
@import DKImagePickerController;
@interface FilePickerPlugin() <UIImagePickerControllerDelegate, MPMediaPickerControllerDelegate, DKImageAssetExporterObserver, PHPickerViewControllerDelegate>
@interface FilePickerPlugin() <DKImageAssetExporterObserver>
@property (nonatomic) FlutterResult result;
@property (nonatomic) FlutterEventSink eventSink;
@property (nonatomic) UIViewController *viewController;
@ -127,7 +127,8 @@
}
- (void) resolvePickMedia:(MediaType)type withMultiPick:(BOOL)multiPick withCompressionAllowed:(BOOL)allowCompression {
#ifdef PHPicker
if (@available(iOS 14, *)) {
PHPickerConfiguration *config = [[PHPickerConfiguration alloc] init];
config.filter = type == IMAGE ? [PHPickerFilter imagesFilter] : type == VIDEO ? [PHPickerFilter videosFilter] : [PHPickerFilter anyFilterMatchingSubfilters:@[[PHPickerFilter videosFilter], [PHPickerFilter imagesFilter]]];
@ -141,6 +142,7 @@
[self.viewController presentViewController:pickerViewController animated:YES completion:nil];
return;
}
#endif
if(multiPick) {
[self resolveMultiPickFromGallery:type withCompressionAllowed:allowCompression];
@ -346,6 +348,8 @@ didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls{
[self handleResult: pickedVideoUrl != nil ? pickedVideoUrl : pickedImageUrl];
}
#ifdef PHPicker
-(void)picker:(PHPickerViewController *)picker didFinishPicking:(NSArray<PHPickerResult *> *)results API_AVAILABLE(ios(14)){
Log(@"Picker:%@ didFinishPicking:%@", picker, results);
@ -376,6 +380,8 @@ didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls{
});
}
#endif
// AudioPicker delegate
- (void)mediaPicker: (MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection

View File

@ -1,7 +1,7 @@
name: file_picker
description: A package that allows you to use a native file explorer to pick single or multiple absolute file paths, with extension filtering support.
homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker
version: 2.0.2
version: 2.0.2+1
dependencies:
flutter: