@@ -158,8 +158,10 @@ - (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::
158158- (void )updateLayoutMetrics : (const react::LayoutMetrics &)layoutMetrics
159159 oldLayoutMetrics : (const react::LayoutMetrics &)oldLayoutMetrics
160160{
161+ #if RNS_IPHONE_OS_VERSION_AVAILABLE(26_0)
161162 _layoutMetrics = layoutMetrics;
162163 [self invalidateIntrinsicContentSize ];
164+ #endif // RNS_IPHONE_OS_VERSION_AVAILABLE(26_0)
163165 CGRect frame = RCTCGRectFromRect (layoutMetrics.frame );
164166 // CALayer will crash if we pass NaN or Inf values.
165167 // It's unclear how to detect this case on cross-platform manner holistically, so we have to do it on the mounting
@@ -207,34 +209,42 @@ - (void)reactSetFrame:(CGRect)frame
207209- (UIBarButtonItem *)getUIBarButtonItem
208210{
209211 if (_barButtonItem == nil ) {
210- // todo: mem leak
212+ # if RNS_IPHONE_OS_VERSION_AVAILABLE(26_0)
211213 UIView *wrapperView = [UIView new ];
212- [wrapperView addSubview: self ];
213-
214214 wrapperView.translatesAutoresizingMaskIntoConstraints = NO ;
215+
215216 self.translatesAutoresizingMaskIntoConstraints = NO ;
217+ [wrapperView addSubview: self ];
216218
217- [NSLayoutConstraint activateConstraints: @[
218- [self .centerXAnchor constraintEqualToAnchor: wrapperView.centerXAnchor],
219- [self .centerYAnchor constraintEqualToAnchor: wrapperView.centerYAnchor],
220- [wrapperView.widthAnchor constraintGreaterThanOrEqualToAnchor: self .widthAnchor],
221- [wrapperView.heightAnchor constraintGreaterThanOrEqualToAnchor: self .heightAnchor]
222- ]];
223- //
224- // [self setContentCompressionResistancePriority:UILayoutPriorityRequired
225- // forAxis:UILayoutConstraintAxisHorizontal]; [self
226- // setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
219+ [self .centerXAnchor constraintEqualToAnchor: wrapperView.centerXAnchor].active = YES ;
220+ [self .centerYAnchor constraintEqualToAnchor: wrapperView.centerYAnchor].active = YES ;
221+
222+ NSLayoutConstraint *widthEqual = [wrapperView.widthAnchor constraintEqualToAnchor: self .widthAnchor];
223+ widthEqual.priority = UILayoutPriorityDefaultHigh;
224+ widthEqual.active = YES ;
225+
226+ NSLayoutConstraint *heightEqual = [wrapperView.heightAnchor constraintEqualToAnchor: self .heightAnchor];
227+ heightEqual.priority = UILayoutPriorityDefaultHigh;
228+ heightEqual.active = YES ;
229+
230+ [self setContentHuggingPriority: UILayoutPriorityRequired forAxis: UILayoutConstraintAxisHorizontal];
231+ [self setContentHuggingPriority: UILayoutPriorityRequired forAxis: UILayoutConstraintAxisVertical];
227232
228233 _barButtonItem = [[UIBarButtonItem alloc ] initWithCustomView: wrapperView];
229- [self configureBarButtonItem ];
234+ #else // RNS_IPHONE_OS_VERSION_AVAILABLE(26_0)
235+ _barButtonItem = [[UIBarButtonItem alloc ] initWithCustomView: self ];
236+ #endif // RNS_IPHONE_OS_VERSION_AVAILABLE(26_0)
230237 }
238+
231239 return _barButtonItem;
232240}
233241
242+ #if RNS_IPHONE_OS_VERSION_AVAILABLE(26_0)
234243- (CGSize)intrinsicContentSize
235244{
236245 return RCTCGSizeFromSize (_layoutMetrics.frame .size );
237246}
247+ #endif // RNS_IPHONE_OS_VERSION_AVAILABLE(26_0)
238248
239249- (void )configureBarButtonItem
240250{
0 commit comments