79 lines
2.4 KiB
Objective-C
79 lines
2.4 KiB
Objective-C
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
#import "RCTScrollViewManager.h"
|
|
|
|
#import "RCTBridge.h"
|
|
#import "RCTConvert.h"
|
|
#import "RCTScrollView.h"
|
|
#import "RCTSparseArray.h"
|
|
#import "RCTUIManager.h"
|
|
|
|
@implementation RCTScrollViewManager
|
|
|
|
- (UIView *)view
|
|
{
|
|
return [[RCTScrollView alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
|
|
}
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(alwaysBounceHorizontal)
|
|
RCT_EXPORT_VIEW_PROPERTY(alwaysBounceVertical)
|
|
RCT_EXPORT_VIEW_PROPERTY(bounces)
|
|
RCT_EXPORT_VIEW_PROPERTY(bouncesZoom)
|
|
RCT_EXPORT_VIEW_PROPERTY(canCancelContentTouches)
|
|
RCT_EXPORT_VIEW_PROPERTY(centerContent)
|
|
RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets)
|
|
RCT_EXPORT_VIEW_PROPERTY(decelerationRate)
|
|
RCT_EXPORT_VIEW_PROPERTY(directionalLockEnabled)
|
|
RCT_EXPORT_VIEW_PROPERTY(keyboardDismissMode)
|
|
RCT_EXPORT_VIEW_PROPERTY(maximumZoomScale)
|
|
RCT_EXPORT_VIEW_PROPERTY(minimumZoomScale)
|
|
RCT_EXPORT_VIEW_PROPERTY(pagingEnabled)
|
|
RCT_EXPORT_VIEW_PROPERTY(scrollEnabled)
|
|
RCT_EXPORT_VIEW_PROPERTY(scrollsToTop)
|
|
RCT_EXPORT_VIEW_PROPERTY(showsHorizontalScrollIndicator)
|
|
RCT_EXPORT_VIEW_PROPERTY(showsVerticalScrollIndicator)
|
|
RCT_EXPORT_VIEW_PROPERTY(stickyHeaderIndices);
|
|
RCT_EXPORT_VIEW_PROPERTY(throttleScrollCallbackMS);
|
|
RCT_EXPORT_VIEW_PROPERTY(zoomScale); // TODO: this needs to be set first because it resets other props like contentOffset
|
|
RCT_EXPORT_VIEW_PROPERTY(contentInset);
|
|
RCT_EXPORT_VIEW_PROPERTY(scrollIndicatorInsets);
|
|
RCT_EXPORT_VIEW_PROPERTY(contentOffset);
|
|
|
|
- (NSDictionary *)constantsToExport
|
|
{
|
|
return @{
|
|
@"DecelerationRate": @{
|
|
@"Normal": @(UIScrollViewDecelerationRateNormal),
|
|
@"Fast": @(UIScrollViewDecelerationRateFast),
|
|
},
|
|
@"KeyboardDismissMode": @{
|
|
@"None": @(UIScrollViewKeyboardDismissModeNone),
|
|
@"Interactive": @(UIScrollViewKeyboardDismissModeInteractive),
|
|
@"OnDrag": @(UIScrollViewKeyboardDismissModeOnDrag),
|
|
},
|
|
};
|
|
}
|
|
|
|
- (void)getContentSize:(NSNumber *)reactTag
|
|
callback:(RCTResponseSenderBlock)callback
|
|
{
|
|
RCT_EXPORT();
|
|
|
|
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
|
|
|
UIView *view = viewRegistry[reactTag];
|
|
if (!view) {
|
|
RCTLogError(@"Cannot find view with tag %@", reactTag);
|
|
return;
|
|
}
|
|
|
|
CGSize size = ((id<RCTScrollableProtocol>)view).contentSize;
|
|
callback(@[@{
|
|
@"width" : @(size.width),
|
|
@"height" : @(size.height)
|
|
}]);
|
|
}];
|
|
}
|
|
|
|
@end
|