Skip to content

Commit a1b397c

Browse files
committed
Move RTL configuratino of header config to separate method
1 parent da2c028 commit a1b397c

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

ios/RNSScreenStackHeaderConfig.mm

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -612,23 +612,7 @@ + (void)updateViewController:(UIViewController *)vc
612612
}
613613

614614
[navctr setNavigationBarHidden:shouldHide animated:animated];
615-
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-
}
615+
[config applySemanticContentAttributeIfNeededToNavCtrl:navctr];
632616

633617
if (shouldHide) {
634618
navitem.title = config.title;
@@ -848,6 +832,26 @@ + (void)updateViewController:(UIViewController *)vc
848832
}
849833
}
850834

835+
- (void)applySemanticContentAttributeIfNeededToNavCtrl:(UINavigationController *)navCtrl
836+
{
837+
if ((self.direction == UISemanticContentAttributeForceLeftToRight ||
838+
self.direction == UISemanticContentAttributeForceRightToLeft) &&
839+
// iOS 12 cancels swipe gesture when direction is changed. See #1091
840+
navCtrl.view.semanticContentAttribute != self.direction) {
841+
// This is needed for swipe back gesture direction
842+
navCtrl.view.semanticContentAttribute = self.direction;
843+
844+
// This is responsible for the direction of the navigationBar and its contents
845+
navCtrl.navigationBar.semanticContentAttribute = self.direction;
846+
[[UIButton appearanceWhenContainedInInstancesOfClasses:@[ navCtrl.navigationBar.class ]]
847+
setSemanticContentAttribute:self.direction];
848+
[[UIView appearanceWhenContainedInInstancesOfClasses:@[ navCtrl.navigationBar.class ]]
849+
setSemanticContentAttribute:self.direction];
850+
[[UISearchBar appearanceWhenContainedInInstancesOfClasses:@[ navCtrl.navigationBar.class ]]
851+
setSemanticContentAttribute:self.direction];
852+
}
853+
}
854+
851855
RNS_IGNORE_SUPER_CALL_BEGIN
852856
- (void)insertReactSubview:(RNSScreenStackHeaderSubview *)subview atIndex:(NSInteger)atIndex
853857
{

0 commit comments

Comments
 (0)