Skip to content
Merged
Show file tree
Hide file tree
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
64 changes: 44 additions & 20 deletions patches/react-native-screens@4.26.2.patch
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.
index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab60e185033 100644
--- a/ios/RNSScreenStackHeaderConfig.mm
+++ b/ios/RNSScreenStackHeaderConfig.mm
@@ -24,11 +24,46 @@
@@ -24,11 +24,62 @@
#import "RNSSearchBar.h"
#import "UINavigationBar+RNSUtility.h"

Expand All @@ -188,6 +188,22 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6
+ objc_setAssociatedObject(navitem, key, itemsKey, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ return YES;
+}
+
+// Group boundaries depend on mutable item appearance as well as item identity.
+static NSArray<NSNumber *> *RNSHeaderItemGroupingKey(NSArray<UIBarButtonItem *> *items)
+{
+ NSMutableArray<NSNumber *> *key = [NSMutableArray arrayWithCapacity:items.count];
+ for (UIBarButtonItem *item in items) {
+ BOOL hidesSharedBackground = NO;
+#if RNS_IPHONE_OS_VERSION_AVAILABLE(26_0)
+ if (@available(iOS 26.0, *)) {
+ hidesSharedBackground = item.hidesSharedBackground;
+ }
+#endif
+ [key addObject:@(hidesSharedBackground)];
+ }
+ return key;
+}
+#endif
+static char RNSAppliedToolbarConfigsKey;
static const NSNumber *const DEFAULT_TITLE_LARGE_FONT_SIZE = @34;
Expand All @@ -209,7 +225,7 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6
@interface RCTImageLoader (Private)
- (id<RCTImageCache>)imageCache;
@end
@@ -46,6 +81,9 @@ + (BOOL)rnscreens_isBlankOrNull:(NSString *)string
@@ -46,6 +97,9 @@ + (BOOL)rnscreens_isBlankOrNull:(NSString *)string
@end

@interface RNSScreenStackHeaderConfig () <RCTMountingTransactionObserving>
Expand All @@ -219,15 +235,15 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6
@end

@implementation RNSScreenStackHeaderConfig {
@@ -80,6 +118,7 @@ - (void)initProps
@@ -80,6 +134,7 @@ - (void)initProps
self.hidden = YES;
_reactSubviews = [NSMutableArray new];
_backTitleVisible = YES;
+ _navigationItemStyle = UINavigationItemStyleNavigator;
_blurEffect = RNSBlurEffectStyleNone;
_synchronousShadowStateUpdatesEnabled = YES;
}
@@ -507,6 +546,10 @@ + (void)updateViewController:(UIViewController *)vc
@@ -507,6 +562,10 @@ + (void)updateViewController:(UIViewController *)vc

if (shouldHide) {
navitem.title = config.title;
Expand All @@ -238,7 +254,7 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6

// Setting navigation bar visibility is split to mitigate iOS 26 bug with bar button items.
[navctr setNavigationBarHidden:YES animated:animated];
@@ -523,11 +566,19 @@ + (void)updateViewController:(UIViewController *)vc
@@ -523,11 +582,19 @@ + (void)updateViewController:(UIViewController *)vc
}
navitem.largeTitleDisplayMode =
config.largeTitle ? UINavigationItemLargeTitleDisplayModeAlways : UINavigationItemLargeTitleDisplayModeNever;
Expand All @@ -258,7 +274,7 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6

// appearance does not apply to the tvOS so we need to use lagacy customization
#if TARGET_OS_TV
@@ -559,8 +610,6 @@ + (void)updateViewController:(UIViewController *)vc
@@ -559,8 +626,6 @@ + (void)updateViewController:(UIViewController *)vc
navitem.leftItemsSupplementBackButton = config.backButtonInCustomView;
#endif
navitem.titleView = nil;
Expand All @@ -267,7 +283,7 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6

#if !TARGET_OS_TV
// We want to set navitem.searchController to nil only if we are sure
@@ -568,22 +617,18 @@ + (void)updateViewController:(UIViewController *)vc
@@ -568,22 +633,18 @@ + (void)updateViewController:(UIViewController *)vc
bool searchBarPresent = false;
#endif /* !TARGET_OS_TV */

