Procházet zdrojové kódy

Fixes backButton doesn't update on childWillAppear

yogevbd před 6 roky
rodič
revize
7f8867da08

+ 1
- 0
lib/ios/RNNNavigationControllerPresenter.m Zobrazit soubor

27
 	[navigationController rnn_setNavigationBarLargeTitleFontFamily:[options.topBar.largeTitle.fontFamily getWithDefaultValue:nil] fontSize:[options.topBar.largeTitle.fontSize getWithDefaultValue:nil] color:[options.topBar.largeTitle.color getWithDefaultValue:nil]];
27
 	[navigationController rnn_setNavigationBarLargeTitleFontFamily:[options.topBar.largeTitle.fontFamily getWithDefaultValue:nil] fontSize:[options.topBar.largeTitle.fontSize getWithDefaultValue:nil] color:[options.topBar.largeTitle.color getWithDefaultValue:nil]];
28
 	[navigationController rnn_setNavigationBarFontFamily:[options.topBar.title.fontFamily getWithDefaultValue:nil] fontSize:[options.topBar.title.fontSize getWithDefaultValue:nil] color:[options.topBar.title.color getWithDefaultValue:nil]];
28
 	[navigationController rnn_setNavigationBarFontFamily:[options.topBar.title.fontFamily getWithDefaultValue:nil] fontSize:[options.topBar.title.fontSize getWithDefaultValue:nil] color:[options.topBar.title.color getWithDefaultValue:nil]];
29
 	[navigationController rnn_setBackButtonColor:[options.topBar.backButton.color getWithDefaultValue:nil]];
29
 	[navigationController rnn_setBackButtonColor:[options.topBar.backButton.color getWithDefaultValue:nil]];
30
+	[navigationController rnn_setBackButtonIcon:[options.topBar.backButton.icon getWithDefaultValue:nil] withColor:[options.topBar.backButton.color getWithDefaultValue:nil] title:[options.topBar.backButton.showTitle getWithDefaultValue:YES] ? [options.topBar.backButton.title getWithDefaultValue:nil] : @""];
30
 }
31
 }
31
 
32
 
32
 - (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options {
33
 - (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options {

+ 50
- 22
lib/ios/ReactNativeNavigationTests/RNNNavigationControllerPresenterTest.m Zobrazit soubor

15
 @implementation RNNNavigationControllerPresenterTest
15
 @implementation RNNNavigationControllerPresenterTest
16
 
16
 
17
 - (void)setUp {
17
 - (void)setUp {
18
-    [super setUp];
18
+	[super setUp];
19
 	self.uut = [[RNNNavigationControllerPresenter alloc] init];
19
 	self.uut = [[RNNNavigationControllerPresenter alloc] init];
20
 	self.bindedViewController = [OCMockObject partialMockForObject:[RNNNavigationController new]];
20
 	self.bindedViewController = [OCMockObject partialMockForObject:[RNNNavigationController new]];
21
 	[self.uut bindViewController:self.bindedViewController];
21
 	[self.uut bindViewController:self.bindedViewController];
22
 	self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
22
 	self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
23
 }
23
 }
24
 
24
 
25
-- (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withDefaultValues {
26
-	[[_bindedViewController expect] rnn_setBackButtonIcon:nil withColor:nil title:nil];
27
-	[self.uut applyOptionsOnWillMoveToParentViewController:self.options];
28
-	[_bindedViewController verify];
29
-}
30
-
31
 - (void)testApplyOptions_shouldSetBackButtonColor_withDefaultValues {
25
 - (void)testApplyOptions_shouldSetBackButtonColor_withDefaultValues {
32
 	[[_bindedViewController expect] rnn_setBackButtonColor:nil];
26
 	[[_bindedViewController expect] rnn_setBackButtonColor:nil];
33
 	[self.uut applyOptions:self.options];
27
 	[self.uut applyOptions:self.options];
41
 	[_bindedViewController verify];
35
 	[_bindedViewController verify];
42
 }
36
 }
43
 
37
 
44
-- (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withIcon {
45
-    Image* image = [[Image alloc] initWithValue:[UIImage new]];
46
-    self.options.topBar.backButton.icon = image;
38
+
39
+- (void)testApplyOptions_shouldSetBackButtonOnBindedViewController_withTitle {
40
+	Text* title = [[Text alloc] initWithValue:@"Title"];
41
+	self.options.topBar.backButton.title = title;
42
+	[[_bindedViewController expect] rnn_setBackButtonIcon:nil withColor:nil title:title.get];
43
+	[self.uut applyOptions:self.options];
44
+	[_bindedViewController verify];
45
+}
46
+
47
+- (void)testApplyOptions_shouldSetBackButtonOnBindedViewController_withHideTitle {
48
+	Text* title = [[Text alloc] initWithValue:@"Title"];
49
+	self.options.topBar.backButton.title = title;
50
+	self.options.topBar.backButton.showTitle = [[Bool alloc] initWithValue:@(0)];
51
+	[[_bindedViewController expect] rnn_setBackButtonIcon:nil withColor:nil title:@""];
52
+	[self.uut applyOptions:self.options];
53
+	[_bindedViewController verify];
54
+}
55
+
56
+- (void)testApplyOptions_shouldSetBackButtonOnBindedViewController_withIcon {
57
+	Image* image = [[Image alloc] initWithValue:[UIImage new]];
58
+	self.options.topBar.backButton.icon = image;
47
 	[[_bindedViewController expect] rnn_setBackButtonIcon:image.get withColor:nil title:nil];
59
 	[[_bindedViewController expect] rnn_setBackButtonIcon:image.get withColor:nil title:nil];
48
-	[self.uut applyOptionsOnWillMoveToParentViewController:self.options];
60
+	[self.uut applyOptions:self.options];
49
 	[_bindedViewController verify];
61
 	[_bindedViewController verify];
50
 }
62
 }
51
 
63
 
52
 - (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withTitle {
64
 - (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withTitle {
53
-    Text* title = [[Text alloc] initWithValue:@"Title"];
54
-    self.options.topBar.backButton.title = title;
55
-    [[_bindedViewController expect] rnn_setBackButtonIcon:nil withColor:nil title:title.get];
56
-    [self.uut applyOptionsOnWillMoveToParentViewController:self.options];
57
-    [_bindedViewController verify];
65
+	Text* title = [[Text alloc] initWithValue:@"Title"];
66
+	self.options.topBar.backButton.title = title;
67
+	[[_bindedViewController expect] rnn_setBackButtonIcon:nil withColor:nil title:title.get];
68
+	[self.uut applyOptionsOnWillMoveToParentViewController:self.options];
69
+	[_bindedViewController verify];
58
 }
70
 }
59
 
71
 
60
 - (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withHideTitle {
72
 - (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withHideTitle {
61
-    Text* title = [[Text alloc] initWithValue:@"Title"];
62
-    self.options.topBar.backButton.title = title;
63
-    self.options.topBar.backButton.showTitle = [[Bool alloc] initWithValue:@(0)];
64
-    [[_bindedViewController expect] rnn_setBackButtonIcon:nil withColor:nil title:@""];
65
-    [self.uut applyOptionsOnWillMoveToParentViewController:self.options];
66
-    [_bindedViewController verify];
73
+	Text* title = [[Text alloc] initWithValue:@"Title"];
74
+	self.options.topBar.backButton.title = title;
75
+	self.options.topBar.backButton.showTitle = [[Bool alloc] initWithValue:@(0)];
76
+	[[_bindedViewController expect] rnn_setBackButtonIcon:nil withColor:nil title:@""];
77
+	[self.uut applyOptionsOnWillMoveToParentViewController:self.options];
78
+	[_bindedViewController verify];
79
+}
80
+
81
+- (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withIcon {
82
+	Image* image = [[Image alloc] initWithValue:[UIImage new]];
83
+	self.options.topBar.backButton.icon = image;
84
+	[[_bindedViewController expect] rnn_setBackButtonIcon:image.get withColor:nil title:nil];
85
+	[self.uut applyOptionsOnWillMoveToParentViewController:self.options];
86
+	[_bindedViewController verify];
67
 }
87
 }
68
 
88
 
89
+- (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withDefaultValues {
90
+	[[_bindedViewController expect] rnn_setBackButtonIcon:nil withColor:nil title:nil];
91
+	[self.uut applyOptionsOnWillMoveToParentViewController:self.options];
92
+	[_bindedViewController verify];
93
+}
94
+
95
+
96
+
69
 @end
97
 @end