Skip to content
Merged
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
17 changes: 14 additions & 3 deletions ios/Fabric/RNCPagerViewComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ @interface RNCPagerViewComponentView () <RCTRNCViewPagerViewProtocol, UIPageView

@implementation RNCPagerViewComponentView {
LayoutMetrics _layoutMetrics;
LayoutMetrics _oldLayoutMetrics;
UIScrollView *scrollView;
BOOL transitioning;
}

// Needed because of this: https://github.com/facebook/react-native/pull/37274
Expand Down Expand Up @@ -111,9 +113,14 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo


-(void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetrics oldLayoutMetrics:(const facebook::react::LayoutMetrics &)oldLayoutMetrics {
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:_layoutMetrics];
self.contentView.frame = RCTCGRectFromRect(layoutMetrics.getContentFrame());
_oldLayoutMetrics = oldLayoutMetrics;
_layoutMetrics = layoutMetrics;

if (transitioning) {
return;
}

[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:_layoutMetrics];
}


Expand Down Expand Up @@ -223,12 +230,15 @@ - (void)setPagerViewControllers:(NSInteger)index
[self enableSwipe];
return;
}


transitioning = YES;

__weak RNCPagerViewComponentView *weakSelf = self;
[_nativePageViewController setViewControllers:@[[_nativeChildrenViewControllers objectAtIndex:index]]
direction:direction
animated:animated
completion:^(BOOL finished) {
self->transitioning = NO;
__strong RNCPagerViewComponentView *strongSelf = weakSelf;
[strongSelf enableSwipe];
if (strongSelf->_eventEmitter != nullptr ) {
Expand All @@ -237,6 +247,7 @@ - (void)setPagerViewControllers:(NSInteger)index
strongEventEmitter.onPageSelected(RNCViewPagerEventEmitter::OnPageSelected{.position = static_cast<double>(position)});
strongSelf->_currentIndex = index;
}
[strongSelf updateLayoutMetrics:strongSelf->_layoutMetrics oldLayoutMetrics:strongSelf->_oldLayoutMetrics];
}];
}

Expand Down
Loading