Add mediaType and showsSelectedCount options for ios

This commit is contained in:
Horcrux 2017-03-09 16:03:15 +08:00
parent 2b04e10b4f
commit ef68e61d97
2 changed files with 16 additions and 3 deletions

View File

@ -89,6 +89,8 @@ ImagePicker.clean().then(() => {
| compressImageMaxHeight | number (default none) | Compress image with maximum height |
| compressImageQuality | number (default 1) | Compress image with quality (from 0 to 1, where 1 is best quality) |
| loadingLabelText (ios only) | string (default "Processing assets...") | Text displayed while photo is loading in picker |
| mediaType (ios only) | string (default any) | Accepted mediaType for image selection, can be one of: 'photo', 'video', or 'any' |
| showsSelectedCount (ios only) | bool (default true) | Whether to show the number of selected assets |
#### Response Object
| Property | Type | Description |

View File

@ -60,6 +60,8 @@ RCT_EXPORT_MODULE();
@"compressImageQuality": @1,
@"compressVideoPreset": @"MediumQuality",
@"loadingLabelText": @"Processing assets...",
@"mediaType": @"any",
@"showsSelectedCount": @YES
};
self.compression = [[Compression alloc] init];
}
@ -230,7 +232,7 @@ RCT_EXPORT_METHOD(openPicker:(NSDictionary *)options
imagePickerController.delegate = self;
imagePickerController.allowsMultipleSelection = [[self.options objectForKey:@"multiple"] boolValue];
imagePickerController.maximumNumberOfSelection = [[self.options objectForKey:@"maxFiles"] intValue];
imagePickerController.showsNumberOfSelectedAssets = YES;
imagePickerController.showsNumberOfSelectedAssets = [[self.options objectForKey:@"showsSelectedCount"] boolValue];
if ([self.options objectForKey:@"smartAlbums"] != nil) {
NSDictionary *smartAlbums = @{
@ -248,11 +250,20 @@ RCT_EXPORT_METHOD(openPicker:(NSDictionary *)options
}
imagePickerController.assetCollectionSubtypes = albumsToShow;
}
if ([[self.options objectForKey:@"cropping"] boolValue]) {
imagePickerController.mediaType = QBImagePickerMediaTypeImage;
} else {
imagePickerController.mediaType = QBImagePickerMediaTypeAny;
NSString *mediaType = [self.options objectForKey:@"mediaType"];
if ([mediaType isEqualToString:@"any"]) {
imagePickerController.mediaType = QBImagePickerMediaTypeAny;
} else if ([mediaType isEqualToString:@"photo"]) {
imagePickerController.mediaType = QBImagePickerMediaTypeImage;
} else {
imagePickerController.mediaType = QBImagePickerMediaTypeVideo;
}
}
[[self getRootVC] presentViewController:imagePickerController animated:YES completion:nil];