From ba627f4970ea558a064689df3ebfdb34467a1c39 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Fri, 24 May 2019 19:11:45 -0700 Subject: [PATCH] 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 --- .../ScrollView/RCTScrollViewComponentView.h | 10 +++++ .../ScrollView/RCTScrollViewComponentView.mm | 39 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h index b476ead4289..ace64fe6f02 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h @@ -7,6 +7,7 @@ #import +#import #import #import @@ -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) + +@end + NS_ASSUME_NONNULL_END diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index 87350b07b8e..5ed4ed9e218 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -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 *)scrollListener +{ + [self.scrollViewDelegateSplitter addDelegate:scrollListener]; +} + +- (void)removeScrollListener:(NSObject *)scrollListener +{ + [self.scrollViewDelegateSplitter removeDelegate:scrollListener]; +} + +@end