Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit 075dade

Browse files
committed
refs #51397 Added parameters to UIDocumentInteractionController
1 parent b70a124 commit 075dade

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

ios/RNFetchBlob/RNFetchBlob.m

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,14 +535,33 @@ - (NSDictionary *)constantsToExport
535535

536536
# pragma mark - open file with UIDocumentInteractionController and delegate
537537

538-
RCT_EXPORT_METHOD(openDocument:(NSString*)uri scheme:(NSString *)scheme resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
538+
RCT_EXPORT_METHOD(openDocument:(NSString*)uri fontFamily:(NSString*)fontFamily fontSize:(float)fontSize hexString:(NSString*)hexString scheme:(NSString*)scheme resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
539539
{
540540
NSString * utf8uri = [uri stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
541541
NSURL * url = [[NSURL alloc] initWithString:utf8uri];
542542
// NSURL * url = [[NSURL alloc] initWithString:uri];
543+
NSMutableDictionary *titleBarAttributes = [NSMutableDictionary dictionaryWithDictionary: [[UINavigationBar appearance] titleTextAttributes]];
544+
[titleBarAttributes setValue:[UIFont fontWithName:fontFamily size:fontSize] forKey:NSFontAttributeName];
545+
unsigned rgbValue = 0;
546+
NSScanner *scanner = [NSScanner scannerWithString:hexString];
547+
[scanner setScanLocation:1]; // bypass '#' character
548+
[scanner scanHexInt:&rgbValue];
549+
[titleBarAttributes setValue:[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
550+
green:((float)((rgbValue & 0x00FF00) >> 8))/255.0 \
551+
blue:((float)((rgbValue & 0x0000FF) >> 0))/255.0 \
552+
alpha:1.0] forKey:NSForegroundColorAttributeName];
553+
[[UINavigationBar appearance] setTitleTextAttributes:titleBarAttributes];
554+
NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithDictionary: [[UIBarButtonItem appearance] titleTextAttributesForState:UIControlStateNormal]];
555+
[attributes setValue:[UIFont fontWithName:fontFamily size:fontSize] forKey:NSFontAttributeName];
556+
[[UIBarButtonItem appearance] setTitleTextAttributes:attributes forState:UIControlStateNormal];
557+
[[UIBarButtonItem appearance] setTintColor: [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
558+
green:((float)((rgbValue & 0x00FF00) >> 8))/255.0 \
559+
blue:((float)((rgbValue & 0x0000FF) >> 0))/255.0 \
560+
alpha:1.0]];
561+
[[UINavigationBar appearance] setBarTintColor: [UIColor whiteColor]];
543562
documentController = [UIDocumentInteractionController interactionControllerWithURL:url];
544563
documentController.delegate = self;
545-
564+
546565
if(scheme == nil || [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:scheme]]) {
547566
dispatch_sync(dispatch_get_main_queue(), ^{
548567
[documentController presentPreviewAnimated:YES];

0 commit comments

Comments
 (0)