yeet
This commit is contained in:
14
node_modules/react-native/React/Views/ScrollView/RCTScrollContentShadowView.h
generated
vendored
Normal file
14
node_modules/react-native/React/Views/ScrollView/RCTScrollContentShadowView.h
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <React/RCTShadowView.h>
|
||||
|
||||
@interface RCTScrollContentShadowView : RCTShadowView
|
||||
|
||||
@end
|
31
node_modules/react-native/React/Views/ScrollView/RCTScrollContentShadowView.m
generated
vendored
Normal file
31
node_modules/react-native/React/Views/ScrollView/RCTScrollContentShadowView.m
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTScrollContentShadowView.h"
|
||||
|
||||
#import <yoga/Yoga.h>
|
||||
|
||||
#import "RCTUtils.h"
|
||||
|
||||
@implementation RCTScrollContentShadowView
|
||||
|
||||
- (void)layoutWithMetrics:(RCTLayoutMetrics)layoutMetrics layoutContext:(RCTLayoutContext)layoutContext
|
||||
{
|
||||
if (layoutMetrics.layoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) {
|
||||
// Motivation:
|
||||
// Yoga place `contentView` on the right side of `scrollView` when RTL layout is enforced.
|
||||
// That breaks everything; it is completely pointless to (re)position `contentView`
|
||||
// because it is `contentView`'s job. So, we work around it here.
|
||||
|
||||
layoutContext.absolutePosition.x += layoutMetrics.frame.size.width;
|
||||
layoutMetrics.frame.origin.x = 0;
|
||||
}
|
||||
|
||||
[super layoutWithMetrics:layoutMetrics layoutContext:layoutContext];
|
||||
}
|
||||
|
||||
@end
|
14
node_modules/react-native/React/Views/ScrollView/RCTScrollContentView.h
generated
vendored
Normal file
14
node_modules/react-native/React/Views/ScrollView/RCTScrollContentView.h
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <React/RCTView.h>
|
||||
|
||||
@interface RCTScrollContentView : RCTView
|
||||
|
||||
@end
|
32
node_modules/react-native/React/Views/ScrollView/RCTScrollContentView.m
generated
vendored
Normal file
32
node_modules/react-native/React/Views/ScrollView/RCTScrollContentView.m
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTScrollContentView.h"
|
||||
|
||||
#import <React/RCTAssert.h>
|
||||
#import <React/UIView+React.h>
|
||||
|
||||
#import "RCTScrollView.h"
|
||||
|
||||
@implementation RCTScrollContentView
|
||||
|
||||
- (void)reactSetFrame:(CGRect)frame
|
||||
{
|
||||
[super reactSetFrame:frame];
|
||||
|
||||
RCTScrollView *scrollView = (RCTScrollView *)self.superview.superview;
|
||||
|
||||
if (!scrollView) {
|
||||
return;
|
||||
}
|
||||
|
||||
RCTAssert([scrollView isKindOfClass:[RCTScrollView class]], @"Unexpected view hierarchy of RCTScrollView component.");
|
||||
|
||||
[scrollView updateContentOffsetIfNeeded];
|
||||
}
|
||||
|
||||
@end
|
12
node_modules/react-native/React/Views/ScrollView/RCTScrollContentViewManager.h
generated
vendored
Normal file
12
node_modules/react-native/React/Views/ScrollView/RCTScrollContentViewManager.h
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <React/RCTViewManager.h>
|
||||
|
||||
@interface RCTScrollContentViewManager : RCTViewManager
|
||||
|
||||
@end
|
27
node_modules/react-native/React/Views/ScrollView/RCTScrollContentViewManager.m
generated
vendored
Normal file
27
node_modules/react-native/React/Views/ScrollView/RCTScrollContentViewManager.m
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTScrollContentViewManager.h"
|
||||
|
||||
#import "RCTScrollContentShadowView.h"
|
||||
#import "RCTScrollContentView.h"
|
||||
|
||||
@implementation RCTScrollContentViewManager
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
- (RCTScrollContentView *)view
|
||||
{
|
||||
return [RCTScrollContentView new];
|
||||
}
|
||||
|
||||
- (RCTShadowView *)shadowView
|
||||
{
|
||||
return [RCTScrollContentShadowView new];
|
||||
}
|
||||
|
||||
@end
|
23
node_modules/react-native/React/Views/ScrollView/RCTScrollEvent.h
generated
vendored
Normal file
23
node_modules/react-native/React/Views/ScrollView/RCTScrollEvent.h
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <React/RCTEventDispatcher.h>
|
||||
|
||||
@interface RCTScrollEvent : NSObject <RCTEvent>
|
||||
|
||||
- (instancetype)initWithEventName:(NSString *)eventName
|
||||
reactTag:(NSNumber *)reactTag
|
||||
scrollViewContentOffset:(CGPoint)scrollViewContentOffset
|
||||
scrollViewContentInset:(UIEdgeInsets)scrollViewContentInset
|
||||
scrollViewContentSize:(CGSize)scrollViewContentSize
|
||||
scrollViewFrame:(CGRect)scrollViewFrame
|
||||
scrollViewZoomScale:(CGFloat)scrollViewZoomScale
|
||||
userData:(NSDictionary *)userData
|
||||
coalescingKey:(uint16_t)coalescingKey NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
109
node_modules/react-native/React/Views/ScrollView/RCTScrollEvent.m
generated
vendored
Normal file
109
node_modules/react-native/React/Views/ScrollView/RCTScrollEvent.m
generated
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTScrollEvent.h"
|
||||
#import <React/RCTAssert.h>
|
||||
|
||||
@implementation RCTScrollEvent {
|
||||
CGPoint _scrollViewContentOffset;
|
||||
UIEdgeInsets _scrollViewContentInset;
|
||||
CGSize _scrollViewContentSize;
|
||||
CGRect _scrollViewFrame;
|
||||
CGFloat _scrollViewZoomScale;
|
||||
NSDictionary *_userData;
|
||||
uint16_t _coalescingKey;
|
||||
}
|
||||
|
||||
@synthesize viewTag = _viewTag;
|
||||
@synthesize eventName = _eventName;
|
||||
|
||||
- (instancetype)initWithEventName:(NSString *)eventName
|
||||
reactTag:(NSNumber *)reactTag
|
||||
scrollViewContentOffset:(CGPoint)scrollViewContentOffset
|
||||
scrollViewContentInset:(UIEdgeInsets)scrollViewContentInset
|
||||
scrollViewContentSize:(CGSize)scrollViewContentSize
|
||||
scrollViewFrame:(CGRect)scrollViewFrame
|
||||
scrollViewZoomScale:(CGFloat)scrollViewZoomScale
|
||||
userData:(NSDictionary *)userData
|
||||
coalescingKey:(uint16_t)coalescingKey
|
||||
{
|
||||
RCTAssertParam(reactTag);
|
||||
|
||||
if ((self = [super init])) {
|
||||
_eventName = [eventName copy];
|
||||
_viewTag = reactTag;
|
||||
_scrollViewContentOffset = scrollViewContentOffset;
|
||||
_scrollViewContentInset = scrollViewContentInset;
|
||||
_scrollViewContentSize = scrollViewContentSize;
|
||||
_scrollViewFrame = scrollViewFrame;
|
||||
_scrollViewZoomScale = scrollViewZoomScale;
|
||||
_userData = userData;
|
||||
_coalescingKey = coalescingKey;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
|
||||
- (uint16_t)coalescingKey
|
||||
{
|
||||
return _coalescingKey;
|
||||
}
|
||||
|
||||
- (NSDictionary *)body
|
||||
{
|
||||
NSDictionary *body = @{
|
||||
@"contentOffset" : @{@"x" : @(_scrollViewContentOffset.x), @"y" : @(_scrollViewContentOffset.y)},
|
||||
@"contentInset" : @{
|
||||
@"top" : @(_scrollViewContentInset.top),
|
||||
@"left" : @(_scrollViewContentInset.left),
|
||||
@"bottom" : @(_scrollViewContentInset.bottom),
|
||||
@"right" : @(_scrollViewContentInset.right)
|
||||
},
|
||||
@"contentSize" : @{@"width" : @(_scrollViewContentSize.width), @"height" : @(_scrollViewContentSize.height)},
|
||||
@"layoutMeasurement" : @{@"width" : @(_scrollViewFrame.size.width), @"height" : @(_scrollViewFrame.size.height)},
|
||||
@"zoomScale" : @(_scrollViewZoomScale ?: 1),
|
||||
};
|
||||
|
||||
if (_userData) {
|
||||
NSMutableDictionary *mutableBody = [body mutableCopy];
|
||||
[mutableBody addEntriesFromDictionary:_userData];
|
||||
body = mutableBody;
|
||||
}
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
- (BOOL)canCoalesce
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (RCTScrollEvent *)coalesceWithEvent:(RCTScrollEvent *)newEvent
|
||||
{
|
||||
NSArray<NSDictionary *> *updatedChildFrames =
|
||||
[_userData[@"updatedChildFrames"] arrayByAddingObjectsFromArray:newEvent->_userData[@"updatedChildFrames"]];
|
||||
if (updatedChildFrames) {
|
||||
NSMutableDictionary *userData = [newEvent->_userData mutableCopy];
|
||||
userData[@"updatedChildFrames"] = updatedChildFrames;
|
||||
newEvent->_userData = userData;
|
||||
}
|
||||
|
||||
return newEvent;
|
||||
}
|
||||
|
||||
+ (NSString *)moduleDotMethod
|
||||
{
|
||||
return @"RCTEventEmitter.receiveEvent";
|
||||
}
|
||||
|
||||
- (NSArray *)arguments
|
||||
{
|
||||
return @[ self.viewTag, RCTNormalizeInputEventName(self.eventName), [self body] ];
|
||||
}
|
||||
|
||||
@end
|
81
node_modules/react-native/React/Views/ScrollView/RCTScrollView.h
generated
vendored
Normal file
81
node_modules/react-native/React/Views/ScrollView/RCTScrollView.h
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIScrollView.h>
|
||||
|
||||
#import <React/RCTAutoInsetsProtocol.h>
|
||||
#import <React/RCTEventDispatcher.h>
|
||||
#import <React/RCTScrollableProtocol.h>
|
||||
#import <React/RCTView.h>
|
||||
|
||||
@protocol UIScrollViewDelegate;
|
||||
|
||||
@interface RCTScrollView : RCTView <UIScrollViewDelegate, RCTScrollableProtocol, RCTAutoInsetsProtocol>
|
||||
|
||||
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
* The `RCTScrollView` may have at most one single subview. This will ensure
|
||||
* that the scroll view's `contentSize` will be efficiently set to the size of
|
||||
* the single subview's frame. That frame size will be determined somewhat
|
||||
* efficiently since it will have already been computed by the off-main-thread
|
||||
* layout system.
|
||||
*/
|
||||
@property (nonatomic, readonly) UIView *contentView;
|
||||
|
||||
/**
|
||||
* If the `contentSize` is not specified (or is specified as {0, 0}, then the
|
||||
* `contentSize` will automatically be determined by the size of the subview.
|
||||
*/
|
||||
@property (nonatomic, assign) CGSize contentSize;
|
||||
|
||||
/**
|
||||
* The underlying scrollView (TODO: can we remove this?)
|
||||
*/
|
||||
@property (nonatomic, readonly) UIScrollView *scrollView;
|
||||
|
||||
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
||||
@property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
|
||||
@property (nonatomic, assign) BOOL DEPRECATED_sendUpdatedChildFrames;
|
||||
@property (nonatomic, assign) NSTimeInterval scrollEventThrottle;
|
||||
@property (nonatomic, assign) BOOL centerContent;
|
||||
@property (nonatomic, copy) NSDictionary *maintainVisibleContentPosition;
|
||||
@property (nonatomic, assign) BOOL scrollToOverflowEnabled;
|
||||
@property (nonatomic, assign) int snapToInterval;
|
||||
@property (nonatomic, assign) BOOL disableIntervalMomentum;
|
||||
@property (nonatomic, copy) NSArray<NSNumber *> *snapToOffsets;
|
||||
@property (nonatomic, assign) BOOL snapToStart;
|
||||
@property (nonatomic, assign) BOOL snapToEnd;
|
||||
@property (nonatomic, copy) NSString *snapToAlignment;
|
||||
@property (nonatomic, assign) BOOL inverted;
|
||||
|
||||
// NOTE: currently these event props are only declared so we can export the
|
||||
// event names to JS - we don't call the blocks directly because scroll events
|
||||
// need to be coalesced before sending, for performance reasons.
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onScrollBeginDrag;
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onScroll;
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onScrollToTop;
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onScrollEndDrag;
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onMomentumScrollBegin;
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onMomentumScrollEnd;
|
||||
|
||||
@end
|
||||
|
||||
@interface RCTScrollView (Internal)
|
||||
|
||||
- (void)updateContentOffsetIfNeeded;
|
||||
|
||||
@end
|
||||
|
||||
@interface RCTEventDispatcher (RCTScrollView)
|
||||
|
||||
/**
|
||||
* Send a fake scroll event.
|
||||
*/
|
||||
- (void)sendFakeScrollEvent:(NSNumber *)reactTag;
|
||||
|
||||
@end
|
1087
node_modules/react-native/React/Views/ScrollView/RCTScrollView.m
generated
vendored
Normal file
1087
node_modules/react-native/React/Views/ScrollView/RCTScrollView.m
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
19
node_modules/react-native/React/Views/ScrollView/RCTScrollViewManager.h
generated
vendored
Normal file
19
node_modules/react-native/React/Views/ScrollView/RCTScrollViewManager.h
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <React/RCTConvert.h>
|
||||
#import <React/RCTViewManager.h>
|
||||
|
||||
@interface RCTConvert (UIScrollView)
|
||||
|
||||
+ (UIScrollViewKeyboardDismissMode)UIScrollViewKeyboardDismissMode:(id)json;
|
||||
|
||||
@end
|
||||
|
||||
@interface RCTScrollViewManager : RCTViewManager
|
||||
|
||||
@end
|
230
node_modules/react-native/React/Views/ScrollView/RCTScrollViewManager.m
generated
vendored
Normal file
230
node_modules/react-native/React/Views/ScrollView/RCTScrollViewManager.m
generated
vendored
Normal file
@ -0,0 +1,230 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTScrollViewManager.h"
|
||||
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTScrollView.h"
|
||||
#import "RCTShadowView.h"
|
||||
#import "RCTUIManager.h"
|
||||
|
||||
@interface RCTScrollView (Private)
|
||||
|
||||
- (NSArray<NSDictionary *> *)calculateChildFramesData;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTConvert (UIScrollView)
|
||||
|
||||
RCT_ENUM_CONVERTER(
|
||||
UIScrollViewKeyboardDismissMode,
|
||||
(@{
|
||||
@"none" : @(UIScrollViewKeyboardDismissModeNone),
|
||||
@"on-drag" : @(UIScrollViewKeyboardDismissModeOnDrag),
|
||||
@"interactive" : @(UIScrollViewKeyboardDismissModeInteractive),
|
||||
// Backwards compatibility
|
||||
@"onDrag" : @(UIScrollViewKeyboardDismissModeOnDrag),
|
||||
}),
|
||||
UIScrollViewKeyboardDismissModeNone,
|
||||
integerValue)
|
||||
|
||||
RCT_ENUM_CONVERTER(
|
||||
UIScrollViewIndicatorStyle,
|
||||
(@{
|
||||
@"default" : @(UIScrollViewIndicatorStyleDefault),
|
||||
@"black" : @(UIScrollViewIndicatorStyleBlack),
|
||||
@"white" : @(UIScrollViewIndicatorStyleWhite),
|
||||
}),
|
||||
UIScrollViewIndicatorStyleDefault,
|
||||
integerValue)
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
|
||||
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
|
||||
RCT_ENUM_CONVERTER(
|
||||
UIScrollViewContentInsetAdjustmentBehavior,
|
||||
(@{
|
||||
@"automatic" : @(UIScrollViewContentInsetAdjustmentAutomatic),
|
||||
@"scrollableAxes" : @(UIScrollViewContentInsetAdjustmentScrollableAxes),
|
||||
@"never" : @(UIScrollViewContentInsetAdjustmentNever),
|
||||
@"always" : @(UIScrollViewContentInsetAdjustmentAlways),
|
||||
}),
|
||||
UIScrollViewContentInsetAdjustmentNever,
|
||||
integerValue)
|
||||
#endif
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTScrollViewManager
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
- (UIView *)view
|
||||
{
|
||||
return [[RCTScrollView alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
|
||||
}
|
||||
|
||||
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(maintainVisibleContentPosition, NSDictionary)
|
||||
RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(decelerationRate, CGFloat)
|
||||
RCT_EXPORT_VIEW_PROPERTY(directionalLockEnabled, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(indicatorStyle, UIScrollViewIndicatorStyle)
|
||||
RCT_EXPORT_VIEW_PROPERTY(keyboardDismissMode, UIScrollViewKeyboardDismissMode)
|
||||
RCT_EXPORT_VIEW_PROPERTY(maximumZoomScale, CGFloat)
|
||||
RCT_EXPORT_VIEW_PROPERTY(minimumZoomScale, CGFloat)
|
||||
RCT_EXPORT_VIEW_PROPERTY(scrollEnabled, BOOL)
|
||||
#if !TARGET_OS_TV
|
||||
RCT_EXPORT_VIEW_PROPERTY(pagingEnabled, BOOL)
|
||||
RCT_REMAP_VIEW_PROPERTY(pinchGestureEnabled, scrollView.pinchGestureEnabled, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(scrollsToTop, BOOL)
|
||||
#endif
|
||||
RCT_EXPORT_VIEW_PROPERTY(showsHorizontalScrollIndicator, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(showsVerticalScrollIndicator, BOOL)
|
||||
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_EXPORT_VIEW_PROPERTY(scrollToOverflowEnabled, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(snapToInterval, int)
|
||||
RCT_EXPORT_VIEW_PROPERTY(disableIntervalMomentum, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(snapToOffsets, NSArray<NSNumber *>)
|
||||
RCT_EXPORT_VIEW_PROPERTY(snapToStart, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(snapToEnd, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(snapToAlignment, NSString)
|
||||
RCT_REMAP_VIEW_PROPERTY(contentOffset, scrollView.contentOffset, CGPoint)
|
||||
RCT_EXPORT_VIEW_PROPERTY(onScrollBeginDrag, RCTDirectEventBlock)
|
||||
RCT_EXPORT_VIEW_PROPERTY(onScroll, RCTDirectEventBlock)
|
||||
RCT_EXPORT_VIEW_PROPERTY(onScrollToTop, RCTDirectEventBlock)
|
||||
RCT_EXPORT_VIEW_PROPERTY(onScrollEndDrag, RCTDirectEventBlock)
|
||||
RCT_EXPORT_VIEW_PROPERTY(onMomentumScrollBegin, RCTDirectEventBlock)
|
||||
RCT_EXPORT_VIEW_PROPERTY(onMomentumScrollEnd, RCTDirectEventBlock)
|
||||
RCT_EXPORT_VIEW_PROPERTY(DEPRECATED_sendUpdatedChildFrames, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(inverted, BOOL)
|
||||
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
|
||||
RCT_EXPORT_VIEW_PROPERTY(contentInsetAdjustmentBehavior, UIScrollViewContentInsetAdjustmentBehavior)
|
||||
#endif
|
||||
|
||||
// overflow is used both in css-layout as well as by react-native. In css-layout
|
||||
// we always want to treat overflow as scroll but depending on what the overflow
|
||||
// is set to from js we want to clip drawing or not. This piece of code ensures
|
||||
// that css-layout is always treating the contents of a scroll container as
|
||||
// overflow: 'scroll'.
|
||||
RCT_CUSTOM_SHADOW_PROPERTY(overflow, YGOverflow, RCTShadowView)
|
||||
{
|
||||
#pragma unused(json)
|
||||
view.overflow = YGOverflowScroll;
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(getContentSize : (nonnull NSNumber *)reactTag callback : (RCTResponseSenderBlock)callback)
|
||||
{
|
||||
[self.bridge.uiManager
|
||||
addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTScrollView *> *viewRegistry) {
|
||||
RCTScrollView *view = viewRegistry[reactTag];
|
||||
if (!view || ![view isKindOfClass:[RCTScrollView class]]) {
|
||||
RCTLogError(@"Cannot find RCTScrollView with tag #%@", reactTag);
|
||||
return;
|
||||
}
|
||||
|
||||
CGSize size = view.scrollView.contentSize;
|
||||
callback(@[ @{@"width" : @(size.width), @"height" : @(size.height)} ]);
|
||||
}];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(calculateChildFrames : (nonnull NSNumber *)reactTag callback : (RCTResponseSenderBlock)callback)
|
||||
{
|
||||
[self.bridge.uiManager
|
||||
addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTScrollView *> *viewRegistry) {
|
||||
RCTScrollView *view = viewRegistry[reactTag];
|
||||
if (!view || ![view isKindOfClass:[RCTScrollView class]]) {
|
||||
RCTLogError(@"Cannot find RCTScrollView with tag #%@", reactTag);
|
||||
return;
|
||||
}
|
||||
|
||||
NSArray<NSDictionary *> *childFrames = [view calculateChildFramesData];
|
||||
if (childFrames) {
|
||||
callback(@[ childFrames ]);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(scrollTo
|
||||
: (nonnull NSNumber *)reactTag offsetX
|
||||
: (CGFloat)x offsetY
|
||||
: (CGFloat)y animated
|
||||
: (BOOL)animated)
|
||||
{
|
||||
[self.bridge.uiManager
|
||||
addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
UIView *view = viewRegistry[reactTag];
|
||||
if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) {
|
||||
[(id<RCTScrollableProtocol>)view scrollToOffset:(CGPoint){x, y} animated:animated];
|
||||
} else {
|
||||
RCTLogError(
|
||||
@"tried to scrollTo: on non-RCTScrollableProtocol view %@ "
|
||||
"with tag #%@",
|
||||
view,
|
||||
reactTag);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(scrollToEnd : (nonnull NSNumber *)reactTag animated : (BOOL)animated)
|
||||
{
|
||||
[self.bridge.uiManager
|
||||
addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
UIView *view = viewRegistry[reactTag];
|
||||
if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) {
|
||||
[(id<RCTScrollableProtocol>)view scrollToEnd:animated];
|
||||
} else {
|
||||
RCTLogError(
|
||||
@"tried to scrollTo: on non-RCTScrollableProtocol view %@ "
|
||||
"with tag #%@",
|
||||
view,
|
||||
reactTag);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(zoomToRect : (nonnull NSNumber *)reactTag withRect : (CGRect)rect animated : (BOOL)animated)
|
||||
{
|
||||
[self.bridge.uiManager
|
||||
addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
UIView *view = viewRegistry[reactTag];
|
||||
if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) {
|
||||
[(id<RCTScrollableProtocol>)view zoomToRect:rect animated:animated];
|
||||
} else {
|
||||
RCTLogError(
|
||||
@"tried to zoomToRect: on non-RCTScrollableProtocol view %@ "
|
||||
"with tag #%@",
|
||||
view,
|
||||
reactTag);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(flashScrollIndicators : (nonnull NSNumber *)reactTag)
|
||||
{
|
||||
[self.bridge.uiManager
|
||||
addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTScrollView *> *viewRegistry) {
|
||||
RCTScrollView *view = viewRegistry[reactTag];
|
||||
if (!view || ![view isKindOfClass:[RCTScrollView class]]) {
|
||||
RCTLogError(@"Cannot find RCTScrollView with tag #%@", reactTag);
|
||||
return;
|
||||
}
|
||||
|
||||
[view.scrollView flashScrollIndicators];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
41
node_modules/react-native/React/Views/ScrollView/RCTScrollableProtocol.h
generated
vendored
Normal file
41
node_modules/react-native/React/Views/ScrollView/RCTScrollableProtocol.h
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <React/RCTComponent.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
/**
|
||||
* Contains any methods related to scrolling. Any `RCTView` that has scrolling
|
||||
* features should implement these methods.
|
||||
*/
|
||||
@protocol RCTScrollableProtocol
|
||||
|
||||
@property (nonatomic, readonly) CGSize contentSize;
|
||||
|
||||
- (void)scrollToOffset:(CGPoint)offset;
|
||||
- (void)scrollToOffset:(CGPoint)offset animated:(BOOL)animated;
|
||||
/**
|
||||
* If this is a vertical scroll view, scrolls to the bottom.
|
||||
* If this is a horizontal scroll view, scrolls to the right.
|
||||
*/
|
||||
- (void)scrollToEnd:(BOOL)animated;
|
||||
- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated;
|
||||
|
||||
- (void)addScrollListener:(NSObject<UIScrollViewDelegate> *)scrollListener;
|
||||
- (void)removeScrollListener:(NSObject<UIScrollViewDelegate> *)scrollListener;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Denotes a view which implements custom pull to refresh functionality.
|
||||
*/
|
||||
@protocol RCTCustomRefreshContolProtocol
|
||||
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onRefresh;
|
||||
@property (nonatomic, readonly, getter=isRefreshing) BOOL refreshing;
|
||||
|
||||
@end
|
Reference in New Issue
Block a user