yogevbd 6 years ago
parent
commit
fbe1edb914

+ 1
- 3
lib/ios/RNNBottomTabsOptions.h View File

@@ -3,7 +3,7 @@
3 3
 @interface RNNBottomTabsOptions : RNNOptions
4 4
 
5 5
 @property (nonatomic, strong) NSNumber* visible;
6
-@property (nonatomic, strong) NSNumber* animateHide;
6
+@property (nonatomic, strong) NSNumber* animate;
7 7
 @property (nonatomic, strong) NSNumber* currentTabIndex;
8 8
 @property (nonatomic, strong) NSString* testID;
9 9
 @property (nonatomic, strong) NSNumber* drawBehind;
@@ -12,10 +12,8 @@
12 12
 @property (nonatomic, strong) NSNumber* translucent;
13 13
 @property (nonatomic, strong) NSNumber* hideShadow;
14 14
 @property (nonatomic, strong) NSNumber* backgroundColor;
15
-@property (nonatomic, strong) NSNumber* textColor;
16 15
 @property (nonatomic, strong) NSNumber* tabColor;
17 16
 @property (nonatomic, strong) NSNumber* selectedTabColor;
18
-@property (nonatomic, strong) NSNumber* selectedTextColor;
19 17
 @property (nonatomic, strong) NSString* fontFamily;
20 18
 @property (nonatomic, strong) NSNumber* fontSize;
21 19
 

+ 9
- 15
lib/ios/RNNBottomTabsOptions.m View File

@@ -14,7 +14,7 @@ extern const NSInteger BLUR_TOPBAR_TAG;
14 14
 	}
15 15
 	
16 16
 	if (self.visible) {
17
-		[((RNNTabBarController *)viewController.tabBarController) setTabBarHidden:![self.visible boolValue] animated:[self.animateHide boolValue]];
17
+		[((RNNTabBarController *)viewController.tabBarController) setTabBarHidden:![self.visible boolValue] animated:[self.animate boolValue]];
18 18
 	}
19 19
 	
20 20
 	if (self.testID) {
@@ -41,27 +41,21 @@ extern const NSInteger BLUR_TOPBAR_TAG;
41 41
 		viewController.tabBarController.tabBar.clipsToBounds = [self.hideShadow boolValue];
42 42
 	}
43 43
 	
