Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iOS): Fix positioning of large header and search bar #1895

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions ios/RNSScreenStackHeaderConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,8 @@ + (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;
Comment on lines +570 to 572
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, would you mind describing why do we first set navitem.hidesBackButton = true and then immediately we set it to the config.hideBackButton? Whats the mechanism here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's because when you're setting your application to RTL mode the arrow in the back button is still pointing to the left - which is wrong, because in RTL mode you should have an arrow pointing to the right. It seems that hiding back button for a while fixes this issue, because any update related to the back button modification updates the it. To be fair I don't know why this is working, unfortunately changing the semanticContentAttribute in dispatch_after doesn't fix that either.

#endif
navitem.leftBarButtonItem = nil;
Expand Down Expand Up @@ -624,6 +626,13 @@ + (void)updateViewController:(UIViewController *)vc
}
}

dispatch_async(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;
}
});
tboba marked this conversation as resolved.
Show resolved Hide resolved

// 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
Loading