Skip to content

Commit

Permalink
Update vendored code on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
tsapeta committed Oct 4, 2022
1 parent f2b44fa commit 756d3df
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 21 deletions.
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Expand Up @@ -2043,7 +2043,7 @@ PODS:
- React-RCTText
- ReactCommon/turbomodule/core
- Yoga
- RNScreens (3.15.0):
- RNScreens (3.17.0):
- React-Core
- React-RCTImage
- Stripe (22.7.1):
Expand Down Expand Up @@ -3511,7 +3511,7 @@ SPEC CHECKSUMS:
RNFlashList: 5116f2de2f543f01bfc30b22d5942d5af84b43df
RNGestureHandler: bad495418bcbd3ab47017a38d93d290ebd406f50
RNReanimated: 5c8c17e26787fd8984cd5accdc70fef2ca70aafd
RNScreens: 4a1af06327774490d97342c00aee0c2bafb497b7
RNScreens: 0df01424e9e0ed7827200d6ed1087ddd06c493f9
Stripe: fb29a476e4866fec4ef22fb76207363dd32795aa
stripe-react-native: 5663bf9de94bff6b3d92c16d32784433b5e94cf7
StripeApplePay: 09955cdf3f49b367af2feadd9c5b3bddb35446c0
Expand Down
@@ -1,6 +1,6 @@
{
"name": "RNScreens",
"version": "3.15.0",
"version": "3.17.0",
"summary": "Native navigation primitives for your React Native app.",
"description": "RNScreens - first incomplete navigation solution for your React Native app",
"homepage": "https://github.com/software-mansion/react-native-screens",
Expand All @@ -14,7 +14,7 @@
},
"source": {
"git": "https://github.com/software-mansion/react-native-screens.git",
"tag": "3.15.0"
"tag": "3.17.0"
},
"source_files": "ios/**/*.{h,m,mm}",
"requires_arc": true,
Expand Down
Expand Up @@ -4,11 +4,11 @@

#ifdef RN_FABRIC_ENABLED
#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
#import <React/RCTSurfaceTouchHandler.h>
#import <react/renderer/components/rnscreens/ComponentDescriptors.h>
#import <react/renderer/components/rnscreens/Props.h>
#import <react/renderer/components/rnscreens/RCTComponentViewHelpers.h>
#import "RCTFabricComponentsPlugins.h"
#else
#import <React/RCTTouchHandler.h>
#endif // RN_FABRIC_ENABLED
Expand Down
Expand Up @@ -103,6 +103,7 @@ NS_ASSUME_NONNULL_BEGIN
#endif

- (void)notifyTransitionProgress:(double)progress closing:(BOOL)closing goingForward:(BOOL)goingForward;
- (BOOL)isModal;

@end

Expand Down
30 changes: 25 additions & 5 deletions ios/vendored/unversioned/react-native-screens/ios/RNSScreen.mm
Expand Up @@ -6,13 +6,13 @@

#ifdef RN_FABRIC_ENABLED
#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
#import <React/RCTRootComponentView.h>
#import <React/RCTSurfaceTouchHandler.h>
#import <react/renderer/components/rnscreens/EventEmitters.h>
#import <react/renderer/components/rnscreens/Props.h>
#import <react/renderer/components/rnscreens/RCTComponentViewHelpers.h>
#import <rnscreens/RNSScreenComponentDescriptor.h>
#import "RCTFabricComponentsPlugins.h"
#import "RNSConvert.h"
#import "RNSScreenViewEvent.h"
#else
Expand Down Expand Up @@ -508,6 +508,11 @@ - (void)presentationControllerDidDismiss:(UIPresentationController *)presentatio
}
}

- (BOOL)isModal
{
return self.stackPresentation != RNSScreenStackPresentationPush;
}

#pragma mark - Fabric specific
#ifdef RN_FABRIC_ENABLED

Expand Down Expand Up @@ -545,6 +550,17 @@ - (void)prepareForRecycle
_dismissed = NO;
_state.reset();
_touchHandler = nil;

// We set this prop to default value here to workaround view-recycling.
// Let's assume the view has had _stackPresentation == <some modal stack presentation> set
// before below line was executed. Then, when instantiated again (with the same modal presentation)
// updateProps:oldProps: method would be called and setter for stack presentation would not be called.
// This is crucial as in that setter we register `self.controller` as a delegate
// (UIAdaptivePresentationControllerDelegate) to presentation controller and this leads to buggy modal behaviour as we
// rely on UIAdaptivePresentationControllerDelegate callbacks. Restoring the default value and then comparing against
// it in updateProps:oldProps: allows for setter to be called, however if there was some additional logic to execute
// when stackPresentation is set to "push" the setter would not be triggered.
_stackPresentation = RNSScreenStackPresentationPush;
}

- (void)updateProps:(facebook::react::Props::Shared const &)props
Expand Down Expand Up @@ -598,9 +614,12 @@ - (void)updateProps:(facebook::react::Props::Shared const &)props
}
#endif

