mirror of
https://github.com/status-im/react-native.git
synced 2025-01-16 20:44:10 +00:00
46c02b6ae5
Summary: This diff refactors the view update process into two stages: 1. The `reactSubviews` array is set, whose order matches the order of the JS components and shadowView components, as specified by the UIManager. 2. The `didUpdateReactSubviews` method is called, which actually inserts the reactSubviews into the view hierarchy. This simplifies a lot of the hacks we had for special-case treatment of subviews: In many cases we don't want to actually insert `reactSubviews` into the parentView, and we had a bunch of component-specific solutions for that (typically overriding all of the reactSubviews methods to store views in an array). Now, we can simply override the `didUpdateReactSubviews` method for those views to do nothing, or do something different. Reviewed By: wwjholmes Differential Revision: D3396594 fbshipit-source-id: 92fc56fd31db0cfc66aac3d1634a4d4ae3903085
64 lines
1.9 KiB
Objective-C
64 lines
1.9 KiB
Objective-C
/**
|
|
* 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.
|
|
*/
|
|
|
|
#import <CoreGraphics/CoreGraphics.h>
|
|
|
|
/**
|
|
* These block types can be used for mapping input event handlers from JS to view
|
|
* properties. Unlike JS method callbacks, these can be called multiple times.
|
|
*/
|
|
typedef void (^RCTDirectEventBlock)(NSDictionary *body);
|
|
typedef void (^RCTBubblingEventBlock)(NSDictionary *body);
|
|
|
|
/**
|
|
* Logical node in a tree of application components. Both `ShadowView` and
|
|
* `UIView` conforms to this. Allows us to write utilities that reason about
|
|
* trees generally.
|
|
*/
|
|
@protocol RCTComponent <NSObject>
|
|
|
|
@property (nonatomic, copy) NSNumber *reactTag;
|
|
|
|
- (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex;
|
|
- (void)removeReactSubview:(id<RCTComponent>)subview;
|
|
- (NSArray<id<RCTComponent>> *)reactSubviews;
|
|
- (id<RCTComponent>)reactSuperview;
|
|
- (NSNumber *)reactTagAtPoint:(CGPoint)point;
|
|
|
|
// View/ShadowView is a root view
|
|
- (BOOL)isReactRootView;
|
|
|
|
@optional
|
|
|
|
/**
|
|
* Called each time props have been set.
|
|
* Not all props have to be set - React can set only changed ones.
|
|
* @param changedProps String names of all set props.
|
|
*/
|
|
- (void)didSetProps:(NSArray<NSString *> *)changedProps;
|
|
|
|
/**
|
|
* Called each time subviews have been updated
|
|
*/
|
|
- (void)didUpdateReactSubviews;
|
|
|
|
// TODO: Deprecate this
|
|
// This method is called after layout has been performed for all views known
|
|
// to the RCTViewManager. It is only called on UIViews, not shadow views.
|
|
- (void)reactBridgeDidFinishTransaction;
|
|
|
|
@end
|
|
|
|
// TODO: this is kinda dumb - let's come up with a
|
|
// better way of identifying root React views please!
|
|
static inline BOOL RCTIsReactRootView(NSNumber *reactTag)
|
|
{
|
|
return reactTag.integerValue % 10 == 1;
|
|
}
|