@@ -58,12 +58,13 @@ - (void)setRoot:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)c
5858 [_modalManager dismissAllModalsAnimated: NO ];
5959 [_store removeAllComponentsFromWindow: _mainWindow];
6060
61- UIViewController *vc = [_controllerFactory createLayout: layout[@" root" ] saveToStore: _store ];
61+ UIViewController<RNNLayoutProtocol> *vc = [_controllerFactory createLayout: layout[@" root" ]];
6262
63- _mainWindow.rootViewController = vc;
64-
65- [_eventEmitter sendOnNavigationCommandCompletion: setRoot params: @{@" layout" : layout}];
66- completion ();
63+ [vc renderTreeAndWait: [vc.resolveOptions.animations.setRoot.waitForRender getWithDefaultValue: NO ] perform: ^{
64+ _mainWindow.rootViewController = vc;
65+ [_eventEmitter sendOnNavigationCommandCompletion: setRoot params: @{@" layout" : layout}];
66+ completion () ;
67+ }];
6768}
6869
6970- (void )mergeOptions : (NSString *)componentId options : (NSDictionary *)mergeOptions completion : (RNNTransitionCompletionBlock)completion {
@@ -96,7 +97,7 @@ - (void)setDefaultOptions:(NSDictionary*)optionsDict completion:(RNNTransitionCo
9697- (void )push : (NSString *)componentId layout : (NSDictionary *)layout completion : (RNNTransitionCompletionBlock)completion rejection : (RCTPromiseRejectBlock)rejection {
9798 [self assertReady ];
9899
99- UIViewController<RNNLayoutProtocol> *newVc = [_controllerFactory createLayout: layout saveToStore: _store ];
100+ UIViewController<RNNLayoutProtocol> *newVc = [_controllerFactory createLayout: layout];
100101 UIViewController *fromVC = [_store findComponentForId: componentId];
101102
102103 if ([[newVc.resolveOptions.preview.reactTag getWithDefaultValue: @(0 )] floatValue ] > 0 ) {
@@ -141,8 +142,8 @@ - (void)push:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNN
141142 }
142143 } else {
143144 id animationDelegate = (newVc.resolveOptions .animations .push .hasCustomAnimation || newVc.getCurrentLeaf .isCustomTransitioned ) ? newVc : nil ;
144- [newVc.getCurrentLeaf waitForReactViewRender: ( newVc.resolveOptions.animations.push.waitForRender || animationDelegate) perform: ^{
145- [_stackManager push: newVc onTop: fromVC animated: newVc.resolveOptions.animations.push.enable animationDelegate: animationDelegate completion: ^{
145+ [newVc renderTreeAndWait: ([ newVc.resolveOptions.animations.push.waitForRender getWithDefaultValue: NO ] || animationDelegate) perform: ^{
146+ [_stackManager push: newVc onTop: fromVC animated: [ newVc.resolveOptions.animations.push.enable getWithDefaultValue: YES ] animationDelegate: animationDelegate completion: ^{
146147 [_eventEmitter sendOnNavigationCommandCompletion: push params: @{@" componentId" : componentId}];
147148 completion ();
148149 } rejection: rejection];
@@ -153,11 +154,14 @@ - (void)push:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNN
153154- (void )setStackRoot : (NSString *)componentId children : (NSArray *)children completion : (RNNTransitionCompletionBlock)completion rejection : (RCTPromiseRejectBlock)rejection {
154155 [self assertReady ];
155156
156- NSArray <RNNLayoutProtocol> *childViewControllers = [_controllerFactory createChildrenLayout: children saveToStore: _store];
157+ NSArray <RNNLayoutProtocol> *childViewControllers = [_controllerFactory createChildrenLayout: children];
158+ for (UIViewController<RNNLayoutProtocol>* viewController in childViewControllers) {
159+ [viewController renderTreeAndWait: NO perform: nil ];
160+ }
157161 RNNNavigationOptions* options = [childViewControllers.lastObject getCurrentChild ].resolveOptions ;
158162 UIViewController *fromVC = [_store findComponentForId: componentId];
159163 __weak typeof (RNNEventEmitter*) weakEventEmitter = _eventEmitter;
160- [_stackManager setStackChildren: childViewControllers fromViewController: fromVC animated: options.animations.setStackRoot.enable completion: ^{
164+ [_stackManager setStackChildren: childViewControllers fromViewController: fromVC animated: [ options.animations.setStackRoot.enable getWithDefaultValue: YES ] completion: ^{
161165 [weakEventEmitter sendOnNavigationCommandCompletion: setStackRoot params: @{@" componentId" : componentId}];
162166 completion ();
163167 } rejection: rejection];
@@ -181,10 +185,10 @@ - (void)pop:(NSString*)componentId mergeOptions:(NSDictionary*)mergeOptions comp
181185 } else {
182186 NSMutableArray * vcs = nvc.viewControllers .mutableCopy ;
183187 [vcs removeObject: vc];
184- [nvc setViewControllers: vcs animated: vc.resolveOptions.animations.pop.enable];
188+ [nvc setViewControllers: vcs animated: [ vc.resolveOptions.animations.pop.enable getWithDefaultValue: YES ] ];
185189 }
186190
187- [_stackManager pop: vc animated: vc.resolveOptions.animations.pop.enable completion: ^{
191+ [_stackManager pop: vc animated: [ vc.resolveOptions.animations.pop.enable getWithDefaultValue: YES ] completion: ^{
188192 [_store removeComponent: componentId];
189193 [_eventEmitter sendOnNavigationCommandCompletion: pop params: @{@" componentId" : componentId}];
190194 completion ();
@@ -197,7 +201,7 @@ - (void)popTo:(NSString*)componentId mergeOptions:(NSDictionary *)mergeOptions c
197201 RNNNavigationOptions *options = [[RNNNavigationOptions alloc ] initWithDict: mergeOptions];
198202 [vc overrideOptions: options];
199203
200- [_stackManager popTo: vc animated: vc.resolveOptions.animations.pop.enable completion: ^(NSArray *poppedViewControllers) {
204+ [_stackManager popTo: vc animated: [ vc.resolveOptions.animations.pop.enable getWithDefaultValue: YES ] completion: ^(NSArray *poppedViewControllers) {
201205 [_eventEmitter sendOnNavigationCommandCompletion: popTo params: @{@" componentId" : componentId}];
202206 [self removePopedViewControllers: poppedViewControllers];
203207 completion ();
@@ -216,7 +220,7 @@ - (void)popToRoot:(NSString*)componentId mergeOptions:(NSDictionary *)mergeOptio
216220 completion ();
217221 }];
218222
219- [_stackManager popToRoot: vc animated: vc.resolveOptions.animations.pop.enable completion: ^(NSArray *poppedViewControllers) {
223+ [_stackManager popToRoot: vc animated: [ vc.resolveOptions.animations.pop.enable getWithDefaultValue: YES ] completion: ^(NSArray *poppedViewControllers) {
220224 [self removePopedViewControllers: poppedViewControllers];
221225 } rejection: ^(NSString *code, NSString *message, NSError *error) {
222226
@@ -228,10 +232,10 @@ - (void)popToRoot:(NSString*)componentId mergeOptions:(NSDictionary *)mergeOptio
228232- (void )showModal : (NSDictionary *)layout completion : (RNNTransitionWithComponentIdCompletionBlock)completion {
229233 [self assertReady ];
230234
231- UIViewController<RNNParentProtocol> *newVc = [_controllerFactory createLayout: layout saveToStore: _store ];
235+ UIViewController<RNNParentProtocol> *newVc = [_controllerFactory createLayout: layout];
232236
233- [newVc.getCurrentLeaf waitForReactViewRender: newVc.getCurrentLeaf.resolveOptions.animations.showModal.waitForRender perform: ^{
234- [_modalManager showModal: newVc animated: newVc.getCurrentChild.resolveOptions.animations.showModal.enable hasCustomAnimation: newVc.getCurrentChild.resolveOptions.animations.showModal.hasCustomAnimation completion: ^(NSString *componentId) {
237+ [newVc renderTreeAndWait: [ newVc.getCurrentLeaf.resolveOptions.animations.showModal.waitForRender getWithDefaultValue: NO ] perform: ^{
238+ [_modalManager showModal: newVc animated: [ newVc.getCurrentChild.resolveOptions.animations.showModal.enable getWithDefaultValue: YES ] hasCustomAnimation: newVc.getCurrentChild.resolveOptions.animations.showModal.hasCustomAnimation completion: ^(NSString *componentId) {
235239 [_eventEmitter sendOnNavigationCommandCompletion: showModal params: @{@" layout" : layout}];
236240 completion (componentId);
237241 }];
@@ -272,20 +276,22 @@ - (void)dismissAllModals:(NSDictionary *)mergeOptions completion:(RNNTransitionC
272276 completion ();
273277 }];
274278 RNNNavigationOptions* options = [[RNNNavigationOptions alloc ] initWithDict: mergeOptions];
275- [_modalManager dismissAllModalsAnimated: options.animations.dismissModal.enable];
279+ [_modalManager dismissAllModalsAnimated: [ options.animations.dismissModal.enable getWithDefaultValue: YES ] ];
276280
277281 [CATransaction commit ];
278282}
279283
280284- (void )showOverlay : (NSDictionary *)layout completion : (RNNTransitionCompletionBlock)completion {
281285 [self assertReady ];
282286
283- UIViewController<RNNParentProtocol>* overlayVC = [_controllerFactory createLayout: layout saveToStore: _store];
284- UIWindow* overlayWindow = [[RNNOverlayWindow alloc ] initWithFrame: [[UIScreen mainScreen ] bounds ]];
285- overlayWindow.rootViewController = overlayVC;
286- [_overlayManager showOverlayWindow: overlayWindow];
287- [_eventEmitter sendOnNavigationCommandCompletion: showOverlay params: @{@" layout" : layout}];
288- completion ();
287+ UIViewController<RNNParentProtocol>* overlayVC = [_controllerFactory createLayout: layout];
288+ [overlayVC renderTreeAndWait: [overlayVC.options.animations.showOverlay.waitForRender getWithDefaultValue: NO ] perform: ^{
289+ UIWindow* overlayWindow = [[RNNOverlayWindow alloc ] initWithFrame: [[UIScreen mainScreen ] bounds ]];
290+ overlayWindow.rootViewController = overlayVC;
291+ [_overlayManager showOverlayWindow: overlayWindow];
292+ [_eventEmitter sendOnNavigationCommandCompletion: showOverlay params: @{@" layout" : layout}];
293+ completion ();
294+ }];
289295}
290296
291297- (void )dismissOverlay : (NSString *)componentId completion : (RNNTransitionCompletionBlock)completion rejection : (RNNTransitionRejectionBlock)reject {
0 commit comments