yogevbd 6 年前
父节点
当前提交
fbe1edb914

+ 1
- 3
lib/ios/RNNBottomTabsOptions.h 查看文件

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

+ 9
- 15
lib/ios/RNNBottomTabsOptions.m 查看文件

14
 	}
14
 	}
15
 	
15
 	
16
 	if (self.visible) {
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
 	if (self.testID) {
20
 	if (self.testID) {
41
 		viewController.tabBarController.tabBar.clipsToBounds = [self.hideShadow boolValue];
41
 		viewController.tabBarController.tabBar.clipsToBounds = [self.hideShadow boolValue];
42
 	}
42
 	}
43
 	
43
 	
44
-	if (self.tabBarTextFont || self.textColor) {
44
+	if (self.tabBarTextFont) {
45
 		NSMutableDictionary* tabBarTitleTextAttributes = [NSMutableDictionary new];
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
 		for (UITabBarItem* item in viewController.tabBarController.tabBar.items) {
48
 		for (UITabBarItem* item in viewController.tabBarController.tabBar.items) {
55
 			[item setTitleTextAttributes:tabBarTitleTextAttributes forState:UIControlStateNormal];
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
 	[self resetOptions];
61
 	[self resetOptions];

+ 1
- 1
lib/ios/RNNTopBarOptions.h 查看文件

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

+ 1
- 1
lib/ios/RNNTopBarOptions.m 查看文件

63
 	
63
 	
64
 	
64
 	
65
 	if (self.visible) {
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
 	if (self.hideOnScroll) {
69
 	if (self.hideOnScroll) {

+ 12
- 11
lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m 查看文件

619
 	XCTAssertTrue([self.uut.tabBarController.tabBar.barTintColor isEqual:expectedColor]);
619
 	XCTAssertTrue([self.uut.tabBarController.tabBar.barTintColor isEqual:expectedColor]);
620
 }
620
 }
621
 
621
 
622
--(void)testTabBarTextColor_validColor{
622
+-(void)testTabBarSelectedColor_validColor{
623
 	NSNumber* inputColor = @(0xFFFF0000);
623
 	NSNumber* inputColor = @(0xFFFF0000);
624
-	self.options.bottomTabs.textColor = inputColor;
624
+	self.options.bottomTabs.tabColor = inputColor;
625
 	[self.uut embedInTabBarController];
625
 	[self.uut embedInTabBarController];
626
 	UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
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
 -(void)testTabBarTextFontFamily_validFont{
638
 -(void)testTabBarTextFontFamily_validFont{
645
 	XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
652
 	XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
646
 }
653
 }
647
 
654
 
648
--(void)testTabBarTextFontSize_withoutTextFontFamily_withTextColor {
655
+-(void)testTabBarTextFontSize_withoutTextFontFamily {
649
 	self.options.bottomTabs.fontSize = @(15);
656
 	self.options.bottomTabs.fontSize = @(15);
650
-	self.options.bottomTabs.textColor = @(0xFFFF0000);
651
 	[self.uut embedInTabBarController];
657
 	[self.uut embedInTabBarController];
652
 	UIFont* expectedFont = [UIFont systemFontOfSize:15];
658
 	UIFont* expectedFont = [UIFont systemFontOfSize:15];
653
-	UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
654
 	NSDictionary* attributes = [self.uut.tabBarController.tabBar.items.firstObject titleTextAttributesForState:UIControlStateNormal];
659
 	NSDictionary* attributes = [self.uut.tabBarController.tabBar.items.firstObject titleTextAttributesForState:UIControlStateNormal];
655
 	XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
660
 	XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
656
-	XCTAssertTrue([attributes[@"NSColor"] isEqual:expectedColor]);
657
 }
661
 }
658
 
662
 
659
 -(void)testTabBarTextFontSize_withTextFontFamily_withTextColor {
663
 -(void)testTabBarTextFontSize_withTextFontFamily_withTextColor {
660
 	NSString* inputFont = @"HelveticaNeue";
664
 	NSString* inputFont = @"HelveticaNeue";
661
 	self.options.bottomTabs.fontSize = @(15);
665
 	self.options.bottomTabs.fontSize = @(15);
662
-	self.options.bottomTabs.textColor = @(0xFFFF0000);
663
 	self.options.bottomTabs.fontFamily = inputFont;
666
 	self.options.bottomTabs.fontFamily = inputFont;
664
 	[self.uut embedInTabBarController];
667
 	[self.uut embedInTabBarController];
665
-	UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
666
 	UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
668
 	UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
667
 	NSDictionary* attributes = [self.uut.tabBarController.tabBar.items.firstObject titleTextAttributesForState:UIControlStateNormal];
669
 	NSDictionary* attributes = [self.uut.tabBarController.tabBar.items.firstObject titleTextAttributesForState:UIControlStateNormal];
668
 	XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
670
 	XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
669
-	XCTAssertTrue([attributes[@"NSColor"] isEqual:expectedColor]);
670
 }
671
 }
671
 
672
 
672
 -(void)testTabBarTextFontSize_withTextFontFamily_withoutTextColor {
673
 -(void)testTabBarTextFontSize_withTextFontFamily_withoutTextColor {

+ 3
- 1
playground/src/screens/TextScreen.js 查看文件

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