Browse Source

Fix setting bottomTabs.currentTabIndex on bottomTabs init (#4457)

Yogev Ben David 6 years ago
parent
commit
631e7dbd55
No account linked to committer's email address

+ 1
- 0
lib/ios/RNNTabBarController.m View File

31
 	self.presenter = presenter;
31
 	self.presenter = presenter;
32
 	[self.presenter bindViewController:self];
32
 	[self.presenter bindViewController:self];
33
 	[self setViewControllers:childViewControllers];
33
 	[self setViewControllers:childViewControllers];
34
+	[self.presenter applyOptionsOnInit:self.options];
34
 	
35
 	
35
 	return self;
36
 	return self;
36
 }
37
 }

+ 5
- 0
lib/ios/RNNTabBarPresenter.m View File

3
 
3
 
4
 @implementation RNNTabBarPresenter
4
 @implementation RNNTabBarPresenter
5
 
5
 
6
+- (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions {
7
+	UITabBarController* tabBarController = self.bindedViewController;
8
+	[tabBarController rnn_setCurrentTabIndex:[initialOptions.bottomTabs.currentTabIndex getWithDefaultValue:0]];
9
+}
10
+
6
 - (void)applyOptions:(RNNNavigationOptions *)options {
11
 - (void)applyOptions:(RNNNavigationOptions *)options {
7
 	UITabBarController* tabBarController = self.bindedViewController;
12
 	UITabBarController* tabBarController = self.bindedViewController;
8
 	
13
 	

+ 10
- 1
lib/ios/ReactNativeNavigationTests/RNNTabBarPresenterTest.m View File

33
 	[self.bindedViewController verify];
33
 	[self.bindedViewController verify];
34
 }
34
 }
35
 
35
 
36
-- (void)testApplyOptions_shouldSetInitialOptions {
36
+- (void)testApplyOptions_shouldApplyOptions {
37
 	RNNNavigationOptions* initialOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
37
 	RNNNavigationOptions* initialOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
38
 	initialOptions.bottomTabs.testID = [[Text alloc] initWithValue:@"testID"];
38
 	initialOptions.bottomTabs.testID = [[Text alloc] initWithValue:@"testID"];
39
 	initialOptions.bottomTabs.backgroundColor = [[Color alloc] initWithValue:[UIColor redColor]];
39
 	initialOptions.bottomTabs.backgroundColor = [[Color alloc] initWithValue:[UIColor redColor]];
53
 	[self.bindedViewController verify];
53
 	[self.bindedViewController verify];
54
 }
54
 }
55
 
55
 
56
+- (void)testApplyOptions_shouldApplyOptionsOnInit {
57
+	RNNNavigationOptions* initialOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
58
+	initialOptions.bottomTabs.currentTabIndex = [[IntNumber alloc] initWithValue:@(1)];
59
+	[[self.bindedViewController expect] rnn_setCurrentTabIndex:1];
60
+	
61
+	[self.uut applyOptionsOnInit:initialOptions];
62
+	[self.bindedViewController verify];
63
+}
64
+
56
 @end
65
 @end