浏览代码

Remove component if title is defined in mergeOptions (#5634)

When mergeOptions was called without a title component, existing component was undesirably removed.
This commit changes how component is removed when mergeOptions is called. It will now be removed if a component is not defined and title is defined in mergeOptions.
Fixes #5628
Guy Carmeli 5 年前
父节点
当前提交
6d446a8882
没有帐户链接到提交者的电子邮件

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

12
 
12
 
13
 - (instancetype)initWithDefaultOptions:(RNNNavigationOptions *)defaultOptions;
13
 - (instancetype)initWithDefaultOptions:(RNNNavigationOptions *)defaultOptions;
14
 
14
 
15
-- (void)bindViewController:(UIViewController *)boundViewController;
15
+- (void)boundViewController:(UIViewController *)boundViewController;
16
 
16
 
17
 - (void)setDefaultOptions:(RNNNavigationOptions *)defaultOptions;
17
 - (void)setDefaultOptions:(RNNNavigationOptions *)defaultOptions;
18
 
18
 

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

18
     return self;
18
     return self;
19
 }
19
 }
20
 
20
 
21
-- (void)bindViewController:(UIViewController <RNNLayoutProtocol> *)boundViewController {
21
+- (void)boundViewController:(UIViewController *)boundViewController {
22
     self.boundComponentId = boundViewController.layoutInfo.componentId;
22
     self.boundComponentId = boundViewController.layoutInfo.componentId;
23
     _boundViewController = boundViewController;
23
     _boundViewController = boundViewController;
24
 }
24
 }

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

89
 		[CATransaction begin];
89
 		[CATransaction begin];
90
 		[CATransaction setCompletionBlock:completion];
90
 		[CATransaction setCompletionBlock:completion];
91
 		
91
 		
92
-		[vc overrideOptions:newOptions];
93
 		[vc mergeOptions:newOptions];
92
 		[vc mergeOptions:newOptions];
94
 		
93
 		
95
 		[CATransaction commit];
94
 		[CATransaction commit];

+ 2
- 0
lib/ios/RNNComponentOptions.h 查看文件

7
 @property (nonatomic, strong) Text* alignment;
7
 @property (nonatomic, strong) Text* alignment;
8
 @property (nonatomic, strong) Bool* waitForRender;
8
 @property (nonatomic, strong) Bool* waitForRender;
9
 
9
 
10
+- (BOOL)hasValue;
11
+
10
 @end
12
 @end

+ 4
- 0
lib/ios/RNNComponentOptions.m 查看文件

13
 	return self;
13
 	return self;
14
 }
14
 }
15
 
15
 
16
+- (BOOL)hasValue {
17
+	return _name.hasValue;
18
+}
19
+
16
 @end
20
 @end

+ 11
- 7
lib/ios/RNNComponentPresenter.m 查看文件

21
 	return self;
21
 	return self;
22
 }
22
 }
23
 
23
 
24
-- (void)bindViewController:(UIViewController<RNNLayoutProtocol> *)bindedViewController {
25
-	[super bindViewController:bindedViewController];
24
+- (void)boundViewController:(UIViewController *)boundViewController {
25
+	[super boundViewController:boundViewController];
26
 	_navigationButtons = [[RNNNavigationButtons alloc] initWithViewController:self.boundViewController componentRegistry:_componentRegistry];
26
 	_navigationButtons = [[RNNNavigationButtons alloc] initWithViewController:self.boundViewController componentRegistry:_componentRegistry];
27
 }
27
 }
28
 
28
 
