Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ios/RNSScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
33 changes: 22 additions & 11 deletions ios/RNSScreen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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<const react::RNSScreenEventEmitter>(_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]
Expand Down Expand Up @@ -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];
}
}
Expand Down Expand Up @@ -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];
}
}
Expand All @@ -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];
}
Expand All @@ -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;
Expand Down Expand Up @@ -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];
}
}

Expand Down
1 change: 1 addition & 0 deletions src/fabric/ModalScreenNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type TransitionProgressEvent = Readonly<{
progress: Double;
closing: Int32;
goingForward: Int32;
swiping: Int32;
}>;

type HeaderHeightChangeEvent = Readonly<{
Expand Down
1 change: 1 addition & 0 deletions src/fabric/ScreenNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type TransitionProgressEvent = Readonly<{
progress: Double;
closing: Int32;
goingForward: Int32;
swiping: Int32;
}>;

type HeaderHeightChangeEvent = Readonly<{
Expand Down
Loading