diff --git a/lib/ios/RNNComponentPresenter.m b/lib/ios/RNNComponentPresenter.m index a2fe60fb9c5..f48d9b12220 100644 --- a/lib/ios/RNNComponentPresenter.m +++ b/lib/ios/RNNComponentPresenter.m @@ -192,7 +192,7 @@ - (void)setCustomNavigationTitleView:(RNNNavigationOptions *)options perform:(RN } - (void)setTitleViewWithSubtitle:(RNNNavigationOptions *)options { - if (!_customTitleView) { + if (!_customTitleView && ![options.topBar.largeTitle.visible getWithDefaultValue:NO]) { _titleViewHelper = [[RNNTitleViewHelper alloc] initWithTitleViewOptions:options.topBar.title subTitleOptions:options.topBar.subtitle viewController:self.boundViewController]; if (options.topBar.title.text.hasValue) { diff --git a/lib/ios/RNNFontAttributesCreator.h b/lib/ios/RNNFontAttributesCreator.h index 6a32647f2d7..0929f77d61f 100644 --- a/lib/ios/RNNFontAttributesCreator.h +++ b/lib/ios/RNNFontAttributesCreator.h @@ -7,6 +7,6 @@ + (NSDictionary *)createWithFontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize fontWeight:(NSString *)fontWeight color:(UIColor *)color; -+ (NSDictionary *)createWithDictionary:(NSDictionary *)attributesDictionary fontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize defaultFontSize:(NSNumber *)defaultFontSize fontWeight:(NSString *)fontWeight color:(UIColor *)color defaultColor:(UIColor *)defaultColor; ++ (NSDictionary *)createFromDictionary:(NSDictionary *)attributesDictionary fontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize defaultFontSize:(NSNumber *)defaultFontSize fontWeight:(NSString *)fontWeight color:(UIColor *)color defaultColor:(UIColor *)defaultColor; @end diff --git a/lib/ios/RNNFontAttributesCreator.m b/lib/ios/RNNFontAttributesCreator.m index 89f3147ead4..f3abb74508d 100644 --- a/lib/ios/RNNFontAttributesCreator.m +++ b/lib/ios/RNNFontAttributesCreator.m @@ -5,33 +5,33 @@ @implementation RNNFontAttributesCreator + (NSDictionary *)createWithFontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize defaultFontSize:(NSNumber *)defaultFontSize fontWeight:(NSString *)fontWeight color:(UIColor *)color defaultColor:(UIColor *)defaultColor { NSMutableDictionary* titleTextAttributes = [NSMutableDictionary new]; - return [self createWithDictionary:titleTextAttributes fontFamily:fontFamily fontSize:fontSize defaultFontSize:defaultFontSize fontWeight:fontWeight color:color defaultColor:defaultColor]; + return [self createFromDictionary:titleTextAttributes fontFamily:fontFamily fontSize:fontSize defaultFontSize:defaultFontSize fontWeight:fontWeight color:color defaultColor:defaultColor]; } + (NSDictionary *)createWithFontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize fontWeight:(NSString *)fontWeight color:(UIColor *)color { NSMutableDictionary* titleTextAttributes = [NSMutableDictionary new]; - return [self createWithDictionary:titleTextAttributes fontFamily:fontFamily fontSize:fontSize fontWeight:fontWeight color:color]; + return [self createFromDictionary:titleTextAttributes fontFamily:fontFamily fontSize:fontSize fontWeight:fontWeight color:color]; } -+ (NSDictionary *)createWithDictionary:(NSDictionary *)attributesDictionary fontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize defaultFontSize:(NSNumber *)defaultFontSize fontWeight:(NSString *)fontWeight color:(UIColor *)color defaultColor:(UIColor *)defaultColor { - return [self createWithDictionary:attributesDictionary fontFamily:fontFamily fontSize:fontSize ?: defaultFontSize fontWeight:fontWeight color:color ?: defaultColor]; ++ (NSDictionary *)createFromDictionary:(NSDictionary *)attributesDictionary fontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize defaultFontSize:(NSNumber *)defaultFontSize fontWeight:(NSString *)fontWeight color:(UIColor *)color defaultColor:(UIColor *)defaultColor { + return [self createFromDictionary:attributesDictionary fontFamily:fontFamily fontSize:fontSize ?: defaultFontSize fontWeight:fontWeight color:color ?: defaultColor]; } -+ (NSDictionary *)createWithDictionary:(NSDictionary *)attributesDictionary fontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize fontWeight:(NSString *)fontWeight color:(UIColor *)color { - NSMutableDictionary* titleTextAttributes = [NSMutableDictionary dictionaryWithDictionary:attributesDictionary]; - if (fontFamily || fontSize || color || fontWeight) { - CGFloat resolvedFontSize = fontSize ? fontSize.floatValue : 17; - if (color) { - titleTextAttributes[NSForegroundColorAttributeName] = color; - } - if (fontWeight) { - titleTextAttributes[NSFontAttributeName] = [UIFont systemFontOfSize:resolvedFontSize weight:[RCTConvert UIFontWeight:fontWeight]]; - } else if (fontFamily){ - titleTextAttributes[NSFontAttributeName] = [UIFont fontWithName:fontFamily size:resolvedFontSize]; - } else { - titleTextAttributes[NSFontAttributeName] = [UIFont systemFontOfSize:resolvedFontSize]; - } - } ++ (NSDictionary *)createFromDictionary:(NSDictionary *)attributesDictionary fontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize fontWeight:(NSString *)fontWeight color:(UIColor *)color { + NSMutableDictionary* titleTextAttributes = [NSMutableDictionary dictionaryWithDictionary:attributesDictionary];\ + UIFont* currentFont = attributesDictionary[NSFontAttributeName]; + + CGFloat resolvedFontSize = fontSize ? fontSize.floatValue : currentFont.fontDescriptor.pointSize; + if (color) { + titleTextAttributes[NSForegroundColorAttributeName] = color; + } + if (fontWeight) { + titleTextAttributes[NSFontAttributeName] = [UIFont systemFontOfSize:resolvedFontSize weight:[RCTConvert UIFontWeight:fontWeight]]; + } else if (fontFamily){ + titleTextAttributes[NSFontAttributeName] = [UIFont fontWithName:fontFamily size:resolvedFontSize]; + } else if (fontSize) { + titleTextAttributes[NSFontAttributeName] = [UIFont fontWithDescriptor:currentFont.fontDescriptor size:resolvedFontSize]; + } return titleTextAttributes; } diff --git a/lib/ios/RNNTabBarItemCreator.m b/lib/ios/RNNTabBarItemCreator.m index c7d0026f798..793d393d419 100644 --- a/lib/ios/RNNTabBarItemCreator.m +++ b/lib/ios/RNNTabBarItemCreator.m @@ -63,11 +63,11 @@ + (UIImage *)getIconImage:(UIImage *)icon withTint:(UIColor *)tintColor { } + (void)appendTitleAttributes:(UITabBarItem *)tabItem textColor:(UIColor *)textColor selectedTextColor:(UIColor *)selectedTextColor fontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize fontWeight:(NSString *)fontWeight { - NSDictionary* selectedAttributes = [RNNFontAttributesCreator createWithDictionary:[tabItem titleTextAttributesForState:UIControlStateSelected] fontFamily:fontFamily fontSize:fontSize defaultFontSize:@(10) fontWeight:fontWeight color:selectedTextColor defaultColor:[UIColor blackColor]]; + NSDictionary* selectedAttributes = [RNNFontAttributesCreator createFromDictionary:[tabItem titleTextAttributesForState:UIControlStateSelected] fontFamily:fontFamily fontSize:fontSize defaultFontSize:@(10) fontWeight:fontWeight color:selectedTextColor defaultColor:[UIColor blackColor]]; [tabItem setTitleTextAttributes:selectedAttributes forState:UIControlStateSelected]; - NSDictionary* normalAttributes = [RNNFontAttributesCreator createWithDictionary:[tabItem titleTextAttributesForState:UIControlStateNormal] fontFamily:fontFamily fontSize:fontSize defaultFontSize:@(10) fontWeight:fontWeight color:textColor defaultColor:[UIColor blackColor]]; + NSDictionary* normalAttributes = [RNNFontAttributesCreator createFromDictionary:[tabItem titleTextAttributesForState:UIControlStateNormal] fontFamily:fontFamily fontSize:fontSize defaultFontSize:@(10) fontWeight:fontWeight color:textColor defaultColor:[UIColor blackColor]]; [tabItem setTitleTextAttributes:normalAttributes forState:UIControlStateNormal]; } diff --git a/lib/ios/UINavigationBar+utils.h b/lib/ios/UINavigationBar+utils.h index fb97f0549e3..03e6a785580 100644 --- a/lib/ios/UINavigationBar+utils.h +++ b/lib/ios/UINavigationBar+utils.h @@ -8,4 +8,8 @@ - (void)rnn_showBorder:(BOOL)showBorder; +- (void)rnn_setNavigationBarLargeTitleFontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize fontWeight:(NSString *)fontWeight color:(UIColor *)color; + +- (void)rnn_setNavigationBarTitleFontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize fontWeight:(NSString *)fontWeight color:(UIColor *)color; + @end diff --git a/lib/ios/UINavigationBar+utils.m b/lib/ios/UINavigationBar+utils.m index 3cf22e8944a..707aa75e681 100644 --- a/lib/ios/UINavigationBar+utils.m +++ b/lib/ios/UINavigationBar+utils.m @@ -1,4 +1,5 @@ #import "UINavigationBar+utils.h" +#import "RNNFontAttributesCreator.h" @implementation UINavigationBar (utils) @@ -26,6 +27,43 @@ - (void)rnn_setBackgroundColor:(UIColor *)color { } } +- (void)rnn_setNavigationBarLargeTitleFontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize fontWeight:(NSString *)fontWeight color:(UIColor *)color { + NSDictionary* fontAttributes; + if (@available(iOS 13.0, *)) { + fontAttributes = [RNNFontAttributesCreator createFromDictionary:self.standardAppearance.largeTitleTextAttributes fontFamily:fontFamily fontSize:fontSize defaultFontSize:nil fontWeight:fontWeight color:color defaultColor:nil]; + [[self getNavigaitonBarStandardAppearance] setLargeTitleTextAttributes:fontAttributes]; + [[self getNavigaitonBarCompactAppearance] setLargeTitleTextAttributes:fontAttributes]; + [[self getNavigaitonBarScrollEdgeAppearance] setLargeTitleTextAttributes:fontAttributes]; + } else if (@available(iOS 11.0, *)) { + fontAttributes = [RNNFontAttributesCreator createFromDictionary:self.largeTitleTextAttributes fontFamily:fontFamily fontSize:fontSize defaultFontSize:nil fontWeight:fontWeight color:color defaultColor:nil]; + self.largeTitleTextAttributes = fontAttributes; + } +} + +- (void)rnn_setNavigationBarTitleFontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize fontWeight:(NSString *)fontWeight color:(UIColor *)color { + NSDictionary* fontAttributes; + if (@available(iOS 13.0, *)) { + fontAttributes = [RNNFontAttributesCreator createFromDictionary:self.standardAppearance.titleTextAttributes fontFamily:fontFamily fontSize:fontSize defaultFontSize:nil fontWeight:fontWeight color:color defaultColor:nil]; + [[self getNavigaitonBarStandardAppearance] setTitleTextAttributes:fontAttributes]; + [[self getNavigaitonBarCompactAppearance] setTitleTextAttributes:fontAttributes]; + [[self getNavigaitonBarScrollEdgeAppearance] setTitleTextAttributes:fontAttributes]; + } else if (@available(iOS 11.0, *)) { + fontAttributes = [RNNFontAttributesCreator createFromDictionary:self.titleTextAttributes fontFamily:fontFamily fontSize:fontSize defaultFontSize:nil fontWeight:fontWeight color:color defaultColor:nil]; + self.titleTextAttributes = fontAttributes; + } +} + +- (void)rnn_showBorder:(BOOL)showBorder { + if (@available(iOS 13.0, *)) { + UIColor* shadowColor = showBorder ? [[UINavigationBarAppearance new] shadowColor] : nil; + [[self getNavigaitonBarStandardAppearance] setShadowColor:shadowColor]; + [[self getNavigaitonBarCompactAppearance] setShadowColor:shadowColor]; + [[self getNavigaitonBarScrollEdgeAppearance] setShadowColor:shadowColor]; + } else { + [self setShadowImage:showBorder ? nil : [UIImage new]]; + } +} + - (void)setBackgroundColor:(UIColor *)color { if (@available(iOS 13.0, *)) { [self getNavigaitonBarStandardAppearance].backgroundColor = color; @@ -54,17 +92,6 @@ - (void)setBackgroundColorTransparent { } } -- (void)rnn_showBorder:(BOOL)showBorder { - if (@available(iOS 13.0, *)) { - UIColor* shadowColor = showBorder ? [[UINavigationBarAppearance new] shadowColor] : nil; - [[self getNavigaitonBarStandardAppearance] setShadowColor:shadowColor]; - [[self getNavigaitonBarCompactAppearance] setShadowColor:shadowColor]; - [[self getNavigaitonBarScrollEdgeAppearance] setShadowColor:shadowColor]; - } else { - [self setShadowImage:showBorder ? nil : [UIImage new]]; - } -} - - (void)configureWithTransparentBackground { if (@available(iOS 13.0, *)) { [[self getNavigaitonBarStandardAppearance] configureWithTransparentBackground]; diff --git a/lib/ios/UINavigationController+RNNOptions.m b/lib/ios/UINavigationController+RNNOptions.m index 206523d06d0..2241ed87c12 100644 --- a/lib/ios/UINavigationController+RNNOptions.m +++ b/lib/ios/UINavigationController+RNNOptions.m @@ -44,11 +44,7 @@ - (void)setBarStyle:(UIBarStyle)barStyle { } - (void)setNavigationBarFontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize fontWeight:(NSString *)fontWeight color:(UIColor *)color { - NSDictionary* fontAttributes = [RNNFontAttributesCreator createWithFontFamily:fontFamily fontSize:fontSize fontWeight:fontWeight color:color]; - - if (fontAttributes.allKeys.count > 0) { - self.navigationBar.titleTextAttributes = fontAttributes; - } + [self.navigationBar rnn_setNavigationBarTitleFontFamily:fontFamily fontSize:fontSize fontWeight:fontWeight color:color]; } - (void)setNavigationBarLargeTitleVisible:(BOOL)visible { @@ -62,10 +58,7 @@ - (void)setNavigationBarLargeTitleVisible:(BOOL)visible { } - (void)setNavigationBarLargeTitleFontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize fontWeight:(NSString *)fontWeight color:(UIColor *)color { - if (@available(iOS 11.0, *)) { - NSDictionary* fontAttributes = [RNNFontAttributesCreator createWithFontFamily:fontFamily fontSize:fontSize fontWeight:fontWeight color:color]; - self.navigationBar.largeTitleTextAttributes = fontAttributes; - } + [self.navigationBar rnn_setNavigationBarLargeTitleFontFamily:fontFamily fontSize:fontSize fontWeight:fontWeight color:color]; } - (void)setNavigationBarTranslucent:(BOOL)translucent { diff --git a/playground/ios/NavigationTests/RNNFontAttributesCreatorTest.m b/playground/ios/NavigationTests/RNNFontAttributesCreatorTest.m index cf40294999f..f3c5c915b89 100644 --- a/playground/ios/NavigationTests/RNNFontAttributesCreatorTest.m +++ b/playground/ios/NavigationTests/RNNFontAttributesCreatorTest.m @@ -44,38 +44,41 @@ - (void)testCreateWithFontFamilyWithDefault_shouldCreateDefaultAttributes { XCTAssertEqual(font.pointSize, defaultFontSize.floatValue); } -- (void)testCreateWithDictionary_shouldCreateAttributes { +- (void)testcreateFromDictionary_shouldCreateAttributes { NSString* familyName = @"Helvetica"; NSNumber* fontSize = @(20); UIColor* fontColor = UIColor.blueColor; - NSDictionary* attributes = [RNNFontAttributesCreator createWithDictionary:@{} fontFamily:familyName fontSize:fontSize defaultFontSize:nil fontWeight:nil color:fontColor defaultColor:nil]; + NSDictionary* attributes = [RNNFontAttributesCreator createFromDictionary:@{} fontFamily:familyName fontSize:fontSize defaultFontSize:nil fontWeight:nil color:fontColor defaultColor:nil]; UIFont* font = attributes[NSFontAttributeName]; XCTAssertEqual(attributes[NSForegroundColorAttributeName], fontColor); XCTAssertTrue([familyName isEqualToString:font.familyName]); XCTAssertEqual(font.pointSize, fontSize.floatValue); } -- (void)testCreateWithDictionary_shouldMergeWithDictionary { +- (void)testcreateFromDictionary_shouldMergeWithDictionary { NSString* familyName = @"Helvetica"; NSNumber* fontSize = @(20); NSDictionary* dictionary = @{NSForegroundColorAttributeName: UIColor.redColor}; - NSDictionary* attributes = [RNNFontAttributesCreator createWithDictionary:dictionary fontFamily:familyName fontSize:fontSize defaultFontSize:nil fontWeight:nil color:nil defaultColor:nil]; + NSDictionary* attributes = [RNNFontAttributesCreator createFromDictionary:dictionary fontFamily:familyName fontSize:fontSize defaultFontSize:nil fontWeight:nil color:nil defaultColor:nil]; UIFont* font = attributes[NSFontAttributeName]; XCTAssertEqual(attributes[NSForegroundColorAttributeName], UIColor.redColor); XCTAssertTrue([familyName isEqualToString:font.familyName]); XCTAssertEqual(font.pointSize, fontSize.floatValue); } -- (void)testCreateWithFontFamily_shouldCreateSystemFontWhenOnlySizeAvailable { +- (void)testCreateWithFontFamily_shouldNotChangeFontFamilyWhenOnlySizeAvailable { NSNumber* fontSize = @(20); + UIFont* initialFont = [UIFont systemFontOfSize:10 weight:UIFontWeightHeavy]; + NSMutableDictionary* initialAttributes = [NSMutableDictionary new]; + initialAttributes[NSFontAttributeName] = initialFont; + + NSDictionary* attributes = [RNNFontAttributesCreator createFromDictionary:initialAttributes fontFamily:nil fontSize:fontSize defaultFontSize:nil fontWeight:nil color:nil defaultColor:nil]; - NSDictionary* attributes = [RNNFontAttributesCreator createWithFontFamily:nil fontSize:fontSize fontWeight:nil color:nil]; UIFont* font = attributes[NSFontAttributeName]; - NSString* systemFontFamilyName = [[UIFont systemFontOfSize:20] familyName]; XCTAssertEqual(font.pointSize, fontSize.floatValue); - XCTAssertTrue([font.familyName isEqualToString:systemFontFamilyName]); + XCTAssertTrue([font.familyName isEqualToString:initialFont.familyName]); } diff --git a/playground/ios/NavigationTests/RNNRootViewControllerTest.m b/playground/ios/NavigationTests/RNNRootViewControllerTest.m index 779d43554c4..cc7920b59d8 100644 --- a/playground/ios/NavigationTests/RNNRootViewControllerTest.m +++ b/playground/ios/NavigationTests/RNNRootViewControllerTest.m @@ -127,7 +127,7 @@ -(void)testTopBarTextColor_validColor{ __unused RNNStackController* nav = [self createNavigationController]; [self.uut viewWillAppear:false]; UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1]; - XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSColor"] isEqual:expectedColor]); + XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSColor"] isEqual:expectedColor]); } -(void)testbackgroundColor_validColor{ @@ -144,7 +144,7 @@ -(void)testTopBarTextFontFamily_validFont{ self.options.topBar.title.fontFamily = [[Text alloc] initWithValue:inputFont]; [self.uut viewWillAppear:false]; UIFont* expectedFont = [UIFont fontWithName:inputFont size:17]; - XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]); + XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSFont"] isEqual:expectedFont]); } -(void)testTopBarHideOnScroll_true { @@ -202,10 +202,10 @@ -(void)testTopBarLargeTitleFontSize_withoutTextFontFamily_withoutTextColor { NSNumber* topBarTextFontSizeInput = @(15); self.options.topBar.largeTitle.fontSize = [[Number alloc] initWithValue:topBarTextFontSizeInput]; __unused RNNStackController* nav = [self createNavigationController]; + UIFont* initialFont = self.uut.navigationController.navigationBar.standardAppearance.largeTitleTextAttributes[@"NSFont"]; [self.uut viewWillAppear:false]; - UIFont* expectedFont = [UIFont systemFontOfSize:15]; - - XCTAssertTrue([self.uut.navigationController.navigationBar.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]); + UIFont* expectedFont = [UIFont fontWithDescriptor:initialFont.fontDescriptor size:topBarTextFontSizeInput.floatValue]; + XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]); } -(void)testTopBarLargeTitleFontSize_withoutTextFontFamily_withTextColor { @@ -214,11 +214,12 @@ -(void)testTopBarLargeTitleFontSize_withoutTextFontFamily_withTextColor { self.options.topBar.largeTitle.fontSize = [[Number alloc] initWithValue:topBarTextFontSizeInput]; self.options.topBar.largeTitle.color = [[Color alloc] initWithValue:inputColor]; __unused RNNStackController* nav = [self createNavigationController]; + UIFont* initialFont = self.uut.navigationController.navigationBar.standardAppearance.largeTitleTextAttributes[@"NSFont"]; [self.uut viewWillAppear:false]; - UIFont* expectedFont = [UIFont systemFontOfSize:15]; + UIFont* expectedFont = [UIFont fontWithDescriptor:initialFont.fontDescriptor size:topBarTextFontSizeInput.floatValue]; UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1]; - XCTAssertTrue([self.uut.navigationController.navigationBar.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]); - XCTAssertTrue([self.uut.navigationController.navigationBar.largeTitleTextAttributes[@"NSColor"] isEqual:expectedColor]); + XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]); + XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.largeTitleTextAttributes[@"NSColor"] isEqual:expectedColor]); } -(void)testTopBarLargeTitleFontSize_withTextFontFamily_withTextColor { @@ -233,8 +234,8 @@ -(void)testTopBarLargeTitleFontSize_withTextFontFamily_withTextColor { [self.uut viewWillAppear:false]; UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1]; UIFont* expectedFont = [UIFont fontWithName:inputFont size:15]; - XCTAssertTrue([self.uut.navigationController.navigationBar.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]); - XCTAssertTrue([self.uut.navigationController.navigationBar.largeTitleTextAttributes[@"NSColor"] isEqual:expectedColor]); + XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]); + XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.largeTitleTextAttributes[@"NSColor"] isEqual:expectedColor]); } -(void)testTopBarLargeTitleFontSize_withTextFontFamily_withoutTextColor { @@ -245,7 +246,7 @@ -(void)testTopBarLargeTitleFontSize_withTextFontFamily_withoutTextColor { __unused RNNStackController* nav = [self createNavigationController]; [self.uut viewWillAppear:false]; UIFont* expectedFont = [UIFont fontWithName:inputFont size:15]; - XCTAssertTrue([self.uut.navigationController.navigationBar.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]); + XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]); } @@ -253,9 +254,10 @@ -(void)testTopBarTextFontSize_withoutTextFontFamily_withoutTextColor { NSNumber* topBarTextFontSizeInput = @(15); self.options.topBar.title.fontSize = [[Number alloc] initWithValue:topBarTextFontSizeInput]; __unused RNNStackController* nav = [self createNavigationController]; + UIFont* initialFont = self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSFont"]; [self.uut viewWillAppear:false]; - UIFont* expectedFont = [UIFont systemFontOfSize:15]; - XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]); + UIFont* expectedFont = [UIFont fontWithDescriptor:initialFont.fontDescriptor size:topBarTextFontSizeInput.floatValue]; + XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSFont"] isEqual:expectedFont]); } -(void)testTopBarTextFontSize_withoutTextFontFamily_withTextColor { @@ -264,11 +266,12 @@ -(void)testTopBarTextFontSize_withoutTextFontFamily_withTextColor { self.options.topBar.title.fontSize = [[Number alloc] initWithValue:topBarTextFontSizeInput]; self.options.topBar.title.color = [[Color alloc] initWithValue:inputColor]; __unused RNNStackController* nav = [self createNavigationController]; + UIFont* initialFont = self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSFont"]; [self.uut viewWillAppear:false]; - UIFont* expectedFont = [UIFont systemFontOfSize:15]; + UIFont* expectedFont = [UIFont fontWithDescriptor:initialFont.fontDescriptor size:topBarTextFontSizeInput.floatValue]; UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1]; - XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]); - XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSColor"] isEqual:expectedColor]); + XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSFont"] isEqual:expectedFont]); + XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSColor"] isEqual:expectedColor]); } -(void)testTopBarTextFontSize_withTextFontFamily_withTextColor { @@ -282,8 +285,8 @@ -(void)testTopBarTextFontSize_withTextFontFamily_withTextColor { [self.uut viewWillAppear:false]; UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1]; UIFont* expectedFont = [UIFont fontWithName:inputFont size:15]; - XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]); - XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSColor"] isEqual:expectedColor]); + XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSFont"] isEqual:expectedFont]); + XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSColor"] isEqual:expectedColor]); } -(void)testTopBarTextFontSize_withTextFontFamily_withoutTextColor { @@ -294,7 +297,7 @@ -(void)testTopBarTextFontSize_withTextFontFamily_withoutTextColor { __unused RNNStackController* nav = [self createNavigationController]; [self.uut viewWillAppear:false]; UIFont* expectedFont = [UIFont fontWithName:inputFont size:15]; - XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]); + XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSFont"] isEqual:expectedFont]); } // TODO: Currently not passing