Skip to content
Merged
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: 9 additions & 9 deletions ios/RNSScreenStackHeaderConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,17 @@ + (void)updateViewController:(UIViewController *)vc
config.direction == UISemanticContentAttributeForceRightToLeft) &&
// iOS 12 cancels swipe gesture when direction is changed. See #1091
navctr.view.semanticContentAttribute != config.direction) {
// This is needed for swipe back gesture direction
navctr.view.semanticContentAttribute = config.direction;

// This is responsible for the direction of the navigationBar and its contents
navctr.navigationBar.semanticContentAttribute = config.direction;
[[UIButton appearanceWhenContainedInInstancesOfClasses:@[ navctr.navigationBar.class ]]
setSemanticContentAttribute:config.direction];
[[UIView appearanceWhenContainedInInstancesOfClasses:@[ navctr.navigationBar.class ]]
setSemanticContentAttribute:config.direction];
[[UISearchBar appearanceWhenContainedInInstancesOfClasses:@[ navctr.navigationBar.class ]]
setSemanticContentAttribute:config.direction];
}

if (shouldHide) {
Expand Down Expand Up @@ -606,8 +615,6 @@ + (void)updateViewController:(UIViewController *)vc
#endif
}
#if !TARGET_OS_TV
// Workaround for the wrong rotation of back button arrow in RTL mode.
navitem.hidesBackButton = true;
navitem.hidesBackButton = config.hideBackButton;
#endif
navitem.leftBarButtonItem = nil;
Expand Down Expand Up @@ -665,13 +672,6 @@ + (void)updateViewController:(UIViewController *)vc
}
}

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0), dispatch_get_main_queue(), ^{
// Position the contents in the navigation bar, regarding to the direction.
for (UIView *view in navctr.navigationBar.subviews) {
view.semanticContentAttribute = config.direction;
}
});

// This assignment should be done after `navitem.titleView = ...` assignment (iOS 16.0 bug).
// See: https://github.com/software-mansion/react-native-screens/issues/1570 (comments)
navitem.title = config.title;
Expand Down