Skip to content

Commit 176ff64

Browse files
revert(ios): drop explicit bar button width and height
The T3 PR toolbar now uses UIKit's intrinsic item sizes, so the custom UIButton path that enforced fixed widths and heights is unused. Reverts 2660966, df4d574 and 7c111e6. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4dd10b6 commit 176ff64

9 files changed

Lines changed: 3 additions & 85 deletions

‎ios/header/RNSHeaderContentFactory.mm‎

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -33,52 +33,8 @@ + (UIBarButtonItem *)barButtonItemForHeaderItem:(id<RNSHeaderItemDataProviding>)
3333

3434
barButtonItem.enabled = !item.disabled;
3535
barButtonItem.tintColor = item.tintColor;
36-
barButtonItem.width = MAX(0, item.width);
3736
barButtonItem.style = item.style;
3837

39-
if ((item.width > 0 || item.height > 0) && item.customView == nil) {
40-
// UIKit's iOS 26 bar renderer ignores width on ordinary title items.
41-
// A native UIButton preserves system styling while honoring the constraint.
42-
BOOL prominent = ![item.variant isEqualToString:@"plain"];
43-
UIButtonConfiguration *configuration;
44-
#if RNS_IPHONE_OS_VERSION_AVAILABLE(26_0) && !TARGET_OS_VISION
45-
if (@available(iOS 26.0, tvOS 26.0, *)) {
46-
configuration = prominent ? [UIButtonConfiguration prominentGlassButtonConfiguration]
47-
: [UIButtonConfiguration glassButtonConfiguration];
48-
} else
49-
#endif
50-
{
51-
configuration = prominent ? [UIButtonConfiguration filledButtonConfiguration]
52-
: [UIButtonConfiguration plainButtonConfiguration];
53-
configuration.cornerStyle = UIButtonConfigurationCornerStyleCapsule;
54-
}
55-
// An explicit empty title keeps UIAction from restoring its accessibility title.
56-
configuration.title = item.icon == nil ? item.title : @"";
57-
configuration.image = barButtonItem.image;
58-
if (prominent && item.tintColor != nil) {
59-
configuration.baseBackgroundColor = item.tintColor;
60-
CGFloat red = 0, green = 0, blue = 0, alpha = 0;
61-
[item.tintColor getRed:&red green:&green blue:&blue alpha:&alpha];
62-
configuration.baseForegroundColor = red + green + blue > 1.5 ? UIColor.blackColor : UIColor.whiteColor;
63-
}
64-
UIAction *action = barButtonItem.primaryAction;
65-
if (item.icon != nil) {
66-
action.title = @"";
67-
}
68-
UIButton *button = [UIButton buttonWithConfiguration:configuration primaryAction:action];
69-
button.configuration = configuration;
70-
button.accessibilityLabel = item.title;
71-
button.tintColor = item.tintColor;
72-
button.enabled = !item.disabled && (item.respondsToOnPress || item.menu != nil);
73-
button.showsMenuAsPrimaryAction = !item.respondsToOnPress && item.menu != nil;
74-
button.translatesAutoresizingMaskIntoConstraints = NO;
75-
if (item.width > 0) {
76-
[button.widthAnchor constraintEqualToConstant:item.width].active = YES;
77-
}
78-
[button.heightAnchor constraintEqualToConstant:item.height > 0 ? item.height : 48].active = YES;
79-
barButtonItem.customView = button;
80-
}
81-
8238
return barButtonItem;
8339
}
8440

@@ -114,12 +70,6 @@ + (UIBarButtonItem *)labelBarButtonItemForHeaderItem:(id<RNSHeaderItemDataProvid
11470
return;
11571
}
11672
weakBarButtonItem.image = image;
117-
if ([weakBarButtonItem.customView isKindOfClass:UIButton.class]) {
118-
UIButton *button = (UIButton *)weakBarButtonItem.customView;
119-
UIButtonConfiguration *configuration = button.configuration;
120-
configuration.image = image;
121-
button.configuration = configuration;
122-
}
12373
}];
12474
barButtonItem.image = syncImage ? syncImage : [RNSHeaderIconResolver placeholderImageForIcon:item.icon];
12575
}

‎ios/header/RNSHeaderCoordinator.mm‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,6 @@ - (void)reapplyMenuForItemWithId:(NSString *)itemId
436436

437437
if (item.menu == nil) {
438438
barButtonItem.menu = nil;
439-
if ([barButtonItem.customView isKindOfClass:UIButton.class]) {
440-
UIButton *button = (UIButton *)barButtonItem.customView;
441-
button.menu = nil;
442-
button.enabled = !item.disabled && item.respondsToOnPress;
443-
}
444439
[self reapplyMenuRepresentationForItemWithId:itemId];
445440
return;
446441
}
@@ -797,8 +792,7 @@ - (UIBarButtonItem *)buildBarButtonItemForItem:(id<RNSHeaderItemDataProviding>)i
797792
if (item.identifier != nil) {
798793
barButtonItem.identifier = item.identifier;
799794
}
800-
barButtonItem.hidesSharedBackground = item.hidesSharedBackground ||
801-
((item.width > 0 || item.height > 0) && [barButtonItem.customView isKindOfClass:UIButton.class]);
795+
barButtonItem.hidesSharedBackground = item.hidesSharedBackground;
802796
}
803797
#endif // RNS_IPHONE_OS_VERSION_AVAILABLE(26_0)
804798