Expand All @@ -294,7 +310,7 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6
break;
}
case RNSScreenStackHeaderSubviewTypeCenter:
@@ -648,10 +693,479 @@ + (void)updateViewController:(UIViewController *)vc
@@ -648,10 +709,487 @@ + (void)updateViewController:(UIViewController *)vc
// 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 All @@ -320,15 +336,17 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6
+ NSArray *headerRightConfigs = config.headerRightBarButtonItems ?: @[];
+ NSArray *headerCenterConfigs = config.headerCenterBarButtonItems ?: @[];
+ if (RNSUpdateHeaderItemsCache(
+ navitem, &RNSAppliedLeadingHeaderItemsKey, @[ config, headerLeftConfigs, subviewLeftItems ])) {
+ navitem, &RNSAppliedLeadingHeaderItemsKey,
+ @[ config, headerLeftConfigs, subviewLeftItems, RNSHeaderItemGroupingKey(subviewLeftItems) ])) {
+ NSArray *items = [config barButtonItemsFromConfigs:config.headerLeftBarButtonItems
+ withCurrentItems:subviewLeftItems
+ navigationItem:navitem
+ allowsSearchBarPlacement:NO];
+ navitem.leadingItemGroups = [config barButtonItemGroupsFromItems:items];
+ }
+ if (RNSUpdateHeaderItemsCache(
+ navitem, &RNSAppliedTrailingHeaderItemsKey, @[ config, headerRightConfigs, subviewRightItems ])) {
+ navitem, &RNSAppliedTrailingHeaderItemsKey,
+ @[ config, headerRightConfigs, subviewRightItems, RNSHeaderItemGroupingKey(subviewRightItems) ])) {
+ NSArray *items = [config barButtonItemsFromConfigs:config.headerRightBarButtonItems
+ withCurrentItems:subviewRightItems
+ navigationItem:navitem
Expand Down Expand Up @@ -390,10 +408,14 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6
+ // the user's in-progress search text and first responder on every unrelated
+ // header update. Keyed on the config instance (the button/search blocks
+ // capture its event emitter), the toolbar config values, and the host width
+ // (the width constraint constant is resolved from it at build time).
+ // (the width constraint constant is resolved from it at build time), and
+ // the search bar embedded when the fallback field is disabled.
+ static char RNSAppliedMailSearchToolbarConfigKey;
+ id mailSearchBarKey = [mailSearchToolbarConfig[@"useFallbackSearchField"] boolValue]
+ ? [NSNull null]
+ : (navitem.searchController.searchBar ?: [NSNull null]);
+ NSArray *mailSearchToolbarKey = mailSearchToolbarConfig != nil
+ ? @[ @((uintptr_t)config), mailSearchToolbarConfig, @(chromeHostView.bounds.size.width) ]
+ ? @[ @((uintptr_t)config), mailSearchToolbarConfig, @(chromeHostView.bounds.size.width), mailSearchBarKey ]
+ : nil;
+ BOOL reuseMailSearchToolbar = existingMailSearchToolbar != nil && mailSearchToolbarKey != nil &&
+ [objc_getAssociatedObject(existingMailSearchToolbar, &RNSAppliedMailSearchToolbarConfigKey)
Expand Down Expand Up @@ -756,7 +778,9 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6
+ // The top-view-controller and hidden-state checks scope the skip to
+ // same-screen refreshes, so transitions between screens with different
+ // toolbars still reapply.
+ NSArray *toolbarCacheKey = @[ @((uintptr_t)config), toolbarConfigsKey ];
+ // Search toolbar items may embed the current controller's search bar.
+ NSArray *toolbarCacheKey =
+ @[ @((uintptr_t)config), toolbarConfigsKey, navitem.searchController.searchBar ?: [NSNull null] ];
+ BOOL reuseToolbarItems = navctr.topViewController == vc &&
+ navctr.isToolbarHidden == (toolbarConfigsKey.count == 0) &&
+ [objc_getAssociatedObject(navitem, &RNSAppliedToolbarConfigsKey) isEqual:toolbarCacheKey];
Expand All @@ -778,7 +802,7 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6

// Setting navigation bar visibility is split to mitigate iOS 26 bug with bar button items
// (setting nav bar visibility should be done after `navitem.*BarButtonItems`).
@@ -784,6 +1289,8 @@ - (void)applySemanticContentAttributeIfNeededToNavCtrl:(UINavigationController *
@@ -784,6 +1322,8 @@ - (void)applySemanticContentAttributeIfNeededToNavCtrl:(UINavigationController *

- (NSArray<UIBarButtonItem *> *)barButtonItemsFromConfigs:(NSArray<NSDictionary<NSString *, id> *> *)dicts
withCurrentItems:(NSArray<UIBarButtonItem *> *)currentItems
Expand All @@ -787,7 +811,7 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6
{
if (dicts.count == 0) {
return currentItems;
@@ -792,7 +1299,200 @@ - (void)applySemanticContentAttributeIfNeededToNavCtrl:(UINavigationController *
@@ -792,7 +1332,200 @@ - (void)applySemanticContentAttributeIfNeededToNavCtrl:(UINavigationController *
[items addObjectsFromArray:currentItems];
for (NSUInteger i = 0; i < dicts.count; i++) {
NSDictionary *dict = dicts[i];
Expand Down Expand Up @@ -989,7 +1013,7 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6
RNSBarButtonItem *item = [[RNSBarButtonItem alloc] initWithConfig:dict
action:^(NSString *buttonId) {
auto eventEmitter = std::static_pointer_cast<const facebook::react::RNSScreenStackHeaderConfigEventEmitter>(
@@ -814,19 +1514,23 @@ - (void)applySemanticContentAttributeIfNeededToNavCtrl:(UINavigationController *
@@ -814,19 +1547,23 @@ - (void)applySemanticContentAttributeIfNeededToNavCtrl:(UINavigationController *
}
imageLoader:_imageLoader];
NSNumber *index = dict[@"index"];
Expand Down Expand Up @@ -1019,7 +1043,7 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6
[items insertObject:item atIndex:index.integerValue];
} else {
[items addObject:item];
@@ -836,6 +1540,47 @@ - (void)applySemanticContentAttributeIfNeededToNavCtrl:(UINavigationController *
@@ -836,6 +1573,47 @@ - (void)applySemanticContentAttributeIfNeededToNavCtrl:(UINavigationController *
return items;
}

Expand Down Expand Up @@ -1067,7 +1091,7 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6
RNS_IGNORE_SUPER_CALL_BEGIN
- (void)insertReactSubview:(RNSScreenStackHeaderSubview *)subview atIndex:(NSInteger)atIndex
{
@@ -1023,6 +1768,8 @@ - (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::
@@ -1023,6 +1801,8 @@ - (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::
}

_title = RCTNSStringFromStringNilIfEmpty(newScreenProps.title);
Expand All @@ -1076,15 +1100,15 @@ index 1c844846a5c66e31cfa530ca462774d2fb6bbea1..a60b96b44e85d3f4b29dc0d190b95ab6
if (newScreenProps.titleFontFamily != oldScreenProps.titleFontFamily) {
_titleFontFamily = RCTNSStringFromStringNilIfEmpty(newScreenProps.titleFontFamily);
}
@@ -1048,6 +1795,7 @@ - (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::
@@ -1048,6 +1828,7 @@ - (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::
_disableBackButtonMenu = newScreenProps.disableBackButtonMenu;
_backButtonDisplayMode =
[RNSConvert UINavigationItemBackButtonDisplayModeFromCppEquivalent:newScreenProps.backButtonDisplayMode];
+ _navigationItemStyle = navigationItemStyleFromCppEquivalent(newScreenProps.navigationItemStyle);

if (newScreenProps.userInterfaceStyle != oldScreenProps.userInterfaceStyle) {
_userInterfaceStyle = [RNSConvert UIUserInterfaceStyleFromCppEquivalent:newScreenProps.userInterfaceStyle];
@@ -1094,6 +1842,30 @@ - (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::
@@ -1094,6 +1875,30 @@ - (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::
_headerRightBarButtonItems = array;
}

Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading