|
@@ -10,6 +10,8 @@
|
10
|
10
|
#import "RCCTheSideBarManagerViewController.h"
|
11
|
11
|
#import "RCCNotification.h"
|
12
|
12
|
|
|
13
|
+#import "RNNViewController.h"
|
|
14
|
+
|
13
|
15
|
#define kSlideDownAnimationDuration 0.35
|
14
|
16
|
|
15
|
17
|
typedef NS_ENUM(NSInteger, RCCManagerModuleErrorCode)
|
|
@@ -170,13 +172,38 @@ RCT_EXPORT_MODULE(RCCManager);
|
170
|
172
|
}
|
171
|
173
|
}
|
172
|
174
|
|
|
175
|
+
|
|
176
|
+-(void)startAppHelper:(NSDictionary*)layout
|
|
177
|
+{
|
|
178
|
+ [[RCCManager sharedInstance] clearModuleRegistry];
|
|
179
|
+
|
|
180
|
+ UIViewController *controller = [RNNViewController controllerWithLayout:layout bridge:[[RCCManager sharedInstance] getBridge]];
|
|
181
|
+ if (controller == nil) return;
|
|
182
|
+
|
|
183
|
+ id<UIApplicationDelegate> appDelegate = [UIApplication sharedApplication].delegate;
|
|
184
|
+
|
|
185
|
+ // set the new controller as the root
|
|
186
|
+ appDelegate.window.rootViewController = controller;
|
|
187
|
+ [appDelegate.window makeKeyAndVisible];
|
|
188
|
+}
|
|
189
|
+
|
|
190
|
+
|
173
|
191
|
#pragma mark - RCT exported methods
|
174
|
192
|
|
175
|
193
|
|
176
|
194
|
RCT_EXPORT_METHOD(
|
177
|
|
-startApp:(NSDictionary*)layout) {
|
178
|
|
-
|
179
|
|
- NSLog(@"layout:%@", layout);
|
|
195
|
+startApp:(NSDictionary*)layout)
|
|
196
|
+{
|
|
197
|
+ if ([[RCCManager sharedInstance] getBridge].loading) {
|
|
198
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0001 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
199
|
+ [self startAppHelper:layout];
|
|
200
|
+ });
|
|
201
|
+ return;
|
|
202
|
+ }
|
|
203
|
+
|
|
204
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
205
|
+ [self startAppHelper:layout];
|
|
206
|
+ });
|
180
|
207
|
}
|
181
|
208
|
|
182
|
209
|
|
|
@@ -184,6 +211,7 @@ startApp:(NSDictionary*)layout) {
|
184
|
211
|
RCT_EXPORT_METHOD(
|
185
|
212
|
setRootController:(NSDictionary*)layout animationType:(NSString*)animationType globalProps:(NSDictionary*)globalProps)
|
186
|
213
|
{
|
|
214
|
+
|
187
|
215
|
if ([[RCCManager sharedInstance] getBridge].loading) {
|
188
|
216
|
[self deferSetRootControllerWhileBridgeLoading:layout animationType:animationType globalProps:globalProps];
|
189
|
217
|
return;
|
|
@@ -194,6 +222,8 @@ setRootController:(NSDictionary*)layout animationType:(NSString*)animationType g
|
194
|
222
|
});
|
195
|
223
|
}
|
196
|
224
|
|
|
225
|
+
|
|
226
|
+
|
197
|
227
|
/**
|
198
|
228
|
* on RN31 there's a timing issue, we must wait for the bridge to finish loading
|
199
|
229
|
*/
|