react-native-screens 4.15.3 → 4.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -562,8 +562,8 @@ RNS_IGNORE_SUPER_CALL_END
562
562
  }
563
563
 
564
564
  NSUInteger currentIndex = [navctr.viewControllers indexOfObject:vc];
565
- UINavigationItem *prevItem =
566
- currentIndex > 0 ? [navctr.viewControllers objectAtIndex:currentIndex - 1].navigationItem : nil;
565
+ UIViewController *prevVC = currentIndex > 0 ? [navctr.viewControllers objectAtIndex:currentIndex - 1] : nil;
566
+ UINavigationItem *prevItem = currentIndex > 0 ? prevVC.navigationItem : nil;
567
567
 
568
568
  BOOL wasHidden = navctr.navigationBarHidden;
569
569
  BOOL shouldHide = config == nil || !config.shouldHeaderBeVisible;
@@ -618,7 +618,7 @@ RNS_IGNORE_SUPER_CALL_END
618
618
  }
619
619
 
620
620
  #if !TARGET_OS_TV
621
- [config configureBackItem:prevItem];
621
+ [config configureBackItem:prevItem withPrevVC:prevVC];
622
622
 
623
623
  if (config.largeTitle) {
624
624
  navctr.navigationBar.prefersLargeTitles = YES;
@@ -770,7 +770,8 @@ RNS_IGNORE_SUPER_CALL_END
770
770
  }
771
771
  }
772
772
 
773
- - (void)configureBackItem:(nullable UINavigationItem *)prevItem API_UNAVAILABLE(tvos)
773
+ - (void)configureBackItem:(nullable UINavigationItem *)prevItem
774
+ withPrevVC:(nullable UIViewController *)prevVC API_UNAVAILABLE(tvos)
774
775
  {
775
776
  #if !TARGET_OS_TV
776
777
  if (prevItem == nil) {
@@ -781,6 +782,15 @@ RNS_IGNORE_SUPER_CALL_END
781
782
 
782
783
  const auto isBackTitleBlank = [NSString rnscreens_isBlankOrNull:config.backTitle] == YES;
783
784
  NSString *resolvedBackTitle = isBackTitleBlank ? prevItem.title : config.backTitle;
785
+
786
+ // If previous screen controller was recreated (e.g. when you go back to tab with stack that has multiple screens),
787
+ // its navigationItem may not have any information from screen's headerConfig, including the title.
788
+ // If this is the case, we attempt to extract the title from previous screen's config directly.
789
+ if (resolvedBackTitle == nil && [prevVC isKindOfClass:[RNSScreen class]]) {
790
+ RNSScreen *prevScreen = static_cast<RNSScreen *>(prevVC);
791
+ resolvedBackTitle = prevScreen.screenView.findHeaderConfig.title;
792
+ }
793
+
784
794
  prevItem.backButtonTitle = resolvedBackTitle;
785
795
  // This has any effect only in case the `backBarButtonItem` is not set.
786
796
  // We apply it before we configure the back item, because it might get overriden.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-screens",
3
- "version": "4.15.3",
3
+ "version": "4.15.4",
4
4
  "description": "Native navigation primitives for your React Native app.",
5
5
  "scripts": {
6
6
  "submodules": "git submodule update --init --recursive && (cd react-navigation && yarn && yarn build && cd ../)",