From a60dcafda40ef0e37dffa201418f4095871263e6 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Tue, 1 Aug 2023 14:49:16 +0200 Subject: [PATCH 01/46] docs: annotate `sheetExpandsWhenScrollingToEdge` prop as iOS specific (#1851) ## Description `sheetExpandsWhenScrollingToEdge` prop is iOS specific and this fact is not described in type info. ## Changes Added a note in type docs that this prop is iOS specific. ## Test code and steps to reproduce ## Checklist - [ ] Ensured that CI passes --- src/native-stack/types.tsx | 2 ++ src/types.tsx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/native-stack/types.tsx b/src/native-stack/types.tsx index 1edc235add..38f0c6db52 100644 --- a/src/native-stack/types.tsx +++ b/src/native-stack/types.tsx @@ -333,6 +333,8 @@ export type NativeStackNavigationOptions = { * Whether the sheet should expand to larger detent when scrolling. * Works only when `stackPresentation` is set to `formSheet`. * Defaults to `true`. + * + * @platform ios */ sheetExpandsWhenScrolledToEdge?: boolean; /** diff --git a/src/types.tsx b/src/types.tsx index c2cc3391c3..9224b4ff06 100644 --- a/src/types.tsx +++ b/src/types.tsx @@ -255,6 +255,8 @@ export interface ScreenProps extends ViewProps { * Whether the sheet should expand to larger detent when scrolling. * Works only when `stackPresentation` is set to `formSheet`. * Defaults to `true`. + * + * @platform ios */ sheetExpandsWhenScrolledToEdge?: boolean; /** From 0844c8530fd914110214cfb506fe1d45f7c09508 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Wed, 2 Aug 2023 17:06:50 +0200 Subject: [PATCH 02/46] fix(iOS): bad parameter type in `toggleCancelButton` search bar command (#1854) ## Description Fixes #1853 Looks like I've made a typo while implemnenting `toggleCancelButton:flag:` (flag has `BOOL *` type instead of just `BOOL`) leading to compile errors as reported in #1853. ## Changes Changed (fixed) the type of `flag` parameter from `BOOL *` to just plain `BOOL`. ## Test code and steps to reproduce See #1853 & try to build on macOS Catalyst ## Checklist - [ ] Ensured that CI passes --- ios/RNSSearchBar.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/RNSSearchBar.mm b/ios/RNSSearchBar.mm index 44b5d7d437..1052758161 100644 --- a/ios/RNSSearchBar.mm +++ b/ios/RNSSearchBar.mm @@ -423,7 +423,7 @@ - (UIView *)view }]; } -RCT_EXPORT_METHOD(toggleCancelButton : (NSNumber *_Nonnull)reactTag flag : (BOOL *)flag) +RCT_EXPORT_METHOD(toggleCancelButton : (NSNumber *_Nonnull)reactTag flag : (BOOL)flag) { [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) { RNSSearchBar *searchBar = viewRegistry[reactTag]; From d062c9107a00e2a3e73c839d298b17eb8389bd62 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Thu, 3 Aug 2023 08:16:42 +0200 Subject: [PATCH 03/46] chore: improve readability of C++ namespaced types (#1856) ## Description 1. Typing `facebook::react` is tedious (XCode completion does not work correctly in case of namespaces for some reason I do not want to spend any more time investigating) 2. `facebook` prefix does not convey any useful meaning from the perspective of this library -- we can achieve the same code-isolation by using just `react` or `rct` 3. We can not resign completely from using this prefix (by putting `using namespace facebook::react` in our `.mm` files) because some C++ codegened types have the same names as their counterparts from Objective-C and we need to distinguish between them (take a look into `RNSConvert.h`). ## Changes Replace all usages of `facebook::react::` with `react::`. Added `namespace react = facebook::react;` where necessary. ## Checklist - [ ] Ensured that CI passes --- ios/RNSConvert.h | 26 ++++--- ios/RNSConvert.mm | 102 +++++++++++++--------------- ios/RNSFullWindowOverlay.h | 8 ++- ios/RNSFullWindowOverlay.mm | 11 ++- ios/RNSScreen.h | 10 ++- ios/RNSScreen.mm | 62 +++++++++-------- ios/RNSScreenContainer.mm | 15 ++-- ios/RNSScreenNavigationContainer.mm | 9 +-- ios/RNSScreenStack.mm | 21 +++--- ios/RNSScreenStackHeaderConfig.mm | 40 +++++------ ios/RNSScreenStackHeaderSubview.mm | 23 ++++--- ios/RNSSearchBar.mm | 39 ++++++----- 12 files changed, 190 insertions(+), 176 deletions(-) diff --git a/ios/RNSConvert.h b/ios/RNSConvert.h index 1dca19797b..17b0485dc8 100644 --- a/ios/RNSConvert.h +++ b/ios/RNSConvert.h @@ -2,36 +2,34 @@ #import #import "RNSEnums.h" +namespace react = facebook::react; + @interface RNSConvert : NSObject + (RNSScreenStackPresentation)RNSScreenStackPresentationFromCppEquivalent: - (facebook::react::RNSScreenStackPresentation)stackPresentation; + (react::RNSScreenStackPresentation)stackPresentation; -+ (RNSScreenStackAnimation)RNSScreenStackAnimationFromCppEquivalent: - (facebook::react::RNSScreenStackAnimation)stackAnimation; ++ (RNSScreenStackAnimation)RNSScreenStackAnimationFromCppEquivalent:(react::RNSScreenStackAnimation)stackAnimation; + (RNSScreenStackHeaderSubviewType)RNSScreenStackHeaderSubviewTypeFromCppEquivalent: - (facebook::react::RNSScreenStackHeaderSubviewType)subviewType; + (react::RNSScreenStackHeaderSubviewType)subviewType; + (RNSScreenReplaceAnimation)RNSScreenReplaceAnimationFromCppEquivalent: - (facebook::react::RNSScreenReplaceAnimation)replaceAnimation; + (react::RNSScreenReplaceAnimation)replaceAnimation; -+ (RNSScreenSwipeDirection)RNSScreenSwipeDirectionFromCppEquivalent: - (facebook::react::RNSScreenSwipeDirection)swipeDirection; ++ (RNSScreenSwipeDirection)RNSScreenSwipeDirectionFromCppEquivalent:(react::RNSScreenSwipeDirection)swipeDirection; -+ (RNSScreenDetentType)RNSScreenDetentTypeFromAllowedDetents: - (facebook::react::RNSScreenSheetAllowedDetents)allowedDetents; ++ (RNSScreenDetentType)RNSScreenDetentTypeFromAllowedDetents:(react::RNSScreenSheetAllowedDetents)allowedDetents; -+ (RNSScreenDetentType)RNSScreenDetentTypeFromLargestUndimmedDetent: - (facebook::react::RNSScreenSheetLargestUndimmedDetent)detent; ++ (RNSScreenDetentType)RNSScreenDetentTypeFromLargestUndimmedDetent:(react::RNSScreenSheetLargestUndimmedDetent)detent; + (NSDictionary *)gestureResponseDistanceDictFromCppStruct: - (const facebook::react::RNSScreenGestureResponseDistanceStruct &)gestureResponseDistance; + (const react::RNSScreenGestureResponseDistanceStruct &)gestureResponseDistance; + (UITextAutocapitalizationType)UITextAutocapitalizationTypeFromCppEquivalent: - (facebook::react::RNSSearchBarAutoCapitalize)autoCapitalize; + (react::RNSSearchBarAutoCapitalize)autoCapitalize; -+ (RNSSearchBarPlacement)RNSScreenSearchBarPlacementFromCppEquivalent:(facebook::react::RNSSearchBarPlacement)placement; ++ (RNSSearchBarPlacement)RNSScreenSearchBarPlacementFromCppEquivalent:(react::RNSSearchBarPlacement)placement; @end diff --git a/ios/RNSConvert.mm b/ios/RNSConvert.mm index 818ecd366a..655d8fba43 100644 --- a/ios/RNSConvert.mm +++ b/ios/RNSConvert.mm @@ -4,119 +4,115 @@ @implementation RNSConvert + (RNSScreenStackPresentation)RNSScreenStackPresentationFromCppEquivalent: - (facebook::react::RNSScreenStackPresentation)stackPresentation + (react::RNSScreenStackPresentation)stackPresentation { switch (stackPresentation) { - case facebook::react::RNSScreenStackPresentation::Push: + case react::RNSScreenStackPresentation::Push: return RNSScreenStackPresentationPush; - case facebook::react::RNSScreenStackPresentation::Modal: + case react::RNSScreenStackPresentation::Modal: return RNSScreenStackPresentationModal; - case facebook::react::RNSScreenStackPresentation::FullScreenModal: + case react::RNSScreenStackPresentation::FullScreenModal: return RNSScreenStackPresentationFullScreenModal; - case facebook::react::RNSScreenStackPresentation::FormSheet: + case react::RNSScreenStackPresentation::FormSheet: return RNSScreenStackPresentationFormSheet; - case facebook::react::RNSScreenStackPresentation::ContainedModal: + case react::RNSScreenStackPresentation::ContainedModal: return RNSScreenStackPresentationContainedModal; - case facebook::react::RNSScreenStackPresentation::TransparentModal: + case react::RNSScreenStackPresentation::TransparentModal: return RNSScreenStackPresentationTransparentModal; - case facebook::react::RNSScreenStackPresentation::ContainedTransparentModal: + case react::RNSScreenStackPresentation::ContainedTransparentModal: return RNSScreenStackPresentationContainedTransparentModal; } } -+ (RNSScreenStackAnimation)RNSScreenStackAnimationFromCppEquivalent: - (facebook::react::RNSScreenStackAnimation)stackAnimation ++ (RNSScreenStackAnimation)RNSScreenStackAnimationFromCppEquivalent:(react::RNSScreenStackAnimation)stackAnimation { switch (stackAnimation) { // these three are intentionally grouped - case facebook::react::RNSScreenStackAnimation::Slide_from_right: - case facebook::react::RNSScreenStackAnimation::Slide_from_left: - case facebook::react::RNSScreenStackAnimation::Default: + case react::RNSScreenStackAnimation::Slide_from_right: + case react::RNSScreenStackAnimation::Slide_from_left: + case react::RNSScreenStackAnimation::Default: return RNSScreenStackAnimationDefault; - case facebook::react::RNSScreenStackAnimation::Flip: + case react::RNSScreenStackAnimation::Flip: return RNSScreenStackAnimationFlip; - case facebook::react::RNSScreenStackAnimation::Simple_push: + case react::RNSScreenStackAnimation::Simple_push: return RNSScreenStackAnimationSimplePush; - case facebook::react::RNSScreenStackAnimation::None: + case react::RNSScreenStackAnimation::None: return RNSScreenStackAnimationNone; - case facebook::react::RNSScreenStackAnimation::Fade: + case react::RNSScreenStackAnimation::Fade: return RNSScreenStackAnimationFade; - case facebook::react::RNSScreenStackAnimation::Slide_from_bottom: + case react::RNSScreenStackAnimation::Slide_from_bottom: return RNSScreenStackAnimationSlideFromBottom; - case facebook::react::RNSScreenStackAnimation::Fade_from_bottom: + case react::RNSScreenStackAnimation::Fade_from_bottom: return RNSScreenStackAnimationFadeFromBottom; } } + (RNSScreenStackHeaderSubviewType)RNSScreenStackHeaderSubviewTypeFromCppEquivalent: - (facebook::react::RNSScreenStackHeaderSubviewType)subviewType + (react::RNSScreenStackHeaderSubviewType)subviewType { switch (subviewType) { - case facebook::react::RNSScreenStackHeaderSubviewType::Left: + case react::RNSScreenStackHeaderSubviewType::Left: return RNSScreenStackHeaderSubviewTypeLeft; - case facebook::react::RNSScreenStackHeaderSubviewType::Right: + case react::RNSScreenStackHeaderSubviewType::Right: return RNSScreenStackHeaderSubviewTypeRight; - case facebook::react::RNSScreenStackHeaderSubviewType::Title: + case react::RNSScreenStackHeaderSubviewType::Title: return RNSScreenStackHeaderSubviewTypeTitle; - case facebook::react::RNSScreenStackHeaderSubviewType::Center: + case react::RNSScreenStackHeaderSubviewType::Center: return RNSScreenStackHeaderSubviewTypeCenter; - case facebook::react::RNSScreenStackHeaderSubviewType::SearchBar: + case react::RNSScreenStackHeaderSubviewType::SearchBar: return RNSScreenStackHeaderSubviewTypeSearchBar; - case facebook::react::RNSScreenStackHeaderSubviewType::Back: + case react::RNSScreenStackHeaderSubviewType::Back: return RNSScreenStackHeaderSubviewTypeBackButton; } } + (RNSScreenReplaceAnimation)RNSScreenReplaceAnimationFromCppEquivalent: - (facebook::react::RNSScreenReplaceAnimation)replaceAnimation + (react::RNSScreenReplaceAnimation)replaceAnimation { switch (replaceAnimation) { - case facebook::react::RNSScreenReplaceAnimation::Pop: + case react::RNSScreenReplaceAnimation::Pop: return RNSScreenReplaceAnimationPop; - case facebook::react::RNSScreenReplaceAnimation::Push: + case react::RNSScreenReplaceAnimation::Push: return RNSScreenReplaceAnimationPush; } } -+ (RNSScreenSwipeDirection)RNSScreenSwipeDirectionFromCppEquivalent: - (facebook::react::RNSScreenSwipeDirection)swipeDirection ++ (RNSScreenSwipeDirection)RNSScreenSwipeDirectionFromCppEquivalent:(react::RNSScreenSwipeDirection)swipeDirection { switch (swipeDirection) { - case facebook::react::RNSScreenSwipeDirection::Horizontal: + case react::RNSScreenSwipeDirection::Horizontal: return RNSScreenSwipeDirectionHorizontal; - case facebook::react::RNSScreenSwipeDirection::Vertical: + case react::RNSScreenSwipeDirection::Vertical: return RNSScreenSwipeDirectionVertical; } } -+ (RNSScreenDetentType)RNSScreenDetentTypeFromAllowedDetents: - (facebook::react::RNSScreenSheetAllowedDetents)allowedDetents ++ (RNSScreenDetentType)RNSScreenDetentTypeFromAllowedDetents:(react::RNSScreenSheetAllowedDetents)allowedDetents { switch (allowedDetents) { - case facebook::react::RNSScreenSheetAllowedDetents::All: + case react::RNSScreenSheetAllowedDetents::All: return RNSScreenDetentTypeAll; - case facebook::react::RNSScreenSheetAllowedDetents::Large: + case react::RNSScreenSheetAllowedDetents::Large: return RNSScreenDetentTypeLarge; - case facebook::react::RNSScreenSheetAllowedDetents::Medium: + case react::RNSScreenSheetAllowedDetents::Medium: return RNSScreenDetentTypeMedium; } } -+ (RNSScreenDetentType)RNSScreenDetentTypeFromLargestUndimmedDetent: - (facebook::react::RNSScreenSheetLargestUndimmedDetent)detent ++ (RNSScreenDetentType)RNSScreenDetentTypeFromLargestUndimmedDetent:(react::RNSScreenSheetLargestUndimmedDetent)detent { switch (detent) { - case facebook::react::RNSScreenSheetLargestUndimmedDetent::All: + case react::RNSScreenSheetLargestUndimmedDetent::All: return RNSScreenDetentTypeAll; - case facebook::react::RNSScreenSheetLargestUndimmedDetent::Large: + case react::RNSScreenSheetLargestUndimmedDetent::Large: return RNSScreenDetentTypeLarge; - case facebook::react::RNSScreenSheetLargestUndimmedDetent::Medium: + case react::RNSScreenSheetLargestUndimmedDetent::Medium: return RNSScreenDetentTypeMedium; } } + (NSDictionary *)gestureResponseDistanceDictFromCppStruct: - (const facebook::react::RNSScreenGestureResponseDistanceStruct &)gestureResponseDistance + (const react::RNSScreenGestureResponseDistanceStruct &)gestureResponseDistance { return @{ @"start" : @(gestureResponseDistance.start), @@ -127,28 +123,28 @@ + (NSDictionary *)gestureResponseDistanceDictFromCppStruct: } + (UITextAutocapitalizationType)UITextAutocapitalizationTypeFromCppEquivalent: - (facebook::react::RNSSearchBarAutoCapitalize)autoCapitalize + (react::RNSSearchBarAutoCapitalize)autoCapitalize { switch (autoCapitalize) { - case facebook::react::RNSSearchBarAutoCapitalize::Words: + case react::RNSSearchBarAutoCapitalize::Words: return UITextAutocapitalizationTypeWords; - case facebook::react::RNSSearchBarAutoCapitalize::Sentences: + case react::RNSSearchBarAutoCapitalize::Sentences: return UITextAutocapitalizationTypeSentences; - case facebook::react::RNSSearchBarAutoCapitalize::Characters: + case react::RNSSearchBarAutoCapitalize::Characters: return UITextAutocapitalizationTypeAllCharacters; - case facebook::react::RNSSearchBarAutoCapitalize::None: + case react::RNSSearchBarAutoCapitalize::None: return UITextAutocapitalizationTypeNone; } } -+ (RNSSearchBarPlacement)RNSScreenSearchBarPlacementFromCppEquivalent:(facebook::react::RNSSearchBarPlacement)placement ++ (RNSSearchBarPlacement)RNSScreenSearchBarPlacementFromCppEquivalent:(react::RNSSearchBarPlacement)placement { switch (placement) { - case facebook::react::RNSSearchBarPlacement::Stacked: + case react::RNSSearchBarPlacement::Stacked: return RNSSearchBarPlacementStacked; - case facebook::react::RNSSearchBarPlacement::Automatic: + case react::RNSSearchBarPlacement::Automatic: return RNSSearchBarPlacementAutomatic; - case facebook::react::RNSSearchBarPlacement::Inline: + case react::RNSSearchBarPlacement::Inline: return RNSSearchBarPlacementInline; } } diff --git a/ios/RNSFullWindowOverlay.h b/ios/RNSFullWindowOverlay.h index 3f756643a2..65d6100117 100644 --- a/ios/RNSFullWindowOverlay.h +++ b/ios/RNSFullWindowOverlay.h @@ -7,6 +7,10 @@ #import #endif +#ifdef RCT_NEW_ARCH_ENABLED +namespace react = facebook::react; +#endif // RCT_NEW_ARCH_ENABLED + @interface RNSFullWindowOverlayManager : RCTViewManager @end @@ -23,8 +27,8 @@ #endif // RCT_NEW_ARCH_ENABLED #ifdef RCT_NEW_ARCH_ENABLED -@property (nonatomic) facebook::react::LayoutMetrics oldLayoutMetrics; -@property (nonatomic) facebook::react::LayoutMetrics newLayoutMetrics; +@property (nonatomic) react::LayoutMetrics oldLayoutMetrics; +@property (nonatomic) react::LayoutMetrics newLayoutMetrics; #endif // RCT_NEW_ARCH_ENABLED @end diff --git a/ios/RNSFullWindowOverlay.mm b/ios/RNSFullWindowOverlay.mm index 841bf11180..101cacecf8 100644 --- a/ios/RNSFullWindowOverlay.mm +++ b/ios/RNSFullWindowOverlay.mm @@ -82,7 +82,7 @@ @implementation RNSFullWindowOverlay { - (instancetype)init { if (self = [super init]) { - static const auto defaultProps = std::make_shared(); + static const auto defaultProps = std::make_shared(); _props = defaultProps; [self _initCommon]; } @@ -162,10 +162,9 @@ - (void)maybeShow } } -+ (facebook::react::ComponentDescriptorProvider)componentDescriptorProvider ++ (react::ComponentDescriptorProvider)componentDescriptorProvider { - return facebook::react::concreteComponentDescriptorProvider< - facebook::react::RNSFullWindowOverlayComponentDescriptor>(); + return react::concreteComponentDescriptorProvider(); } - (void)prepareForRecycle @@ -193,8 +192,8 @@ - (void)unmountChildComponentView:(UIView *)childCompo [childComponentView removeFromSuperview]; } -- (void)updateLayoutMetrics:(facebook::react::LayoutMetrics const &)layoutMetrics - oldLayoutMetrics:(facebook::react::LayoutMetrics const &)oldLayoutMetrics +- (void)updateLayoutMetrics:(react::LayoutMetrics const &)layoutMetrics + oldLayoutMetrics:(react::LayoutMetrics const &)oldLayoutMetrics { CGRect frame = RCTCGRectFromRect(layoutMetrics.frame); _reactFrame = frame; diff --git a/ios/RNSScreen.h b/ios/RNSScreen.h index 9179699d68..3583ddedb6 100644 --- a/ios/RNSScreen.h +++ b/ios/RNSScreen.h @@ -8,10 +8,14 @@ #import #else #import -#endif +#endif // RCT_NEW_ARCH_ENABLED NS_ASSUME_NONNULL_BEGIN +#ifdef RCT_NEW_ARCH_ENABLED +namespace react = facebook::react; +#endif // RCT_NEW_ARCH_ENABLED + @interface RCTConvert (RNSScreen) + (RNSScreenStackPresentation)RNSScreenStackPresentation:(id)json; @@ -88,8 +92,8 @@ NS_ASSUME_NONNULL_BEGIN #ifdef RCT_NEW_ARCH_ENABLED // we recreate the behavior of `reactSetFrame` on new architecture -@property (nonatomic) facebook::react::LayoutMetrics oldLayoutMetrics; -@property (nonatomic) facebook::react::LayoutMetrics newLayoutMetrics; +@property (nonatomic) react::LayoutMetrics oldLayoutMetrics; +@property (nonatomic) react::LayoutMetrics newLayoutMetrics; @property (weak, nonatomic) RNSScreenStackHeaderConfig *config; @property (nonatomic, readonly) BOOL hasHeaderConfig; #else diff --git a/ios/RNSScreen.mm b/ios/RNSScreen.mm index 5dd618f1eb..b2608acd06 100644 --- a/ios/RNSScreen.mm +++ b/ios/RNSScreen.mm @@ -24,6 +24,10 @@ #import "RNSScreenStack.h" #import "RNSScreenStackHeaderConfig.h" +#ifdef RCT_NEW_ARCH_ENABLED +namespace react = facebook::react; +#endif // RCT_NEW_ARCH_ENABLED + @interface RNSScreenView () #ifdef RCT_NEW_ARCH_ENABLED @@ -36,7 +40,7 @@ @implementation RNSScreenView { __weak RCTBridge *_bridge; #ifdef RCT_NEW_ARCH_ENABLED RCTSurfaceTouchHandler *_touchHandler; - facebook::react::RNSScreenShadowNode::ConcreteState::Shared _state; + react::RNSScreenShadowNode::ConcreteState::Shared _state; // on fabric, they are not available by default so we need them exposed here too NSMutableArray *_reactSubviews; #else @@ -49,7 +53,7 @@ @implementation RNSScreenView { - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { - static const auto defaultProps = std::make_shared(); + static const auto defaultProps = std::make_shared(); _props = defaultProps; _reactSubviews = [NSMutableArray new]; [self initCommonProps]; @@ -102,7 +106,7 @@ - (void)updateBounds { #ifdef RCT_NEW_ARCH_ENABLED if (_state != nullptr) { - auto newState = facebook::react::RNSScreenState{RCTSizeFromCGSize(self.bounds.size)}; + auto newState = react::RNSScreenState{RCTSizeFromCGSize(self.bounds.size)}; _state->updateState(std::move(newState)); UINavigationController *navctr = _controller.navigationController; [navctr.view setNeedsLayout]; @@ -283,8 +287,8 @@ - (void)notifyDismissedWithCount:(int)dismissCount // If screen is already unmounted then there will be no event emitter // it will be cleaned in prepareForRecycle if (_eventEmitter != nullptr) { - std::dynamic_pointer_cast(_eventEmitter) - ->onDismissed(facebook::react::RNSScreenEventEmitter::OnDismissed{.dismissCount = dismissCount}); + std::dynamic_pointer_cast(_eventEmitter) + ->onDismissed(react::RNSScreenEventEmitter::OnDismissed{.dismissCount = dismissCount}); } #else // TODO: hopefully problems connected to dismissed prop are only the case on paper @@ -305,9 +309,9 @@ - (void)notifyDismissCancelledWithDismissCount:(int)dismissCount // If screen is already unmounted then there will be no event emitter // it will be cleaned in prepareForRecycle if (_eventEmitter != nullptr) { - std::dynamic_pointer_cast(_eventEmitter) + std::dynamic_pointer_cast(_eventEmitter) ->onNativeDismissCancelled( - facebook::react::RNSScreenEventEmitter::OnNativeDismissCancelled{.dismissCount = dismissCount}); + react::RNSScreenEventEmitter::OnNativeDismissCancelled{.dismissCount = dismissCount}); } #else if (self.onNativeDismissCancelled) { @@ -322,8 +326,8 @@ - (void)notifyWillAppear // If screen is already unmounted then there will be no event emitter // it will be cleaned in prepareForRecycle if (_eventEmitter != nullptr) { - std::dynamic_pointer_cast(_eventEmitter) - ->onWillAppear(facebook::react::RNSScreenEventEmitter::OnWillAppear{}); + std::dynamic_pointer_cast(_eventEmitter) + ->onWillAppear(react::RNSScreenEventEmitter::OnWillAppear{}); } [self updateLayoutMetrics:_newLayoutMetrics oldLayoutMetrics:_oldLayoutMetrics]; #else @@ -345,8 +349,8 @@ - (void)notifyWillDisappear // If screen is already unmounted then there will be no event emitter // it will be cleaned in prepareForRecycle if (_eventEmitter != nullptr) { - std::dynamic_pointer_cast(_eventEmitter) - ->onWillDisappear(facebook::react::RNSScreenEventEmitter::OnWillDisappear{}); + std::dynamic_pointer_cast(_eventEmitter) + ->onWillDisappear(react::RNSScreenEventEmitter::OnWillDisappear{}); } #else if (self.onWillDisappear) { @@ -361,8 +365,8 @@ - (void)notifyAppear // If screen is already unmounted then there will be no event emitter // it will be cleaned in prepareForRecycle if (_eventEmitter != nullptr) { - std::dynamic_pointer_cast(_eventEmitter) - ->onAppear(facebook::react::RNSScreenEventEmitter::OnAppear{}); + std::dynamic_pointer_cast(_eventEmitter) + ->onAppear(react::RNSScreenEventEmitter::OnAppear{}); } #else if (self.onAppear) { @@ -381,8 +385,8 @@ - (void)notifyDisappear // If screen is already unmounted then there will be no event emitter // it will be cleaned in prepareForRecycle if (_eventEmitter != nullptr) { - std::dynamic_pointer_cast(_eventEmitter) - ->onDisappear(facebook::react::RNSScreenEventEmitter::OnDisappear{}); + std::dynamic_pointer_cast(_eventEmitter) + ->onDisappear(react::RNSScreenEventEmitter::OnDisappear{}); } #else if (self.onDisappear) { @@ -395,8 +399,8 @@ - (void)notifyGestureCancel { #ifdef RCT_NEW_ARCH_ENABLED if (_eventEmitter != nullptr) { - std::dynamic_pointer_cast(_eventEmitter) - ->onGestureCancel(facebook::react::RNSScreenEventEmitter::OnGestureCancel{}); + std::dynamic_pointer_cast(_eventEmitter) + ->onGestureCancel(react::RNSScreenEventEmitter::OnGestureCancel{}); } #else if (self.onGestureCancel) { @@ -467,8 +471,8 @@ - (void)notifyTransitionProgress:(double)progress closing:(BOOL)closing goingFor { #ifdef RCT_NEW_ARCH_ENABLED if (_eventEmitter != nullptr) { - std::dynamic_pointer_cast(_eventEmitter) - ->onTransitionProgress(facebook::react::RNSScreenEventEmitter::OnTransitionProgress{ + std::dynamic_pointer_cast(_eventEmitter) + ->onTransitionProgress(react::RNSScreenEventEmitter::OnTransitionProgress{ .progress = progress, .closing = closing ? 1 : 0, .goingForward = goingForward ? 1 : 0}); } RNSScreenViewEvent *event = [[RNSScreenViewEvent alloc] initWithEventName:@"onTransitionProgress" @@ -602,9 +606,9 @@ - (BOOL)hasHeaderConfig return _config != nil; } -+ (facebook::react::ComponentDescriptorProvider)componentDescriptorProvider ++ (react::ComponentDescriptorProvider)componentDescriptorProvider { - return facebook::react::concreteComponentDescriptorProvider(); + return react::concreteComponentDescriptorProvider(); } - (void)mountChildComponentView:(UIView *)childComponentView index:(NSInteger)index @@ -649,11 +653,10 @@ - (void)prepareForRecycle _stackPresentation = RNSScreenStackPresentationPush; } -- (void)updateProps:(facebook::react::Props::Shared const &)props - oldProps:(facebook::react::Props::Shared const &)oldProps +- (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::Shared const &)oldProps { - const auto &oldScreenProps = *std::static_pointer_cast(_props); - const auto &newScreenProps = *std::static_pointer_cast(props); + const auto &oldScreenProps = *std::static_pointer_cast(_props); + const auto &newScreenProps = *std::static_pointer_cast(props); [self setFullScreenSwipeEnabled:newScreenProps.fullScreenSwipeEnabled]; @@ -732,14 +735,13 @@ - (void)updateProps:(facebook::react::Props::Shared const &)props [super updateProps:props oldProps:oldProps]; } -- (void)updateState:(facebook::react::State::Shared const &)state - oldState:(facebook::react::State::Shared const &)oldState +- (void)updateState:(react::State::Shared const &)state oldState:(react::State::Shared const &)oldState { - _state = std::static_pointer_cast(state); + _state = std::static_pointer_cast(state); } -- (void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetrics - oldLayoutMetrics:(const facebook::react::LayoutMetrics &)oldLayoutMetrics +- (void)updateLayoutMetrics:(const react::LayoutMetrics &)layoutMetrics + oldLayoutMetrics:(const react::LayoutMetrics &)oldLayoutMetrics { _newLayoutMetrics = layoutMetrics; _oldLayoutMetrics = oldLayoutMetrics; diff --git a/ios/RNSScreenContainer.mm b/ios/RNSScreenContainer.mm index f7bd2a4bf1..09f5d4d4f5 100644 --- a/ios/RNSScreenContainer.mm +++ b/ios/RNSScreenContainer.mm @@ -6,7 +6,10 @@ #import #import #import -#endif + +namespace react = facebook::react; + +#endif // RCT_NEW_ARCH_ENABLED @implementation RNSViewController @@ -59,7 +62,7 @@ - (instancetype)init { if (self = [super init]) { #ifdef RCT_NEW_ARCH_ENABLED - static const auto defaultProps = std::make_shared(); + static const auto defaultProps = std::make_shared(); _props = defaultProps; #endif _activeScreens = [NSMutableSet new]; @@ -235,7 +238,7 @@ - (void)layoutSubviews _controller.view.frame = self.bounds; for (RNSScreenView *subview in _reactSubviews) { #ifdef RCT_NEW_ARCH_ENABLED - facebook::react::LayoutMetrics screenLayoutMetrics = subview.newLayoutMetrics; + react::LayoutMetrics screenLayoutMetrics = subview.newLayoutMetrics; screenLayoutMetrics.frame = RCTRectFromCGRect(CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)); [subview updateLayoutMetrics:screenLayoutMetrics oldLayoutMetrics:subview.oldLayoutMetrics]; #else @@ -267,7 +270,7 @@ - (void)mountChildComponentView:(UIView *)childCompone [_reactSubviews insertObject:screenView atIndex:index]; screenView.reactSuperview = self; - facebook::react::LayoutMetrics screenLayoutMetrics = screenView.newLayoutMetrics; + react::LayoutMetrics screenLayoutMetrics = screenView.newLayoutMetrics; screenLayoutMetrics.frame = RCTRectFromCGRect(CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)); [screenView updateLayoutMetrics:screenLayoutMetrics oldLayoutMetrics:screenView.oldLayoutMetrics]; [self markChildUpdated]; @@ -295,9 +298,9 @@ - (void)unmountChildComponentView:(UIView *)childCompo [self markChildUpdated]; } -+ (facebook::react::ComponentDescriptorProvider)componentDescriptorProvider ++ (react::ComponentDescriptorProvider)componentDescriptorProvider { - return facebook::react::concreteComponentDescriptorProvider(); + return react::concreteComponentDescriptorProvider(); } - (void)prepareForRecycle diff --git a/ios/RNSScreenNavigationContainer.mm b/ios/RNSScreenNavigationContainer.mm index e7160ea6be..f10671e230 100644 --- a/ios/RNSScreenNavigationContainer.mm +++ b/ios/RNSScreenNavigationContainer.mm @@ -6,7 +6,9 @@ #import #import #import -#endif + +namespace react = facebook::react; +#endif // RCT_NEW_ARCH_ENABLED @implementation RNSContainerNavigationController @@ -37,10 +39,9 @@ - (void)updateContainer #pragma mark-- Fabric specific #ifdef RCT_NEW_ARCH_ENABLED -+ (facebook::react::ComponentDescriptorProvider)componentDescriptorProvider ++ (react::ComponentDescriptorProvider)componentDescriptorProvider { - return facebook::react::concreteComponentDescriptorProvider< - facebook::react::RNSScreenNavigationContainerComponentDescriptor>(); + return react::concreteComponentDescriptorProvider(); } #endif diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm index 271e5ffda9..b06ffbd9c7 100644 --- a/ios/RNSScreenStack.mm +++ b/ios/RNSScreenStack.mm @@ -22,6 +22,10 @@ #import "RNSScreenStackHeaderConfig.h" #import "RNSScreenWindowTraits.h" +#ifdef RCT_NEW_ARCH_ENABLED +namespace react = facebook::react; +#endif // RCT_NEW_ARCH_ENABLED + @interface RNSScreenStackView () < UINavigationControllerDelegate, UIAdaptivePresentationControllerDelegate, @@ -102,7 +106,7 @@ @implementation RNSScreenStackView { - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { - static const auto defaultProps = std::make_shared(); + static const auto defaultProps = std::make_shared(); _props = defaultProps; [self initCommonProps]; } @@ -159,8 +163,8 @@ - (void)emitOnFinishTransitioningEvent { #ifdef RCT_NEW_ARCH_ENABLED if (_eventEmitter != nullptr) { - std::dynamic_pointer_cast(_eventEmitter) - ->onFinishTransitioning(facebook::react::RNSScreenStackEventEmitter::OnFinishTransitioning{}); + std::dynamic_pointer_cast(_eventEmitter) + ->onFinishTransitioning(react::RNSScreenStackEventEmitter::OnFinishTransitioning{}); } #else if (self.onFinishTransitioning) { @@ -1003,12 +1007,11 @@ - (void)takeSnapshot _snapshot = [_controller.visibleViewController.view snapshotViewAfterScreenUpdates:NO]; } -- (void)mountingTransactionWillMount:(facebook::react::MountingTransaction const &)transaction - withSurfaceTelemetry:(facebook::react::SurfaceTelemetry const &)surfaceTelemetry +- (void)mountingTransactionWillMount:(react::MountingTransaction const &)transaction + withSurfaceTelemetry:(react::SurfaceTelemetry const &)surfaceTelemetry { for (auto &mutation : transaction.getMutations()) { - if (mutation.type == facebook::react::ShadowViewMutation::Type::Remove && - mutation.parentShadowView.componentName != nil && + if (mutation.type == react::ShadowViewMutation::Type::Remove && mutation.parentShadowView.componentName != nil && strcmp(mutation.parentShadowView.componentName, "RNSScreenStack") == 0) { [self takeSnapshot]; return; @@ -1032,9 +1035,9 @@ - (void)prepareForRecycle [_controller setViewControllers:@[ [UIViewController new] ]]; } -+ (facebook::react::ComponentDescriptorProvider)componentDescriptorProvider ++ (react::ComponentDescriptorProvider)componentDescriptorProvider { - return facebook::react::concreteComponentDescriptorProvider(); + return react::concreteComponentDescriptorProvider(); } #else #pragma mark - Paper specific diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index 33ec2f06cf..de0d910f5b 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -25,7 +25,7 @@ #import "RNSUIBarButtonItem.h" #ifdef RCT_NEW_ARCH_ENABLED -namespace rct = facebook::react; +namespace react = facebook::react; #endif // RCT_NEW_ARCH_ENABLED #ifndef RCT_NEW_ARCH_ENABLED @@ -64,7 +64,7 @@ @implementation RNSScreenStackHeaderConfig { - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { - static const auto defaultProps = std::make_shared(); + static const auto defaultProps = std::make_shared(); _props = defaultProps; _show = YES; _translucent = NO; @@ -315,7 +315,7 @@ + (UIImage *)loadBackButtonImageInViewController:(UIViewController *)vc withConf scale:imageSource.scale #ifdef RCT_NEW_ARCH_ENABLED resizeMode:resizeModeFromCppEquiv( - std::static_pointer_cast(imageView.props)->resizeMode)]; + std::static_pointer_cast(imageView.props)->resizeMode)]; #else resizeMode:imageView.resizeMode]; #endif // RCT_NEW_ARCH_ENABLED @@ -704,18 +704,18 @@ - (void)unmountChildComponentView:(UIView *)childCompo [childComponentView removeFromSuperview]; } -static RCTResizeMode resizeModeFromCppEquiv(rct::ImageResizeMode resizeMode) +static RCTResizeMode resizeModeFromCppEquiv(react::ImageResizeMode resizeMode) { switch (resizeMode) { - case rct::ImageResizeMode::Cover: + case react::ImageResizeMode::Cover: return RCTResizeModeCover; - case rct::ImageResizeMode::Contain: + case react::ImageResizeMode::Contain: return RCTResizeModeContain; - case rct::ImageResizeMode::Stretch: + case react::ImageResizeMode::Stretch: return RCTResizeModeStretch; - case rct::ImageResizeMode::Center: + case react::ImageResizeMode::Center: return RCTResizeModeCenter; - case rct::ImageResizeMode::Repeat: + case react::ImageResizeMode::Repeat: return RCTResizeModeRepeat; } } @@ -726,8 +726,8 @@ static RCTResizeMode resizeModeFromCppEquiv(rct::ImageResizeMode resizeMode) */ + (RCTImageSource *)imageSourceFromImageView:(RCTImageComponentView *)view { - auto const imageProps = *std::static_pointer_cast(view.props); - rct::ImageSource cppImageSource = imageProps.sources.at(0); + auto const imageProps = *std::static_pointer_cast(view.props); + react::ImageSource cppImageSource = imageProps.sources.at(0); auto imageSize = CGSize{cppImageSource.size.width, cppImageSource.size.height}; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:RCTNSStringFromStringNilIfEmpty(cppImageSource.uri)]]; @@ -745,9 +745,9 @@ - (void)prepareForRecycle _initialPropsSet = NO; } -+ (rct::ComponentDescriptorProvider)componentDescriptorProvider ++ (react::ComponentDescriptorProvider)componentDescriptorProvider { - return rct::concreteComponentDescriptorProvider(); + return react::concreteComponentDescriptorProvider(); } - (NSNumber *)getFontSizePropValue:(int)value @@ -757,20 +757,20 @@ - (NSNumber *)getFontSizePropValue:(int)value return nil; } -- (UISemanticContentAttribute)getDirectionPropValue:(rct::RNSScreenStackHeaderConfigDirection)direction +- (UISemanticContentAttribute)getDirectionPropValue:(react::RNSScreenStackHeaderConfigDirection)direction { switch (direction) { - case rct::RNSScreenStackHeaderConfigDirection::Rtl: + case react::RNSScreenStackHeaderConfigDirection::Rtl: return UISemanticContentAttributeForceRightToLeft; - case rct::RNSScreenStackHeaderConfigDirection::Ltr: + case react::RNSScreenStackHeaderConfigDirection::Ltr: return UISemanticContentAttributeForceLeftToRight; } } -- (void)updateProps:(rct::Props::Shared const &)props oldProps:(rct::Props::Shared const &)oldProps +- (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::Shared const &)oldProps { - const auto &oldScreenProps = *std::static_pointer_cast(_props); - const auto &newScreenProps = *std::static_pointer_cast(props); + const auto &oldScreenProps = *std::static_pointer_cast(_props); + const auto &newScreenProps = *std::static_pointer_cast(props); BOOL needsNavigationControllerLayout = !_initialPropsSet; @@ -832,7 +832,7 @@ - (void)updateProps:(rct::Props::Shared const &)props oldProps:(rct::Props::Shar } _initialPropsSet = YES; - _props = std::static_pointer_cast(props); + _props = std::static_pointer_cast(props); [super updateProps:props oldProps:oldProps]; } diff --git a/ios/RNSScreenStackHeaderSubview.mm b/ios/RNSScreenStackHeaderSubview.mm index c8b1c8f572..c23c7b301d 100644 --- a/ios/RNSScreenStackHeaderSubview.mm +++ b/ios/RNSScreenStackHeaderSubview.mm @@ -8,7 +8,11 @@ #import #import -#endif +#endif // RCT_NEW_ARCH_ENABLED + +#ifdef RCT_NEW_ARCH_ENABLED +namespace react = facebook::react; +#endif // RCT_NEW_ARCH_ENABLED @interface RCTBridge (Private) + (RCTBridge *)currentBridge; @@ -25,7 +29,7 @@ @implementation RNSScreenStackHeaderSubview - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { - static const auto defaultProps = std::make_shared(); + static const auto defaultProps = std::make_shared(); _props = defaultProps; } @@ -39,24 +43,21 @@ - (void)prepareForRecycle [super prepareForRecycle]; } -- (void)updateProps:(facebook::react::Props::Shared const &)props - oldProps:(facebook::react::Props::Shared const &)oldProps +- (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::Shared const &)oldProps { - const auto &newHeaderSubviewProps = - *std::static_pointer_cast(props); + const auto &newHeaderSubviewProps = *std::static_pointer_cast(props); [self setType:[RNSConvert RNSScreenStackHeaderSubviewTypeFromCppEquivalent:newHeaderSubviewProps.type]]; [super updateProps:props oldProps:oldProps]; } -+ (facebook::react::ComponentDescriptorProvider)componentDescriptorProvider ++ (react::ComponentDescriptorProvider)componentDescriptorProvider { - return facebook::react::concreteComponentDescriptorProvider< - facebook::react::RNSScreenStackHeaderSubviewComponentDescriptor>(); + return react::concreteComponentDescriptorProvider(); } -- (void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetrics - oldLayoutMetrics:(const facebook::react::LayoutMetrics &)oldLayoutMetrics +- (void)updateLayoutMetrics:(const react::LayoutMetrics &)layoutMetrics + oldLayoutMetrics:(const react::LayoutMetrics &)oldLayoutMetrics { CGRect frame = RCTCGRectFromRect(layoutMetrics.frame); // CALayer will crash if we pass NaN or Inf values. diff --git a/ios/RNSSearchBar.mm b/ios/RNSSearchBar.mm index 1052758161..39e06c9ad1 100644 --- a/ios/RNSSearchBar.mm +++ b/ios/RNSSearchBar.mm @@ -13,7 +13,11 @@ #import #import #import "RNSConvert.h" -#endif +#endif // RCT_NEW_ARCH_ENABLED + +#ifdef RCT_NEW_ARCH_ENABLED +namespace react = facebook::react; +#endif // RCT_NEW_ARCH_ENABLED @implementation RNSSearchBar { __weak RCTBridge *_bridge; @@ -36,7 +40,7 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge - (instancetype)init { if (self = [super init]) { - static const auto defaultProps = std::make_shared(); + static const auto defaultProps = std::make_shared(); _props = defaultProps; [self initCommonProps]; } @@ -56,8 +60,8 @@ - (void)emitOnFocusEvent { #ifdef RCT_NEW_ARCH_ENABLED if (_eventEmitter != nullptr) { - std::dynamic_pointer_cast(_eventEmitter) - ->onFocus(facebook::react::RNSSearchBarEventEmitter::OnFocus{}); + std::dynamic_pointer_cast(_eventEmitter) + ->onFocus(react::RNSSearchBarEventEmitter::OnFocus{}); } #else if (self.onFocus) { @@ -70,8 +74,8 @@ - (void)emitOnBlurEvent { #ifdef RCT_NEW_ARCH_ENABLED if (_eventEmitter != nullptr) { - std::dynamic_pointer_cast(_eventEmitter) - ->onBlur(facebook::react::RNSSearchBarEventEmitter::OnBlur{}); + std::dynamic_pointer_cast(_eventEmitter) + ->onBlur(react::RNSSearchBarEventEmitter::OnBlur{}); } #else if (self.onBlur) { @@ -84,9 +88,9 @@ - (void)emitOnSearchButtonPressEventWithText:(NSString *)text { #ifdef RCT_NEW_ARCH_ENABLED if (_eventEmitter != nullptr) { - std::dynamic_pointer_cast(_eventEmitter) + std::dynamic_pointer_cast(_eventEmitter) ->onSearchButtonPress( - facebook::react::RNSSearchBarEventEmitter::OnSearchButtonPress{.text = RCTStringFromNSString(text)}); + react::RNSSearchBarEventEmitter::OnSearchButtonPress{.text = RCTStringFromNSString(text)}); } #else if (self.onSearchButtonPress) { @@ -101,8 +105,8 @@ - (void)emitOnCancelButtonPressEvent { #ifdef RCT_NEW_ARCH_ENABLED if (_eventEmitter != nullptr) { - std::dynamic_pointer_cast(_eventEmitter) - ->onCancelButtonPress(facebook::react::RNSSearchBarEventEmitter::OnCancelButtonPress{}); + std::dynamic_pointer_cast(_eventEmitter) + ->onCancelButtonPress(react::RNSSearchBarEventEmitter::OnCancelButtonPress{}); } #else if (self.onCancelButtonPress) { @@ -115,8 +119,8 @@ - (void)emitOnChangeTextEventWithText:(NSString *)text { #ifdef RCT_NEW_ARCH_ENABLED if (_eventEmitter != nullptr) { - std::dynamic_pointer_cast(_eventEmitter) - ->onChangeText(facebook::react::RNSSearchBarEventEmitter::OnChangeText{.text = RCTStringFromNSString(text)}); + std::dynamic_pointer_cast(_eventEmitter) + ->onChangeText(react::RNSSearchBarEventEmitter::OnChangeText{.text = RCTStringFromNSString(text)}); } #else if (self.onChangeText) { @@ -299,11 +303,10 @@ - (void)setText:(NSString *)text #pragma mark-- Fabric specific #ifdef RCT_NEW_ARCH_ENABLED -- (void)updateProps:(facebook::react::Props::Shared const &)props - oldProps:(facebook::react::Props::Shared const &)oldProps +- (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::Shared const &)oldProps { - const auto &oldScreenProps = *std::static_pointer_cast(_props); - const auto &newScreenProps = *std::static_pointer_cast(props); + const auto &oldScreenProps = *std::static_pointer_cast(_props); + const auto &newScreenProps = *std::static_pointer_cast(props); [self setHideWhenScrolling:newScreenProps.hideWhenScrolling]; @@ -346,9 +349,9 @@ - (void)updateProps:(facebook::react::Props::Shared const &)props [super updateProps:props oldProps:oldProps]; } -+ (facebook::react::ComponentDescriptorProvider)componentDescriptorProvider ++ (react::ComponentDescriptorProvider)componentDescriptorProvider { - return facebook::react::concreteComponentDescriptorProvider(); + return react::concreteComponentDescriptorProvider(); } - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args From 46945255b9883778b03272323490defc7aa77923 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Fri, 4 Aug 2023 10:04:42 +0200 Subject: [PATCH 04/46] fix(iOS): add missing iOS API availbility checks (#1860) ## Description When adding https://github.com/software-mansion/react-native-screens/pull/1843 I've forgotten to add API avaibility checks for method definitions (usage and declarations were guarded). This caused build problems when deploying for lower iOS versions. Fixes #1859 ## Changes Added missing availbility checks. ## Test code and steps to reproduce Build iOS without having iOS 16 installed (or somehow disabled?). ## Checklist - [x] Ensured that CI passes --- ios/RNSSearchBar.h | 3 +++ ios/RNSSearchBar.mm | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ios/RNSSearchBar.h b/ios/RNSSearchBar.h index 00882b4138..9ac04c0ba2 100644 --- a/ios/RNSSearchBar.h +++ b/ios/RNSSearchBar.h @@ -21,8 +21,11 @@ @property (nonatomic) RNSSearchBarPlacement placement; @property (nonatomic, retain) UISearchController *controller; +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_16_0) && \ + __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_16_0 && !TARGET_OS_TV - (UINavigationItemSearchBarPlacement)placementAsUINavigationItemSearchBarPlacement API_AVAILABLE(ios(16.0)) API_UNAVAILABLE(tvos, watchos); +#endif // Check for iOS >= 16 && !TARGET_OS_TV #ifdef RCT_NEW_ARCH_ENABLED #else diff --git a/ios/RNSSearchBar.mm b/ios/RNSSearchBar.mm index 39e06c9ad1..94475b7d34 100644 --- a/ios/RNSSearchBar.mm +++ b/ios/RNSSearchBar.mm @@ -213,7 +213,10 @@ - (void)showCancelButton #endif } -- (UINavigationItemSearchBarPlacement)placementAsUINavigationItemSearchBarPlacement +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_16_0) && \ + __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_16_0 && !TARGET_OS_TV +- (UINavigationItemSearchBarPlacement)placementAsUINavigationItemSearchBarPlacement API_AVAILABLE(ios(16.0)) + API_UNAVAILABLE(tvos, watchos) { switch (_placement) { case RNSSearchBarPlacementStacked: @@ -224,6 +227,7 @@ - (UINavigationItemSearchBarPlacement)placementAsUINavigationItemSearchBarPlacem return UINavigationItemSearchBarPlacementInline; } } +#endif // Check for iOS >= 16 && !TARGET_OS_TV #pragma mark delegate methods From 5427eb565ab6410cac1ccd2ef990cc22501f6354 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Fri, 4 Aug 2023 11:25:41 +0200 Subject: [PATCH 05/46] Release 3.24.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c6ff59963f..172455c0c1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-screens", - "version": "3.23.0", + "version": "3.24.0", "description": "Native navigation primitives for your React Native app.", "scripts": { "check-types": "tsc --noEmit", From d12e47bea54b776ae54cfff3de911971200b8b75 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 7 Aug 2023 15:40:09 +0200 Subject: [PATCH 06/46] chore: reinstall deps & pods in example apps after release (#1862) ## Description Reinstalling pods & deps in example apps after `3.24.0` was released, so that `Podfile.lock` is up to date on any new branch. ## Test code and steps to reproduce Create new branch, reinstall pods and notice that no changes were generated in `Podfile.lock`. TODO: We should really make CI for this ## Checklist - [ ] Ensured that CI passes --- Example/ios/Podfile.lock | 4 ++-- FabricExample/ios/Podfile.lock | 8 ++++---- FabricTestExample/ios/Podfile.lock | 8 ++++---- TestsExample/ios/Podfile.lock | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Example/ios/Podfile.lock b/Example/ios/Podfile.lock index 74188f8e10..0bbe095b7a 100644 --- a/Example/ios/Podfile.lock +++ b/Example/ios/Podfile.lock @@ -364,7 +364,7 @@ PODS: - React - RNGestureHandler (2.12.0): - React-Core - - RNScreens (3.22.1): + - RNScreens (3.24.0): - React-Core - React-RCTImage - RNVectorIcons (8.1.0): @@ -587,7 +587,7 @@ SPEC CHECKSUMS: ReactCommon: 1e783348b9aa73ae68236271df972ba898560a95 RNCMaskedView: 0e1bc4bfa8365eba5fbbb71e07fbdc0555249489 RNGestureHandler: dec4645026e7401a0899f2846d864403478ff6a5 - RNScreens: 50ffe2fa2342eabb2d0afbe19f7c1af286bc7fb3 + RNScreens: b21dc57dfa2b710c30ec600786a3fc223b1b92e7 RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4 SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608 Yoga: 0b84a956f7393ef1f37f3bb213c516184e4a689d diff --git a/FabricExample/ios/Podfile.lock b/FabricExample/ios/Podfile.lock index 5968105dda..b2233c8b82 100644 --- a/FabricExample/ios/Podfile.lock +++ b/FabricExample/ios/Podfile.lock @@ -1109,7 +1109,7 @@ PODS: - React-jsi (= 0.72.3) - React-logger (= 0.72.3) - React-perflogger (= 0.72.3) - - RNScreens (3.23.0): + - RNScreens (3.24.0): - RCT-Folly - RCTRequired - RCTTypeSafety @@ -1117,8 +1117,8 @@ PODS: - React-Codegen - React-RCTFabric - ReactCommon/turbomodule/core - - RNScreens/common (= 3.23.0) - - RNScreens/common (3.23.0): + - RNScreens/common (= 3.24.0) + - RNScreens/common (3.24.0): - RCT-Folly - RCTRequired - RCTTypeSafety @@ -1365,7 +1365,7 @@ SPEC CHECKSUMS: React-runtimescheduler: 837c1bebd2f84572db17698cd702ceaf585b0d9a React-utils: bcb57da67eec2711f8b353f6e3d33bd8e4b2efa3 ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9 - RNScreens: 95b62f9fb2aa427d7c1a2a2d127a72edb7450390 + RNScreens: e114ddbc9b91fbde662870c4256196ab0833314b SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce YogaKit: f782866e155069a2cca2517aafea43200b01fd5a diff --git a/FabricTestExample/ios/Podfile.lock b/FabricTestExample/ios/Podfile.lock index 4bd0aeef94..c2c3024de3 100644 --- a/FabricTestExample/ios/Podfile.lock +++ b/FabricTestExample/ios/Podfile.lock @@ -1147,7 +1147,7 @@ PODS: - React-RCTText - ReactCommon/turbomodule/core - Yoga - - RNScreens (3.23.0): + - RNScreens (3.24.0): - RCT-Folly - RCTRequired - RCTTypeSafety @@ -1155,8 +1155,8 @@ PODS: - React-Codegen - React-RCTFabric - ReactCommon/turbomodule/core - - RNScreens/common (= 3.23.0) - - RNScreens/common (3.23.0): + - RNScreens/common (= 3.24.0) + - RNScreens/common (3.24.0): - RCT-Folly - RCTRequired - RCTTypeSafety @@ -1411,7 +1411,7 @@ SPEC CHECKSUMS: ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9 RNGestureHandler: d8224aad6d7081834ae6e6cf925397059485b69e RNReanimated: 3ce2aec600ad2ef47a5927abf2742329d7a190e9 - RNScreens: 95b62f9fb2aa427d7c1a2a2d127a72edb7450390 + RNScreens: e114ddbc9b91fbde662870c4256196ab0833314b SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce YogaKit: f782866e155069a2cca2517aafea43200b01fd5a diff --git a/TestsExample/ios/Podfile.lock b/TestsExample/ios/Podfile.lock index 3494f89bf1..8bd80296c5 100644 --- a/TestsExample/ios/Podfile.lock +++ b/TestsExample/ios/Podfile.lock @@ -518,7 +518,7 @@ PODS: - React-RCTText - ReactCommon/turbomodule/core - Yoga - - RNScreens (3.23.0): + - RNScreens (3.24.0): - React-Core - React-RCTImage - SocketRocket (0.6.1) @@ -755,7 +755,7 @@ SPEC CHECKSUMS: ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9 RNGestureHandler: dec4645026e7401a0899f2846d864403478ff6a5 RNReanimated: 020859659f64be2d30849a1fe88c821a7c3e0cbf - RNScreens: 6a8a3c6b808aa48dca1780df7b73ea524f602c63 + RNScreens: b21dc57dfa2b710c30ec600786a3fc223b1b92e7 SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce YogaKit: f782866e155069a2cca2517aafea43200b01fd5a From 6152f4ce7859448b1df179a35024af4b870da5af Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 7 Aug 2023 17:05:08 +0200 Subject: [PATCH 07/46] fix(iOS): add missing call to super method in `RNSScreenView#finalizeUpdates` (#1855) ## Description `RNSScreenView` (iOS) inherits from `RCTViewComponentView` which has custom implementation of `finalizeUpdates:` method, thus we should call it. ## Changes Added missing call to `[super finalizeUpdates:]` in `RNSScreenView`. ## Test code and steps to reproduce WIP ## Checklist - [x] Ensured that CI passes --- ios/RNSScreen.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/ios/RNSScreen.mm b/ios/RNSScreen.mm index b2608acd06..bca3fcfb85 100644 --- a/ios/RNSScreen.mm +++ b/ios/RNSScreen.mm @@ -760,6 +760,7 @@ - (void)updateLayoutMetrics:(const react::LayoutMetrics &)layoutMetrics - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask { + [super finalizeUpdates:updateMask]; #if !TARGET_OS_TV [self updatePresentationStyle]; #endif // !TARGET_OS_TV From 05f4dd7c77608010d3990ae2af3ec54d5f735760 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Tue, 8 Aug 2023 08:22:09 +0200 Subject: [PATCH 08/46] fix(Android): shorten alpha animation to 83ms on default enter-out (#1835) ## Description The issue was reported [here](https://github.com/react-navigation/react-navigation/issues/11438) on `@react-navigation` repo. *Note* Awaiting for response from people that reported the issue ## Changes Adjusted alpha animation duration as suggested in one of the comments. ## Test code and steps to reproduce Basing on people opinion that this improves the situation. ## Checklist - [x] Ensured that CI passes --- android/src/main/res/v33/anim-v33/rns_default_enter_out.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/res/v33/anim-v33/rns_default_enter_out.xml b/android/src/main/res/v33/anim-v33/rns_default_enter_out.xml index 965d47f6c3..c3ff70f810 100644 --- a/android/src/main/res/v33/anim-v33/rns_default_enter_out.xml +++ b/android/src/main/res/v33/anim-v33/rns_default_enter_out.xml @@ -11,7 +11,7 @@ android:fillAfter="true" android:interpolator="@anim/rns_standard_accelerate_interpolator" android:startOffset="0" - android:duration="450" /> + android:duration="83" /> Date: Tue, 8 Aug 2023 11:19:16 +0200 Subject: [PATCH 09/46] chore: fix typo in docs on `sheetCornerRadius` (#1863) ## Description Just fixing a typo I've noticed while doing other things. ## Checklist - [x] Ensured that CI passes --- src/native-stack/types.tsx | 2 +- src/types.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/native-stack/types.tsx b/src/native-stack/types.tsx index 38f0c6db52..35fe2ad045 100644 --- a/src/native-stack/types.tsx +++ b/src/native-stack/types.tsx @@ -341,7 +341,7 @@ export type NativeStackNavigationOptions = { * The corner radius that the sheet will try to render with. * Works only when `stackPresentation` is set to `formSheet`. * - * If set to non-negative value it will try to render sheet with provided radius, else ti will apply system default. + * If set to non-negative value it will try to render sheet with provided radius, else it will apply system default. * * If left unset system default is used. * diff --git a/src/types.tsx b/src/types.tsx index 9224b4ff06..4a8f4dc381 100644 --- a/src/types.tsx +++ b/src/types.tsx @@ -263,7 +263,7 @@ export interface ScreenProps extends ViewProps { * The corner radius that the sheet will try to render with. * Works only when `stackPresentation` is set to `formSheet`. * - * If set to non-negative value it will try to render sheet with provided radius, else ti will apply system default. + * If set to non-negative value it will try to render sheet with provided radius, else it will apply system default. * * If left unset system default is used. * From b196048263bbe4dea48a690d4c5b8632cb198525 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Fri, 11 Aug 2023 12:57:53 +0200 Subject: [PATCH 10/46] fix(iOS): wrong title in back button menu for screens w/ hidden header (#1866) ## Description Ah, here we go again... When header is hidden (`headerShown: false` in v6, `hidden: true` in v5) the method that updates header configuration returns early just after setting some layout related and LTR/RTL options, thus `title` property of current `UINavigationItem` is left unset leading to system default name `Back` being displayed in "back context menu". Fixes #1864 ## Changes When returning early (because header is hidden) we now set the `UINavigationItem` property to proper value. ## Test code and steps to reproduce `Test1864` in `FabricTestExample` & `TestsExample`. I've also tested it in context of * https://github.com/software-mansion/react-native-screens/pull/1646 and mix of both. Seems to work fine. ## Checklist - [x] Included code example that can be used to test this change - [x] Ensured that CI passes --- FabricTestExample/App.js | 1 + FabricTestExample/src/Test1864.tsx | 76 ++++++++++++++++++++++++++++++ TestsExample/App.js | 1 + TestsExample/src/Test1864.tsx | 76 ++++++++++++++++++++++++++++++ ios/RNSScreenStackHeaderConfig.mm | 1 + 5 files changed, 155 insertions(+) create mode 100644 FabricTestExample/src/Test1864.tsx create mode 100644 TestsExample/src/Test1864.tsx diff --git a/FabricTestExample/App.js b/FabricTestExample/App.js index 5c8753e887..70a8903646 100644 --- a/FabricTestExample/App.js +++ b/FabricTestExample/App.js @@ -86,6 +86,7 @@ import Test1649 from './src/Test1649'; import Test1683 from './src/Test1683'; import Test1726 from './src/Test1726'; import Test1844 from './src/Test1844'; +import Test1864 from './src/Test1864'; enableFreeze(true); diff --git a/FabricTestExample/src/Test1864.tsx b/FabricTestExample/src/Test1864.tsx new file mode 100644 index 0000000000..4ce08b73a2 --- /dev/null +++ b/FabricTestExample/src/Test1864.tsx @@ -0,0 +1,76 @@ +import * as React from 'react'; +import { Button, View, Text } from 'react-native'; +import { NavigationContainer, ParamListBase } from '@react-navigation/native'; +import { createNativeStackNavigator } from '@react-navigation/native-stack'; +import { NativeStackNavigationProp } from 'react-native-screens/native-stack'; + +const Stack = createNativeStackNavigator(); + +type NavProp = { + navigation: NativeStackNavigationProp; +}; + +export default function App() { + return ( + + + + + + + + + ); +} + +const ScreenA = ({ navigation }: NavProp) => ( + + Screen A +