if (newScreenProps.stackPresentation != oldScreenProps.stackPresentation) {
[self
setStackPresentation:[RNSConvert RNSScreenStackPresentationFromCppEquivalent:newScreenProps.stackPresentation]];
// Notice that we compare against _stackPresentation, not oldScreenProps.stackPresentation.
// See comment in prepareForRecycle method for explanation.
RNSScreenStackPresentation newStackPresentation =
[RNSConvert RNSScreenStackPresentationFromCppEquivalent:newScreenProps.stackPresentation];
if (newStackPresentation != _stackPresentation) {
[self setStackPresentation:newStackPresentation];
}

if (newScreenProps.stackAnimation != oldScreenProps.stackAnimation) {
Expand Down Expand Up @@ -739,7 +758,8 @@ - (void)viewWillAppear:(BOOL)animated
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
if (!self.transitionCoordinator.isInteractive) {
// self.navigationController might be null when we are dismissing a modal
if (!self.transitionCoordinator.isInteractive && self.navigationController != nil) {
// user might have long pressed ios 14 back button item,
// so he can go back more than one screen and we need to dismiss more screens in JS stack then.
// We check it by calculating the difference between the index of currently displayed screen
Expand Down
Expand Up @@ -3,9 +3,9 @@

#ifdef RN_FABRIC_ENABLED
#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
#import <react/renderer/components/rnscreens/ComponentDescriptors.h>
#import <react/renderer/components/rnscreens/Props.h>
#import "RCTFabricComponentsPlugins.h"
#endif

@implementation RNScreensViewController
Expand Down
Expand Up @@ -3,9 +3,9 @@
#import "RNSScreenContainer.h"

#ifdef RN_FABRIC_ENABLED
#import <React/RCTFabricComponentsPlugins.h>
#import <react/renderer/components/rnscreens/ComponentDescriptors.h>
#import <react/renderer/components/rnscreens/Props.h>
#import "RCTFabricComponentsPlugins.h"
#endif

@implementation RNScreensContainerNavigationController
Expand Down
Expand Up @@ -7,7 +7,7 @@
#import <react/renderer/components/rnscreens/Props.h>
#import <react/renderer/components/rnscreens/RCTComponentViewHelpers.h>

#import "RCTFabricComponentsPlugins.h"
#import <React/RCTFabricComponentsPlugins.h>

#else
#import <React/RCTBridge.h>
Expand Down Expand Up @@ -823,7 +823,7 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceive
RNSScreenView *topScreen = _reactSubviews.lastObject;

if (![topScreen isKindOfClass:[RNSScreenView class]] || !topScreen.gestureEnabled ||
_controller.viewControllers.count < 2) {
_controller.viewControllers.count < 2 || [topScreen isModal]) {
return NO;
}

Expand Down Expand Up @@ -969,7 +969,7 @@ - (void)takeSnapshot
- (void)mountingTransactionWillMount:(facebook::react::MountingTransaction const &)transaction
withSurfaceTelemetry:(facebook::react::SurfaceTelemetry const &)surfaceTelemetry
{
for (auto mutation : transaction.getMutations()) {
for (auto &mutation : transaction.getMutations()) {
if (mutation.type == facebook::react::ShadowViewMutation::Type::Remove &&
mutation.parentShadowView.componentName != nil &&
strcmp(mutation.parentShadowView.componentName, "RNSScreenStack") == 0) {
Expand Down
@@ -1,11 +1,11 @@
#ifdef RN_FABRIC_ENABLED
#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
#import <React/UIView+React.h>
#import <react/renderer/components/rnscreens/ComponentDescriptors.h>
#import <react/renderer/components/rnscreens/EventEmitters.h>
#import <react/renderer/components/rnscreens/Props.h>
#import <react/renderer/components/rnscreens/RCTComponentViewHelpers.h>
#import "RCTFabricComponentsPlugins.h"
#else
#import <React/RCTBridge.h>
#import <React/RCTImageLoader.h>
Expand Down Expand Up @@ -118,7 +118,7 @@ - (void)updateViewControllerIfNeeded
}

// we want updates sent to the VC below modal too since it is also visible
BOOL isPresentingVC = vc.presentedViewController == nextVC;
BOOL isPresentingVC = nextVC != nil && vc.presentedViewController == nextVC;

BOOL isInFullScreenModal = nav == nil && _screenView.stackPresentation == RNSScreenStackPresentationFullScreenModal;
// if nav is nil, it means we can be in a fullScreen modal, so there is no nextVC, but we still want to update
Expand Down Expand Up @@ -459,7 +459,6 @@ + (void)updateViewController:(UIViewController *)vc
return;
}

navitem.title = config.title;
#if !TARGET_OS_TV
if (config.backTitle != nil || config.backTitleFontFamily || config.backTitleFontSize ||
config.disableBackButtonMenu) {
Expand Down Expand Up @@ -580,13 +579,17 @@ + (void)updateViewController:(UIViewController *)vc
}
case RNSScreenStackHeaderSubviewTypeBackButton: {
#ifdef RN_FABRIC_ENABLED
RCTLogWarn(@"Back button subivew is not yet Fabric compatible in react-native-screens");
RCTLogWarn(@"Back button subview is not yet Fabric compatible in react-native-screens");
#endif
break;
}
}
}

// 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;

if (animated && vc.transitionCoordinator != nil &&
vc.transitionCoordinator.presentationStyle == UIModalPresentationNone && !wasHidden) {
// when there is an ongoing transition we may need to update navbar setting in animation block
Expand Down
Expand Up @@ -7,7 +7,7 @@
#import <react/renderer/components/rnscreens/RCTComponentViewHelpers.h>

#import <React/RCTConversions.h>
#import "RCTFabricComponentsPlugins.h"
#import <React/RCTFabricComponentsPlugins.h>
#endif

@implementation RNSScreenStackHeaderSubview
Expand Down
Expand Up @@ -8,11 +8,11 @@

#ifdef RN_FABRIC_ENABLED
#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
#import <react/renderer/components/rnscreens/ComponentDescriptors.h>
#import <react/renderer/components/rnscreens/EventEmitters.h>
#import <react/renderer/components/rnscreens/Props.h>
#import <react/renderer/components/rnscreens/RCTComponentViewHelpers.h>
#import "RCTFabricComponentsPlugins.h"
#import "RNSConvert.h"
#endif

Expand Down

0 comments on commit 756d3df

Please sign in to comment.