mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 04:35:36 +08:00
Added lightweight generic annotations
Summary: public Added lightweight genarics annotations to make the code more readable and help the compiler catch bugs. Fixed some type bugs and improved bridge validation in a few places. Reviewed By: javache Differential Revision: D2600189 fb-gh-sync-id: f81e22f2cdc107bf8d0b15deec6d5b83aacc5b56
This commit is contained in:
committed by
facebook-github-bot-7
parent
31565781f2
commit
c5b990f65f
@@ -27,7 +27,7 @@ typedef void (^RCTBubblingEventBlock)(NSDictionary *body);
|
||||
|
||||
- (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex;
|
||||
- (void)removeReactSubview:(id<RCTComponent>)subview;
|
||||
- (NSArray *)reactSubviews;
|
||||
- (NSArray<id<RCTComponent>> *)reactSubviews;
|
||||
- (id<RCTComponent>)reactSuperview;
|
||||
- (NSNumber *)reactTagAtPoint:(CGPoint)point;
|
||||
|
||||
|
||||
@@ -100,7 +100,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
SEL selector = NSSelectorFromString([NSString stringWithFormat:@"propConfig%@_%@", shadowView ? @"Shadow" : @"", name]);
|
||||
Class managerClass = [_manager class];
|
||||
if ([managerClass respondsToSelector:selector]) {
|
||||
NSArray *typeAndKeyPath = ((NSArray *(*)(id, SEL))objc_msgSend)(managerClass, selector);
|
||||
NSArray<NSString *> *typeAndKeyPath =
|
||||
((NSArray<NSString *> *(*)(id, SEL))objc_msgSend)(managerClass, selector);
|
||||
type = NSSelectorFromString([typeAndKeyPath[0] stringByAppendingString:@":"]);
|
||||
keyPath = typeAndKeyPath.count > 1 ? typeAndKeyPath[1] : nil;
|
||||
} else {
|
||||
@@ -125,7 +126,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
|
||||
// Disect keypath
|
||||
NSString *key = name;
|
||||
NSArray *parts = [keyPath componentsSeparatedByString:@"."];
|
||||
NSArray<NSString *> *parts = [keyPath componentsSeparatedByString:@"."];
|
||||
if (parts) {
|
||||
key = parts.lastObject;
|
||||
parts = [parts subarrayWithRange:(NSRange){0, parts.count - 1}];
|
||||
@@ -312,9 +313,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
{
|
||||
Class managerClass = [_manager class];
|
||||
|
||||
NSMutableArray *directEvents = [NSMutableArray new];
|
||||
NSMutableArray<NSString *> *directEvents = [NSMutableArray new];
|
||||
if (RCTClassOverridesInstanceMethod(managerClass, @selector(customDirectEventTypes))) {
|
||||
NSArray *events = [_manager customDirectEventTypes];
|
||||
NSArray<NSString *> *events = [_manager customDirectEventTypes];
|
||||
if (RCT_DEBUG) {
|
||||
RCTAssert(!events || [events isKindOfClass:[NSArray class]],
|
||||
@"customDirectEventTypes must return an array, but %@ returned %@",
|
||||
@@ -325,9 +326,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
}
|
||||
}
|
||||
|
||||
NSMutableArray *bubblingEvents = [NSMutableArray new];
|
||||
NSMutableArray<NSString *> *bubblingEvents = [NSMutableArray new];
|
||||
if (RCTClassOverridesInstanceMethod(managerClass, @selector(customBubblingEventTypes))) {
|
||||
NSArray *events = [_manager customBubblingEventTypes];
|
||||
NSArray<NSString *> *events = [_manager customBubblingEventTypes];
|
||||
if (RCT_DEBUG) {
|
||||
RCTAssert(!events || [events isKindOfClass:[NSArray class]],
|
||||
@"customBubblingEventTypes must return an array, but %@ returned %@",
|
||||
@@ -349,7 +350,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
NSRange nameRange = [methodName rangeOfString:@"_"];
|
||||
if (nameRange.length) {
|
||||
NSString *name = [methodName substringFromIndex:nameRange.location + 1];
|
||||
NSString *type = ((NSArray *(*)(id, SEL))objc_msgSend)(managerClass, selector)[0];
|
||||
NSString *type = ((NSArray<NSString *> *(*)(id, SEL))objc_msgSend)(managerClass, selector)[0];
|
||||
if (RCT_DEBUG && propTypes[name] && ![propTypes[name] isEqualToString:type]) {
|
||||
RCTLogError(@"Property '%@' of component '%@' redefined from '%@' "
|
||||
"to '%@'", name, _name, propTypes[name], type);
|
||||
|
||||
@@ -25,7 +25,7 @@ extern const CGFloat RCTMapZoomBoundBuffer;
|
||||
@property (nonatomic, assign) CGFloat maxDelta;
|
||||
@property (nonatomic, assign) UIEdgeInsets legalLabelInsets;
|
||||
@property (nonatomic, strong) NSTimer *regionChangeObserveTimer;
|
||||
@property (nonatomic, strong) NSMutableArray *annotationIds;
|
||||
@property (nonatomic, copy) NSArray<NSString *> *annotationIds;
|
||||
|
||||
@property (nonatomic, copy) RCTBubblingEventBlock onChange;
|
||||
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
|
||||
|
||||
@@ -109,9 +109,9 @@ const CGFloat RCTMapZoomBoundBuffer = 0.01;
|
||||
|
||||
- (void)setAnnotations:(RCTPointAnnotationArray *)annotations
|
||||
{
|
||||
NSMutableArray *newAnnotationIds = [NSMutableArray new];
|
||||
NSMutableArray *annotationsToDelete = [NSMutableArray new];
|
||||
NSMutableArray *annotationsToAdd = [NSMutableArray new];
|
||||
NSMutableArray<NSString *> *newAnnotationIds = [NSMutableArray new];
|
||||
NSMutableArray<RCTPointAnnotation *> *annotationsToDelete = [NSMutableArray new];
|
||||
NSMutableArray<RCTPointAnnotation *> *annotationsToAdd = [NSMutableArray new];
|
||||
|
||||
for (RCTPointAnnotation *annotation in annotations) {
|
||||
if (![annotation isKindOfClass:[RCTPointAnnotation class]]) {
|
||||
@@ -138,19 +138,19 @@ const CGFloat RCTMapZoomBoundBuffer = 0.01;
|
||||
}
|
||||
|
||||
if (annotationsToDelete.count) {
|
||||
[self removeAnnotations:annotationsToDelete];
|
||||
[self removeAnnotations:(NSArray<id<MKAnnotation>> *)annotationsToDelete];
|
||||
}
|
||||
|
||||
if (annotationsToAdd.count) {
|
||||
[self addAnnotations:annotationsToAdd];
|
||||
[self addAnnotations:(NSArray<id<MKAnnotation>> *)annotationsToAdd];
|
||||
}
|
||||
|
||||
NSMutableArray *newIds = [NSMutableArray new];
|
||||
for (RCTPointAnnotation *anno in self.annotations) {
|
||||
if ([anno isKindOfClass:[MKUserLocation class]]) {
|
||||
NSMutableArray<NSString *> *newIds = [NSMutableArray new];
|
||||
for (RCTPointAnnotation *annotation in self.annotations) {
|
||||
if ([annotation isKindOfClass:[MKUserLocation class]]) {
|
||||
continue;
|
||||
}
|
||||
[newIds addObject:anno.identifier];
|
||||
[newIds addObject:annotation.identifier];
|
||||
}
|
||||
self.annotationIds = newIds;
|
||||
}
|
||||
|
||||
@@ -51,18 +51,18 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:coder)
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)reactSubviews
|
||||
- (NSArray<UIView<RCTComponent> *> *)reactSubviews
|
||||
{
|
||||
return [NSArray arrayWithObjects:_modalViewController.view, nil];
|
||||
return _modalViewController.view ? @[_modalViewController.view] : @[];
|
||||
}
|
||||
|
||||
- (void)insertReactSubview:(UIView *)subview atIndex:(__unused NSInteger)atIndex
|
||||
- (void)insertReactSubview:(UIView<RCTComponent> *)subview atIndex:(__unused NSInteger)atIndex
|
||||
{
|
||||
[subview addGestureRecognizer:_touchHandler];
|
||||
_modalViewController.view = subview;
|
||||
}
|
||||
|
||||
- (void)removeReactSubview:(UIView *)subview
|
||||
- (void)removeReactSubview:(UIView<RCTComponent> *)subview
|
||||
{
|
||||
RCTAssert(subview == _modalViewController.view, @"Cannot remove view other than modal view");
|
||||
_modalViewController.view = nil;
|
||||
|
||||
@@ -200,8 +200,8 @@ NSInteger kNeverProgressed = -10000;
|
||||
|
||||
// Previous views are only mainted in order to detect incorrect
|
||||
// addition/removal of views below the `requestedTopOfStack`
|
||||
@property (nonatomic, copy, readwrite) NSArray *previousViews;
|
||||
@property (nonatomic, readwrite, strong) NSMutableArray *currentViews;
|
||||
@property (nonatomic, copy, readwrite) NSArray<RCTNavItem *> *previousViews;
|
||||
@property (nonatomic, readwrite, strong) NSMutableArray<RCTNavItem *> *currentViews;
|
||||
@property (nonatomic, readwrite, strong) RCTNavigationController *navigationController;
|
||||
/**
|
||||
* Display link is used to get high frequency sample rate during
|
||||
@@ -400,7 +400,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
* `requestedTopOfStack` changes, there had better be enough subviews present
|
||||
* to satisfy the push/pop.
|
||||
*/
|
||||
- (void)insertReactSubview:(UIView *)view atIndex:(NSInteger)atIndex
|
||||
- (void)insertReactSubview:(RCTNavItem *)view atIndex:(NSInteger)atIndex
|
||||
{
|
||||
RCTAssert([view isKindOfClass:[RCTNavItem class]], @"RCTNavigator only accepts RCTNavItem subviews");
|
||||
RCTAssert(
|
||||
@@ -410,7 +410,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
[_currentViews insertObject:view atIndex:atIndex];
|
||||
}
|
||||
|
||||
- (NSArray *)reactSubviews
|
||||
- (NSArray<RCTNavItem *> *)reactSubviews
|
||||
{
|
||||
return _currentViews;
|
||||
}
|
||||
@@ -422,7 +422,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
_navigationController.view.frame = self.bounds;
|
||||
}
|
||||
|
||||
- (void)removeReactSubview:(UIView *)subview
|
||||
- (void)removeReactSubview:(RCTNavItem *)subview
|
||||
{
|
||||
if (_currentViews.count <= 0 || subview == _currentViews[0]) {
|
||||
RCTLogError(@"Attempting to remove invalid RCT subview of RCTNavigator");
|
||||
|
||||
@@ -9,6 +9,12 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "UIView+React.h"
|
||||
|
||||
@interface RCTPicker : UIPickerView
|
||||
|
||||
@property (nonatomic, copy) NSArray<NSDictionary *> *items;
|
||||
@property (nonatomic, assign) NSInteger selectedIndex;
|
||||
@property (nonatomic, copy) RCTBubblingEventBlock onChange;
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,14 +10,8 @@
|
||||
#import "RCTPicker.h"
|
||||
|
||||
#import "RCTUtils.h"
|
||||
#import "UIView+React.h"
|
||||
|
||||
@interface RCTPicker() <UIPickerViewDataSource, UIPickerViewDelegate>
|
||||
|
||||
@property (nonatomic, copy) NSArray *items;
|
||||
@property (nonatomic, assign) NSInteger selectedIndex;
|
||||
@property (nonatomic, copy) RCTBubblingEventBlock onChange;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTPicker
|
||||
@@ -33,7 +27,7 @@
|
||||
|
||||
RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
|
||||
- (void)setItems:(NSArray *)items
|
||||
- (void)setItems:(NSArray<NSDictionary *> *)items
|
||||
{
|
||||
_items = [items copy];
|
||||
[self setNeedsLayout];
|
||||
|
||||
@@ -117,7 +117,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
|
||||
- (RCTScrollEvent *)coalesceWithEvent:(RCTScrollEvent *)newEvent
|
||||
{
|
||||
NSArray *updatedChildFrames = [_userData[@"updatedChildFrames"] arrayByAddingObjectsFromArray:newEvent->_userData[@"updatedChildFrames"]];
|
||||
NSArray<NSDictionary *> *updatedChildFrames = [_userData[@"updatedChildFrames"] arrayByAddingObjectsFromArray:newEvent->_userData[@"updatedChildFrames"]];
|
||||
|
||||
if (updatedChildFrames) {
|
||||
NSMutableDictionary *userData = [newEvent->_userData mutableCopy];
|
||||
@@ -360,7 +360,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
RCTCustomScrollView *_scrollView;
|
||||
UIView *_contentView;
|
||||
NSTimeInterval _lastScrollDispatchTime;
|
||||
NSMutableArray *_cachedChildFrames;
|
||||
NSMutableArray<NSValue *> *_cachedChildFrames;
|
||||
BOOL _allowNextScrollNoMatterWhat;
|
||||
CGRect _lastClippedToRect;
|
||||
}
|
||||
@@ -412,7 +412,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
[subview removeFromSuperview];
|
||||
}
|
||||
|
||||
- (NSArray *)reactSubviews
|
||||
- (NSArray<UIView<RCTComponent> *> *)reactSubviews
|
||||
{
|
||||
return _contentView ? @[_contentView] : @[];
|
||||
}
|
||||
@@ -564,7 +564,7 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidZoom, RCTScrollEventTypeMove)
|
||||
(_scrollEventThrottle > 0 && _scrollEventThrottle < (now - _lastScrollDispatchTime))) {
|
||||
|
||||
// Calculate changed frames
|
||||
NSArray *childFrames = [self calculateChildFramesData];
|
||||
NSArray<NSDictionary *> *childFrames = [self calculateChildFramesData];
|
||||
|
||||
// Dispatch event
|
||||
[_eventDispatcher sendScrollEventWithType:RCTScrollEventTypeMove
|
||||
@@ -579,9 +579,9 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidZoom, RCTScrollEventTypeMove)
|
||||
RCT_FORWARD_SCROLL_EVENT(scrollViewDidScroll:scrollView);
|
||||
}
|
||||
|
||||
- (NSArray *)calculateChildFramesData
|
||||
- (NSArray<NSDictionary *> *)calculateChildFramesData
|
||||
{
|
||||
NSMutableArray *updatedChildFrames = [NSMutableArray new];
|
||||
NSMutableArray<NSDictionary *> *updatedChildFrames = [NSMutableArray new];
|
||||
[[_contentView reactSubviews] enumerateObjectsUsingBlock:
|
||||
^(UIView *subview, NSUInteger idx, __unused BOOL *stop) {
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
@interface RCTScrollView (Private)
|
||||
|
||||
- (NSArray *)calculateChildFramesData;
|
||||
- (NSArray<NSDictionary *> *)calculateChildFramesData;
|
||||
|
||||
@end
|
||||
|
||||
@@ -83,13 +83,13 @@ RCT_EXPORT_METHOD(getContentSize:(nonnull NSNumber *)reactTag
|
||||
{
|
||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
|
||||
UIView *view = viewRegistry[reactTag];
|
||||
if (!view) {
|
||||
RCTLogError(@"Cannot find view with tag #%@", reactTag);
|
||||
RCTScrollView *view = viewRegistry[reactTag];
|
||||
if (!view || ![view isKindOfClass:[RCTScrollView class]]) {
|
||||
RCTLogError(@"Cannot find RCTScrollView with tag #%@", reactTag);
|
||||
return;
|
||||
}
|
||||
|
||||
CGSize size = ((RCTScrollView *)view).scrollView.contentSize;
|
||||
CGSize size = view.scrollView.contentSize;
|
||||
callback(@[@{
|
||||
@"width" : @(size.width),
|
||||
@"height" : @(size.height)
|
||||
@@ -102,20 +102,20 @@ RCT_EXPORT_METHOD(calculateChildFrames:(nonnull NSNumber *)reactTag
|
||||
{
|
||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
|
||||
UIView *view = viewRegistry[reactTag];
|
||||
if (!view) {
|
||||
RCTLogError(@"Cannot find view with tag #%@", reactTag);
|
||||
RCTScrollView *view = viewRegistry[reactTag];
|
||||
if (!view || ![view isKindOfClass:[RCTScrollView class]]) {
|
||||
RCTLogError(@"Cannot find RCTScrollView with tag #%@", reactTag);
|
||||
return;
|
||||
}
|
||||
|
||||
NSArray *childFrames = [((RCTScrollView *)view) calculateChildFramesData];
|
||||
NSArray<NSDictionary *> *childFrames = [view calculateChildFramesData];
|
||||
if (childFrames) {
|
||||
callback(@[childFrames]);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSArray *)customDirectEventTypes
|
||||
- (NSArray<NSString *> *)customDirectEventTypes
|
||||
{
|
||||
return @[
|
||||
@"scrollBeginDrag",
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
@interface RCTSegmentedControl : UISegmentedControl
|
||||
|
||||
@property (nonatomic, copy) NSArray *values;
|
||||
@property (nonatomic, copy) NSArray<NSString *> *values;
|
||||
@property (nonatomic, assign) NSInteger selectedIndex;
|
||||
@property (nonatomic, copy) RCTBubblingEventBlock onChange;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setValues:(NSArray *)values
|
||||
- (void)setValues:(NSArray<NSString *> *)values
|
||||
{
|
||||
_values = [values copy];
|
||||
[self removeAllSegments];
|
||||
|
||||
@@ -35,6 +35,9 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *viewRegistry);
|
||||
*/
|
||||
@interface RCTShadowView : NSObject <RCTComponent>
|
||||
|
||||
- (NSArray<RCTShadowView *> *)reactSubviews;
|
||||
- (RCTShadowView *)reactSuperview;
|
||||
|
||||
@property (nonatomic, weak, readonly) RCTShadowView *superview;
|
||||
@property (nonatomic, assign, readonly) css_node_t *cssNode;
|
||||
@property (nonatomic, copy) NSString *viewName;
|
||||
@@ -120,27 +123,27 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *viewRegistry);
|
||||
* The applierBlocks set contains RCTApplierBlock functions that must be applied
|
||||
* on the main thread in order to update the view.
|
||||
*/
|
||||
- (void)collectUpdatedProperties:(NSMutableSet *)applierBlocks
|
||||
- (void)collectUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
|
||||
parentProperties:(NSDictionary *)parentProperties;
|
||||
|
||||
/**
|
||||
* Process the updated properties and apply them to view. Shadow view classes
|
||||
* that add additional propagating properties should override this method.
|
||||
*/
|
||||
- (NSDictionary *)processUpdatedProperties:(NSMutableSet *)applierBlocks
|
||||
- (NSDictionary *)processUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
|
||||
parentProperties:(NSDictionary *)parentProperties NS_REQUIRES_SUPER;
|
||||
|
||||
/**
|
||||
* Calculate all views whose frame needs updating after layout has been calculated.
|
||||
* The viewsWithNewFrame set contains the reactTags of the views that need updating.
|
||||
*/
|
||||
- (void)collectRootUpdatedFrames:(NSMutableSet *)viewsWithNewFrame;
|
||||
- (void)collectRootUpdatedFrames:(NSMutableSet<RCTShadowView *> *)viewsWithNewFrame;
|
||||
|
||||
/**
|
||||
* Recursively apply layout to children.
|
||||
*/
|
||||
- (void)applyLayoutNode:(css_node_t *)node
|
||||
viewsWithNewFrame:(NSMutableSet *)viewsWithNewFrame
|
||||
viewsWithNewFrame:(NSMutableSet<RCTShadowView *> *)viewsWithNewFrame
|
||||
absolutePosition:(CGPoint)absolutePosition NS_REQUIRES_SUPER;
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,7 @@ typedef NS_ENUM(unsigned int, meta_prop_t) {
|
||||
RCTUpdateLifecycle _propagationLifecycle;
|
||||
RCTUpdateLifecycle _textLifecycle;
|
||||
NSDictionary *_lastParentProperties;
|
||||
NSMutableArray *_reactSubviews;
|
||||
NSMutableArray<RCTShadowView *> *_reactSubviews;
|
||||
BOOL _recomputePadding;
|
||||
BOOL _recomputeMargin;
|
||||
BOOL _recomputeBorder;
|
||||
@@ -123,7 +123,7 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st
|
||||
// You'll notice that this is the same width we calculated for the parent view because we've taken its position into account.
|
||||
|
||||
- (void)applyLayoutNode:(css_node_t *)node
|
||||
viewsWithNewFrame:(NSMutableSet *)viewsWithNewFrame
|
||||
viewsWithNewFrame:(NSMutableSet<RCTShadowView *> *)viewsWithNewFrame
|
||||
absolutePosition:(CGPoint)absolutePosition
|
||||
{
|
||||
if (!node->layout.should_update) {
|
||||
@@ -171,7 +171,7 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st
|
||||
}
|
||||
}
|
||||
|
||||
- (NSDictionary *)processUpdatedProperties:(NSMutableSet *)applierBlocks
|
||||
- (NSDictionary *)processUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
|
||||
parentProperties:(NSDictionary *)parentProperties
|
||||
{
|
||||
// TODO: we always refresh all propagated properties when propagation is
|
||||
@@ -201,7 +201,7 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st
|
||||
return parentProperties;
|
||||
}
|
||||
|
||||
- (void)collectUpdatedProperties:(NSMutableSet *)applierBlocks
|
||||
- (void)collectUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
|
||||
parentProperties:(NSDictionary *)parentProperties
|
||||
{
|
||||
if (_propagationLifecycle == RCTUpdateLifecycleComputed && [parentProperties isEqualToDictionary:_lastParentProperties]) {
|
||||
@@ -234,7 +234,7 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st
|
||||
}
|
||||
}
|
||||
|
||||
- (void)collectRootUpdatedFrames:(NSMutableSet *)viewsWithNewFrame
|
||||
- (void)collectRootUpdatedFrames:(NSMutableSet<RCTShadowView *> *)viewsWithNewFrame
|
||||
{
|
||||
RCTAssert(RCTIsReactRootView(self.reactTag),
|
||||
@"The method has been called on a view with react tag %@, which is not a root view", self.reactTag);
|
||||
@@ -367,7 +367,7 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st
|
||||
_cssNode->children_count = (int)_reactSubviews.count;
|
||||
}
|
||||
|
||||
- (NSArray *)reactSubviews
|
||||
- (NSArray<RCTShadowView *> *)reactSubviews
|
||||
{
|
||||
return _reactSubviews;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
{
|
||||
BOOL _tabsChanged;
|
||||
UITabBarController *_tabController;
|
||||
NSMutableArray *_tabViews;
|
||||
NSMutableArray<RCTTabBarItem *> *_tabViews;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
@@ -52,12 +52,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
_tabController.delegate = nil;
|
||||
}
|
||||
|
||||
- (NSArray *)reactSubviews
|
||||
- (NSArray<RCTTabBarItem *> *)reactSubviews
|
||||
{
|
||||
return _tabViews;
|
||||
}
|
||||
|
||||
- (void)insertReactSubview:(UIView *)view atIndex:(NSInteger)atIndex
|
||||
- (void)insertReactSubview:(RCTTabBarItem *)view atIndex:(NSInteger)atIndex
|
||||
{
|
||||
if (![view isKindOfClass:[RCTTabBarItem class]]) {
|
||||
RCTLogError(@"subview should be of type RCTTabBarItem");
|
||||
@@ -67,7 +67,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
_tabsChanged = YES;
|
||||
}
|
||||
|
||||
- (void)removeReactSubview:(UIView *)subview
|
||||
- (void)removeReactSubview:(RCTTabBarItem *)subview
|
||||
{
|
||||
if (_tabViews.count == 0) {
|
||||
RCTLogError(@"should have at least one view to remove a subview");
|
||||
@@ -92,7 +92,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
|
||||
if (_tabsChanged) {
|
||||
|
||||
NSMutableArray *viewControllers = [NSMutableArray array];
|
||||
NSMutableArray<UIViewController *> *viewControllers = [NSMutableArray array];
|
||||
for (RCTTabBarItem *tab in [self reactSubviews]) {
|
||||
UIViewController *controller = tab.reactViewController;
|
||||
if (!controller) {
|
||||
@@ -105,7 +105,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
_tabsChanged = NO;
|
||||
}
|
||||
|
||||
[[self reactSubviews] enumerateObjectsUsingBlock:
|
||||
[_tabViews enumerateObjectsUsingBlock:
|
||||
^(RCTTabBarItem *tab, NSUInteger index, __unused BOOL *stop) {
|
||||
UIViewController *controller = _tabController.viewControllers[index];
|
||||
controller.tabBarItem = tab.barItem;
|
||||
@@ -148,7 +148,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
|
||||
{
|
||||
NSUInteger index = [tabBarController.viewControllers indexOfObject:viewController];
|
||||
RCTTabBarItem *tab = [self reactSubviews][index];
|
||||
RCTTabBarItem *tab = _tabViews[index];
|
||||
if (tab.onPress) tab.onPress(nil);
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ static NSString *RCTRecursiveAccessibilityLabel(UIView *view)
|
||||
|
||||
@implementation RCTView
|
||||
{
|
||||
NSMutableArray *_reactSubviews;
|
||||
NSMutableArray<UIView<RCTComponent> *> *_reactSubviews;
|
||||
UIColor *_backgroundColor;
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:unused)
|
||||
[subview removeFromSuperview];
|
||||
}
|
||||
|
||||
- (NSArray *)reactSubviews
|
||||
- (NSArray<UIView<RCTComponent> *> *)reactSubviews
|
||||
{
|
||||
// The _reactSubviews array is only used when we have hidden
|
||||
// offscreen views. If _reactSubviews is nil, we can assume
|
||||
|
||||
@@ -70,7 +70,7 @@ typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, RCTSparseArray *v
|
||||
* Note that this method is not inherited when you subclass a view module, and
|
||||
* you should not call [super customBubblingEventTypes] when overriding it.
|
||||
*/
|
||||
- (NSArray *)customBubblingEventTypes;
|
||||
- (NSArray<NSString *> *)customBubblingEventTypes;
|
||||
|
||||
/**
|
||||
* DEPRECATED: declare properties of type RCTDirectEventBlock instead
|
||||
@@ -83,7 +83,7 @@ typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, RCTSparseArray *v
|
||||
* Note that this method is not inherited when you subclass a view module, and
|
||||
* you should not call [super customDirectEventTypes] when overriding it.
|
||||
*/
|
||||
- (NSArray *)customDirectEventTypes;
|
||||
- (NSArray<NSString *> *)customDirectEventTypes;
|
||||
|
||||
/**
|
||||
* Called to notify manager that layout has finished, in case any calculated
|
||||
@@ -103,13 +103,13 @@ typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, RCTSparseArray *v
|
||||
* This handles the simple case, where JS and native property names match.
|
||||
*/
|
||||
#define RCT_EXPORT_VIEW_PROPERTY(name, type) \
|
||||
+ (NSArray *)propConfig_##name { return @[@#type]; }
|
||||
+ (NSArray<NSString *> *)propConfig_##name { return @[@#type]; }
|
||||
|
||||
/**
|
||||
* This macro maps a named property to an arbitrary key path in the view.
|
||||
*/
|
||||
#define RCT_REMAP_VIEW_PROPERTY(name, keyPath, type) \
|
||||
+ (NSArray *)propConfig_##name { return @[@#type, @#keyPath]; }
|
||||
+ (NSArray<NSString *> *)propConfig_##name { return @[@#type, @#keyPath]; }
|
||||
|
||||
/**
|
||||
* This macro can be used when you need to provide custom logic for setting
|
||||
@@ -124,6 +124,6 @@ RCT_REMAP_VIEW_PROPERTY(name, __custom__, type) \
|
||||
* This macro is used to map properties to the shadow view, instead of the view.
|
||||
*/
|
||||
#define RCT_EXPORT_SHADOW_PROPERTY(name, type) \
|
||||
+ (NSArray *)propConfigShadow_##name { return @[@#type]; }
|
||||
+ (NSArray<NSString *> *)propConfigShadow_##name { return @[@#type]; }
|
||||
|
||||
@end
|
||||
|
||||
@@ -69,7 +69,7 @@ RCT_EXPORT_MODULE()
|
||||
return [RCTShadowView new];
|
||||
}
|
||||
|
||||
- (NSArray *)customBubblingEventTypes
|
||||
- (NSArray<NSString *> *)customBubblingEventTypes
|
||||
{
|
||||
return @[
|
||||
|
||||
@@ -90,7 +90,7 @@ RCT_EXPORT_MODULE()
|
||||
];
|
||||
}
|
||||
|
||||
- (NSArray *)customDirectEventTypes
|
||||
- (NSArray<NSString *> *)customDirectEventTypes
|
||||
{
|
||||
return @[];
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
|
||||
@interface UIView (React) <RCTComponent>
|
||||
|
||||
- (NSArray<UIView<RCTComponent> *> *)reactSubviews;
|
||||
- (UIView<RCTComponent> *)reactSuperview;
|
||||
|
||||
/**
|
||||
* Used by the UIIManager to set the view frame.
|
||||
* May be overriden to disable animation, etc.
|
||||
|
||||
@@ -51,12 +51,12 @@
|
||||
[subview removeFromSuperview];
|
||||
}
|
||||
|
||||
- (NSArray *)reactSubviews
|
||||
- (NSArray<UIView<RCTComponent> *> *)reactSubviews
|
||||
{
|
||||
return self.subviews;
|
||||
}
|
||||
|
||||
- (UIView *)reactSuperview
|
||||
- (UIView<RCTComponent> *)reactSuperview
|
||||
{
|
||||
return self.superview;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user