Browse Source

simplest possible fix for #311 (#313)

Steve Liles 7 years ago
parent
commit
335d83d36c
1 changed files with 14 additions and 13 deletions
  1. 14
    13
      ios/RNFetchBlob/RNFetchBlob.m

+ 14
- 13
ios/RNFetchBlob/RNFetchBlob.m View File

@@ -300,7 +300,7 @@ RCT_EXPORT_METHOD(ls:(NSString *)path callback:(RCTResponseSenderBlock) callback
300 300
 #pragma mark - fs.stat
301 301
 RCT_EXPORT_METHOD(stat:(NSString *)target callback:(RCTResponseSenderBlock) callback)
302 302
 {
303
-    
303
+
304 304
     [RNFetchBlobFS getPathFromUri:target completionHandler:^(NSString *path, ALAssetRepresentation *asset) {
305 305
         __block NSMutableArray * result;
306 306
         if(path != nil)
@@ -309,14 +309,14 @@ RCT_EXPORT_METHOD(stat:(NSString *)target callback:(RCTResponseSenderBlock) call
309 309
             BOOL exist = nil;
310 310
             BOOL isDir = nil;
311 311
             NSError * error = nil;
312
-            
312
+
313 313
             exist = [fm fileExistsAtPath:path isDirectory:&isDir];
314 314
             if(exist == NO) {
315 315
                 callback(@[[NSString stringWithFormat:@"failed to stat path `%@` for it is not exist or it is not exist", path]]);
316 316
                 return ;
317 317
             }
318 318
             result = [RNFetchBlobFS stat:path error:&error];
319
-            
319
+
320 320
             if(error == nil)
321 321
                 callback(@[[NSNull null], result]);
322 322
             else
@@ -375,7 +375,7 @@ RCT_EXPORT_METHOD(lstat:(NSString *)path callback:(RCTResponseSenderBlock) callb
375 375
 #pragma mark - fs.cp
376 376
 RCT_EXPORT_METHOD(cp:(NSString*)src toPath:(NSString *)dest callback:(RCTResponseSenderBlock) callback)
377 377
 {
378
-    
378
+
379 379
 //    path = [RNFetchBlobFS getPathOfAsset:path];
380 380
     [RNFetchBlobFS getPathFromUri:src completionHandler:^(NSString *path, ALAssetRepresentation *asset) {
381 381
         NSError * error = nil;
@@ -387,14 +387,14 @@ RCT_EXPORT_METHOD(cp:(NSString*)src toPath:(NSString *)dest callback:(RCTRespons
387 387
         else
388 388
         {
389 389
             BOOL result = [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:path] toURL:[NSURL fileURLWithPath:dest] error:&error];
390
-            
390
+
391 391
             if(error == nil)
392 392
                 callback(@[[NSNull null], @YES]);
393 393
             else
394 394
                 callback(@[[error localizedDescription], @NO]);
395 395
         }
396 396
     }];
397
-    
397
+
398 398
 }
399 399
 
400 400
 
@@ -456,7 +456,7 @@ RCT_EXPORT_METHOD(readStream:(NSString *)path withEncoding:(NSString *)encoding
456 456
         else
457 457
             bufferSize = 4096;
458 458
     }
459
-    
459
+
460 460
     dispatch_async(fsQueue, ^{
461 461
         [RNFetchBlobFS readStream:path encoding:encoding bufferSize:bufferSize tick:tick streamId:streamId bridgeRef:_bridge];
462 462
     });
@@ -482,7 +482,7 @@ RCT_EXPORT_METHOD(cancelRequest:(NSString *)taskId callback:(RCTResponseSenderBl
482 482
 #pragma mark - net.enableProgressReport
483 483
 RCT_EXPORT_METHOD(enableProgressReport:(NSString *)taskId interval:(nonnull NSNumber*)interval count:(nonnull NSNumber*)count)
484 484
 {
485
-    
485
+
486 486
     RNFetchBlobProgress * cfg = [[RNFetchBlobProgress alloc] initWithType:Download interval:interval count:count];
487 487
     [RNFetchBlobNetwork enableProgressReport:taskId config:cfg];
488 488
 }
@@ -509,9 +509,10 @@ RCT_EXPORT_METHOD(previewDocument:(NSString*)uri scheme:(NSString *)scheme resol
509 509
     UIViewController *rootCtrl = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
510 510
     documentController.delegate = self;
511 511
     if(scheme == nil || [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:scheme]]) {
512
-        dispatch_sync(dispatch_get_main_queue(), ^{
513
-            [documentController  presentOptionsMenuFromRect:rootCtrl.view.bounds inView:rootCtrl.view animated:YES];
514
-        });
512
+      CGRect rect = CGRectMake(0.0, 0.0, 0.0, 0.0);
513
+      dispatch_sync(dispatch_get_main_queue(), ^{
514
+          [documentController  presentOptionsMenuFromRect:rect inView:rootCtrl.view animated:YES];
515
+      });
515 516
         resolve(@[[NSNull null]]);
516 517
     } else {
517 518
         reject(@"RNFetchBlob could not open document", @"scheme is not supported", nil);
@@ -527,7 +528,7 @@ RCT_EXPORT_METHOD(openDocument:(NSString*)uri scheme:(NSString *)scheme resolver
527 528
     // NSURL * url = [[NSURL alloc] initWithString:uri];
528 529
     documentController = [UIDocumentInteractionController interactionControllerWithURL:url];
529 530
     documentController.delegate = self;
530
-    
531
+
531 532
     if(scheme == nil || [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:scheme]]) {
532 533
         dispatch_sync(dispatch_get_main_queue(), ^{
533 534
             [documentController presentPreviewAnimated:YES];
@@ -550,7 +551,7 @@ RCT_EXPORT_METHOD(excludeFromBackupKey:(NSString *)url resolver:(RCTPromiseResol
550 551
     } else {
551 552
         reject(@"RNFetchBlob could not open document", [error description], nil);
552 553
     }
553
-    
554
+
554 555
 }
555 556
 
556 557