Преглед изворни кода

[V2][iOS] Added waitForRender support for setStackRoot (#5141)

* Properly check setStackRoot animation and waitForRender of each child

* Read waitForRender from the last child of the new stackRoot

* Fixed indentation

* Use setStackRoot.waitForRender instead of push.waitForRender

* Fixed merge issues caused by the text editor

* removed eof newline

* Added a missing semicolon

* Variable toVC renamed to newVC for consistency

* Fixed indentation problems
Jasu пре 5 година
родитељ
комит
5459fa5344
1 измењених фајлова са 9 додато и 5 уклоњено
  1. 9
    5
      lib/ios/RNNCommandsHandler.m

+ 9
- 5
lib/ios/RNNCommandsHandler.m Прегледај датотеку

@@ -175,13 +175,17 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
175 175
 	for (UIViewController<RNNLayoutProtocol>* viewController in childViewControllers) {
176 176
 		[viewController renderTreeAndWait:NO perform:nil];
177 177
 	}
178
-	RNNNavigationOptions* options = childViewControllers.lastObject.resolveOptions;
178
+	UIViewController *newVC = childViewControllers.lastObject;
179 179
 	UIViewController *fromVC = [RNNLayoutManager findComponentForId:componentId];
180
+	RNNNavigationOptions* options = newVC.resolveOptions;
180 181
 	__weak typeof(RNNEventEmitter*) weakEventEmitter = _eventEmitter;
181
-	[_stackManager setStackChildren:childViewControllers fromViewController:fromVC animated:[options.animations.setStackRoot.enable getWithDefaultValue:YES] completion:^{
182
-		[weakEventEmitter sendOnNavigationCommandCompletion:setStackRoot commandId:commandId params:@{@"componentId": componentId}];
183
-		completion();
184
-	} rejection:rejection];
182
+
183
+	[newVC renderTreeAndWait:([options.animations.setStackRoot.waitForRender getWithDefaultValue:NO]) perform:^{
184
+		[_stackManager setStackChildren:childViewControllers fromViewController:fromVC animated:[options.animations.setStackRoot.enable getWithDefaultValue:YES] completion:^{
185
+			[weakEventEmitter sendOnNavigationCommandCompletion:setStackRoot commandId:commandId params:@{@"componentId": componentId}];
186
+			completion();
187
+		} rejection:rejection];
188
+	}]; 
185 189
 }
186 190
 
187 191
 - (void)pop:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary*)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {