Fabric: Implementaion of RCTScrollableProtocol for RCTScrollViewComponentView

Summary: We need this only until Fabric has own command-execution pipeline.

Reviewed By: mdvacca

Differential Revision: D15501202

fbshipit-source-id: aad77660ada43e429722b13d1da2f998a1726c73
This commit is contained in:
Valentin Shergin
2019-05-24 19:16:32 -07:00
committed by Facebook Github Bot
parent 94dfc153a4
commit ba627f4970
2 changed files with 49 additions and 0 deletions
@@ -7,6 +7,7 @@
#import <UIKit/UIKit.h>
#import <React/RCTScrollableProtocol.h>
#import <React/RCTViewComponentView.h>
#import <React/RNGenericDelegateSplitter.h>
@@ -46,4 +47,13 @@ NS_ASSUME_NONNULL_BEGIN
@end
/*
* RCTScrollableProtocol is a protocol which RCTScrollViewManager uses to communicate with all kinds of `UIScrollView`s.
* Until Fabric has own command-execution pipeline we have to support that to some extent. The implementation shouldn't
* be perfect though because very soon we will migrate that to the new commands infra and get rid of this.
*/
@interface RCTScrollViewComponentView (ScrollableProtocol) <RCTScrollableProtocol>
@end
NS_ASSUME_NONNULL_END
@@ -218,3 +218,42 @@ using namespace facebook::react;
}
@end
@implementation RCTScrollViewComponentView (ScrollableProtocol)
- (CGSize)contentSize
{
return _contentSize;
}
- (void)scrollToOffset:(CGPoint)offset
{
[self scrollToOffset:offset animated:YES];
}
- (void)scrollToOffset:(CGPoint)offset animated:(BOOL)animated
{
[self.scrollView setContentOffset:offset animated:animated];
}
- (void)scrollToEnd:(BOOL)animated
{
// Not implemented.
}
- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated
{
// Not implemented.
}
- (void)addScrollListener:(NSObject<UIScrollViewDelegate> *)scrollListener
{
[self.scrollViewDelegateSplitter addDelegate:scrollListener];
}
- (void)removeScrollListener:(NSObject<UIScrollViewDelegate> *)scrollListener
{
[self.scrollViewDelegateSplitter removeDelegate:scrollListener];
}
@end