80
 - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)currentOptions {
80
 - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)currentOptions {
81
     [super mergeOptions:options resolvedOptions:currentOptions];
81
     [super mergeOptions:options resolvedOptions:currentOptions];
82
 	RNNNavigationOptions * withDefault	= (RNNNavigationOptions *) [[currentOptions overrideOptions:options] withDefault:[self defaultOptions]];
82
 	RNNNavigationOptions * withDefault	= (RNNNavigationOptions *) [[currentOptions overrideOptions:options] withDefault:[self defaultOptions]];
83
-
84
 	UIViewController* viewController = self.boundViewController;
83
 	UIViewController* viewController = self.boundViewController;
85
-	
84
+	[self removeTitleComponentIfNeeded:options];
85
+
86
 	if (options.backgroundImage.hasValue) {
86
 	if (options.backgroundImage.hasValue) {
87
 		[viewController setBackgroundImage:options.backgroundImage.get];
87
 		[viewController setBackgroundImage:options.backgroundImage.get];
88
 	}
88
 	}
155
 
155
 
156
 	if (options.topBar.title.component.name.hasValue) {
156
 	if (options.topBar.title.component.name.hasValue) {
157
 		[self setCustomNavigationTitleView:options perform:nil];
157
 		[self setCustomNavigationTitleView:options perform:nil];
158
-	} else {
159
-		[_customTitleView removeFromSuperview];
160
-		_customTitleView = nil;
161
 	}
158
 	}
162
 
159
 
163
 	[self setTitleViewWithSubtitle:withDefault];
160
 	[self setTitleViewWithSubtitle:withDefault];
169
 	}
166
 	}
170
 }
167
 }
171
 
168
 
169
+- (void)removeTitleComponentIfNeeded:(RNNNavigationOptions *)options {
170
+	if (options.topBar.title.text.hasValue && !options.topBar.component.hasValue) {
171
+		[_customTitleView removeFromSuperview];
172
+		_customTitleView = nil;
173
+	}
174
+}
175
+
172
 - (void)renderComponents:(RNNNavigationOptions *)options perform:(RNNReactViewReadyCompletionBlock)readyBlock {
176
 - (void)renderComponents:(RNNNavigationOptions *)options perform:(RNNReactViewReadyCompletionBlock)readyBlock {
173
 	[self setCustomNavigationTitleView:options perform:readyBlock];
177
 	[self setCustomNavigationTitleView:options perform:readyBlock];
174
 }
178
 }

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

16
 	self = [super initWithCenterViewController:self.center leftDrawerViewController:self.left rightDrawerViewController:self.right];
16
 	self = [super initWithCenterViewController:self.center leftDrawerViewController:self.left rightDrawerViewController:self.right];
17
 	
17
 	
18
 	self.presenter = presenter;
18
 	self.presenter = presenter;
19
-	[self.presenter bindViewController:self];
19
+    [self.presenter boundViewController:self];
20
 	
20
 	
21
 	self.defaultOptions = defaultOptions;
21
 	self.defaultOptions = defaultOptions;
22
 	self.options = options;
22
 	self.options = options;

+ 4
- 4
lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj 查看文件

183
 		506A2B1420973DFD00F43A95 /* RNNErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 506A2B1220973DFD00F43A95 /* RNNErrorHandler.h */; };
183
 		506A2B1420973DFD00F43A95 /* RNNErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 506A2B1220973DFD00F43A95 /* RNNErrorHandler.h */; };
184
 		506A2B1520973DFD00F43A95 /* RNNErrorHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 506A2B1320973DFD00F43A95 /* RNNErrorHandler.m */; };
184
 		506A2B1520973DFD00F43A95 /* RNNErrorHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 506A2B1320973DFD00F43A95 /* RNNErrorHandler.m */; };
185
 		506F630D216A599300AD0D0A /* RNNTabBarControllerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 506F630C216A599300AD0D0A /* RNNTabBarControllerTest.m */; };
185
 		506F630D216A599300AD0D0A /* RNNTabBarControllerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 506F630C216A599300AD0D0A /* RNNTabBarControllerTest.m */; };
186
-		506F630F216A5AD700AD0D0A /* RNNViewControllerPresenterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 506F630E216A5AD700AD0D0A /* RNNViewControllerPresenterTest.m */; };
186
+		506F630F216A5AD700AD0D0A /* RNNComponentPresenterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 506F630E216A5AD700AD0D0A /* RNNComponentPresenterTest.m */; };
187
 		50706E6D20CE7CA5003345C3 /* UIImage+tint.h in Headers */ = {isa = PBXBuildFile; fileRef = 50706E6B20CE7CA5003345C3 /* UIImage+tint.h */; };
