Browse Source

Fixes topBar.backButton.color - #4164

yogevbd 6 years ago
parent
commit
3a1637b056

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

@@ -26,6 +26,7 @@
26 26
 	[navigationController rnn_setNavigationBarLargeTitleVisible:[options.topBar.largeTitle.visible getWithDefaultValue:NO]];
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
+	[navigationController rnn_setBackButtonColor:[options.topBar.backButton.color getWithDefaultValue:nil]];
29 30
 }
30 31
 
31 32
 - (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options {
@@ -94,6 +95,10 @@
94 95
 		
95 96
 	}
96 97
 	
98
+	if (options.topBar.backButton.color.hasValue) {
99
+		[navigationController rnn_setBackButtonColor:options.topBar.backButton.color.get];
100
+	}
101
+	
97 102
 	[navigationController rnn_setNavigationBarLargeTitleFontFamily:[withDefault.topBar.largeTitle.fontFamily getWithDefaultValue:nil] fontSize:[withDefault.topBar.largeTitle.fontSize getWithDefaultValue:nil] color:[withDefault.topBar.largeTitle.color getWithDefaultValue:nil]];
98 103
 	
99 104
 	[navigationController rnn_setNavigationBarFontFamily:[withDefault.topBar.title.fontFamily getWithDefaultValue:nil] fontSize:[withDefault.topBar.title.fontSize getWithDefaultValue:nil] color:[withDefault.topBar.title.color getWithDefaultValue:nil]];

+ 13
- 0
lib/ios/ReactNativeNavigationTests/RNNNavigationControllerPresenterTest.m View File

@@ -28,6 +28,19 @@
28 28
 	[_bindedViewController verify];
29 29
 }
30 30
 
31
+- (void)testApplyOptions_shouldSetBackButtonColor_withDefaultValues {
32
+	[[_bindedViewController expect] rnn_setBackButtonColor:nil];
33
+	[self.uut applyOptions:self.options];
34
+	[_bindedViewController verify];
35
+}
36
+
37
+- (void)testApplyOptions_shouldSetBackButtonColor_withColor {
38
+	self.options.topBar.backButton.color = [[Color alloc] initWithValue:[UIColor redColor]];
39
+	[[_bindedViewController expect] rnn_setBackButtonColor:[UIColor redColor]];
40
+	[self.uut applyOptions:self.options];
41
+	[_bindedViewController verify];
42
+}
43
+
31 44
 - (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withIcon {
32 45
     Image* image = [[Image alloc] initWithValue:[UIImage new]];
33 46
     self.options.topBar.backButton.icon = image;

+ 2
- 0
lib/ios/UINavigationController+RNNOptions.h View File

@@ -30,4 +30,6 @@
30 30
 
31 31
 - (void)rnn_setNavigationBarLargeTitleFontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize color:(UIColor *)color;
32 32
 
33
+- (void)rnn_setBackButtonColor:(UIColor *)color;
34
+
33 35
 @end

+ 5
- 1
lib/ios/UINavigationController+RNNOptions.m View File

@@ -114,10 +114,14 @@ const NSInteger BLUR_TOPBAR_TAG = 78264802;
114 114
 	
115 115
 	backItem.title = title ? title : lastViewControllerInStack.navigationItem.title;
116 116
 	backItem.tintColor = color;
117
-	
117
+
118 118
 	lastViewControllerInStack.navigationItem.backBarButtonItem = backItem;
119 119
 }
120 120
 
121
+- (void)rnn_setBackButtonColor:(UIColor *)color {
122
+	self.navigationBar.tintColor = color;
123
+}
124
+
121 125
 - (void)rnn_setNavigationBarClipsToBounds:(BOOL)clipsToBounds {
122 126
 	self.navigationBar.clipsToBounds = clipsToBounds;
123 127
 }