|
@@ -33,7 +33,7 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
33
|
33
|
RNNEventEmitter* _eventEmitter;
|
34
|
34
|
}
|
35
|
35
|
|
36
|
|
--(instancetype) initWithStore:(RNNStore*)store controllerFactory:(RNNControllerFactory*)controllerFactory eventEmitter:(RNNEventEmitter *)eventEmitter {
|
|
36
|
+- (instancetype)initWithStore:(RNNStore*)store controllerFactory:(RNNControllerFactory*)controllerFactory eventEmitter:(RNNEventEmitter *)eventEmitter {
|
37
|
37
|
self = [super init];
|
38
|
38
|
_store = store;
|
39
|
39
|
_controllerFactory = controllerFactory;
|
|
@@ -46,7 +46,7 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
46
|
46
|
|
47
|
47
|
#pragma mark - public
|
48
|
48
|
|
49
|
|
--(void) setRoot:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion {
|
|
49
|
+- (void)setRoot:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion {
|
50
|
50
|
[self assertReady];
|
51
|
51
|
|
52
|
52
|
[_modalManager dismissAllModals];
|
|
@@ -59,7 +59,7 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
59
|
59
|
completion();
|
60
|
60
|
}
|
61
|
61
|
|
62
|
|
--(void) mergeOptions:(NSString*)componentId options:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion {
|
|
62
|
+- (void)mergeOptions:(NSString*)componentId options:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion {
|
63
|
63
|
[self assertReady];
|
64
|
64
|
|
65
|
65
|
UIViewController* vc = [_store findComponentForId:componentId];
|
|
@@ -87,12 +87,12 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
87
|
87
|
|
88
|
88
|
}
|
89
|
89
|
|
90
|
|
--(void) setDefaultOptions:(NSDictionary*)optionsDict completion:(RNNTransitionCompletionBlock)completion {
|
|
90
|
+- (void)setDefaultOptions:(NSDictionary*)optionsDict completion:(RNNTransitionCompletionBlock)completion {
|
91
|
91
|
[self assertReady];
|
92
|
92
|
[_controllerFactory setDefaultOptionsDict:optionsDict];
|
93
|
93
|
}
|
94
|
94
|
|
95
|
|
--(void)push:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
|
95
|
+- (void)push:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
96
|
96
|
[self assertReady];
|
97
|
97
|
|
98
|
98
|
RNNRootViewController *newVc = (RNNRootViewController *)[_controllerFactory createLayoutAndSaveToStore:layout];
|
|
@@ -135,7 +135,7 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
135
|
135
|
}
|
136
|
136
|
}
|
137
|
137
|
|
138
|
|
--(void)setStackRoot:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
|
138
|
+- (void)setStackRoot:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
139
|
139
|
[self assertReady];
|
140
|
140
|
|
141
|
141
|
UIViewController<RNNRootViewProtocol> *newVC = [_controllerFactory createLayoutAndSaveToStore:layout];
|
|
@@ -148,7 +148,7 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
148
|
148
|
} rejection:rejection];
|
149
|
149
|
}
|
150
|
150
|
|
151
|
|
--(void)pop:(NSString*)componentId options:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
|
151
|
+- (void)pop:(NSString*)componentId options:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
152
|
152
|
[self assertReady];
|
153
|
153
|
|
154
|
154
|
RNNRootViewController *vc = (RNNRootViewController*)[_store findComponentForId:componentId];
|
|
@@ -175,7 +175,7 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
175
|
175
|
}];
|
176
|
176
|
}
|
177
|
177
|
|
178
|
|
--(void) popTo:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
|
178
|
+- (void)popTo:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
|
179
|
179
|
[self assertReady];
|
180
|
180
|
RNNRootViewController *vc = (RNNRootViewController*)[_store findComponentForId:componentId];
|
181
|
181
|
|
|
@@ -205,7 +205,7 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
205
|
205
|
[CATransaction commit];
|
206
|
206
|
}
|
207
|
207
|
|
208
|
|
--(void) showModal:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion {
|
|
208
|
+- (void)showModal:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion {
|
209
|
209
|
[self assertReady];
|
210
|
210
|
|
211
|
211
|
UIViewController<RNNRootViewProtocol> *newVc = [_controllerFactory createLayoutAndSaveToStore:layout];
|
|
@@ -215,21 +215,20 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
215
|
215
|
}];
|
216
|
216
|
}
|
217
|
217
|
|
218
|
|
--(void) dismissModal:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion {
|
|
218
|
+- (void)dismissModal:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion {
|
219
|
219
|
[self assertReady];
|
220
|
220
|
|
221
|
221
|
[CATransaction begin];
|
222
|
222
|
[CATransaction setCompletionBlock:^{
|
223
|
223
|
[_eventEmitter sendOnNavigationCommandCompletion:dismissModal params:@{@"componentId": componentId}];
|
224
|
|
- completion();
|
225
|
224
|
}];
|
226
|
225
|
|
227
|
|
- [_modalManager dismissModal:componentId];
|
|
226
|
+ [_modalManager dismissModal:componentId completion:completion];
|
228
|
227
|
|
229
|
228
|
[CATransaction commit];
|
230
|
229
|
}
|
231
|
230
|
|
232
|
|
--(void) dismissAllModalsWithCompletion:(RNNTransitionCompletionBlock)completion {
|
|
231
|
+- (void)dismissAllModalsWithCompletion:(RNNTransitionCompletionBlock)completion {
|
233
|
232
|
[self assertReady];
|
234
|
233
|
|
235
|
234
|
[CATransaction begin];
|
|
@@ -243,7 +242,7 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
243
|
242
|
[CATransaction commit];
|
244
|
243
|
}
|
245
|
244
|
|
246
|
|
--(void)showOverlay:(NSDictionary *)layout completion:(RNNTransitionCompletionBlock)completion {
|
|
245
|
+- (void)showOverlay:(NSDictionary *)layout completion:(RNNTransitionCompletionBlock)completion {
|
247
|
246
|
[self assertReady];
|
248
|
247
|
|
249
|
248
|
UIViewController<RNNRootViewProtocol>* overlayVC = [_controllerFactory createOverlay:layout];
|
|
@@ -266,13 +265,13 @@ static NSString* const setDefaultOptions = @"setDefaultOptions";
|
266
|
265
|
|
267
|
266
|
#pragma mark - private
|
268
|
267
|
|
269
|
|
--(void)removePopedViewControllers:(NSArray*)viewControllers {
|
|
268
|
+- (void)removePopedViewControllers:(NSArray*)viewControllers {
|
270
|
269
|
for (UIViewController *popedVC in viewControllers) {
|
271
|
270
|
[_store removeComponentByViewControllerInstance:popedVC];
|
272
|
271
|
}
|
273
|
272
|
}
|
274
|
273
|
|
275
|
|
--(void) assertReady {
|
|
274
|
+- (void)assertReady {
|
276
|
275
|
if (!_store.isReadyToReceiveCommands) {
|
277
|
276
|
[[NSException exceptionWithName:@"BridgeNotLoadedError"
|
278
|
277
|
reason:@"Bridge not yet loaded! Send commands after Navigation.events().onAppLaunched() has been called."
|