187
 		50706E6D20CE7CA5003345C3 /* UIImage+tint.h in Headers */ = {isa = PBXBuildFile; fileRef = 50706E6B20CE7CA5003345C3 /* UIImage+tint.h */; };
188
 		50706E6E20CE7CA5003345C3 /* UIImage+tint.m in Sources */ = {isa = PBXBuildFile; fileRef = 50706E6C20CE7CA5003345C3 /* UIImage+tint.m */; };
188
 		50706E6E20CE7CA5003345C3 /* UIImage+tint.m in Sources */ = {isa = PBXBuildFile; fileRef = 50706E6C20CE7CA5003345C3 /* UIImage+tint.m */; };
189
 		507E7D57201DDD3000444E6C /* RNNSharedElementAnimationOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 507E7D55201DDD3000444E6C /* RNNSharedElementAnimationOptions.h */; };
189
 		507E7D57201DDD3000444E6C /* RNNSharedElementAnimationOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 507E7D55201DDD3000444E6C /* RNNSharedElementAnimationOptions.h */; };
531
 		506A2B1220973DFD00F43A95 /* RNNErrorHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNErrorHandler.h; sourceTree = "<group>"; };
531
 		506A2B1220973DFD00F43A95 /* RNNErrorHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNErrorHandler.h; sourceTree = "<group>"; };
532
 		506A2B1320973DFD00F43A95 /* RNNErrorHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNErrorHandler.m; sourceTree = "<group>"; };
532
 		506A2B1320973DFD00F43A95 /* RNNErrorHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNErrorHandler.m; sourceTree = "<group>"; };
533
 		506F630C216A599300AD0D0A /* RNNTabBarControllerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNTabBarControllerTest.m; sourceTree = "<group>"; };
533
 		506F630C216A599300AD0D0A /* RNNTabBarControllerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNTabBarControllerTest.m; sourceTree = "<group>"; };
534
-		506F630E216A5AD700AD0D0A /* RNNViewControllerPresenterTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNViewControllerPresenterTest.m; sourceTree = "<group>"; };
534
+		506F630E216A5AD700AD0D0A /* RNNComponentPresenterTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNComponentPresenterTest.m; sourceTree = "<group>"; };
535
 		50706E6B20CE7CA5003345C3 /* UIImage+tint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImage+tint.h"; sourceTree = "<group>"; };
535
 		50706E6B20CE7CA5003345C3 /* UIImage+tint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImage+tint.h"; sourceTree = "<group>"; };
536
 		50706E6C20CE7CA5003345C3 /* UIImage+tint.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImage+tint.m"; sourceTree = "<group>"; };
536
 		50706E6C20CE7CA5003345C3 /* UIImage+tint.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImage+tint.m"; sourceTree = "<group>"; };
537
 		507E7D55201DDD3000444E6C /* RNNSharedElementAnimationOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNSharedElementAnimationOptions.h; sourceTree = "<group>"; };
537
 		507E7D55201DDD3000444E6C /* RNNSharedElementAnimationOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNSharedElementAnimationOptions.h; sourceTree = "<group>"; };
1054
 				504753772109C13C00FFFBE6 /* RNNOverlayManagerTest.m */,
1054
 				504753772109C13C00FFFBE6 /* RNNOverlayManagerTest.m */,
1055
 				505EDD31214E4BE80071C7DE /* RNNNavigationControllerTest.m */,
1055
 				505EDD31214E4BE80071C7DE /* RNNNavigationControllerTest.m */,
1056
 				506F630C216A599300AD0D0A /* RNNTabBarControllerTest.m */,
1056
 				506F630C216A599300AD0D0A /* RNNTabBarControllerTest.m */,
1057
-				506F630E216A5AD700AD0D0A /* RNNViewControllerPresenterTest.m */,
1057
+				506F630E216A5AD700AD0D0A /* RNNComponentPresenterTest.m */,
1058
 				509B258E2178BE7A00C83C23 /* RNNStackPresenterTest.m */,
