feat: Add ContentScrollViewDetector component
Description
This PR adds the ContentScrollViewDetector native component. This component allows us to locate and interface with content ScrollView.
The component holds an instance to the ScrollView and registers it for the closest view that implements ContentScrollViewConsumer. It is also responsible for unregistering the view when the ScrollView is destroyed.
We do not support the case when ContentScrollViewDetector does not wrap any ScrollView or the ScrollView is detached after some time. In the second case, the application will likely crash. Similarly, we do not support nested ContentScrollViewDetectors.
Changes
Added ContentScrollViewDetector component. Added ContentScrollViewConsumer protocol that the Detector looks for.
Test code and steps to reproduce
Wrap a ScrollView with <ContentScrollViewDetector>. Add the following to RNSScreen and/or RNSBottomTabsScreenComponentView:
#pragma mark - ContentScrollViewConsumer
- (void)registerContentScrollView:(UIScrollView *)scrollView
{
RCTLogInfo(@"Registering content ScrollView");
}
- (void)unregisterContentScrollView:(UIScrollView *)scrollView
{
RCTLogInfo(@"Unregistering content ScrollView");
}
along with conformance declaration in the header. Observe the logs.