From d8c66775c6ae59b6393e818d192206d425181a8d Mon Sep 17 00:00:00 2001 From: Yogev B Date: Wed, 2 May 2018 15:23:09 +0300 Subject: [PATCH 1/3] Revert "fix build issue" This reverts commit 864a84dfcfcf50a6070116343e9ce094773a559c. From 6791f372731637012a52ba21690a65d33035b7ce Mon Sep 17 00:00:00 2001 From: Yogev B Date: Wed, 2 May 2018 15:23:09 +0300 Subject: [PATCH 2/3] Revert "fixed a bug modal viewController was not deallocated when to call dismissAllModals (#2843)" This reverts commit f7267009de924cf17368d8b46136d778ede35c2e. From 59a80b763d47d674879583102ac3139f3fcab7f9 Mon Sep 17 00:00:00 2001 From: Yogev B Date: Wed, 2 May 2018 15:23:09 +0300 Subject: [PATCH 3/3] =?UTF-8?q?Revert=20"Support=20a=20=E2=80=9Cmodal?= =?UTF-8?q?=E2=80=9D=20prop=20for=20tabbed=20iOS=20apps=20(#1578)"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 5cd2972ca068f1b0a58937bcf0fd8bc1461b7c41. --- docs/top-level-api.md | 3 +- ios/RCCTabBarController.m | 242 +++++++++++++------------------------- 2 files changed, 81 insertions(+), 164 deletions(-) diff --git a/docs/top-level-api.md b/docs/top-level-api.md index 1096170ce67..174533cb2bd 100644 --- a/docs/top-level-api.md +++ b/docs/top-level-api.md @@ -44,8 +44,7 @@ Navigation.startTabBasedApp({ title: 'Screen One', // title of the screen as appears in the nav bar (optional) titleImage: require('../img/titleImage.png'), // iOS only. navigation bar title image instead of the title text of the pushed screen (optional) navigatorStyle: {}, // override the navigator style for the tab screen, see "Styling the navigator" below (optional), - navigatorButtons: {}, // override the nav buttons for the tab screen, see "Adding buttons to the navigator" below (optional) - modal: false // Prevent tab selection and send a 'modalTabSelected' navigator event instead (optional, iOS only) + navigatorButtons: {} // override the nav buttons for the tab screen, see "Adding buttons to the navigator" below (optional) }, { label: 'Two', diff --git a/ios/RCCTabBarController.m b/ios/RCCTabBarController.m index 42227e367dc..6c5fa9dcfb4 100755 --- a/ios/RCCTabBarController.m +++ b/ios/RCCTabBarController.m @@ -14,12 +14,6 @@ - (void)configureNextLayoutAnimation:(NSDictionary *)config @end -@interface RCCTabBarController () - -@property (nonatomic, strong) NSSet *modalTabIndices; - -@end - @implementation RCCTabBarController @@ -28,47 +22,37 @@ -(UIInterfaceOrientationMask)supportedInterfaceOrientations { } - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController { - id queue = [[RCCManager sharedInstance].getBridge uiManager].methodQueue; - dispatch_async(queue, ^{ - [[[RCCManager sharedInstance].getBridge uiManager] configureNextLayoutAnimation:nil withCallback:^(NSArray* arr){} errorCallback:^(NSArray* arr){}]; - }); - - NSUInteger selectedIndex = [tabBarController.viewControllers indexOfObject:viewController]; - - if (tabBarController.selectedIndex != selectedIndex) { - NSDictionary *body = @{ - @"selectedTabIndex": @(selectedIndex), - @"unselectedTabIndex": @(tabBarController.selectedIndex) - }; - - if ([self.modalTabIndices containsObject:@(selectedIndex)]) { - [RCCTabBarController sendScreenTabModalEvent:viewController body:body]; - return NO; - } + id queue = [[RCCManager sharedInstance].getBridge uiManager].methodQueue; + dispatch_async(queue, ^{ + [[[RCCManager sharedInstance].getBridge uiManager] configureNextLayoutAnimation:nil withCallback:^(NSArray* arr){} errorCallback:^(NSArray* arr){}]; + }); - else { - [RCCTabBarController sendScreenTabChangedEvent:viewController body:body]; - - [[[RCCManager sharedInstance] getBridge].eventDispatcher sendAppEventWithName:@"bottomTabSelected" body:body]; - } - - if ([viewController isKindOfClass:[UINavigationController class]]) { - UINavigationController *navigationController = (UINavigationController*)viewController; - UIViewController *topViewController = navigationController.topViewController; - - if ([topViewController isKindOfClass:[RCCViewController class]]) { - RCCViewController *topRCCViewController = (RCCViewController*)topViewController; - topRCCViewController.commandType = COMMAND_TYPE_BOTTOME_TAB_SELECTED; - topRCCViewController.timestamp = [RCTHelpers getTimestampString]; - } + if (tabBarController.selectedIndex != [tabBarController.viewControllers indexOfObject:viewController]) { + NSDictionary *body = @{ + @"selectedTabIndex": @([tabBarController.viewControllers indexOfObject:viewController]), + @"unselectedTabIndex": @(tabBarController.selectedIndex) + }; + [RCCTabBarController sendScreenTabChangedEvent:viewController body:body]; + + [[[RCCManager sharedInstance] getBridge].eventDispatcher sendAppEventWithName:@"bottomTabSelected" body:body]; + if ([viewController isKindOfClass:[UINavigationController class]]) { + UINavigationController *navigationController = (UINavigationController*)viewController; + UIViewController *topViewController = navigationController.topViewController; + + if ([topViewController isKindOfClass:[RCCViewController class]]) { + RCCViewController *topRCCViewController = (RCCViewController*)topViewController; + topRCCViewController.commandType = COMMAND_TYPE_BOTTOME_TAB_SELECTED; + topRCCViewController.timestamp = [RCTHelpers getTimestampString]; + } + } + + } else { + [RCCTabBarController sendScreenTabPressedEvent:viewController body:nil]; } - } else { - [RCCTabBarController sendScreenTabPressedEvent:viewController body:nil]; - } - - - - return YES; + + + + return YES; } - (UIImage *)image:(UIImage*)image withColor:(UIColor *)color1 { @@ -86,105 +70,59 @@ - (UIImage *)image:(UIImage*)image withColor:(UIColor *)color1 { return newImage; } -- (instancetype)initWithProps:(NSDictionary *)props children:(NSArray *)children globalProps:(NSDictionary*)globalProps bridge:(RCTBridge *)bridge -{ - self = [super init]; - if (!self) return nil; - - self.delegate = self; - - self.tabBar.translucent = YES; // default - - UIColor *buttonColor = nil; - UIColor *selectedButtonColor = nil; - UIColor *labelColor = nil; - UIColor *selectedLabelColor = nil; - NSDictionary *tabsStyle = props[@"style"]; - if (tabsStyle) - { - NSString *tabBarButtonColor = tabsStyle[@"tabBarButtonColor"]; - if (tabBarButtonColor) - { - UIColor *color = tabBarButtonColor != (id)[NSNull null] ? [RCTConvert UIColor:tabBarButtonColor] : nil; - self.tabBar.tintColor = color; - buttonColor = color; - selectedButtonColor = color; - } - NSString *tabBarSelectedButtonColor = tabsStyle[@"tabBarSelectedButtonColor"]; - if (tabBarSelectedButtonColor) - { - UIColor *color = tabBarSelectedButtonColor != (id)[NSNull null] ? [RCTConvert UIColor:tabBarSelectedButtonColor] : nil; - self.tabBar.tintColor = color; - selectedButtonColor = color; - } - NSString *tabBarLabelColor = tabsStyle[@"tabBarLabelColor"]; - if(tabBarLabelColor) { - UIColor *color = tabBarLabelColor != (id)[NSNull null] ? [RCTConvert UIColor:tabBarLabelColor] : nil; - labelColor = color; - } - NSString *tabBarSelectedLabelColor = tabsStyle[@"tabBarSelectedLabelColor"]; - if(tabBarLabelColor) { - UIColor *color = tabBarSelectedLabelColor != (id)[NSNull null] ? [RCTConvert UIColor: - tabBarSelectedLabelColor] : nil; - selectedLabelColor = color; - } - NSString *tabBarBackgroundColor = tabsStyle[@"tabBarBackgroundColor"]; - if (tabBarBackgroundColor) - { - UIColor *color = tabBarBackgroundColor != (id)[NSNull null] ? [RCTConvert UIColor:tabBarBackgroundColor] : nil; - self.tabBar.barTintColor = color; - } - - NSString *tabBarTranslucent = tabsStyle[@"tabBarTranslucent"]; - if (tabBarTranslucent) - { - self.tabBar.translucent = [tabBarTranslucent boolValue] ? YES : NO; - } - - NSString *tabBarHideShadow = tabsStyle[@"tabBarHideShadow"]; - if (tabBarHideShadow) - { - self.tabBar.clipsToBounds = [tabBarHideShadow boolValue] ? YES : NO; - } - } - - NSMutableArray *viewControllers = [NSMutableArray array]; - NSMutableSet *modalTabs = [NSMutableSet new]; - - // go over all the tab bar items - for (NSDictionary *tabItemLayout in children) - { - // make sure the layout is valid - if (![tabItemLayout[@"type"] isEqualToString:@"TabBarControllerIOS.Item"]) continue; - if (!tabItemLayout[@"props"]) continue; +- (instancetype)initWithProps:(NSDictionary *)props children:(NSArray *)children globalProps:(NSDictionary*)globalProps bridge:(RCTBridge *)bridge { + self = [super init]; + if (!self) return nil; self.delegate = self; - // create the tab icon and title - NSString *title = tabItemLayout[@"props"][@"title"]; - id isModal = tabItemLayout[@"props"][@"modal"]; - if (isModal && isModal != (id)[NSNull null]) { - BOOL isModalBool = [RCTConvert BOOL:isModal]; - if (isModalBool) { - [modalTabs addObject:@([viewControllers count])]; - } - } - UIImage *iconImage = nil; - id icon = tabItemLayout[@"props"][@"icon"]; - if (icon) - { - iconImage = [RCTConvert UIImage:icon]; - if (buttonColor) - { - iconImage = [[self image:iconImage withColor:buttonColor] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; - } - } - UIImage *iconImageSelected = nil; - id selectedIcon = tabItemLayout[@"props"][@"selectedIcon"]; - if (selectedIcon) { - iconImageSelected = [RCTConvert UIImage:selectedIcon]; - } else { - iconImageSelected = [RCTConvert UIImage:icon]; + self.tabBar.translucent = YES; // default + + UIColor *buttonColor = nil; + UIColor *selectedButtonColor = nil; + UIColor *labelColor = nil; + UIColor *selectedLabelColor = nil; + NSDictionary *tabsStyle = props[@"style"]; + if (tabsStyle) { + NSString *tabBarButtonColor = tabsStyle[@"tabBarButtonColor"]; + if (tabBarButtonColor) { + UIColor *color = tabBarButtonColor != (id)[NSNull null] ? [RCTConvert UIColor:tabBarButtonColor] : nil; + self.tabBar.tintColor = color; + buttonColor = color; + selectedButtonColor = color; + } + NSString *tabBarSelectedButtonColor = tabsStyle[@"tabBarSelectedButtonColor"]; + if (tabBarSelectedButtonColor) { + UIColor *color = tabBarSelectedButtonColor != (id)[NSNull null] ? [RCTConvert UIColor:tabBarSelectedButtonColor] : nil; + self.tabBar.tintColor = color; + selectedButtonColor = color; + } + NSString *tabBarLabelColor = tabsStyle[@"tabBarLabelColor"]; + if (tabBarLabelColor) { + UIColor *color = tabBarLabelColor != (id)[NSNull null] ? [RCTConvert UIColor:tabBarLabelColor] : nil; + labelColor = color; + } + NSString *tabBarSelectedLabelColor = tabsStyle[@"tabBarSelectedLabelColor"]; + if (tabBarLabelColor) { + UIColor *color = tabBarSelectedLabelColor != (id)[NSNull null] ? [RCTConvert UIColor: + tabBarSelectedLabelColor] : nil; + selectedLabelColor = color; + } + NSString *tabBarBackgroundColor = tabsStyle[@"tabBarBackgroundColor"]; + if (tabBarBackgroundColor) { + UIColor *color = tabBarBackgroundColor != (id)[NSNull null] ? [RCTConvert UIColor:tabBarBackgroundColor] : nil; + self.tabBar.barTintColor = color; + } + + NSString *tabBarTranslucent = tabsStyle[@"tabBarTranslucent"]; + if (tabBarTranslucent) { + self.tabBar.translucent = [tabBarTranslucent boolValue] ? YES : NO; + } + + NSString *tabBarHideShadow = tabsStyle[@"tabBarHideShadow"]; + if (tabBarHideShadow) { + self.tabBar.clipsToBounds = [tabBarHideShadow boolValue] ? YES : NO; + } } NSMutableArray *viewControllers = [NSMutableArray array]; @@ -274,23 +212,7 @@ - (instancetype)initWithProps:(NSDictionary *)props children:(NSArray *)children [self setRotation:props]; - [viewControllers addObject:viewController]; - } - - // replace the tabs - self.viewControllers = viewControllers; - self.modalTabIndices = [modalTabs copy]; - - NSNumber *initialTab = tabsStyle[@"initialTabIndex"]; - if (initialTab) - { - NSInteger initialTabIndex = initialTab.integerValue; - [self setSelectedIndex:initialTabIndex]; - } - - [self setRotation:props]; - - return self; + return self; } - (void)performAction:(NSString*)performAction actionParams:(NSDictionary*)actionParams bridge:(RCTBridge *)bridge completion:(void (^)(void))completion { @@ -425,10 +347,6 @@ +(void)sendScreenTabPressedEvent:(UIViewController*)viewController body:(NSDicti [RCCTabBarController sendTabEvent:@"bottomTabReselected" controller:viewController body:body]; } -+(void)sendScreenTabModalEvent:(UIViewController*)viewController body:(NSDictionary*)body{ - [RCCTabBarController sendTabEvent:@"modalTabSelected" controller:viewController body:body]; -} - +(void)sendTabEvent:(NSString *)event controller:(UIViewController*)viewController body:(NSDictionary*)body{ if ([viewController.view isKindOfClass:[RCTRootView class]]){ RCTRootView *rootView = (RCTRootView *)viewController.view;