Browse Source

Closes #3787 (#3934)

* Closes #3787

* Merge options only when viewController conforms to RNNRootViewProtocol

* better practice

* Fixes e2e
Yogev Ben David 6 years ago
parent
commit
ba626e919e
No account linked to committer's email address
3 changed files with 4 additions and 32 deletions
  1. 4
    19
      lib/ios/RNNCommandsHandler.m
  2. 0
    1
      lib/ios/RNNTabBarController.h
  3. 0
    12
      lib/ios/RNNTabBarController.m

+ 4
- 19
lib/ios/RNNCommandsHandler.m View File

67
 - (void)mergeOptions:(NSString*)componentId options:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion {
67
 - (void)mergeOptions:(NSString*)componentId options:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion {
68
 	[self assertReady];
68
 	[self assertReady];
69
 	
69
 	
70
-	UIViewController* vc = [_store findComponentForId:componentId];
71
-	if([vc isKindOfClass:[RNNRootViewController class]]) {
72
-		RNNRootViewController* rootVc = (RNNRootViewController*)vc;
73
-		[rootVc.options mergeWith:options];
70
+	UIViewController<RNNRootViewProtocol>* vc = (UIViewController<RNNRootViewProtocol>*)[_store findComponentForId:componentId];
71
+	if ([vc conformsToProtocol:@protocol(RNNRootViewProtocol)] || [vc isKindOfClass:[RNNRootViewController class]]) {
72
+		[vc.getLeafViewController.options mergeWith:options];
74
 		[CATransaction begin];
73
 		[CATransaction begin];
75
 		[CATransaction setCompletionBlock:completion];
74
 		[CATransaction setCompletionBlock:completion];
76
-		
77
-		[rootVc.options applyOn:vc];
78
-		
79
-		[CATransaction commit];
80
-	}
81
-	
82
-	if ([vc isKindOfClass:[RNNSplitViewController class]]) {
83
-		RNNSplitViewController* splitVc = (RNNSplitViewController*)vc;
84
-		[splitVc.options mergeWith:options];
85
-		[CATransaction begin];
86
-		[CATransaction setCompletionBlock:completion];
87
-		
88
-		[splitVc.options applyOn:vc];
89
-		
75
+		[vc.getLeafViewController.options applyOn:vc.getLeafViewController];
90
 		[CATransaction commit];
76
 		[CATransaction commit];
91
 	}
77
 	}
92
-	
93
 }
78
 }
94
 
79
 
95
 - (void)setDefaultOptions:(NSDictionary*)optionsDict completion:(RNNTransitionCompletionBlock)completion {
80
 - (void)setDefaultOptions:(NSDictionary*)optionsDict completion:(RNNTransitionCompletionBlock)completion {

+ 0
- 1
lib/ios/RNNTabBarController.h View File

7
 
7
 
8
 - (instancetype)initWithEventEmitter:(RNNEventEmitter*)eventEmitter;
8
 - (instancetype)initWithEventEmitter:(RNNEventEmitter*)eventEmitter;
9
 
9
 
10
-- (void)setTabBarHidden:(BOOL)hidden animated:(BOOL)animated;
11
 - (void)setSelectedIndexByComponentID:(NSString *)componentID;
10
 - (void)setSelectedIndexByComponentID:(NSString *)componentID;
12
 
11
 
13
 @end
12
 @end

+ 0
- 12
lib/ios/RNNTabBarController.m View File

19
 	return self.selectedViewController.supportedInterfaceOrientations;
19
 	return self.selectedViewController.supportedInterfaceOrientations;
20
 }
20
 }
21
 
21
 
22
-- (void)setTabBarHidden:(BOOL)hidden animated:(BOOL)animated {
23
-	CGRect frame = self.tabBar.frame;
24
-	CGFloat height = frame.size.height;
25
-	CGFloat offsetY = (hidden ? self.view.frame.size.height : self.view.frame.size.height-height);
26
-	frame.origin.y = offsetY;
27
-	NSTimeInterval duration = animated ? kTabBarHiddenDuration : 0.0;
28
-	
29
-	[UIView animateWithDuration:duration animations:^{
30
-		self.tabBar.frame = frame;
31
-	}];
32
-}
33
-
34
 - (void)setSelectedIndexByComponentID:(NSString *)componentID {
22
 - (void)setSelectedIndexByComponentID:(NSString *)componentID {
35
 	for (id child in self.childViewControllers) {
23
 	for (id child in self.childViewControllers) {
36
 		RNNRootViewController* vc = child;
24
 		RNNRootViewController* vc = child;