1058
 				509B258E2178BE7A00C83C23 /* RNNStackPresenterTest.m */,
1059
 				502F0E172179C39900367CC3 /* RNNTabBarPresenterTest.m */,
1059
 				502F0E172179C39900367CC3 /* RNNTabBarPresenterTest.m */,
1060
 				50CE8502217C6C9B00084EBF /* RNNSideMenuPresenterTest.m */,
1060
 				50CE8502217C6C9B00084EBF /* RNNSideMenuPresenterTest.m */,
1474
 				502F0E162178D09600367CC3 /* RNNBasePresenterTest.m in Sources */,
1474
 				502F0E162178D09600367CC3 /* RNNBasePresenterTest.m in Sources */,
1475
 				504753782109C13C00FFFBE6 /* RNNOverlayManagerTest.m in Sources */,
1475
 				504753782109C13C00FFFBE6 /* RNNOverlayManagerTest.m in Sources */,
1476
 				502F0E182179C39900367CC3 /* RNNTabBarPresenterTest.m in Sources */,
1476
 				502F0E182179C39900367CC3 /* RNNTabBarPresenterTest.m in Sources */,
1477
-				506F630F216A5AD700AD0D0A /* RNNViewControllerPresenterTest.m in Sources */,
1477
+				506F630F216A5AD700AD0D0A /* RNNComponentPresenterTest.m in Sources */,
1478
 				505963F722676A0000EBB63C /* RNNLayoutManagerTest.m in Sources */,
1478
 				505963F722676A0000EBB63C /* RNNLayoutManagerTest.m in Sources */,
1479
 				7B49FECE1E95098500DEB3EA /* RNNCommandsHandlerTest.m in Sources */,
1479
 				7B49FECE1E95098500DEB3EA /* RNNCommandsHandlerTest.m in Sources */,
1480
 				E5F6C3AB22DB4D0F0093C2CE /* UIColor+RNNUtils.m in Sources */,
1480
 				E5F6C3AB22DB4D0F0093C2CE /* UIColor+RNNUtils.m in Sources */,

+ 3
- 3
lib/ios/ReactNativeNavigationTests/RNNBasePresenterTest.m 查看文件

20
     self.uut = [[RNNBasePresenter alloc] init];
20
     self.uut = [[RNNBasePresenter alloc] init];
21
     self.boundViewController = [RNNComponentViewController new];
21
     self.boundViewController = [RNNComponentViewController new];
22
     self.mockBoundViewController = [OCMockObject partialMockForObject:self.boundViewController];
22
     self.mockBoundViewController = [OCMockObject partialMockForObject:self.boundViewController];
23
-    [self.uut bindViewController:self.mockBoundViewController];
23
+    [self.uut boundViewController:self.mockBoundViewController];
24
     self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
24
     self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
25
 }
25
 }
26
 
26
 
45
 }
45
 }
46
 
46
 
47
 - (void)testApplyOptions_setTabBarItemBadgeShouldNotCalledOnUITabBarController {
47
 - (void)testApplyOptions_setTabBarItemBadgeShouldNotCalledOnUITabBarController {
48
-    [self.uut bindViewController:self.mockBoundViewController];
48
+    [self.uut boundViewController:self.mockBoundViewController];
49
     self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"];
49
     self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"];
50
     [[self.mockBoundViewController reject] setTabBarItemBadge:[[RNNBottomTabOptions alloc] initWithDict:@{@"badge": @"badge"}]];
50
     [[self.mockBoundViewController reject] setTabBarItemBadge:[[RNNBottomTabOptions alloc] initWithDict:@{@"badge": @"badge"}]];
51
     [self.uut applyOptions:self.options];
51
     [self.uut applyOptions:self.options];
53
 }
53
 }
54
 
54
 
