@connectedbits/react-native-image-picker 2.4.8 → 2.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -106,10 +106,10 @@
|
|
|
106
106
|
<servers />
|
|
107
107
|
</component>
|
|
108
108
|
<component name="WindowStateProjectService">
|
|
109
|
-
<state x="972" y="271" width="615" height="490" key="find.popup" timestamp="
|
|
109
|
+
<state x="972" y="271" width="615" height="490" key="find.popup" timestamp="1614713491506">
|
|
110
110
|
<screen x="0" y="25" width="2560" height="983" />
|
|
111
111
|
</state>
|
|
112
|
-
<state x="972" y="271" width="615" height="490" key="find.popup/0.25.2560.983@0.25.2560.983" timestamp="
|
|
112
|
+
<state x="972" y="271" width="615" height="490" key="find.popup/0.25.2560.983@0.25.2560.983" timestamp="1614713491506" />
|
|
113
113
|
</component>
|
|
114
114
|
<component name="masterDetails">
|
|
115
115
|
<states>
|
package/ios/ImagePickerManager.m
CHANGED
|
@@ -299,7 +299,7 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
|
|
|
299
299
|
else {
|
|
300
300
|
originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
|
|
301
301
|
}
|
|
302
|
-
|
|
302
|
+
|
|
303
303
|
if (imageURL) {
|
|
304
304
|
PHAsset *pickedAsset;
|
|
305
305
|
if (@available(iOS 11.0, *)) {
|
|
@@ -334,6 +334,8 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
|
|
|
334
334
|
[gifResponse setObject:@(originalImage.size.width) forKey:@"width"];
|
|
335
335
|
[gifResponse setObject:@(originalImage.size.height) forKey:@"height"];
|
|
336
336
|
|
|
337
|
+
[self populateResponse:gifResponse fromAsset:asset];
|
|
338
|
+
|
|
337
339
|
BOOL vertical = (originalImage.size.width < originalImage.size.height) ? YES : NO;
|
|
338
340
|
[gifResponse setObject:@(vertical) forKey:@"isVertical"];
|
|
339
341
|
|
|
@@ -351,10 +353,13 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
|
|
|
351
353
|
if (fileSizeValue){
|
|
352
354
|
[gifResponse setObject:fileSizeValue forKey:@"fileSize"];
|
|
353
355
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
357
|
+
self.callback(@[gifResponse]);
|
|
358
|
+
});
|
|
356
359
|
} failureBlock:^(NSError *error) {
|
|
357
|
-
|
|
360
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
361
|
+
self.callback(@[@{@"error": error.localizedFailureReason}]);
|
|
362
|
+
});
|
|
358
363
|
}];
|
|
359
364
|
return;
|
|
360
365
|
}
|
|
@@ -376,11 +381,11 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
|
|
|
376
381
|
NSString *mimeType;
|
|
377
382
|
if ([[self.options objectForKey:@"imageFileType"] isEqualToString:@"png"]) {
|
|
378
383
|
data = UIImagePNGRepresentation(editedImage);
|
|
379
|
-
mimeType = (__bridge_transfer NSString *)
|
|
384
|
+
mimeType = (__bridge_transfer NSString *)@"image/png";
|
|
380
385
|
}
|
|
381
386
|
else {
|
|
382
387
|
data = UIImageJPEGRepresentation(editedImage, [[self.options valueForKey:@"quality"] floatValue]);
|
|
383
|
-
mimeType = (__bridge_transfer NSString *)
|
|
388
|
+
mimeType = (__bridge_transfer NSString *)@"image/jpeg";
|
|
384
389
|
}
|
|
385
390
|
[self.response setObject:mimeType forKey:@"type"];
|
|
386
391
|
[data writeToFile:path atomically:YES];
|
|
@@ -430,7 +435,7 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
|
|
|
430
435
|
self.response[@"timestamp"] = [[ImagePickerManager ISO8601DateFormatter] stringFromDate:capturedAsset.creationDate];
|
|
431
436
|
}
|
|
432
437
|
}
|
|
433
|
-
|
|
438
|
+
[self dispatchCallbackForUrl:assetURL withResponse:self.response];
|
|
434
439
|
}
|
|
435
440
|
}];
|
|
436
441
|
} else {
|
|
@@ -491,7 +496,9 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
|
|
|
491
496
|
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
|
|
492
497
|
[library writeVideoAtPathToSavedPhotosAlbum:videoDestinationURL completionBlock:^(NSURL *assetURL, NSError *error) {
|
|
493
498
|
if (error) {
|
|
494
|
-
|
|
499
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
500
|
+
self.callback(@[@{@"error": error.localizedFailureReason}]);
|
|
501
|
+
});
|
|
495
502
|
return;
|
|
496
503
|
} else {
|
|
497
504
|
NSLog(@"Save video succeed.");
|
|
@@ -504,9 +511,12 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
|
|
|
504
511
|
if (capturedAsset.creationDate) {
|
|
505
512
|
self.response[@"timestamp"] = [[ImagePickerManager ISO8601DateFormatter] stringFromDate:capturedAsset.creationDate];
|
|
506
513
|
}
|
|
514
|
+
[self dispatchCallbackForUrl:assetURL withResponse:self.response];
|
|
515
|
+
} else {
|
|
516
|
+
[self dispatchCallbackForUrl:[info valueForKey:UIImagePickerControllerReferenceURL] withResponse:self.response];
|
|
507
517
|
}
|
|
508
518
|
|
|
509
|
-
|
|
519
|
+
|
|
510
520
|
}
|
|
511
521
|
}
|
|
512
522
|
}];
|
|
@@ -525,11 +535,11 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
|
|
|
525
535
|
[[storageOptions objectForKey:@"cameraRoll"] boolValue] == NO ||
|
|
526
536
|
self.picker.sourceType != UIImagePickerControllerSourceTypeCamera)
|
|
527
537
|
{
|
|
528
|
-
self
|
|
538
|
+
[self dispatchCallbackForUrl:[info valueForKey:UIImagePickerControllerReferenceURL] withResponse:self.response];
|
|
529
539
|
}
|
|
530
540
|
}
|
|
531
541
|
else {
|
|
532
|
-
self
|
|
542
|
+
[self dispatchCallbackForUrl:[info valueForKey:UIImagePickerControllerReferenceURL] withResponse:self.response];
|
|
533
543
|
}
|
|
534
544
|
};
|
|
535
545
|
|
|
@@ -538,6 +548,39 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
|
|
|
538
548
|
});
|
|
539
549
|
}
|
|
540
550
|
|
|
551
|
+
- (void) populateResponse:(NSMutableDictionary *) response fromAsset:(ALAsset *) asset {
|
|
552
|
+
CLLocation * location = [asset valueForProperty:ALAssetPropertyLocation];
|
|
553
|
+
if(location){
|
|
554
|
+
response[@"latitude"] = @(location.coordinate.latitude);
|
|
555
|
+
response[@"longitude"] = @(location.coordinate.longitude);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
- (void) dispatchCallbackForUrl: (NSURL *) url withResponse: (NSMutableDictionary *)response {
|
|
560
|
+
if(!url){
|
|
561
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
562
|
+
self.callback(@[response]);
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
if(response && !response[@"latitude"] && !response[@"longitude"]){
|
|
566
|
+
ALAssetsLibrary * library = [[ALAssetsLibrary alloc] init];
|
|
567
|
+
[library assetForURL:url resultBlock:^(ALAsset * asset){
|
|
568
|
+
[self populateResponse:response fromAsset:asset];
|
|
569
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
570
|
+
self.callback(@[response]);
|
|
571
|
+
});
|
|
572
|
+
} failureBlock:^(NSError * error){
|
|
573
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
574
|
+
self.callback(@[response]);
|
|
575
|
+
});
|
|
576
|
+
}];
|
|
577
|
+
} else {
|
|
578
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
579
|
+
self.callback(@[response]);
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
541
584
|
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
|
|
542
585
|
{
|
|
543
586
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@connectedbits/react-native-image-picker",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.12",
|
|
4
4
|
"description": "A React Native module that allows you to use native UI to select media from the device library or directly from the camera",
|
|
5
5
|
"react-native": "src/index.ts",
|
|
6
6
|
"types": "lib/typescript/index.d.ts",
|