소스 검색

Fixes backButton doesn't update on childWillAppear

yogevbd 6 년 전
부모
커밋
7f8867da08
2개의 변경된 파일51개의 추가작업 그리고 22개의 파일을 삭제
  1. 1
    0
      lib/ios/RNNNavigationControllerPresenter.m
  2. 50
    22
      lib/ios/ReactNativeNavigationTests/RNNNavigationControllerPresenterTest.m

+ 1
- 0
lib/ios/RNNNavigationControllerPresenter.m 파일 보기

@@ -27,6 +27,7 @@
27 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 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 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 33
 - (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options {

+ 50
- 22
lib/ios/ReactNativeNavigationTests/RNNNavigationControllerPresenterTest.m 파일 보기

@@ -15,19 +15,13 @@
15 15
 @implementation RNNNavigationControllerPresenterTest
16 16
 
17 17
 - (void)setUp {
18
-    [super setUp];
18
+	[super setUp];
19 19
 	self.uut = [[RNNNavigationControllerPresenter alloc] init];
20 20
 	self.bindedViewController = [OCMockObject partialMockForObject:[RNNNavigationController new]];
21 21
 	[self.uut bindViewController:self.bindedViewController];
22 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 25
 - (void)testApplyOptions_shouldSetBackButtonColor_withDefaultValues {
32 26
 	[[_bindedViewController expect] rnn_setBackButtonColor:nil];
33 27
 	[self.uut applyOptions:self.options];
@@ -41,29 +35,63 @@
41 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 59
 	[[_bindedViewController expect] rnn_setBackButtonIcon:image.get withColor:nil title:nil];
48
-	[self.uut applyOptionsOnWillMoveToParentViewController:self.options];
60
+	[self.uut applyOptions:self.options];
49 61
 	[_bindedViewController verify];
50 62
 }
51 63
 
52 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 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 97
 @end