55
 - (void)testApplyOptions_setTabBarItemBadgeShouldWhenNoValue {
55
 - (void)testApplyOptions_setTabBarItemBadgeShouldWhenNoValue {
56
-    [self.uut bindViewController:self.mockBoundViewController];
56
+    [self.uut boundViewController:self.mockBoundViewController];
57
     self.options.bottomTab.badge = nil;
57
     self.options.bottomTab.badge = nil;
58
     [[self.mockBoundViewController reject] setTabBarItemBadge:[OCMArg any]];
58
     [[self.mockBoundViewController reject] setTabBarItemBadge:[OCMArg any]];
59
     [self.uut applyOptions:self.options];
59
     [self.uut applyOptions:self.options];

lib/ios/ReactNativeNavigationTests/RNNViewControllerPresenterTest.m → lib/ios/ReactNativeNavigationTests/RNNComponentPresenterTest.m 查看文件

3
 #import "RNNComponentPresenter.h"
3
 #import "RNNComponentPresenter.h"
4
 #import "UIViewController+RNNOptions.h"
4
 #import "UIViewController+RNNOptions.h"
5
 #import "RNNComponentViewController.h"
5
 #import "RNNComponentViewController.h"
6
+#import "UIViewController+LayoutProtocol.h"
7
+#import "RNNTitleViewHelper.h"
6
 
8
 
7
-@interface RNNViewControllerPresenterTest : XCTestCase
9
+@interface RNNComponentPresenterTest : XCTestCase
8
 
10
 
9
 @property (nonatomic, strong) RNNComponentPresenter *uut;
11
 @property (nonatomic, strong) RNNComponentPresenter *uut;
10
 @property (nonatomic, strong) RNNNavigationOptions *options;
12
 @property (nonatomic, strong) RNNNavigationOptions *options;
13
 
15
 
14
 @end
16
 @end
15
 
17
 
16
-@implementation RNNViewControllerPresenterTest
18
+@implementation RNNComponentPresenterTest
17
 
19
 
18
 - (void)setUp {
20
 - (void)setUp {
19
     [super setUp];
21
     [super setUp];
20
 	self.componentRegistry = [OCMockObject partialMockForObject:[RNNReactComponentRegistry new]];
22
 	self.componentRegistry = [OCMockObject partialMockForObject:[RNNReactComponentRegistry new]];
21
 	self.uut = [[RNNComponentPresenter alloc] initWithComponentRegistry:self.componentRegistry:[[RNNNavigationOptions alloc] initEmptyOptions]];
23
 	self.uut = [[RNNComponentPresenter alloc] initWithComponentRegistry:self.componentRegistry:[[RNNNavigationOptions alloc] initEmptyOptions]];
22
 	self.boundViewController = [OCMockObject partialMockForObject:[RNNComponentViewController new]];
24
 	self.boundViewController = [OCMockObject partialMockForObject:[RNNComponentViewController new]];
23
-	[self.uut bindViewController:self.boundViewController];
25
+	[self.uut boundViewController:self.boundViewController];
24
 	self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
26
 	self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
25
 }
27
 }
26
 
28
 
71
 
73
 
72
 - (void)testBindViewControllerShouldCreateNavigationButtonsCreator {
74
 - (void)testBindViewControllerShouldCreateNavigationButtonsCreator {
73
 	RNNComponentPresenter* presenter = [[RNNComponentPresenter alloc] init];
75
 	RNNComponentPresenter* presenter = [[RNNComponentPresenter alloc] init];
74
-	[presenter bindViewController:self.boundViewController];
76
+	[presenter boundViewController:self.boundViewController];
75
 	XCTAssertNotNil(presenter.navigationButtons);
77
 	XCTAssertNotNil(presenter.navigationButtons);
76
 }
78
 }
77
 
79
 
136
 - (void)testReactViewShouldBeReleasedOnDealloc {
138
 - (void)testReactViewShouldBeReleasedOnDealloc {
137
 	RNNComponentViewController* bindViewController = [RNNComponentViewController new];
139
 	RNNComponentViewController* bindViewController = [RNNComponentViewController new];
138
 	bindViewController.layoutInfo = [self createLayoutInfoWithComponentId:@"componentId"];
140
 	bindViewController.layoutInfo = [self createLayoutInfoWithComponentId:@"componentId"];
139
-	[self.uut bindViewController:bindViewController];
141
+	[self.uut boundViewController:bindViewController];
140
 	
142
 	
141
 	self.options.topBar.title.component = [[RNNComponentOptions alloc] initWithDict:@{@"name": @"componentName"}];
143
 	self.options.topBar.title.component = [[RNNComponentOptions alloc] initWithDict:@{@"name": @"componentName"}];
142
 	
144
 	
145
 	[(id)self.componentRegistry verify];
147
 	[(id)self.componentRegistry verify];
146
 }
148
 }
147
 
149
 
148
-- (void)testBindViewControllerShouldSetBindedComponentId {
150
+- (void)testBindViewControllerShouldSetBoundComponentId {
149
 	RNNComponentViewController* bindViewController = [RNNComponentViewController new];
151
 	RNNComponentViewController* bindViewController = [RNNComponentViewController new];
150
 	RNNLayoutInfo* layoutInfo = [[RNNLayoutInfo alloc] init];
152
 	RNNLayoutInfo* layoutInfo = [[RNNLayoutInfo alloc] init];
151
 	layoutInfo.componentId = @"componentId";
153
 	layoutInfo.componentId = @"componentId";
152
 	bindViewController.layoutInfo = layoutInfo;
154
 	bindViewController.layoutInfo = layoutInfo;
153
-	
154
-	[self.uut bindViewController:bindViewController];
155
+
156
+	[self.uut boundViewController:bindViewController];
155
 	XCTAssertEqual(self.uut.boundComponentId, @"componentId");
157
 	XCTAssertEqual(self.uut.boundComponentId, @"componentId");
156
 }
158
 }
157
 
159
 
158
-- (void)testRenderComponentsCreateReactViewWithBindedComponentId {
159
-	RNNComponentViewController* bindedViewController = [RNNComponentViewController new];
160
+- (void)testRenderComponentsCreateReactViewWithBoundComponentId {
161
+	RNNComponentViewController* boundViewController = [RNNComponentViewController new];
160
 	RNNLayoutInfo* layoutInfo = [self createLayoutInfoWithComponentId:@"componentId"];
162
 	RNNLayoutInfo* layoutInfo = [self createLayoutInfoWithComponentId:@"componentId"];
161
-	bindedViewController.layoutInfo = layoutInfo;
162
-	
163
-	[self.uut bindViewController:bindedViewController];
163
+	boundViewController.layoutInfo = layoutInfo;
164
+	[self.uut boundViewController:boundViewController];
164
 	
165
 	
165
 	self.options.topBar.title.component = [[RNNComponentOptions alloc] initWithDict:@{@"name": @"titleComponent"}];
166
 	self.options.topBar.title.component = [[RNNComponentOptions alloc] initWithDict:@{@"name": @"titleComponent"}];
166
 	
167
 	
172
 	XCTAssertEqual(self.uut.boundComponentId, @"componentId");
173
 	XCTAssertEqual(self.uut.boundComponentId, @"componentId");
173
 }
174
 }
174
 
175
 
175
-- (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withTitle {
176
+- (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBoundViewController_withTitle {
176
 	Text* title = [[Text alloc] initWithValue:@"Title"];
177
 	Text* title = [[Text alloc] initWithValue:@"Title"];
177
 	self.options.topBar.backButton.title = title;
178
 	self.options.topBar.backButton.title = title;
178
 	[[(id) self.boundViewController expect] setBackButtonIcon:nil withColor:nil title:title.get];
179
 	[[(id) self.boundViewController expect] setBackButtonIcon:nil withColor:nil title:title.get];
180
 	[(id)self.boundViewController verify];
181
 	[(id)self.boundViewController verify];
181
 }
182
 }
182
 
183
 
183
-- (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withHideTitle {
184
+- (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBoundViewController_withHideTitle {
184
 	Text* title = [[Text alloc] initWithValue:@"Title"];
185
 	Text* title = [[Text alloc] initWithValue:@"Title"];
185
 	self.options.topBar.backButton.title = title;
186
 	self.options.topBar.backButton.title = title;
186
 	self.options.topBar.backButton.showTitle = [[Bool alloc] initWithValue:@(0)];
187
 	self.options.topBar.backButton.showTitle = [[Bool alloc] initWithValue:@(0)];
189
 	[(id)self.boundViewController verify];
190
 	[(id)self.boundViewController verify];
190
 }
191
 }
191
 
192
 
192
-- (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withIcon {
193
+- (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBoundViewController_withIcon {
193
 	Image* image = [[Image alloc] initWithValue:[UIImage new]];
194
 	Image* image = [[Image alloc] initWithValue:[UIImage new]];
194
 	self.options.topBar.backButton.icon = image;
195
 	self.options.topBar.backButton.icon = image;
195
 	[[(id) self.boundViewController expect] setBackButtonIcon:image.get withColor:nil title:nil];
196
 	[[(id) self.boundViewController expect] setBackButtonIcon:image.get withColor:nil title:nil];
197
 	[(id)self.boundViewController verify];
198
 	[(id)self.boundViewController verify];
198
 }
199
 }
199
 
200
 
200
-- (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withDefaultValues {
201
+- (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBoundViewController_withDefaultValues {
201
 	[[(id) self.boundViewController expect] setBackButtonIcon:nil withColor:nil title:nil];
202
 	[[(id) self.boundViewController expect] setBackButtonIcon:nil withColor:nil title:nil];
202
 	[self.uut applyOptionsOnWillMoveToParentViewController:self.options];
203
 	[self.uut applyOptionsOnWillMoveToParentViewController:self.options];
203
 	[(id)self.boundViewController verify];
204
 	[(id)self.boundViewController verify];
204
 }
205
 }
205
 
206
 
207
+- (void)testRemoveTitleComponentIfNeeded_componentIsRemovedIfTitleTextIsDefined {
208
+	id mockTitle = [OCMockObject niceMockForClass:[RNNReactView class]];
209
+    OCMStub([self.componentRegistry createComponentIfNotExists:[OCMArg any] parentComponentId:[OCMArg any] reactViewReadyBlock:nil]).andReturn(mockTitle);
210
+
211
+	RNNComponentOptions* component = [RNNComponentOptions new];
212
+	component.name = [[Text alloc] initWithValue:@"componentName"];
213
+	component.componentId = [[Text alloc] initWithValue:@"someId"];
214
+	_options.topBar.title.component = component;
215
+
216
+	[self.uut mergeOptions:_options resolvedOptions:[[RNNNavigationOptions alloc] initEmptyOptions]];
217
+    XCTAssertNotNil(self.boundViewController.navigationItem.titleView);
218
+	XCTAssertEqual(self.boundViewController.navigationItem.titleView, mockTitle);
219
+
220
+	[[mockTitle expect] removeFromSuperview];
221
+    _options = [[RNNNavigationOptions alloc] initEmptyOptions];
222
+    _options.topBar.title.text = [[Text alloc] initWithValue:@""];
223
+	[self.uut mergeOptions:_options resolvedOptions:[[RNNNavigationOptions alloc] initEmptyOptions]];
224
+    XCTAssertNotEqual(self.boundViewController.navigationItem.titleView, mockTitle);
225
+	[mockTitle verify];
226
+}
227
+
228
+- (void)testRemoveTitleComponentIfNeeded_componentIsNotRemovedIfMergeOptionsIsCalledWithoutTitleText {
229
+    id mockTitle = [OCMockObject niceMockForClass:[RNNReactView class]];
230
+    OCMStub([self.componentRegistry createComponentIfNotExists:[OCMArg any] parentComponentId:[OCMArg any] reactViewReadyBlock:nil]).andReturn(mockTitle);
231
+
232
+    RNNComponentOptions* component = [RNNComponentOptions new];
233
+    component.name = [[Text alloc] initWithValue:@"componentName"];
234
+    component.componentId = [[Text alloc] initWithValue:@"someId"];
235
+    _options.topBar.title.component = component;
236
+
237
+    [self.uut mergeOptions:_options resolvedOptions:[[RNNNavigationOptions alloc] initEmptyOptions]];
238
+    XCTAssertNotNil(self.boundViewController.navigationItem.titleView);
239
+    XCTAssertEqual(self.boundViewController.navigationItem.titleView, mockTitle);
240
+
241
+
242
+    _options = [[RNNNavigationOptions alloc] initEmptyOptions];
243
+    _options.bottomTabs.visible = [[Bool alloc] initWithBOOL:NO];
244
+    [self.uut mergeOptions:_options resolvedOptions:[[RNNNavigationOptions alloc] initEmptyOptions]];
245
+    XCTAssertEqual(self.boundViewController.navigationItem.titleView, mockTitle);
246
+}
206
 
247
 
207
 - (RNNLayoutInfo *)createLayoutInfoWithComponentId:(NSString *)componentId {
248
 - (RNNLayoutInfo *)createLayoutInfoWithComponentId:(NSString *)componentId {
208
 	RNNLayoutInfo* layoutInfo = [[RNNLayoutInfo alloc] init];
249
 	RNNLayoutInfo* layoutInfo = [[RNNLayoutInfo alloc] init];
209
-	layoutInfo.componentId = @"componentId";
250
+	layoutInfo.componentId = componentId;
210
 	return layoutInfo;
251
 	return layoutInfo;
211
 }
252
 }
212
 
253
 

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

17
     [super setUp];
17
     [super setUp];
18
 	self.uut = [[RNNSideMenuPresenter alloc] init];
18
 	self.uut = [[RNNSideMenuPresenter alloc] init];
19
 	self.bindedViewController = [OCMockObject partialMockForObject:[RNNSideMenuController new]];
19
 	self.bindedViewController = [OCMockObject partialMockForObject:[RNNSideMenuController new]];
20
-	[self.uut bindViewController:self.bindedViewController];
20
+    [self.uut boundViewController:self.bindedViewController];
21
 	self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
21
 	self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
22
 }
22
 }
23
 
23
 

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

18
 	[super setUp];
18
 	[super setUp];
19
 	self.uut = [[RNNStackPresenter alloc] init];
19
 	self.uut = [[RNNStackPresenter alloc] init];
20
 	self.boundViewController = [OCMockObject partialMockForObject:[RNNStackController new]];
20
 	self.boundViewController = [OCMockObject partialMockForObject:[RNNStackController new]];
21
-	[self.uut bindViewController:self.boundViewController];
21
+    [self.uut boundViewController:self.boundViewController];
22
 	self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
22
 	self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
23
 }
23
 }
24
 
24
 

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

18
     [super setUp];
18
     [super setUp];
19
     self.uut = [OCMockObject partialMockForObject:[RNNBottomTabsPresenter new]];
19
     self.uut = [OCMockObject partialMockForObject:[RNNBottomTabsPresenter new]];
20
     self.boundViewController = [OCMockObject partialMockForObject:[RNNBottomTabsController new]];
20
     self.boundViewController = [OCMockObject partialMockForObject:[RNNBottomTabsController new]];
21
-    [self.uut bindViewController:self.boundViewController];
21
+    [self.uut boundViewController:self.boundViewController];
22
     self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
22
     self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
23
 }
23
 }
24
 
24
 

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

22
 		[self performSelector:@selector(setViewControllers:) withObject:childViewControllers];
22
 		[self performSelector:@selector(setViewControllers:) withObject:childViewControllers];
23
 	}
23
 	}
24
 	self.presenter = presenter;
24
 	self.presenter = presenter;
25
-	[self.presenter bindViewController:self];
25
+    [self.presenter boundViewController:self];
26
 	[self.presenter applyOptionsOnInit:self.resolveOptions];
26
 	[self.presenter applyOptionsOnInit:self.resolveOptions];
27
 
27
 
28
 	return self;
28
 	return self;