Browse Source

Fix badge should not reset

yogevbd 6 years ago
parent
commit
40d3472fdb

+ 2
- 2
lib/ios/RNNBasePresenter.m View File

@@ -26,8 +26,8 @@
26 26
 - (void)applyOptions:(RNNNavigationOptions *)options {
27 27
 	UIViewController* viewController = self.bindedViewController;
28 28
 	
29
-	if ([viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
30
-		[viewController rnn_setTabBarItemBadge:[options.bottomTab.badge getWithDefaultValue:nil]];
29
+	if (options.bottomTab.badge.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
30
+		[viewController rnn_setTabBarItemBadge:options.bottomTab.badge.get];
31 31
 	}
32 32
 }
33 33
 

+ 8
- 7
lib/ios/ReactNativeNavigationTests/RNNBasePresenterTest.m View File

@@ -29,13 +29,6 @@
29 29
 	self.bindedViewController = nil;
30 30
 }
31 31
 
32
-- (void)testApplyOptions_shouldSetTabBarItemBadgeWithDefaultWhenParentIsUITabBarController {
33
-	OCMStub([self.mockBindedViewController parentViewController]).andReturn([UITabBarController new]);
34
-	[[self.mockBindedViewController expect] rnn_setTabBarItemBadge:nil];
35
-	[self.uut applyOptions:self.options];
36
-	[self.mockBindedViewController verify];
37
-}
38
-
39 32
 - (void)testApplyOptions_shouldSetTabBarItemBadgeOnlyWhenParentIsUITabBarController {
40 33
 	[[self.mockBindedViewController reject] rnn_setTabBarItemBadge:[OCMArg any]];
41 34
 	[self.uut applyOptions:self.options];
@@ -58,4 +51,12 @@
58 51
 	[self.mockBindedViewController verify];
59 52
 }
60 53
 
54
+- (void)testApplyOptions_setTabBarItemBadgeShouldWhenNoValue {
55
+	[self.uut bindViewController:self.mockBindedViewController];
56
+	self.options.bottomTab.badge = nil;
57
+	[[self.mockBindedViewController reject] rnn_setTabBarItemBadge:[OCMArg any]];
58
+	[self.uut applyOptions:self.options];
59
+	[self.mockBindedViewController verify];
60
+}
61
+
61 62
 @end