diff --git a/ios/RNSScreen.h b/ios/RNSScreen.h index 6b0c87abb7..996aeaee32 100644 --- a/ios/RNSScreen.h +++ b/ios/RNSScreen.h @@ -165,7 +165,10 @@ namespace react = facebook::react; - (instancetype)initWithBridge:(RCTBridge *)bridge; #endif // RCT_NEW_ARCH_ENABLED -- (void)notifyTransitionProgress:(double)progress closing:(BOOL)closing goingForward:(BOOL)goingForward; +- (void)notifyTransitionProgress:(double)progress + closing:(BOOL)closing + goingForward:(BOOL)goingForward + swiping:(BOOL)swiping; - (void)notifyDismissCancelledWithDismissCount:(int)dismissCount; - (BOOL)isModal; - (BOOL)isPresentedAsNativeModal; diff --git a/ios/RNSScreen.mm b/ios/RNSScreen.mm index 65c18f1ddc..b1c5526bf2 100644 --- a/ios/RNSScreen.mm +++ b/ios/RNSScreen.mm @@ -760,14 +760,19 @@ - (void)notifyFinishTransitioning [_controller notifyFinishTransitioning]; } -- (void)notifyTransitionProgress:(double)progress closing:(BOOL)closing goingForward:(BOOL)goingForward +- (void)notifyTransitionProgress:(double)progress + closing:(BOOL)closing + goingForward:(BOOL)goingForward + swiping:(BOOL)swiping { #ifdef RCT_NEW_ARCH_ENABLED if (_eventEmitter != nullptr) { std::dynamic_pointer_cast(_eventEmitter) - ->onTransitionProgress( - react::RNSScreenEventEmitter::OnTransitionProgress{ - .progress = progress, .closing = closing ? 1 : 0, .goingForward = goingForward ? 1 : 0}); + ->onTransitionProgress(react::RNSScreenEventEmitter::OnTransitionProgress{ + .progress = progress, + .closing = closing ? 1 : 0, + .goingForward = goingForward ? 1 : 0, + .swiping = swiping ? 1 : 0}); } RNSScreenViewEvent *event = [[RNSScreenViewEvent alloc] initWithEventName:@"onTransitionProgress" reactTag:[NSNumber numberWithInteger:self.tag] @@ -1608,7 +1613,7 @@ - (void)viewWillAppear:(BOOL)animated [RNSScreenWindowTraits updateWindowTraits]; if (_shouldNotify) { _closing = NO; - [self notifyTransitionProgress:0.0 closing:_closing goingForward:_goingForward]; + [self notifyTransitionProgress:0.0 closing:_closing goingForward:_goingForward swiping:_isSwiping]; [self setupProgressNotification]; } } @@ -1645,7 +1650,7 @@ - (void)viewWillDisappear:(BOOL)animated if (_shouldNotify) { _closing = YES; - [self notifyTransitionProgress:0.0 closing:_closing goingForward:_goingForward]; + [self notifyTransitionProgress:0.0 closing:_closing goingForward:_goingForward swiping:_isSwiping]; [self setupProgressNotification]; } } @@ -1661,7 +1666,7 @@ - (void)viewDidAppear:(BOOL)animated // we are going forward or dismissing without swipe // or successfully swiped back [self.screenView notifyAppear]; - [self notifyTransitionProgress:1.0 closing:NO goingForward:_goingForward]; + [self notifyTransitionProgress:1.0 closing:NO goingForward:_goingForward swiping:_isSwiping]; } else { [self.screenView notifyGestureCancel]; } @@ -1687,7 +1692,7 @@ - (void)viewDidDisappear:(BOOL)animated // same flow as in viewDidAppear if (!_isSwiping || _shouldNotify) { [self.screenView notifyDisappear]; - [self notifyTransitionProgress:1.0 closing:YES goingForward:_goingForward]; + [self notifyTransitionProgress:1.0 closing:YES goingForward:_goingForward swiping:_isSwiping]; } _isSwiping = NO; @@ -1886,17 +1891,23 @@ - (void)handleAnimation CGFloat fakeViewAlpha = _fakeView.layer.presentationLayer.opacity; if (_currentAlpha != fakeViewAlpha) { _currentAlpha = fmax(0.0, fmin(1.0, fakeViewAlpha)); - [self notifyTransitionProgress:_currentAlpha closing:_closing goingForward:_goingForward]; + [self notifyTransitionProgress:_currentAlpha closing:_closing goingForward:_goingForward swiping:_isSwiping]; } } } -- (void)notifyTransitionProgress:(double)progress closing:(BOOL)closing goingForward:(BOOL)goingForward +- (void)notifyTransitionProgress:(double)progress + closing:(BOOL)closing + goingForward:(BOOL)goingForward + swiping:(BOOL)swiping { if ([self.view isKindOfClass:[RNSScreenView class]]) { // if the view is already snapshot, there is not sense in sending progress since on JS side // the component is already not present - [(RNSScreenView *)self.view notifyTransitionProgress:progress closing:closing goingForward:goingForward]; + [(RNSScreenView *)self.view notifyTransitionProgress:progress + closing:closing + goingForward:goingForward + swiping:swiping]; } } diff --git a/src/fabric/ModalScreenNativeComponent.ts b/src/fabric/ModalScreenNativeComponent.ts index 5675438eaa..3c33edd33b 100644 --- a/src/fabric/ModalScreenNativeComponent.ts +++ b/src/fabric/ModalScreenNativeComponent.ts @@ -22,6 +22,7 @@ type TransitionProgressEvent = Readonly<{ progress: Double; closing: Int32; goingForward: Int32; + swiping: Int32; }>; type HeaderHeightChangeEvent = Readonly<{ diff --git a/src/fabric/ScreenNativeComponent.ts b/src/fabric/ScreenNativeComponent.ts index e9844498af..ba489c4071 100644 --- a/src/fabric/ScreenNativeComponent.ts +++ b/src/fabric/ScreenNativeComponent.ts @@ -22,6 +22,7 @@ type TransitionProgressEvent = Readonly<{ progress: Double; closing: Int32; goingForward: Int32; + swiping: Int32; }>; type HeaderHeightChangeEvent = Readonly<{