Procházet zdrojové kódy

Fixes tabBarItem in navigationController return first child tabBarItem

yogevbd před 6 roky
rodič
revize
ce9f431e6c

+ 2
- 2
lib/ios/RNNNavigationController.m Zobrazit soubor

48
 }
48
 }
49
 
49
 
50
 - (UITabBarItem *)tabBarItem {
50
 - (UITabBarItem *)tabBarItem {
51
-	return self.viewControllers.lastObject.tabBarItem;
51
+	return self.viewControllers.firstObject.tabBarItem;
52
 }
52
 }
53
 
53
 
54
 - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
54
 - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
55
-	return self.viewControllers.lastObject.supportedInterfaceOrientations;
55
+	return self.getCurrentChild.supportedInterfaceOrientations;
56
 }
56
 }
57
 
57
 
58
 - (UINavigationController *)navigationController {
58
 - (UINavigationController *)navigationController {

+ 19
- 11
lib/ios/ReactNativeNavigationTests/RNNNavigationControllerTest.m Zobrazit soubor

21
 	_vc2 = [[RNNRootViewController alloc] initWithLayoutInfo:nil rootViewCreator:nil eventEmitter:nil presenter:[[RNNViewControllerPresenter alloc] init] options:nil];
21
 	_vc2 = [[RNNRootViewController alloc] initWithLayoutInfo:nil rootViewCreator:nil eventEmitter:nil presenter:[[RNNViewControllerPresenter alloc] init] options:nil];
22
 	_vc3 = [UIViewController new];
22
 	_vc3 = [UIViewController new];
23
 	
23
 	
24
-	self.uut = [[RNNNavigationController alloc] initWithLayoutInfo:nil childViewControllers:@[_vc1] options:[[RNNNavigationOptions alloc] initWithDict:@{}] presenter:[[RNNViewControllerPresenter alloc] init]];
24
+	self.uut = [[RNNNavigationController alloc] initWithLayoutInfo:nil childViewControllers:@[_vc1, _vc2] options:[[RNNNavigationOptions alloc] initWithDict:@{}] presenter:[[RNNViewControllerPresenter alloc] init]];
25
 }
25
 }
26
 
26
 
27
 - (void)testInitWithLayoutInfo_shouldBindPresenter {
27
 - (void)testInitWithLayoutInfo_shouldBindPresenter {
68
 	XCTAssertTrue(self.uut.interactivePopGestureRecognizer.enabled);
68
 	XCTAssertTrue(self.uut.interactivePopGestureRecognizer.enabled);
69
 }
69
 }
70
 
70
 
71
-//- (void)testRootBackgroundImage {
72
-//	UIImage* rootBackgroundImage = [[UIImage alloc] init];
73
-//	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initEmptyOptions];
74
-//	options.rootBackgroundImage = rootBackgroundImage;
75
-//	
76
-//	self.uut = [self createNavigationControllerWithOptions:options];
77
-//	[self.uut viewWillAppear:false];
78
-//	
79
-//	XCTAssertTrue([[(UIImageView*)self.uut.view.subviews[0] image] isEqual:rootBackgroundImage]);
80
-//}
71
+- (void)testRootBackgroundImage {
72
+	UIImage* rootBackgroundImage = [[UIImage alloc] init];
73
+	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initEmptyOptions];
74
+	options.rootBackgroundImage = [[Image alloc] initWithValue:rootBackgroundImage];
75
+	
76
+	self.uut = [self createNavigationControllerWithOptions:options];
77
+	[self.uut onChildWillAppear];
78
+	
79
+	XCTAssertTrue([[(UIImageView*)self.uut.view.subviews[0] image] isEqual:rootBackgroundImage]);
80
+}
81
 
81
 
82
 - (void)testTopBarBackgroundClipToBounds_true {
82
 - (void)testTopBarBackgroundClipToBounds_true {
83
 	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initEmptyOptions];
83
 	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initEmptyOptions];
98
 	XCTAssertFalse(self.uut.navigationController.navigationBar.clipsToBounds);
98
 	XCTAssertFalse(self.uut.navigationController.navigationBar.clipsToBounds);
99
 }
99
 }
100
 
100
 
101
+- (void)testTabBarItemShouldReturnFirstChildTabBarItem {
102
+	XCTAssertEqual(self.uut.tabBarItem, self.uut.childViewControllers.firstObject.tabBarItem);
103
+}
104
+
105
+- (void)testSupportedOrientationsShouldReturnCurrentChildSupportedOrientations {
106
+	XCTAssertEqual(self.uut.supportedInterfaceOrientations, self.uut.getCurrentChild.supportedInterfaceOrientations);
107
+}
108
+
101
 - (RNNNavigationController *)createNavigationControllerWithOptions:(RNNNavigationOptions *)options {
109
 - (RNNNavigationController *)createNavigationControllerWithOptions:(RNNNavigationOptions *)options {
102
 	return [[RNNNavigationController alloc] initWithLayoutInfo:nil childViewControllers:@[_vc1] options:options presenter:[[RNNNavigationControllerPresenter alloc] init]];
110
 	return [[RNNNavigationController alloc] initWithLayoutInfo:nil childViewControllers:@[_vc1] options:options presenter:[[RNNNavigationControllerPresenter alloc] init]];
103
 }
111
 }