Let native modules know when root views get added and removed
This commit is contained in:
parent
12d5f0d6f4
commit
65713992c4
|
@ -20,6 +20,23 @@
|
|||
*/
|
||||
RCT_EXTERN NSString *const RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification;
|
||||
|
||||
/**
|
||||
* Posted whenever a new root view is registered with RCTUIManager. The userInfo property
|
||||
* will contain a RCTUIManagerRootViewKey with the registered root view.
|
||||
*/
|
||||
RCT_EXTERN NSString *const RCTUIManagerDidRegisterRootViewNotification;
|
||||
|
||||
/**
|
||||
* Posted whenever a root view is removed from the RCTUIManager. The userInfo property
|
||||
* will contain a RCTUIManagerRootViewKey with the removed root view.
|
||||
*/
|
||||
RCT_EXTERN NSString *const RCTUIManagerDidRemoveRootViewNotification;
|
||||
|
||||
/**
|
||||
* Key for the root view property in the above notifications
|
||||
*/
|
||||
RCT_EXTERN NSString *const RCTUIManagerRootViewKey;
|
||||
|
||||
@protocol RCTScrollableProtocol;
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,6 +41,9 @@ static void RCTTraverseViewNodes(id<RCTComponent> view, void (^block)(id<RCTComp
|
|||
}
|
||||
|
||||
NSString *const RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification = @"RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification";
|
||||
NSString *const RCTUIManagerDidRegisterRootViewNotification = @"RCTUIManagerDidRegisterRootViewNotification";
|
||||
NSString *const RCTUIManagerDidRemoveRootViewNotification = @"RCTUIManagerDidRemoveRootViewNotification";
|
||||
NSString *const RCTUIManagerRootViewKey = @"RCTUIManagerRootViewKey";
|
||||
|
||||
@interface RCTAnimation : NSObject
|
||||
|
||||
|
@ -331,6 +334,10 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
|||
strongSelf->_shadowViewRegistry[shadowView.reactTag] = shadowView;
|
||||
[strongSelf->_rootViewTags addObject:reactTag];
|
||||
});
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTUIManagerDidRegisterRootViewNotification
|
||||
object:self
|
||||
userInfo:@{ RCTUIManagerRootViewKey: rootView }];
|
||||
}
|
||||
|
||||
- (UIView *)viewForReactTag:(NSNumber *)reactTag
|
||||
|
@ -637,6 +644,10 @@ RCT_EXPORT_METHOD(removeRootView:(nonnull NSNumber *)rootReactTag)
|
|||
UIView *rootView = viewRegistry[rootReactTag];
|
||||
[uiManager _purgeChildren:rootView.reactSubviews fromRegistry:viewRegistry];
|
||||
viewRegistry[rootReactTag] = nil;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTUIManagerDidRemoveRootViewNotification
|
||||
object:uiManager
|
||||
userInfo:@{ RCTUIManagerRootViewKey: rootView }];
|
||||
}];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue