Skip to content

Commit

Permalink
Fix large title styles (#6489)
Browse files Browse the repository at this point in the history
On iOS 13, title attributes should be applied on `scrollEdgeAppearance` as it applied on `standardAppearance`.

Closes #6337
  • Loading branch information
yogevbd authored Aug 20, 2020
1 parent 627c6e9 commit e845afe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/ios/TopBarAppearancePresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ - (void)setLargeTitleAttributes:(RNNLargeTitleOptions *)largeTitleOptions {
NSString* fontWeight = [largeTitleOptions.fontWeight getWithDefaultValue:nil];
NSNumber* fontSize = [largeTitleOptions.fontSize getWithDefaultValue:nil];
UIColor* fontColor = [largeTitleOptions.color getWithDefaultValue:nil];

self.getAppearance.largeTitleTextAttributes = [RNNFontAttributesCreator createFromDictionary:self.getAppearance.largeTitleTextAttributes fontFamily:fontFamily fontSize:fontSize defaultFontSize:nil fontWeight:fontWeight color:fontColor defaultColor:nil];
NSDictionary* largeTitleTextAttributes = [RNNFontAttributesCreator createFromDictionary:self.getAppearance.largeTitleTextAttributes fontFamily:fontFamily fontSize:fontSize defaultFontSize:nil fontWeight:fontWeight color:fontColor defaultColor:nil];
self.getAppearance.largeTitleTextAttributes = largeTitleTextAttributes;
self.getScrollEdgeAppearance.largeTitleTextAttributes = largeTitleTextAttributes;
}

- (UINavigationBarAppearance *)getAppearance {
Expand Down
4 changes: 4 additions & 0 deletions playground/ios/NavigationTests/RNNRootViewControllerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ - (void)testTopBarLargeTitleFontSize_withoutTextFontFamily_withoutTextColor {
[self.uut viewWillAppear:false];
UIFont* expectedFont = [UIFont fontWithDescriptor:initialFont.fontDescriptor size:topBarTextFontSizeInput.floatValue];
XCTAssertTrue([self.uut.navigationItem.standardAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
XCTAssertTrue([self.uut.navigationItem.scrollEdgeAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
}

- (void)testTopBarLargeTitleFontSize_withoutTextFontFamily_withTextColor {
Expand All @@ -231,6 +232,8 @@ - (void)testTopBarLargeTitleFontSize_withoutTextFontFamily_withTextColor {
UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
XCTAssertTrue([self.uut.navigationItem.standardAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
XCTAssertTrue([self.uut.navigationItem.standardAppearance.largeTitleTextAttributes[@"NSColor"] isEqual:expectedColor]);
XCTAssertTrue([self.uut.navigationItem.scrollEdgeAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
XCTAssertTrue([self.uut.navigationItem.scrollEdgeAppearance.largeTitleTextAttributes[@"NSColor"] isEqual:expectedColor]);
}

- (void)testTopBarLargeTitleFontSize_withTextFontFamily_withTextColor {
Expand Down Expand Up @@ -258,6 +261,7 @@ - (void)testTopBarLargeTitleFontSize_withTextFontFamily_withoutTextColor {
[self.uut viewWillAppear:false];
UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
XCTAssertTrue([self.uut.navigationItem.standardAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
XCTAssertTrue([self.uut.navigationItem.scrollEdgeAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
}


Expand Down

0 comments on commit e845afe

Please sign in to comment.