2015-03-23 22:07:33 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
2015-01-30 01:10:49 +00:00
|
|
|
|
|
|
|
#import "RCTScrollViewManager.h"
|
|
|
|
|
2015-03-06 17:54:10 +00:00
|
|
|
#import "RCTBridge.h"
|
2015-01-30 01:10:49 +00:00
|
|
|
#import "RCTConvert.h"
|
|
|
|
#import "RCTScrollView.h"
|
2015-03-11 19:29:36 +00:00
|
|
|
#import "RCTSparseArray.h"
|
|
|
|
#import "RCTUIManager.h"
|
2015-01-30 01:10:49 +00:00
|
|
|
|
|
|
|
@implementation RCTScrollViewManager
|
|
|
|
|
2015-02-04 00:15:20 +00:00
|
|
|
- (UIView *)view
|
2015-01-30 01:10:49 +00:00
|
|
|
{
|
2015-03-06 17:54:10 +00:00
|
|
|
return [[RCTScrollView alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
|
2015-01-30 01:10:49 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 13:32:01 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(alwaysBounceHorizontal, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(alwaysBounceVertical, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(bounces, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(bouncesZoom, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(canCancelContentTouches, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(centerContent, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(decelerationRate, CGFloat)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(directionalLockEnabled, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(keyboardDismissMode, UIScrollViewKeyboardDismissMode)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(maximumZoomScale, CGFloat)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(minimumZoomScale, CGFloat)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(pagingEnabled, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(scrollEnabled, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(scrollsToTop, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(showsHorizontalScrollIndicator, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(showsVerticalScrollIndicator, BOOL)
|
2015-03-31 03:12:32 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(stickyHeaderIndices, NSNumberArray)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(scrollEventThrottle, NSTimeInterval)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(zoomScale, CGFloat)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(scrollIndicatorInsets, UIEdgeInsets)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(contentOffset, scrollView.contentOffset, CGPoint)
|
|
|
|
|
|
|
|
RCT_DEPRECATED_VIEW_PROPERTY(throttleScrollCallbackMS, scrollEventThrottle)
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2015-03-02 19:36:55 +00:00
|
|
|
- (NSDictionary *)constantsToExport
|
2015-01-30 01:10:49 +00:00
|
|
|
{
|
2015-03-02 19:36:55 +00:00
|
|
|
return @{
|
2015-01-30 01:10:49 +00:00
|
|
|
@"DecelerationRate": @{
|
2015-03-02 19:36:55 +00:00
|
|
|
@"Normal": @(UIScrollViewDecelerationRateNormal),
|
|
|
|
@"Fast": @(UIScrollViewDecelerationRateFast),
|
2015-01-30 01:10:49 +00:00
|
|
|
},
|
|
|
|
@"KeyboardDismissMode": @{
|
2015-03-02 19:36:55 +00:00
|
|
|
@"None": @(UIScrollViewKeyboardDismissModeNone),
|
|
|
|
@"Interactive": @(UIScrollViewKeyboardDismissModeInteractive),
|
|
|
|
@"OnDrag": @(UIScrollViewKeyboardDismissModeOnDrag),
|
2015-01-30 01:10:49 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-03-11 19:29:36 +00:00
|
|
|
- (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;
|
|
|
|
}
|
|
|
|
|
2015-03-23 17:06:16 +00:00
|
|
|
CGSize size = ((RCTScrollView *)view).scrollView.contentSize;
|
2015-03-11 19:29:36 +00:00
|
|
|
callback(@[@{
|
|
|
|
@"width" : @(size.width),
|
|
|
|
@"height" : @(size.height)
|
|
|
|
}]);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2015-01-30 01:10:49 +00:00
|
|
|
@end
|