@@ -315,7 +315,6 @@ - (NSDictionary *)constantsToExport
315
315
#pragma mark - fs.stat
316
316
RCT_EXPORT_METHOD (stat:(NSString *)target callback:(RCTResponseSenderBlock) callback)
317
317
{
318
-
319
318
[RNFetchBlobFS getPathFromUri: target completionHandler: ^(NSString *path, ALAssetRepresentation *asset) {
320
319
__block NSMutableArray * result;
321
320
if (path != nil )
@@ -536,11 +535,40 @@ - (NSDictionary *)constantsToExport
536
535
537
536
# pragma mark - open file with UIDocumentInteractionController and delegate
538
537
539
- RCT_EXPORT_METHOD (openDocument:(NSString *)uri scheme:(NSString *)scheme name:(NSString *)name resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
538
+ - (void )openDocument : (NSString *)uri
539
+ scheme : (NSString *)scheme
540
+ resolver : (RCTPromiseResolveBlock)resolve
541
+ rejecter : (RCTPromiseRejectBlock)reject
542
+ fontFamily : (NSString *)fontFamily
543
+ fontSize : (float )fontSize
544
+ hexString : (NSString *)hexString
540
545
{
541
546
NSString * utf8uri = [uri stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
542
547
NSURL * url = [[NSURL alloc ] initWithString: utf8uri];
543
548
// NSURL * url = [[NSURL alloc] initWithString:uri];
549
+ if (fontFamily) {
550
+ NSMutableDictionary *titleBarAttributes = [NSMutableDictionary dictionaryWithDictionary: [[UINavigationBar appearance ] titleTextAttributes ]];
551
+ [titleBarAttributes setValue: [UIFont fontWithName: fontFamily size: fontSize] forKey: NSFontAttributeName ];
552
+ unsigned rgbValue = 0 ;
553
+ NSScanner *scanner = [NSScanner scannerWithString: hexString];
554
+ [scanner setScanLocation: 1 ]; // bypass '#' character
555
+ [scanner scanHexInt: &rgbValue];
556
+ [titleBarAttributes setValue: [UIColor colorWithRed: ((float )((rgbValue & 0xFF0000 ) >> 16 ))/255.0 \
557
+ green: ((float )((rgbValue & 0x00FF00 ) >> 8 ))/255.0 \
558
+ blue: ((float )((rgbValue & 0x0000FF ) >> 0 ))/255.0 \
559
+ alpha: 1.0 ] forKey: NSForegroundColorAttributeName ];
560
+ [[UINavigationBar appearance ] setTitleTextAttributes: titleBarAttributes];
561
+
562
+ NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithDictionary: [[UIBarButtonItem appearance ] titleTextAttributesForState: UIControlStateNormal]];
563
+ [attributes setValue: [UIFont fontWithName: fontFamily size: fontSize] forKey: NSFontAttributeName ];
564
+ [[UIBarButtonItem appearance ] setTitleTextAttributes: attributes forState: UIControlStateNormal];
565
+ [[UIBarButtonItem appearance ] setTintColor: [UIColor colorWithRed: ((float )((rgbValue & 0xFF0000 ) >> 16 ))/255.0 \
566
+ green: ((float )((rgbValue & 0x00FF00 ) >> 8 ))/255.0 \
567
+ blue: ((float )((rgbValue & 0x0000FF ) >> 0 ))/255.0 \
568
+ alpha: 1.0 ]];
569
+ [[UINavigationBar appearance ] setBarTintColor: [UIColor whiteColor ]];
570
+ }
571
+
544
572
documentController = [UIDocumentInteractionController interactionControllerWithURL: url];
545
573
documentController.delegate = self;
546
574
documentController.name = name;
@@ -555,6 +583,16 @@ - (NSDictionary *)constantsToExport
555
583
}
556
584
}
557
585
586
+ RCT_EXPORT_METHOD (openDocument:(NSString *)uri scheme:(NSString *)scheme resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject fontFamily:(NSString *)fontFamily fontSize:(float )fontSize hexString:(NSString *)hexString)
587
+ {
588
+ [self openDocument: uri scheme: scheme resolver: resolver rejecter: rejecter fontFamily: fontFamily fontSize: fontSize hexString: hexString];
589
+ }
590
+
591
+ RCT_EXPORT_METHOD (openDocument:(NSString *)uri scheme:(NSString *)scheme name:(NSString *)name resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
592
+ {
593
+ [self openDocument: uri scheme: scheme resolver: resolver rejecter: rejecter fontFamily: nil fontSize: NULL hexString: nil ];
594
+ }
595
+
558
596
# pragma mark - exclude from backup key
559
597
560
598
RCT_EXPORT_METHOD (excludeFromBackupKey:(NSString *)url resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
@@ -576,7 +614,7 @@ - (NSDictionary *)constantsToExport
576
614
[RNFetchBlobFS df: callback];
577
615
}
578
616
579
- - (UIViewController *) documentInteractionControllerViewControllerForPreview : (UIDocumentInteractionController *) controller
617
+ - (UIViewController *)documentInteractionControllerViewControllerForPreview : (UIDocumentInteractionController *)controller
580
618
{
581
619
UIWindow *window = [UIApplication sharedApplication ].keyWindow ;
582
620
return window.rootViewController ;
0 commit comments