2015-03-23 20:28:42 +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-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
#import "RCTScrollViewManager.h"
|
|
|
|
|
2015-03-06 00:36:41 +00:00
|
|
|
#import "RCTBridge.h"
|
2015-02-20 04:10:52 +00:00
|
|
|
#import "RCTConvert.h"
|
|
|
|
#import "RCTScrollView.h"
|
2015-03-11 02:03:59 +00:00
|
|
|
#import "RCTSparseArray.h"
|
|
|
|
#import "RCTUIManager.h"
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
@implementation RCTScrollViewManager
|
|
|
|
|
2015-04-08 12:42:43 +00:00
|
|
|
RCT_EXPORT_MODULE()
|
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
- (UIView *)view
|
|
|
|
{
|
2015-03-06 00:36:41 +00:00
|
|
|
return [[RCTScrollView alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 04:29:28 +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-05-06 17:46:45 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(stickyHeaderIndices, NSIndexSet)
|
2015-03-30 11:58:02 +00:00
|
|
|
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-02-20 04:10:52 +00:00
|
|
|
|
2015-03-01 23:33:55 +00:00
|
|
|
- (NSDictionary *)constantsToExport
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
2015-03-01 23:33:55 +00:00
|
|
|
return @{
|
2015-02-20 04:10:52 +00:00
|
|
|
@"DecelerationRate": @{
|
2015-03-01 23:33:55 +00:00
|
|
|
@"Normal": @(UIScrollViewDecelerationRateNormal),
|
|
|
|
@"Fast": @(UIScrollViewDecelerationRateFast),
|
2015-02-20 04:10:52 +00:00
|
|
|
},
|
|
|
|
@"KeyboardDismissMode": @{
|
2015-03-01 23:33:55 +00:00
|
|
|
@"None": @(UIScrollViewKeyboardDismissModeNone),
|
|
|
|
@"Interactive": @(UIScrollViewKeyboardDismissModeInteractive),
|
|
|
|
@"OnDrag": @(UIScrollViewKeyboardDismissModeOnDrag),
|
2015-02-20 04:10:52 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-04-08 15:52:48 +00:00
|
|
|
RCT_EXPORT_METHOD(getContentSize:(NSNumber *)reactTag
|
|
|
|
callback:(RCTResponseSenderBlock)callback)
|
2015-03-11 02:03:59 +00:00
|
|
|
{
|
|
|
|
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
|
|
|
|
|
|
|
UIView *view = viewRegistry[reactTag];
|
|
|
|
if (!view) {
|
2015-04-07 14:36:26 +00:00
|
|
|
RCTLogError(@"Cannot find view with tag #%@", reactTag);
|
2015-03-11 02:03:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-22 20:54:43 +00:00
|
|
|
CGSize size = ((RCTScrollView *)view).scrollView.contentSize;
|
2015-03-11 02:03:59 +00:00
|
|
|
callback(@[@{
|
|
|
|
@"width" : @(size.width),
|
|
|
|
@"height" : @(size.height)
|
|
|
|
}]);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
@end
|