Skip to content

Commit

Permalink
feat: remove usage of currentBridge
Browse files Browse the repository at this point in the history
  • Loading branch information
WoLewicki committed Oct 1, 2024
1 parent 057d8e7 commit 48e1a68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
11 changes: 4 additions & 7 deletions ios/Fabric/RNCPagerViewComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,10 @@ -(void)scrollViewDidScroll:(UIScrollView *)scrollView {

strongEventEmitter.onPageScroll(RNCViewPagerEventEmitter::OnPageScroll{.position = static_cast<double>(position), .offset = offset});

//This is temporary workaround to allow animations based on onPageScroll event
//until Fabric implements proper NativeAnimationDriver
RCTBridge *bridge = [RCTBridge currentBridge];

if (bridge) {
[bridge.eventDispatcher sendEvent:[[RCTOnPageScrollEvent alloc] initWithReactTag:[NSNumber numberWithInt:self.tag] position:@(position) offset:@(offset)]];
}
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:[[RCTOnPageScrollEvent alloc] initWithReactTag:[NSNumber numberWithInt:self.tag] position:@(position) offset:@(offset)], @"event", nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED"
object:nil
userInfo:userInfo];
}

#pragma mark - Internal methods
Expand Down
12 changes: 4 additions & 8 deletions ios/LEGACY/Fabric/LEGACY_RNCPagerViewComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,10 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
int eventPosition = (int) position;
strongEventEmitter.onPageScroll(LEGACY_RNCViewPagerEventEmitter::OnPageScroll{.position = static_cast<double>(eventPosition), .offset = interpolatedOffset});

//This is temporary workaround to allow animations based on onPageScroll event
//until Fabric implements proper NativeAnimationDriver
RCTBridge *bridge = [RCTBridge currentBridge];

if (bridge) {
[bridge.eventDispatcher sendEvent:[[RCTOnPageScrollEvent alloc] initWithReactTag:[NSNumber numberWithInt:self.tag] position:@(position) offset:@(interpolatedOffset)]];
}

NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:[[RCTOnPageScrollEvent alloc] initWithReactTag:[NSNumber numberWithInt:self.tag] position:@(position) offset:@(interpolatedOffset)], @"event", nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED"
object:nil
userInfo:userInfo];
}


Expand Down

0 comments on commit 48e1a68

Please sign in to comment.