@@ -535,14 +535,33 @@ - (NSDictionary *)constantsToExport
535
535
536
536
# pragma mark - open file with UIDocumentInteractionController and delegate
537
537
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)
539
539
{
540
540
NSString * utf8uri = [uri stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
541
541
NSURL * url = [[NSURL alloc ] initWithString: utf8uri];
542
542
// 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 ]];
543
562
documentController = [UIDocumentInteractionController interactionControllerWithURL: url];
544
563
documentController.delegate = self;
545
-
564
+
546
565
if (scheme == nil || [[UIApplication sharedApplication ] canOpenURL: [NSURL URLWithString: scheme]]) {
547
566
dispatch_sync (dispatch_get_main_queue (), ^{
548
567
[documentController presentPreviewAnimated: YES ];
0 commit comments