Browse Source

passProps in iOS

Daniel Zlotin 8 years ago
parent
commit
2eb6548bd2
1 changed files with 40 additions and 1 deletions
  1. 40
    1
      src/deprecated/platformSpecificDeprecated.ios.js

+ 40
- 1
src/deprecated/platformSpecificDeprecated.ios.js View File

@@ -78,6 +78,8 @@ function startTabBasedApp(params) {
78 78
       );
79 79
     }
80 80
   });
81
+  savePassProps(params);
82
+
81 83
   ControllerRegistry.registerController(controllerID, () => Controller);
82 84
   ControllerRegistry.setRootController(controllerID, params.animationType, params.passProps || {});
83 85
 }
@@ -137,6 +139,8 @@ function startSingleScreenApp(params) {
137 139
       );
138 140
     }
139 141
   });
142
+  savePassProps(params);
143
+
140 144
   ControllerRegistry.registerController(controllerID, () => Controller);
141 145
   ControllerRegistry.setRootController(controllerID, params.animationType, params.passProps || {});
142 146
 }
@@ -185,6 +189,9 @@ function navigatorPush(navigator, params) {
185 189
   passProps.navigatorID = navigator.navigatorID;
186 190
   passProps.screenInstanceID = screenInstanceID;
187 191
   passProps.navigatorEventID = navigatorEventID;
192
+
193
+  savePassProps(params);
194
+
188 195
   Controllers.NavigationControllerIOS(navigator.navigatorID).push({
189 196
     title: params.title,
190 197
     titleImage: params.titleImage,
@@ -226,6 +233,9 @@ function navigatorResetTo(navigator, params) {
226 233
   passProps.navigatorID = navigator.navigatorID;
227 234
   passProps.screenInstanceID = screenInstanceID;
228 235
   passProps.navigatorEventID = navigatorEventID;
236
+
237
+  savePassProps(params);
238
+
229 239
   Controllers.NavigationControllerIOS(navigator.navigatorID).resetTo({
230 240
     title: params.title,
231 241
     titleImage: params.titleImage,
@@ -364,6 +374,9 @@ function showModal(params) {
364 374
       );
365 375
     }
366 376
   });
377
+
378
+  savePassProps(params);
379
+
367 380
   ControllerRegistry.registerController(controllerID, () => Controller);
368 381
   Modal.showController(controllerID, params.animationType);
369 382
 }
@@ -393,6 +406,9 @@ function showLightBox(params) {
393 406
   passProps.navigatorID = navigatorID;
394 407
   passProps.screenInstanceID = screenInstanceID;
395 408
   passProps.navigatorEventID = navigatorEventID;
409
+
410
+  savePassProps(params);
411
+
396 412
   Modal.showLightBox({
397 413
     component: params.screen,
398 414
     passProps: passProps,
@@ -439,6 +455,29 @@ function dismissInAppNotification(params) {
439 455
   Notification.dismiss(params);
440 456
 }
441 457
 
458
+function savePassProps(params) {
459
+  //TODO this needs to be handled in a common place,
460
+  //TODO also, all global passProps should be handled differently
461
+  if (params.navigationParams && params.passProps) {
462
+    PropRegistry.save(params.navigationParams.screenInstanceID, params.passProps);
463
+  }
464
+
465
+  if (params.screen && params.screen.passProps) {
466
+    PropRegistry.save(params.screen.navigationParams.screenInstanceID, params.screen.passProps);
467
+  }
468
+
469
+  if (_.get(params, 'screen.topTabs')) {
470
+    _.forEach(params.screen.topTabs, (tab) => savePassProps(tab));
471
+  }
472
+
473
+  if (params.tabs) {
474
+    _.forEach(params.tabs, (tab) => {
475
+      tab.passProps = params.passProps;
476
+      savePassProps(tab);
477
+    });
478
+  }
479
+}
480
+
442 481
 export default {
443 482
   startTabBasedApp,
444 483
   startSingleScreenApp,
@@ -461,4 +500,4 @@ export default {
461 500
   navigatorSetTabBadge,
462 501
   navigatorSwitchToTab,
463 502
   navigatorToggleNavBar
464
-}
503
+};