Browse Source

deep stack for startTabBasedApp and startSingleScreenApp (#2770)

yogevbd 7 years ago
parent
commit
97d62f9c34
2 changed files with 27 additions and 3 deletions
  1. 7
    0
      ios/RCCNavigationController.m
  2. 20
    3
      src/deprecated/platformSpecificDeprecated.ios.js

+ 7
- 0
ios/RCCNavigationController.m View File

@@ -68,6 +68,13 @@ NSString const *CALLBACK_ASSOCIATED_ID = @"RCCNavigationController.CALLBACK_ASSO
68 68
 
69 69
   [self setRotation:props];
70 70
   
71
+  NSArray* components = props[@"components"];
72
+  if (components.count) {
73
+    for (NSDictionary* component in components) {
74
+      [self performAction:@"push" actionParams:@{@"animated": @(0), @"component": component[@"screen"]} bridge:bridge];
75
+    }
76
+  }
77
+  
71 78
   return self;
72 79
 }
73 80
 

+ 20
- 3
src/deprecated/platformSpecificDeprecated.ios.js View File

@@ -24,10 +24,19 @@ async function startTabBasedApp(params) {
24 24
   params.tabs.map(function(tab, index) {
25 25
     const navigatorID = controllerID + '_nav' + index;
26 26
     const screenInstanceID = _.uniqueId('screenInstanceID');
27
-    if (!tab.screen) {
27
+
28
+    const components = tab.components;
29
+    if (!tab.screen && !components) {
28 30
       console.error('startTabBasedApp(params): every tab must include a screen property, take a look at tab#' + (index + 1));
29 31
       return;
30 32
     }
33
+
34
+    if (components) {
35
+      params.tabs[index].components = components;
36
+      Object.assign(tab, components[0]);
37
+      components.shift();
38
+    }
39
+    
31 40
     const {
32 41
       navigatorStyle,
33 42
       navigatorButtons,
@@ -98,6 +107,7 @@ async function startTabBasedApp(params) {
98 107
                     subtitle={tab.subtitle}
99 108
                     titleImage={tab.titleImage}
100 109
                     component={tab.screen}
110
+                    components={tab.components}
101 111
                     passProps={{
102 112
                     navigatorID: tab.navigationParams.navigatorID,
103 113
                     screenInstanceID: tab.navigationParams.screenInstanceID,
@@ -123,13 +133,19 @@ async function startTabBasedApp(params) {
123 133
 }
124 134
 
125 135
 async function startSingleScreenApp(params) {
126
-  if (!params.screen) {
136
+  const components = params.components;
137
+  let screen = params.screen;
138
+  if (!screen && !components) {
127 139
     console.error('startSingleScreenApp(params): params.screen is required');
128 140
     return;
129 141
   }
130 142
 
143
+  if (components) {
144
+    screen = components[0];
145
+    components.shift();
146
+  }
147
+
131 148
   const controllerID = _.uniqueId('controllerID');
132
-  const screen = params.screen;
133 149
   if (!screen.screen) {
134 150
     console.error('startSingleScreenApp(params): screen must include a screen property');
135 151
     return;
@@ -183,6 +199,7 @@ async function startSingleScreenApp(params) {
183 199
           subtitle={params.subtitle}
184 200
           titleImage={screen.titleImage}
185 201
           component={screen.screen}
202
+          components={components}
186 203
           passProps={{
187 204
             navigatorID: navigatorID,
188 205
             screenInstanceID: screenInstanceID,