Skip to content

Commit

Permalink
apply changes made from software-mansion#1646
Browse files Browse the repository at this point in the history
not included originally due to merge conflict
  • Loading branch information
DrOverbuild committed Dec 16, 2022
1 parent 72c02a6 commit e7121d9
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions ios/RNSScreenStackHeaderConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,33 @@ + (void)updateViewController:(UIViewController *)vc
}

#if !TARGET_OS_TV
if (config.backTitle) {
prevItem.backButtonTitle = config.backTitle;
// Fix for github.com/react-navigation/react-navigation/issues/11015
// It allows to hide back button title and use back button menu as normal.
// Back button display mode and back button menu are available since iOS 14.
if (@available(iOS 14.0, *)) {
// Make sure to set display mode to default.
// This line resets back button display mode - especially needed on the Fabric architecture.
navitem.backButtonDisplayMode = UINavigationItemBackButtonDisplayModeDefault;

if (config.backTitle) {
NSString *trimmedBackTitle =
[config.backTitle stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];

if ([trimmedBackTitle length] == 0) {
// When an whitespace only back title is passed set back button mode to minimal.
navitem.backButtonDisplayMode = UINavigationItemBackButtonDisplayModeMinimal;

// we DO NOT want to set prevItem.backButtonTitle if we're just hiding the title because
// it messes up the back button menu
} else if (config.backTitle) {
// otherwise set title as we normally would
prevItem.backButtonTitle = config.backTitle;
}
}
} else {
if (config.backTitle) {
prevItem.backButtonTitle = config.backTitle;
}
}

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_14_0) && \
Expand Down

0 comments on commit e7121d9

Please sign in to comment.