|
@@ -53,7 +53,7 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
53
|
53
|
|
54
|
54
|
#pragma mark - public
|
55
|
55
|
|
56
|
|
-- (void)setRoot:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion {
|
|
56
|
+- (void)setRoot:(NSDictionary*)layout commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion {
|
57
|
57
|
[self assertReady];
|
58
|
58
|
|
59
|
59
|
if (@available(iOS 9, *)) {
|
|
@@ -79,7 +79,7 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
79
|
79
|
|
80
|
80
|
[vc renderTreeAndWait:[vc.resolveOptions.animations.setRoot.waitForRender getWithDefaultValue:NO] perform:^{
|
81
|
81
|
_mainWindow.rootViewController = vc;
|
82
|
|
- [_eventEmitter sendOnNavigationCommandCompletion:setRoot params:@{@"layout": layout}];
|
|
82
|
+ [_eventEmitter sendOnNavigationCommandCompletion:setRoot commandId:commandId params:@{@"layout": layout}];
|
83
|
83
|
completion() ;
|
84
|
84
|
}];
|
85
|
85
|
}
|
|
@@ -111,7 +111,7 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
111
|
111
|
completion();
|
112
|
112
|
}
|
113
|
113
|
|
114
|
|
-- (void)push:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
|
114
|
+- (void)push:(NSString*)componentId commandId:(NSString*)commandId layout:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
115
|
115
|
[self assertReady];
|
116
|
116
|
|
117
|
117
|
UIViewController<RNNLayoutProtocol> *newVc = [_controllerFactory createLayout:layout];
|
|
@@ -131,7 +131,7 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
131
|
131
|
if ([newVc.resolveOptions.preview.commit getWithDefaultValue:NO]) {
|
132
|
132
|
[CATransaction begin];
|
133
|
133
|
[CATransaction setCompletionBlock:^{
|
134
|
|
- [self->_eventEmitter sendOnNavigationCommandCompletion:push params:@{@"componentId": componentId}];
|
|
134
|
+ [self->_eventEmitter sendOnNavigationCommandCompletion:push commandId:commandId params:@{@"componentId": componentId}];
|
135
|
135
|
completion();
|
136
|
136
|
}];
|
137
|
137
|
[rvc.navigationController pushViewController:newVc animated:YES];
|
|
@@ -162,14 +162,14 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
162
|
162
|
id animationDelegate = (newVc.resolveOptions.animations.push.hasCustomAnimation || newVc.resolveOptions.customTransition.animations) ? newVc : nil;
|
163
|
163
|
[newVc renderTreeAndWait:([newVc.resolveOptions.animations.push.waitForRender getWithDefaultValue:NO] || animationDelegate) perform:^{
|
164
|
164
|
[_stackManager push:newVc onTop:fromVC animated:[newVc.resolveOptions.animations.push.enable getWithDefaultValue:YES] animationDelegate:animationDelegate completion:^{
|
165
|
|
- [_eventEmitter sendOnNavigationCommandCompletion:push params:@{@"componentId": componentId}];
|
|
165
|
+ [_eventEmitter sendOnNavigationCommandCompletion:push commandId:commandId params:@{@"componentId": componentId}];
|
166
|
166
|
completion();
|
167
|
167
|
} rejection:rejection];
|
168
|
168
|
}];
|
169
|
169
|
}
|
170
|
170
|
}
|
171
|
171
|
|
172
|
|
-- (void)setStackRoot:(NSString*)componentId children:(NSArray*)children completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
|
172
|
+- (void)setStackRoot:(NSString*)componentId commandId:(NSString*)commandId children:(NSArray*)children completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
173
|
173
|
[self assertReady];
|
174
|
174
|
|
175
|
175
|
NSArray<RNNLayoutProtocol> *childViewControllers = [_controllerFactory createChildrenLayout:children];
|
|
@@ -180,12 +180,12 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
180
|
180
|
UIViewController *fromVC = [_store findComponentForId:componentId];
|
181
|
181
|
__weak typeof(RNNEventEmitter*) weakEventEmitter = _eventEmitter;
|
182
|
182
|
[_stackManager setStackChildren:childViewControllers fromViewController:fromVC animated:[options.animations.setStackRoot.enable getWithDefaultValue:YES] completion:^{
|
183
|
|
- [weakEventEmitter sendOnNavigationCommandCompletion:setStackRoot params:@{@"componentId": componentId}];
|
|
183
|
+ [weakEventEmitter sendOnNavigationCommandCompletion:setStackRoot commandId:commandId params:@{@"componentId": componentId}];
|
184
|
184
|
completion();
|
185
|
185
|
} rejection:rejection];
|
186
|
186
|
}
|
187
|
187
|
|
188
|
|
-- (void)pop:(NSString*)componentId mergeOptions:(NSDictionary*)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
|
188
|
+- (void)pop:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary*)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
189
|
189
|
[self assertReady];
|
190
|
190
|
|
191
|
191
|
RNNRootViewController *vc = (RNNRootViewController*)[_store findComponentForId:componentId];
|
|
@@ -208,25 +208,25 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
208
|
208
|
|
209
|
209
|
[_stackManager pop:vc animated:[vc.resolveOptions.animations.pop.enable getWithDefaultValue:YES] completion:^{
|
210
|
210
|
[_store removeComponent:componentId];
|
211
|
|
- [_eventEmitter sendOnNavigationCommandCompletion:pop params:@{@"componentId": componentId}];
|
|
211
|
+ [_eventEmitter sendOnNavigationCommandCompletion:pop commandId:commandId params:@{@"componentId": componentId}];
|
212
|
212
|
completion();
|
213
|
213
|
} rejection:rejection];
|
214
|
214
|
}
|
215
|
215
|
|
216
|
|
-- (void)popTo:(NSString*)componentId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
|
216
|
+- (void)popTo:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
217
|
217
|
[self assertReady];
|
218
|
218
|
RNNRootViewController *vc = (RNNRootViewController*)[_store findComponentForId:componentId];
|
219
|
219
|
RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
|
220
|
220
|
[vc overrideOptions:options];
|
221
|
221
|
|
222
|
222
|
[_stackManager popTo:vc animated:[vc.resolveOptions.animations.pop.enable getWithDefaultValue:YES] completion:^(NSArray *poppedViewControllers) {
|
223
|
|
- [_eventEmitter sendOnNavigationCommandCompletion:popTo params:@{@"componentId": componentId}];
|
|
223
|
+ [_eventEmitter sendOnNavigationCommandCompletion:popTo commandId:commandId params:@{@"componentId": componentId}];
|
224
|
224
|
[self removePopedViewControllers:poppedViewControllers];
|
225
|
225
|
completion();
|
226
|
226
|
} rejection:rejection];
|
227
|
227
|
}
|
228
|
228
|
|
229
|
|
-- (void)popToRoot:(NSString*)componentId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
|
229
|
+- (void)popToRoot:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
230
|
230
|
[self assertReady];
|
231
|
231
|
RNNRootViewController *vc = (RNNRootViewController*)[_store findComponentForId:componentId];
|
232
|
232
|
RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
|
|
@@ -234,7 +234,7 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
234
|
234
|
|
235
|
235
|
[CATransaction begin];
|
236
|
236
|
[CATransaction setCompletionBlock:^{
|
237
|
|
- [_eventEmitter sendOnNavigationCommandCompletion:popToRoot params:@{@"componentId": componentId}];
|
|
237
|
+ [_eventEmitter sendOnNavigationCommandCompletion:popToRoot commandId:commandId params:@{@"componentId": componentId}];
|
238
|
238
|
completion();
|
239
|
239
|
}];
|
240
|
240
|
|
|
@@ -247,20 +247,20 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
247
|
247
|
[CATransaction commit];
|
248
|
248
|
}
|
249
|
249
|
|
250
|
|
-- (void)showModal:(NSDictionary*)layout completion:(RNNTransitionWithComponentIdCompletionBlock)completion {
|
|
250
|
+- (void)showModal:(NSDictionary*)layout commandId:(NSString *)commandId completion:(RNNTransitionWithComponentIdCompletionBlock)completion {
|
251
|
251
|
[self assertReady];
|
252
|
252
|
|
253
|
253
|
UIViewController<RNNParentProtocol> *newVc = [_controllerFactory createLayout:layout];
|
254
|
254
|
|
255
|
255
|
[newVc renderTreeAndWait:[newVc.resolveOptions.animations.showModal.waitForRender getWithDefaultValue:NO] perform:^{
|
256
|
256
|
[_modalManager showModal:newVc animated:[newVc.getCurrentChild.resolveOptions.animations.showModal.enable getWithDefaultValue:YES] hasCustomAnimation:newVc.getCurrentChild.resolveOptions.animations.showModal.hasCustomAnimation completion:^(NSString *componentId) {
|
257
|
|
- [_eventEmitter sendOnNavigationCommandCompletion:showModal params:@{@"layout": layout}];
|
|
257
|
+ [_eventEmitter sendOnNavigationCommandCompletion:showModal commandId:commandId params:@{@"layout": layout}];
|
258
|
258
|
completion(componentId);
|
259
|
259
|
}];
|
260
|
260
|
}];
|
261
|
261
|
}
|
262
|
262
|
|
263
|
|
-- (void)dismissModal:(NSString*)componentId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject {
|
|
263
|
+- (void)dismissModal:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject {
|
264
|
264
|
[self assertReady];
|
265
|
265
|
|
266
|
266
|
UIViewController<RNNParentProtocol> *modalToDismiss = (UIViewController<RNNParentProtocol>*)[_store findComponentForId:componentId];
|
|
@@ -277,7 +277,7 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
277
|
277
|
|
278
|
278
|
[CATransaction begin];
|
279
|
279
|
[CATransaction setCompletionBlock:^{
|
280
|
|
- [_eventEmitter sendOnNavigationCommandCompletion:dismissModal params:@{@"componentId": componentId}];
|
|
280
|
+ [_eventEmitter sendOnNavigationCommandCompletion:dismissModal commandId:commandId params:@{@"componentId": componentId}];
|
281
|
281
|
}];
|
282
|
282
|
|
283
|
283
|
[_modalManager dismissModal:modalToDismiss completion:completion];
|
|
@@ -285,12 +285,12 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
285
|
285
|
[CATransaction commit];
|
286
|
286
|
}
|
287
|
287
|
|
288
|
|
-- (void)dismissAllModals:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion {
|
|
288
|
+- (void)dismissAllModals:(NSDictionary *)mergeOptions commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion {
|
289
|
289
|
[self assertReady];
|
290
|
290
|
|
291
|
291
|
[CATransaction begin];
|
292
|
292
|
[CATransaction setCompletionBlock:^{
|
293
|
|
- [_eventEmitter sendOnNavigationCommandCompletion:dismissAllModals params:@{}];
|
|
293
|
+ [_eventEmitter sendOnNavigationCommandCompletion:dismissAllModals commandId:commandId params:@{}];
|
294
|
294
|
completion();
|
295
|
295
|
}];
|
296
|
296
|
RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
|
|
@@ -299,7 +299,7 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
299
|
299
|
[CATransaction commit];
|
300
|
300
|
}
|
301
|
301
|
|
302
|
|
-- (void)showOverlay:(NSDictionary *)layout completion:(RNNTransitionCompletionBlock)completion {
|
|
302
|
+- (void)showOverlay:(NSDictionary *)layout commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion {
|
303
|
303
|
[self assertReady];
|
304
|
304
|
|
305
|
305
|
UIViewController<RNNParentProtocol>* overlayVC = [_controllerFactory createLayout:layout];
|
|
@@ -307,17 +307,17 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
307
|
307
|
UIWindow* overlayWindow = [[RNNOverlayWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
308
|
308
|
overlayWindow.rootViewController = overlayVC;
|
309
|
309
|
[_overlayManager showOverlayWindow:overlayWindow];
|
310
|
|
- [_eventEmitter sendOnNavigationCommandCompletion:showOverlay params:@{@"layout": layout}];
|
|
310
|
+ [_eventEmitter sendOnNavigationCommandCompletion:showOverlay commandId:commandId params:@{@"layout": layout}];
|
311
|
311
|
completion();
|
312
|
312
|
}];
|
313
|
313
|
}
|
314
|
314
|
|
315
|
|
-- (void)dismissOverlay:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject {
|
|
315
|
+- (void)dismissOverlay:(NSString*)componentId commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject {
|
316
|
316
|
[self assertReady];
|
317
|
317
|
UIViewController* viewController = [_store findComponentForId:componentId];
|
318
|
318
|
if (viewController) {
|
319
|
319
|
[_overlayManager dismissOverlay:viewController];
|
320
|
|
- [_eventEmitter sendOnNavigationCommandCompletion:dismissOverlay params:@{@"componentId": componentId}];
|
|
320
|
+ [_eventEmitter sendOnNavigationCommandCompletion:dismissOverlay commandId:commandId params:@{@"componentId": componentId}];
|
321
|
321
|
completion();
|
322
|
322
|
} else {
|
323
|
323
|
[RNNErrorHandler reject:reject withErrorCode:1010 errorDescription:@"ComponentId not found"];
|