소스 검색

Fixes bottomTab.badge for bottomTabs inside sideMenu - #4171

yogevbd 5 년 전
부모
커밋
8e9c647fa5
4개의 변경된 파일19개의 추가작업 그리고 7개의 파일을 삭제
  1. 6
    0
      e2e/ScreenStyle.test.js
  2. 2
    2
      lib/ios/RNNBottomTabPresenter.m
  3. 0
    4
      lib/ios/RNNTabBarController.m
  4. 11
    1
      lib/ios/ReactNativeNavigationTests/RNNBottomTabPresenterTest.m

+ 6
- 0
e2e/ScreenStyle.test.js 파일 보기

58
     await expect(element(by.text('TeSt'))).toBeVisible();
58
     await expect(element(by.text('TeSt'))).toBeVisible();
59
   });
59
   });
60
 
60
 
61
+  test('set Tab Bar badge on a current Tab appear once', async () => {
62
+    await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
63
+    await elementById(testIDs.SET_TAB_BADGE_BUTTON).tap();
64
+    await expect(element(by.text('TeSt'))).toBeVisible();
65
+  });
66
+
61
   test(':android: hide Tab Bar', async () => {
67
   test(':android: hide Tab Bar', async () => {
62
     await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
68
     await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
63
     await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
69
     await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();

+ 2
- 2
lib/ios/RNNBottomTabPresenter.m 파일 보기

26
 		[options.bottomTab.selectedIcon consume];
26
 		[options.bottomTab.selectedIcon consume];
27
 	}
27
 	}
28
 	
28
 	
29
-	if (![viewController isKindOfClass:[UITabBarController class]]) {
29
+	if ([viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
30
 		[viewController rnn_setTabBarItemBadge:[options.bottomTab.badge getWithDefaultValue:nil]];
30
 		[viewController rnn_setTabBarItemBadge:[options.bottomTab.badge getWithDefaultValue:nil]];
31
 	}
31
 	}
32
 }
32
 }
33
 
33
 
34
 - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)resolvedOptions {
34
 - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)resolvedOptions {
35
 	UIViewController* viewController = self.bindedViewController;
35
 	UIViewController* viewController = self.bindedViewController;
36
-	if (options.bottomTab.badge.hasValue && ![viewController isKindOfClass:[UITabBarController class]]) {
36
+	if (options.bottomTab.badge.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
37
 		[viewController rnn_setTabBarItemBadge:options.bottomTab.badge.get];
37
 		[viewController rnn_setTabBarItemBadge:options.bottomTab.badge.get];
38
 	}
38
 	}
39
 }
39
 }

+ 0
- 4
lib/ios/RNNTabBarController.m 파일 보기

52
 	[((UIViewController<RNNLayoutProtocol> *)self.parentViewController) mergeOptions:options];
52
 	[((UIViewController<RNNLayoutProtocol> *)self.parentViewController) mergeOptions:options];
53
 }
53
 }
54
 
54
 
55
-- (UITabBarItem *)tabBarItem {
56
-	return self.viewControllers.lastObject.tabBarItem;
57
-}
58
-
59
 - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
55
 - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
60
 	return self.selectedViewController.supportedInterfaceOrientations;
56
 	return self.selectedViewController.supportedInterfaceOrientations;
61
 }
57
 }

+ 11
- 1
lib/ios/ReactNativeNavigationTests/RNNBottomTabPresenterTest.m 파일 보기

21
     self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
21
     self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
22
 }
22
 }
23
 
23
 
24
-- (void)testApplyOptions_shouldSetTabBarItemBadgeWithDefault {
24
+- (void)testApplyOptions_shouldSetTabBarItemBadgeWithDefaultWhenParentIsUITabBarController {
25
+	UITabBarController* tabBarController = [[UITabBarController alloc] init];
26
+	[tabBarController setViewControllers:@[self.bindedViewController]];
25
 	[[self.bindedViewController expect] rnn_setTabBarItemBadge:nil];
27
 	[[self.bindedViewController expect] rnn_setTabBarItemBadge:nil];
26
 	[self.uut applyOptions:self.options];
28
 	[self.uut applyOptions:self.options];
27
 	[self.bindedViewController verify];
29
 	[self.bindedViewController verify];
28
 }
30
 }
29
 
31
 
32
+- (void)testApplyOptions_shouldSetTabBarItemBadgeOnlyWhenParentIsUITabBarController {
33
+	[[self.bindedViewController reject] rnn_setTabBarItemBadge:[OCMArg any]];
34
+	[self.uut applyOptions:self.options];
35
+	[self.bindedViewController verify];
36
+}
37
+
30
 - (void)testApplyOptions_shouldSetTabBarItemBadgeWithValue {
38
 - (void)testApplyOptions_shouldSetTabBarItemBadgeWithValue {
39
+	UITabBarController* tabBarController = [[UITabBarController alloc] init];
40
+	[tabBarController setViewControllers:@[self.bindedViewController]];
31
 	self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"];
41
 	self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"];
32
 	[[self.bindedViewController expect] rnn_setTabBarItemBadge:@"badge"];
42
 	[[self.bindedViewController expect] rnn_setTabBarItemBadge:@"badge"];
33
 	[self.uut applyOptions:self.options];
43
 	[self.uut applyOptions:self.options];