44
-	if (self.tabBarTextFont || self.textColor) {
44
+	if (self.tabBarTextFont) {
45 45
 		NSMutableDictionary* tabBarTitleTextAttributes = [NSMutableDictionary new];
46
-		if (self.textColor) {
47
-			tabBarTitleTextAttributes[NSForegroundColorAttributeName] = [RCTConvert UIColor:self.textColor];
48
-		}
49
-		
50
-		if (self.tabBarTextFont) {
51
-			tabBarTitleTextAttributes[NSFontAttributeName] = self.tabBarTextFont;
52
-		}
46
+		tabBarTitleTextAttributes[NSFontAttributeName] = self.tabBarTextFont;
53 47
 		
54 48
 		for (UITabBarItem* item in viewController.tabBarController.tabBar.items) {
55 49
 			[item setTitleTextAttributes:tabBarTitleTextAttributes forState:UIControlStateNormal];
56 50
 		}
57 51
 	}
58 52
 	
59
-	if (self.selectedTextColor){
60
-		for (UITabBarItem* item in viewController.tabBarController.tabBar.items) {
61
-			NSMutableDictionary* tabBarTitleTextAttributes = [NSMutableDictionary new];
62
-			tabBarTitleTextAttributes[NSForegroundColorAttributeName] = [RCTConvert UIColor:self.selectedTextColor];
63
-			[item setTitleTextAttributes:tabBarTitleTextAttributes forState:UIControlStateSelected];
64
-		}
53
+	if (self.tabColor) {
54
+		viewController.tabBarController.tabBar.unselectedItemTintColor = [RCTConvert UIColor:self.tabColor];
55
+	}
56
+	
57
+	if (self.selectedTabColor) {
58
+		viewController.tabBarController.tabBar.tintColor = [RCTConvert UIColor:self.selectedTabColor];
65 59
 	}
66 60
 	
67 61
 	[self resetOptions];

+ 1
- 1
lib/ios/RNNTopBarOptions.h View File

@@ -17,7 +17,7 @@
17 17
 @property (nonatomic, strong) NSNumber* textFontSize;
18 18
 @property (nonatomic, strong) NSNumber* noBorder;
19 19
 @property (nonatomic, strong) NSNumber* blur;
20
-@property (nonatomic, strong) NSNumber* animateHide;
20
+@property (nonatomic, strong) NSNumber* animate;
21 21
 @property (nonatomic, strong) NSNumber* largeTitle;
22 22
 @property (nonatomic, strong) NSString* testID;
23 23
 

+ 1
- 1
lib/ios/RNNTopBarOptions.m View File

@@ -63,7 +63,7 @@ extern const NSInteger BLUR_TOPBAR_TAG;
63 63
 	
64 64
 	
65 65
 	if (self.visible) {
66
-		[viewController.navigationController setNavigationBarHidden:![self.visible boolValue] animated:[self.animateHide boolValue]];
66
+		[viewController.navigationController setNavigationBarHidden:![self.visible boolValue] animated:[self.animate boolValue]];
67 67
 	}
68 68
 	
69 69
 	if (self.hideOnScroll) {

+ 12
- 11
lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m View File

@@ -619,13 +619,20 @@
619 619
 	XCTAssertTrue([self.uut.tabBarController.tabBar.barTintColor isEqual:expectedColor]);
620 620
 }
621 621
 
622
--(void)testTabBarTextColor_validColor{
622
+-(void)testTabBarSelectedColor_validColor{
623 623
 	NSNumber* inputColor = @(0xFFFF0000);
624
-	self.options.bottomTabs.textColor = inputColor;
624
+	self.options.bottomTabs.tabColor = inputColor;
625 625
 	[self.uut embedInTabBarController];
626 626
 	UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
627
-	NSDictionary* attributes = [self.uut.tabBarController.tabBar.items.firstObject titleTextAttributesForState:UIControlStateNormal];
628
-	XCTAssertTrue([attributes[@"NSColor"] isEqual:expectedColor]);
627
+	XCTAssertTrue([self.uut.tabBarController.tabBar.unselectedItemTintColor isEqual:expectedColor]);
628
+}
629
+
630
+-(void)testTabBarUnselectedColor_validColor{
631
+	NSNumber* inputColor = @(0xFFFF0000);
632
+	self.options.bottomTabs.selectedTabColor = inputColor;
633
+	[self.uut embedInTabBarController];
634
+	UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
635
+	XCTAssertTrue([self.uut.tabBarController.tabBar.tintColor isEqual:expectedColor]);
629 636
 }
630 637
 
631 638
 -(void)testTabBarTextFontFamily_validFont{
@@ -645,28 +652,22 @@
645 652
 	XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
646 653
 }
647 654
 
648
--(void)testTabBarTextFontSize_withoutTextFontFamily_withTextColor {
655
+-(void)testTabBarTextFontSize_withoutTextFontFamily {
649 656
 	self.options.bottomTabs.fontSize = @(15);
650
-	self.options.bottomTabs.textColor = @(0xFFFF0000);
651 657
 	[self.uut embedInTabBarController];
652 658
 	UIFont* expectedFont = [UIFont systemFontOfSize:15];
653
-	UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
654 659
 	NSDictionary* attributes = [self.uut.tabBarController.tabBar.items.firstObject titleTextAttributesForState:UIControlStateNormal];
655 660
 	XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
656
-	XCTAssertTrue([attributes[@"NSColor"] isEqual:expectedColor]);
657 661
 }
658 662
 
659 663
 -(void)testTabBarTextFontSize_withTextFontFamily_withTextColor {
660 664
 	NSString* inputFont = @"HelveticaNeue";
661 665
 	self.options.bottomTabs.fontSize = @(15);
662
-	self.options.bottomTabs.textColor = @(0xFFFF0000);
663 666
 	self.options.bottomTabs.fontFamily = inputFont;
664 667
 	[self.uut embedInTabBarController];
665
-	UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
666 668
 	UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
667 669
 	NSDictionary* attributes = [self.uut.tabBarController.tabBar.items.firstObject titleTextAttributesForState:UIControlStateNormal];
668 670
 	XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
669
-	XCTAssertTrue([attributes[@"NSColor"] isEqual:expectedColor]);
670 671
 }
671 672
 
672 673
 -(void)testTabBarTextFontSize_withTextFontFamily_withoutTextColor {

+ 3
- 1
playground/src/screens/TextScreen.js View File

@@ -70,7 +70,9 @@ class TextScreen extends Component {
70 70
       bottomTabs: {
71 71
         currentTabIndex: 1,
72 72
         visible: false,
73
-        animate: true
73
+        animate: true,
74
+        tabColor: 'blue',
75
+        selectedTabColor: 'red'
74 76
       }
75 77
     });
76 78
   }