diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp index 506babc08b..855e04e66f 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp @@ -26,10 +26,10 @@ findHeaderConfigChild(const YogaLayoutableShadowNode &screenShadowNode) { return {}; } +#ifdef ANDROID static constexpr const char *kScreenDummyLayoutHelperClass = "com/swmansion/rnscreens/utils/ScreenDummyLayoutHelper"; -#ifdef ANDROID std::optional findHeaderHeight( const int fontSize, const bool isTitleEmpty) { diff --git a/ios/RNSConvert.h b/ios/RNSConvert.h index 6ebd7bd9ae..8891c6c75d 100644 --- a/ios/RNSConvert.h +++ b/ios/RNSConvert.h @@ -43,8 +43,6 @@ namespace react = facebook::react; + (RNSSearchBarPlacement)RNSScreenSearchBarPlacementFromCppEquivalent:(react::RNSSearchBarPlacement)placement; -+ (NSMutableArray *)NSNumberMutableArrayFromFloatVector:(const std::vector &)vector; - + (NSMutableArray *)arrayFromVector:(const std::vector &)vector; + (RNSBlurEffectStyle)RNSBlurEffectStyleFromCppEquivalent:(react::RNSScreenStackHeaderConfigBlurEffect)blurEffect; diff --git a/ios/RNSFullWindowOverlay.mm b/ios/RNSFullWindowOverlay.mm index fc8a4f8c68..b7e3aaf998 100644 --- a/ios/RNSFullWindowOverlay.mm +++ b/ios/RNSFullWindowOverlay.mm @@ -1,5 +1,6 @@ #import +#import "RNSDefines.h" #import "RNSFullWindowOverlay.h" #ifdef RCT_NEW_ARCH_ENABLED @@ -198,6 +199,8 @@ - (void)unmountChildComponentView:(UIView *)childCompo [childComponentView removeFromSuperview]; } +RNS_IGNORE_SUPER_CALL_BEGIN +// We do not set frame for ouselves, but rather for the container. - (void)updateLayoutMetrics:(react::LayoutMetrics const &)layoutMetrics oldLayoutMetrics:(react::LayoutMetrics const &)oldLayoutMetrics { @@ -205,6 +208,7 @@ - (void)updateLayoutMetrics:(react::LayoutMetrics const &)layoutMetrics _reactFrame = frame; [_container setFrame:frame]; } +RNS_IGNORE_SUPER_CALL_END #else #pragma mark - Paper specific diff --git a/ios/RNSScreen.mm b/ios/RNSScreen.mm index d834a98a96..6d05957932 100644 --- a/ios/RNSScreen.mm +++ b/ios/RNSScreen.mm @@ -31,6 +31,7 @@ #import "RNSScreenStack.h" #import "RNSScreenStackHeaderConfig.h" +#import "RNSDefines.h" #import "UIView+RNSUtility.h" #ifdef RCT_NEW_ARCH_ENABLED @@ -136,10 +137,12 @@ - (UIViewController *)reactViewController } #ifdef RCT_NEW_ARCH_ENABLED +RNS_IGNORE_SUPER_CALL_BEGIN - (NSArray *)reactSubviews { return _reactSubviews; } +RNS_IGNORE_SUPER_CALL_END #endif - (void)updateBounds @@ -374,10 +377,12 @@ - (void)setHomeIndicatorHidden:(BOOL)homeIndicatorHidden } #endif +RNS_IGNORE_SUPER_CALL_BEGIN - (UIView *)reactSuperview { return _reactSuperview; } +RNS_IGNORE_SUPER_CALL_END /// This is RNSScreenContentWrapperDelegate method, where we do get notified when React did update frame of our child. - (void)reactDidSetFrame:(CGRect)reactFrame forContentWrapper:(RNSScreenContentWrapper *)contentWrapepr diff --git a/ios/RNSScreenContainer.mm b/ios/RNSScreenContainer.mm index dddff3239b..433a8ec8ca 100644 --- a/ios/RNSScreenContainer.mm +++ b/ios/RNSScreenContainer.mm @@ -1,4 +1,5 @@ #import "RNSScreenContainer.h" +#import "RNSDefines.h" #import "RNSScreen.h" #ifdef RCT_NEW_ARCH_ENABLED @@ -89,6 +90,9 @@ - (void)markChildUpdated [self updateContainer]; } +RNS_IGNORE_SUPER_CALL_BEGIN +// We do not call super as we do not want to update UIKit model. It will +// be updated after we receive all mutations. - (void)insertReactSubview:(RNSScreenView *)subview atIndex:(NSInteger)atIndex { subview.reactSuperview = self; @@ -106,6 +110,7 @@ - (void)removeReactSubview:(RNSScreenView *)subview { return _reactSubviews; } +RNS_IGNORE_SUPER_CALL_END - (UIViewController *)reactViewController { diff --git a/ios/RNSScreenFooter.mm b/ios/RNSScreenFooter.mm index 91026a7d51..5e72b0df03 100644 --- a/ios/RNSScreenFooter.mm +++ b/ios/RNSScreenFooter.mm @@ -26,35 +26,34 @@ - (instancetype)init - (void)willMoveToSuperview:(UIView *)newSuperview { [super willMoveToSuperview:newSuperview]; - if ([newSuperview isKindOfClass:RNSScreenView.class]) { - RNSScreenView *screen = (RNSScreenView *)newSuperview; - _parent = (RNSScreenView *)newSuperview; - - // [NSLayoutConstraint activateConstraints:@[ - // [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeBottom - // relatedBy:NSLayoutRelationEqual toItem:screen attribute:NSLayoutAttributeBottom multiplier:1.0 - // constant:0.0], [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeLeft - // relatedBy:NSLayoutRelationEqual toItem:screen attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0], - // [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual - // toItem:screen attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0], [NSLayoutConstraint - // constraintWithItem:self attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:screen - // attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen - // attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self - // attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0], [NSLayoutConstraint - // constraintWithItem:screen attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self - // attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen - // attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self - // attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen - // attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop - // multiplier:1.0 constant:0.0], - // ]]; - // [self setNeedsLayout]; - } + // if ([newSuperview isKindOfClass:RNSScreenView.class]) { + // RNSScreenView *screen = (RNSScreenView *)newSuperview; + // _parent = (RNSScreenView *)newSuperview; + + // [NSLayoutConstraint activateConstraints:@[ + // [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeBottom + // relatedBy:NSLayoutRelationEqual toItem:screen attribute:NSLayoutAttributeBottom multiplier:1.0 + // constant:0.0], [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeLeft + // relatedBy:NSLayoutRelationEqual toItem:screen attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0], + // [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual + // toItem:screen attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0], [NSLayoutConstraint + // constraintWithItem:self attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:screen + // attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen + // attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self + // attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0], [NSLayoutConstraint + // constraintWithItem:screen attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self + // attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen + // attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self + // attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen + // attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop + // multiplier:1.0 constant:0.0], + // ]]; + // [self setNeedsLayout]; + // } } - (void)didMoveToSuperview { - NSLog(@"Adding constraints between %@ and %@", self, _parent); if (_parent != nil) { // [NSLayoutConstraint activateConstraints:@[ // [NSLayoutConstraint constraintWithItem:self diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm index ed581e26cf..328db860ff 100644 --- a/ios/RNSScreenStack.mm +++ b/ios/RNSScreenStack.mm @@ -20,6 +20,7 @@ #import "RCTTouchHandler+RNSUtility.h" #endif // RCT_NEW_ARCH_ENABLED +#import "RNSDefines.h" #import "RNSPercentDrivenInteractiveTransition.h" #import "RNSScreen.h" #import "RNSScreenStack.h" @@ -290,10 +291,12 @@ - (void)presentationControllerDidDismiss:(UIPresentationController *)presentatio } } +RNS_IGNORE_SUPER_CALL_BEGIN - (NSArray *)reactSubviews { return _reactSubviews; } +RNS_IGNORE_SUPER_CALL_END - (void)didMoveToWindow { @@ -1086,6 +1089,9 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer #endif // !TARGET_OS_TV +RNS_IGNORE_SUPER_CALL_BEGIN +// We hijack the udpates as we don't want to update UIKit model yet. +// This is done after all mutations are processed. - (void)insertReactSubview:(RNSScreenView *)subview atIndex:(NSInteger)atIndex { if (![subview isKindOfClass:[RNSScreenView class]]) { @@ -1101,6 +1107,7 @@ - (void)removeReactSubview:(RNSScreenView *)subview subview.reactSuperview = nil; [_reactSubviews removeObject:subview]; } +RNS_IGNORE_SUPER_CALL_END - (void)didUpdateReactSubviews { diff --git a/ios/RNSScreenStackHeaderConfig.h b/ios/RNSScreenStackHeaderConfig.h index b9d33831d3..8928a0177a 100644 --- a/ios/RNSScreenStackHeaderConfig.h +++ b/ios/RNSScreenStackHeaderConfig.h @@ -12,7 +12,7 @@ @interface NSString (RNSStringUtil) -+ (BOOL)RNSisBlank:(NSString *)string; ++ (BOOL)RNSisBlank:(nullable NSString *)string; @end @@ -31,6 +31,8 @@ @property (nonatomic) BOOL hide; #endif +NS_ASSUME_NONNULL_BEGIN + @property (nonatomic, retain) NSString *title; @property (nonatomic, retain) NSString *titleFontFamily; @property (nonatomic, retain) NSNumber *titleFontSize; @@ -58,9 +60,11 @@ @property (nonatomic) UINavigationItemBackButtonDisplayMode backButtonDisplayMode; @property (nonatomic) RNSBlurEffectStyle blurEffect; -+ (void)willShowViewController:(UIViewController *)vc +NS_ASSUME_NONNULL_END + ++ (void)willShowViewController:(nonnull UIViewController *)vc animated:(BOOL)animated - withConfig:(RNSScreenStackHeaderConfig *)config; + withConfig:(nonnull RNSScreenStackHeaderConfig *)config; /** * Allows to send information with insets to the corresponding node in shadow tree. @@ -132,8 +136,7 @@ @interface RCTConvert (RNSScreenStackHeader) -+ (UIBlurEffectStyle)UIBlurEffectStyle:(id)json; -+ (UISemanticContentAttribute)UISemanticContentAttribute:(id)json; -+ (UINavigationItemBackButtonDisplayMode)UINavigationItemBackButtonDisplayMode:(id)json; ++ (UISemanticContentAttribute)UISemanticContentAttribute:(nonnull id)json; ++ (UINavigationItemBackButtonDisplayMode)UINavigationItemBackButtonDisplayMode:(nonnull id)json; @end diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index d9ad274ae9..d0b9e4be74 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -21,6 +21,7 @@ #import #import #import "RNSConvert.h" +#import "RNSDefines.h" #import "RNSScreen.h" #import "RNSScreenStackHeaderConfig.h" #import "RNSSearchBar.h" @@ -113,6 +114,7 @@ - (void)initProps _blurEffect = RNSBlurEffectStyleNone; } +RNS_IGNORE_SUPER_CALL_BEGIN - (UIView *)reactSuperview { return _screenView; @@ -122,6 +124,7 @@ - (UIView *)reactSuperview { return _reactSubviews; } +RNS_IGNORE_SUPER_CALL_END - (void)removeFromSuperview { @@ -785,6 +788,7 @@ + (void)updateViewController:(UIViewController *)vc } } +RNS_IGNORE_SUPER_CALL_BEGIN - (void)insertReactSubview:(RNSScreenStackHeaderSubview *)subview atIndex:(NSInteger)atIndex { [_reactSubviews insertObject:subview atIndex:atIndex]; @@ -795,6 +799,7 @@ - (void)removeReactSubview:(RNSScreenStackHeaderSubview *)subview { [_reactSubviews removeObject:subview]; } +RNS_IGNORE_SUPER_CALL_BEGIN - (void)didUpdateReactSubviews { @@ -879,6 +884,9 @@ static RCTResizeMode resizeModeFromCppEquiv(react::ImageResizeMode resizeMode) return RCTResizeModeCenter; case react::ImageResizeMode::Repeat: return RCTResizeModeRepeat; + default: + // Both RCTConvert and ImageProps use this as a default as of RN 0.76 + return RCTResizeModeStretch; } } diff --git a/ios/RNSScreenStackHeaderSubview.mm b/ios/RNSScreenStackHeaderSubview.mm index d5756fb54e..a2dbc7585e 100644 --- a/ios/RNSScreenStackHeaderSubview.mm +++ b/ios/RNSScreenStackHeaderSubview.mm @@ -1,5 +1,6 @@ #import "RNSScreenStackHeaderSubview.h" #import "RNSConvert.h" +#import "RNSDefines.h" #import "RNSScreenStackHeaderConfig.h" #ifdef RCT_NEW_ARCH_ENABLED @@ -86,6 +87,8 @@ - (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props:: return react::concreteComponentDescriptorProvider(); } +RNS_IGNORE_SUPER_CALL_BEGIN +// System layouts the subviews. - (void)updateLayoutMetrics:(const react::LayoutMetrics &)layoutMetrics oldLayoutMetrics:(const react::LayoutMetrics &)oldLayoutMetrics { @@ -105,6 +108,7 @@ - (void)updateLayoutMetrics:(const react::LayoutMetrics &)layoutMetrics [self layoutNavigationBarIfNeeded]; } } +RNS_IGNORE_SUPER_CALL_BEGIN + (BOOL)shouldBeRecycled { diff --git a/ios/utils/RNSDefines.h b/ios/utils/RNSDefines.h new file mode 100644 index 0000000000..83bde1c817 --- /dev/null +++ b/ios/utils/RNSDefines.h @@ -0,0 +1,7 @@ +#pragma once + +#define RNS_IGNORE_SUPER_CALL_BEGIN \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wobjc-missing-super-calls\"") + +#define RNS_IGNORE_SUPER_CALL_END _Pragma("clang diagnostic pop")