Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions ios/TopBarPresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,21 @@ - (void)setBackButtonOptions:(RNNBackButtonOptions *)backButtonOptions {
NSNumber *fontSize = [backButtonOptions.fontSize withDefault:nil];

UIViewController *previousViewControllerInStack = self.previousViewControllerInStack;
UIBarButtonItem *backItem = [[RNNUIBarBackButtonItem alloc] initWithOptions:backButtonOptions];
UINavigationItem *previousNavigationItem = previousViewControllerInStack.navigationItem;

BOOL hasCustomization = icon || color || title || fontFamily || fontSize ||
backButtonOptions.displayMode.hasValue ||
backButtonOptions.sfSymbol.hasValue ||
backButtonOptions.iconBackground.hasValue ||
backButtonOptions.enableMenu.hasValue ||
![backButtonOptions.showTitle withDefault:YES];

if (!hasCustomization) {
return;
}

UIBarButtonItem *backItem = [[RNNUIBarBackButtonItem alloc] initWithOptions:backButtonOptions];

if (@available(iOS 13.0, *)) {
UIImage *sfSymbol = [UIImage systemImageNamed:[backButtonOptions.sfSymbol withDefault:nil]];
if (backButtonOptions.sfSymbol.hasValue) {
Expand Down Expand Up @@ -195,7 +207,9 @@ - (void)setBackButtonOptions:(RNNBackButtonOptions *)backButtonOptions {
cornerRadius:cornerRadius];
}

[self setBackIndicatorImage:icon withColor:color];
if (icon) {
[self setBackIndicatorImage:icon withColor:color];
}

title = title ? title : (previousNavigationItem.title ? previousNavigationItem.title : @"");

Expand Down
5 changes: 2 additions & 3 deletions playground/ios/NavigationTests/RNNStackPresenterTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ - (void)testApplyOptions_shouldSetBackButtonOnBoundViewController_withHideTitle

- (void)testApplyOptions_shouldSetBackButtonOnBoundViewController_withDefaultValues {
[self.uut applyOptions:self.options];
XCTAssertTrue(
[self.boundViewController.viewControllers.firstObject.navigationItem.backBarButtonItem.title
isEqualToString:@""]);
XCTAssertNil(
self.boundViewController.viewControllers.firstObject.navigationItem.backBarButtonItem);
}

- (void)testSetBackButtonIcon_withColor_shouldSetColor {
Expand Down