mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 20:01:01 +08:00
Remove scrollview support from UIManager, remove mainScrollView(delegate)
Reviewed By: nicklockwood Differential Revision: D2692749 fb-gh-sync-id: 48975d2f09f3b2902dfa2e56ff9d34257b2395bc
This commit is contained in:
committed by
facebook-github-bot-5
parent
fc5a8678d3
commit
38db6fa465
@@ -44,19 +44,6 @@ RCT_EXTERN NSString *const RCTUIManagerRootViewKey;
|
||||
*/
|
||||
@interface RCTUIManager : NSObject <RCTBridgeModule, RCTInvalidating>
|
||||
|
||||
/**
|
||||
* The UIIManager has the concept of a designated "main scroll view", which is
|
||||
* useful for apps built around a central scrolling content area (e.g. a
|
||||
* timeline).
|
||||
*/
|
||||
@property (nonatomic, weak) id<RCTScrollableProtocol> mainScrollView;
|
||||
|
||||
/**
|
||||
* Allows native environment code to respond to "the main scroll view" events.
|
||||
* see `RCTUIManager`'s `setMainScrollViewTag`.
|
||||
*/
|
||||
@property (nonatomic, readwrite, weak) id<UIScrollViewDelegate> nativeMainScrollDelegate;
|
||||
|
||||
/**
|
||||
* Register a root view with the RCTUIManager.
|
||||
*/
|
||||
|
||||
@@ -1095,73 +1095,6 @@ RCT_EXPORT_METHOD(measureViewsInRect:(CGRect)rect
|
||||
callback(@[results]);
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(setMainScrollViewTag:(nonnull NSNumber *)reactTag)
|
||||
{
|
||||
[self addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
// - There should be at most one designated "main scroll view"
|
||||
// - There should be at most one designated "`nativeMainScrollDelegate`"
|
||||
// - The one designated main scroll view should have the one designated
|
||||
// `nativeMainScrollDelegate` set as its `nativeMainScrollDelegate`.
|
||||
if (uiManager.mainScrollView) {
|
||||
uiManager.mainScrollView.nativeMainScrollDelegate = nil;
|
||||
}
|
||||
id view = viewRegistry[reactTag];
|
||||
if (view) {
|
||||
if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) {
|
||||
uiManager.mainScrollView = (id<RCTScrollableProtocol>)view;
|
||||
uiManager.mainScrollView.nativeMainScrollDelegate = uiManager.nativeMainScrollDelegate;
|
||||
} else {
|
||||
RCTLogError(@"Tag #%@ does not conform to RCTScrollableProtocol", reactTag);
|
||||
}
|
||||
} else {
|
||||
uiManager.mainScrollView = nil;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
// TODO: we could just pass point property
|
||||
RCT_EXPORT_METHOD(scrollTo:(nonnull NSNumber *)reactTag
|
||||
withOffsetX:(CGFloat)offsetX
|
||||
offsetY:(CGFloat)offsetY)
|
||||
{
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry){
|
||||
UIView *view = viewRegistry[reactTag];
|
||||
if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) {
|
||||
[(id<RCTScrollableProtocol>)view scrollToOffset:(CGPoint){offsetX, offsetY} animated:YES];
|
||||
} else {
|
||||
RCTLogError(@"tried to scrollToOffset: on non-RCTScrollableProtocol view %@ with tag #%@", view, reactTag);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
// TODO: we could just pass point property
|
||||
RCT_EXPORT_METHOD(scrollWithoutAnimationTo:(nonnull NSNumber *)reactTag
|
||||
offsetX:(CGFloat)offsetX
|
||||
offsetY:(CGFloat)offsetY)
|
||||
{
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry){
|
||||
UIView *view = viewRegistry[reactTag];
|
||||
if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) {
|
||||
[(id<RCTScrollableProtocol>)view scrollToOffset:(CGPoint){offsetX, offsetY} animated:NO];
|
||||
} else {
|
||||
RCTLogError(@"tried to scrollToOffset: on non-RCTScrollableProtocol view %@ with tag #%@", view, reactTag);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(zoomToRect:(nonnull NSNumber *)reactTag
|
||||
withRect:(CGRect)rect)
|
||||
{
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry){
|
||||
UIView *view = viewRegistry[reactTag];
|
||||
if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) {
|
||||
[(id<RCTScrollableProtocol>)view zoomToRect:rect animated:YES];
|
||||
} else {
|
||||
RCTLogError(@"tried to zoomToRect: on non-RCTScrollableProtocol view %@ with tag #%@", view, reactTag);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
/**
|
||||
* JS sets what *it* considers to be the responder. Later, scroll views can use
|
||||
* this in order to determine if scrolling is appropriate.
|
||||
|
||||
Reference in New Issue
Block a user