‎ios/header/RNSHeaderItemComponentView.mm‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,6 @@ - (nullable UIView *)customView
153153
return self.subviews.count > 0 ? self : nil;
154154
}
155155

156-
- (CGFloat)width
157-
{
158-
return std::static_pointer_cast<const react::RNSHeaderItemIOSProps>(_props)->width;
159-
}
160-
161-
- (CGFloat)height
162-
{
163-
return std::static_pointer_cast<const react::RNSHeaderItemIOSProps>(_props)->height;
164-
}
165-
166156
#pragma mark - RNSViewFrameChangeDelegate
167157

168158
- (void)viewFrameDidChange:(nonnull UINavigationBar *)navigationBar
@@ -246,8 +236,7 @@ - (void)updateProps:(const react::Props::Shared &)props oldProps:(const react::P
246236

247237
BOOL needsUpdate = oldItemProps.searchBarPlacement != newItemProps.searchBarPlacement ||
248238
oldItemProps.axisBehavior != newItemProps.axisBehavior || oldItemProps.variant != newItemProps.variant ||
249-
oldItemProps.tintColor != newItemProps.tintColor || oldItemProps.width != newItemProps.width ||
250-
oldItemProps.height != newItemProps.height;
239+
oldItemProps.tintColor != newItemProps.tintColor;
251240
BOOL menuDidChange = NO;
252241

253242
if (oldItemProps.itemId != newItemProps.itemId) {

‎ios/header/RNSHeaderItemDataProviding.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ NS_ASSUME_NONNULL_BEGIN
1818
@property (nonatomic, readonly, nullable) NSString *title;
1919
@property (nonatomic, readonly) NSString *variant;
2020
@property (nonatomic, readonly, nullable) UIColor *tintColor;
21-
@property (nonatomic, readonly) CGFloat width;
22-
@property (nonatomic, readonly) CGFloat height;
2321
@property (nonatomic, readonly, nullable) RNSHeaderIconData *icon;
2422
@property (nonatomic, readonly, nullable) RNSHeaderMenuData *menu;
2523
@property (nonatomic, readonly, nullable) RNSHeaderMenuData *menuRepresentation;

‎ios/header/RNSHeaderMenuCoordinator.mm‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ + (void)applyMenu:(RNSHeaderMenuData *)data
2222
initialSingleSelectionStateClaimed:NULL
2323
withImageLoader:imageLoader
2424
menuInvalidatedCallback:onMenuInvalidated];
25-
if ([item.customView isKindOfClass:UIButton.class]) {
26-
((UIButton *)item.customView).menu = item.menu;
27-
((UIButton *)item.customView).enabled = item.enabled;
28-
}
2925
}
3026
#endif // !TARGET_OS_TV || __TV_OS_VERSION_MAX_ALLOWED >= 170000
3127
}

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-screens",
3-
"version": "5.0.0-t3.26",
3+
"version": "5.0.0-t3.27",
44
"description": "Native navigation primitives for your React Native app.",
55
"scripts": {
66
"submodules": "git submodule update --init --recursive && (cd react-navigation && yarn && yarn build && cd ../)",

‎src/components/stack/header/StackHeaderConfig.ios.types.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,6 @@ export interface StackHeaderInlineItemIOS
250250
SupportsVisibilityPriorityIOS {
251251
/** Button tint, including the background of a prominent button. */
252252
tintColor?: ColorValue | undefined;
253-
/** Preferred bar-button width in points. Zero uses UIKit's intrinsic width. */
254-
width?: number | undefined;
255-
/** Preferred native button height. Zero uses the default. */
256-
height?: number | undefined;
257253
/** Uses UIKit's search placement item on iOS 26 and later. */
258254
searchBarPlacement?: boolean | undefined;
259255
/**

‎src/components/stack/header/ios/StackHeaderItem.ios.types.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ export type StackHeaderItemProps = {
2424
visibilityPriority?: StackHeaderItemVisibilityPriorityIOS | undefined;
2525
variant?: 'plain' | 'done' | 'prominent' | undefined;
2626
tintColor?: ColorValue | undefined;
27-
width?: number | undefined;
28-
/** Preferred native button height. Zero uses the default. */
29-
height?: number | undefined;
3027
title?: string | undefined;
3128
icon?: PlatformIconIOS | undefined;
3229
render?: (() => ReactElement) | undefined;

‎src/fabric/header/HeaderItemIOSNativeComponent.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ export interface NativeProps extends ViewProps {
8888
'standard'
8989
>;
9090
variant?: CT.WithDefault<'plain' | 'done' | 'prominent', 'plain'>;
91-
width?: CT.WithDefault<CT.Float, 0>;
92-
height?: CT.WithDefault<CT.Float, 0>;
9391
tintColor?: ColorValue | undefined;
9492
title?: string | undefined;
9593
icon?: UnsafeMixed<PlatformIconIOS> | undefined;

0 commit comments

Comments
 (0)