mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 12:45:37 +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
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user