@@ -49,7 +49,7 @@ @interface RCTImageLoader (Private)
4949
5050@implementation NSString (RNSStringUtil)
5151
52- + (BOOL )RNSisBlank : (NSString *)string
52+ + (BOOL )rnscreens_isBlankOrNull : (NSString *)string
5353{
5454 if (string == nil ) {
5555 return YES ;
@@ -613,38 +613,23 @@ + (void)updateViewController:(UIViewController *)vc
613613
614614 [navctr setNavigationBarHidden: shouldHide animated: animated];
615615
616- if ((config.direction == UISemanticContentAttributeForceLeftToRight ||
617- config.direction == UISemanticContentAttributeForceRightToLeft) &&
618- // iOS 12 cancels swipe gesture when direction is changed. See #1091
619- navctr.view .semanticContentAttribute != config.direction ) {
620- // This is needed for swipe back gesture direction
621- navctr.view .semanticContentAttribute = config.direction ;
622-
623- // This is responsible for the direction of the navigationBar and its contents
624- navctr.navigationBar .semanticContentAttribute = config.direction ;
625- [[UIButton appearanceWhenContainedInInstancesOfClasses: @[ navctr.navigationBar.class ]]
626- setSemanticContentAttribute: config.direction];
627- [[UIView appearanceWhenContainedInInstancesOfClasses: @[ navctr.navigationBar.class ]]
628- setSemanticContentAttribute: config.direction];
629- [[UISearchBar appearanceWhenContainedInInstancesOfClasses: @[ navctr.navigationBar.class ]]
630- setSemanticContentAttribute: config.direction];
631- }
616+ [config applySemanticContentAttributeIfNeededToNavCtrl: navctr];
632617
633618 if (shouldHide) {
634619 navitem.title = config.title ;
635620 return ;
636621 }
637622
638623#if !TARGET_OS_TV
639- const auto isBackTitleBlank = [NSString RNSisBlank : config.backTitle] == YES ;
624+ const auto isBackTitleBlank = [NSString rnscreens_isBlankOrNull : config.backTitle] == YES ;
640625 NSString *resolvedBackTitle = isBackTitleBlank ? prevItem.title : config.backTitle ;
641626 RNSUIBarButtonItem *backBarButtonItem = [[RNSUIBarButtonItem alloc ] initWithTitle: resolvedBackTitle
642627 style: UIBarButtonItemStylePlain
643628 target: nil
644629 action: nil ];
645630 [backBarButtonItem setMenuHidden: config.disableBackButtonMenu];
646631
647- auto isBackButtonCustomized = !isBackTitleBlank || config.disableBackButtonMenu ;
632+ auto shouldUseCustomBackBarButtonItem = !isBackTitleBlank || config.disableBackButtonMenu ;
648633
649634#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_14_0) && \
650635 __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0
@@ -661,7 +646,7 @@ + (void)updateViewController:(UIViewController *)vc
661646 // See: https://github.com/software-mansion/react-native-screens/pull/2105#discussion_r1565222738
662647 ![config.backTitleFontFamily isEqual: @" System" ]) ||
663648 config.backTitleFontSize ) {
664- isBackButtonCustomized = YES ;
649+ shouldUseCustomBackBarButtonItem = YES ;
665650 NSMutableDictionary *attrs = [NSMutableDictionary new ];
666651 NSNumber *size = config.backTitleFontSize ?: @17 ;
667652 if (config.backTitleFontFamily ) {
@@ -684,15 +669,15 @@ + (void)updateViewController:(UIViewController *)vc
684669 // When backBarButtonItem's title is null, back menu will use value
685670 // of backButtonTitle
686671 [backBarButtonItem setTitle: nil ];
687- isBackButtonCustomized = YES ;
672+ shouldUseCustomBackBarButtonItem = YES ;
688673 prevItem.backButtonTitle = resolvedBackTitle;
689674 }
690675
691676 // Prevent unnecessary assignment of backBarButtonItem if it is not customized,
692677 // as assigning one will override the native behavior of automatically shortening
693678 // the title to "Back" or hide the back title if there's not enough space.
694679 // See: https://github.com/software-mansion/react-native-screens/issues/1589
695- if (isBackButtonCustomized ) {
680+ if (shouldUseCustomBackBarButtonItem ) {
696681 prevItem.backBarButtonItem = backBarButtonItem;
697682 }
698683
@@ -848,6 +833,26 @@ + (void)updateViewController:(UIViewController *)vc
848833 }
849834}
850835
836+ - (void )applySemanticContentAttributeIfNeededToNavCtrl: (UINavigationController *)navCtrl
837+ {
838+ if ((self.direction == UISemanticContentAttributeForceLeftToRight ||
839+ self.direction == UISemanticContentAttributeForceRightToLeft) &&
840+ // iOS 12 cancels swipe gesture when direction is changed. See #1091
841+ navCtrl.view .semanticContentAttribute != self.direction ) {
842+ // This is needed for swipe back gesture direction
843+ navCtrl.view .semanticContentAttribute = self.direction ;
844+
845+ // This is responsible for the direction of the navigationBar and its contents
846+ navCtrl.navigationBar .semanticContentAttribute = self.direction ;
847+ [[UIButton appearanceWhenContainedInInstancesOfClasses: @[ navCtrl.navigationBar.class ]]
848+ setSemanticContentAttribute: self .direction];
849+ [[UIView appearanceWhenContainedInInstancesOfClasses: @[ navCtrl.navigationBar.class ]]
850+ setSemanticContentAttribute: self .direction];
851+ [[UISearchBar appearanceWhenContainedInInstancesOfClasses: @[ navCtrl.navigationBar.class ]]
852+ setSemanticContentAttribute: self .direction];
853+ }
854+ }
855+
851856RNS_IGNORE_SUPER_CALL_BEGIN
852857- (void )insertReactSubview: (RNSScreenStackHeaderSubview *)subview atIndex: (NSInteger )atIndex
853858{
0 commit comments