| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | #import "RNNTitleOptions.h"
#import "RNNTitleViewHelper.h"
@implementation RNNTitleOptions
- (void)applyOn:(UIViewController *)viewController {
	if (self.text) {
		viewController.navigationItem.title = self.text;
	}
	
	NSDictionary* fontAttributes = [self fontAttributes];
	
	viewController.navigationController.navigationBar.titleTextAttributes = fontAttributes;
	if (self.subtitle.text) {
		RNNTitleViewHelper* titleViewHelper = [[RNNTitleViewHelper alloc] init:viewController title:self.text subtitle:self.subtitle.text titleImageData:nil isSetSubtitle:NO];
		[titleViewHelper setup:self];
	}
}
- (NSDictionary *)fontAttributes {
	NSMutableDictionary* navigationBarTitleTextAttributes = [NSMutableDictionary new];
	if (self.fontFamily || self.fontSize || self.color) {
		if (self.color) {
			navigationBarTitleTextAttributes[NSForegroundColorAttributeName] = [RCTConvert UIColor:self.color];
		}
		if (self.fontFamily){
			if (self.fontSize) {
				navigationBarTitleTextAttributes[NSFontAttributeName] = [UIFont fontWithName:self.fontFamily size:[self.fontSize floatValue]];
			} else {
				navigationBarTitleTextAttributes[NSFontAttributeName] = [UIFont fontWithName:self.fontFamily size:20];
			}
		} else if (self.fontSize) {
			navigationBarTitleTextAttributes[NSFontAttributeName] = [UIFont systemFontOfSize:[self.fontSize floatValue]];
		}
	}
	
	return navigationBarTitleTextAttributes;
}
- (NSNumber *)fontSize {
	return _fontSize ? _fontSize : nil;
}
@end
 |