File tree Expand file tree Collapse file tree
playground/ios/NavigationTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -160,9 +160,21 @@ - (void)setBackButtonOptions:(RNNBackButtonOptions *)backButtonOptions {
160160 NSNumber *fontSize = [backButtonOptions.fontSize withDefault: nil ];
161161
162162 UIViewController *previousViewControllerInStack = self.previousViewControllerInStack ;
163- UIBarButtonItem *backItem = [[RNNUIBarBackButtonItem alloc ] initWithOptions: backButtonOptions];
164163 UINavigationItem *previousNavigationItem = previousViewControllerInStack.navigationItem ;
165164
165+ BOOL hasCustomization = icon || color || title || fontFamily || fontSize ||
166+ backButtonOptions.displayMode .hasValue ||
167+ backButtonOptions.sfSymbol .hasValue ||
168+ backButtonOptions.iconBackground .hasValue ||
169+ backButtonOptions.enableMenu .hasValue ||
170+ ![backButtonOptions.showTitle withDefault: YES ];
171+
172+ if (!hasCustomization) {
173+ return ;
174+ }
175+
176+ UIBarButtonItem *backItem = [[RNNUIBarBackButtonItem alloc ] initWithOptions: backButtonOptions];
177+
166178 if (@available (iOS 13.0 , *)) {
167179 UIImage *sfSymbol = [UIImage systemImageNamed: [backButtonOptions.sfSymbol withDefault: nil ]];
168180 if (backButtonOptions.sfSymbol .hasValue ) {
@@ -195,7 +207,9 @@ - (void)setBackButtonOptions:(RNNBackButtonOptions *)backButtonOptions {
195207 cornerRadius: cornerRadius];
196208 }
197209
198- [self setBackIndicatorImage: icon withColor: color];
210+ if (icon) {
211+ [self setBackIndicatorImage: icon withColor: color];
212+ }
199213
200214 title = title ? title : (previousNavigationItem.title ? previousNavigationItem.title : @" " );
201215
Original file line number Diff line number Diff line change @@ -73,9 +73,8 @@ - (void)testApplyOptions_shouldSetBackButtonOnBoundViewController_withHideTitle
7373
7474- (void )testApplyOptions_shouldSetBackButtonOnBoundViewController_withDefaultValues {
7575 [self .uut applyOptions: self .options];
76- XCTAssertTrue (
77- [self .boundViewController.viewControllers.firstObject.navigationItem.backBarButtonItem.title
78- isEqualToString: @" " ]);
76+ XCTAssertNil (
77+ self.boundViewController .viewControllers .firstObject .navigationItem .backBarButtonItem );
7978}
8079
8180- (void )testSetBackButtonIcon_withColor_shouldSetColor {
You can’t perform that action at this time.
0 commit comments