Sfoglia il codice sorgente

deep stack passProps fix

yogevbd 7 anni fa
parent
commit
466387287f

+ 3
- 1
ios/RCCNavigationController.m Vedi File

@@ -71,7 +71,9 @@ NSString const *CALLBACK_ASSOCIATED_ID = @"RCCNavigationController.CALLBACK_ASSO
71 71
   NSArray* components = props[@"components"];
72 72
   if (components.count) {
73 73
     for (NSDictionary* component in components) {
74
-      [self performAction:@"push" actionParams:@{@"animated": @(0), @"component": component[@"screen"]} bridge:bridge];
74
+      NSMutableDictionary *mutableParams = [[NSMutableDictionary alloc] initWithDictionary:@{@"animated": @(0), @"component": component[@"screen"]}];
75
+      [mutableParams addEntriesFromDictionary:component];
76
+      [self performAction:@"push" actionParams:mutableParams bridge:bridge];
75 77
     }
76 78
   }
77 79
   

+ 35
- 25
src/deprecated/platformSpecificDeprecated.ios.js Vedi File

@@ -36,7 +36,7 @@ async function startTabBasedApp(params) {
36 36
       Object.assign(tab, components[0]);
37 37
       components.shift();
38 38
     }
39
-    
39
+
40 40
     const {
41 41
       navigatorStyle,
42 42
       navigatorButtons,
@@ -90,7 +90,7 @@ async function startTabBasedApp(params) {
90 90
         );
91 91
       }
92 92
     },
93
-    renderBody: function() {
93
+    renderBody: function () {
94 94
       return (
95 95
         <TabBarControllerIOS
96 96
           id={controllerID + '_tabs'}
@@ -98,7 +98,7 @@ async function startTabBasedApp(params) {
98 98
           appStyle={params.appStyle}
99 99
           initialTabIndex={params.initialTabIndex}>
100 100
           {
101
-            params.tabs.map(function(tab, index) {
101
+            params.tabs.map(function (tab, index) {
102 102
               return (
103 103
                 <TabBarControllerIOS.Item {...tab} title={tab.label}>
104 104
                   <NavigationControllerIOS
@@ -109,10 +109,10 @@ async function startTabBasedApp(params) {
109 109
                     component={tab.screen}
110 110
                     components={tab.components}
111 111
                     passProps={{
112
-                    navigatorID: tab.navigationParams.navigatorID,
113
-                    screenInstanceID: tab.navigationParams.screenInstanceID,
114
-                    navigatorEventID: tab.navigationParams.navigatorEventID,
115
-                  }}
112
+                      navigatorID: tab.navigationParams.navigatorID,
113
+                      screenInstanceID: tab.navigationParams.screenInstanceID,
114
+                      navigatorEventID: tab.navigationParams.navigatorEventID,
115
+                    }}
116 116
                     style={tab.navigationParams.navigatorStyle}
117 117
                     leftButtons={tab.navigationParams.navigatorButtons.leftButtons}
118 118
                     rightButtons={tab.navigationParams.navigatorButtons.rightButtons}
@@ -141,8 +141,15 @@ async function startSingleScreenApp(params) {
141 141
   }
142 142
 
143 143
   if (components) {
144
-    screen = components[0];
145
-    components.shift();
144
+    components.forEach(component => {
145
+      screen = components[0];
146
+      components.shift();
147
+      const screenInstanceID = _.uniqueId('screenInstanceID');
148
+      component.navigationParams = {
149
+        screenInstanceID
150
+      };
151
+      savePassProps(component);
152
+    });
146 153
   }
147 154
 
148 155
   const controllerID = _.uniqueId('controllerID');
@@ -168,6 +175,13 @@ async function startSingleScreenApp(params) {
168 175
     navigatorID
169 176
   };
170 177
 
178
+  const passProps = {
179
+    navigatorID: navigatorID,
180
+    screenInstanceID: screenInstanceID,
181
+    navigatorEventID: navigatorEventID,
182
+    ...screen.passProps
183
+  };
184
+
171 185
   const Controller = Controllers.createClass({
172 186
     render: function() {
173 187
       if (!params.drawer || (!params.drawer.left && !params.drawer.right)) {
@@ -176,15 +190,15 @@ async function startSingleScreenApp(params) {
176 190
         const navigatorID = controllerID + '_drawer';
177 191
         return (
178 192
           <DrawerControllerIOS id={navigatorID}
179
-                               componentLeft={params.drawer.left ? params.drawer.left.screen : undefined}
180
-                               passPropsLeft={{navigatorID: navigatorID}}
181
-                               componentRight={params.drawer.right ? params.drawer.right.screen : undefined}
182
-                               passPropsRight={{navigatorID: navigatorID}}
183
-                               disableOpenGesture={params.drawer.disableOpenGesture}
184
-                               type={params.drawer.type ? params.drawer.type : 'MMDrawer'}
185
-                               animationType={params.drawer.animationType ? params.drawer.animationType : 'slide'}
186
-                               style={params.drawer.style}
187
-                               appStyle={params.appStyle}
193
+            componentLeft={params.drawer.left ? params.drawer.left.screen : undefined}
194
+            passPropsLeft={{navigatorID: navigatorID}}
195
+            componentRight={params.drawer.right ? params.drawer.right.screen : undefined}
196
+            passPropsRight={{navigatorID: navigatorID}}
197
+            disableOpenGesture={params.drawer.disableOpenGesture}
198
+            type={params.drawer.type ? params.drawer.type : 'MMDrawer'}
199
+            animationType={params.drawer.animationType ? params.drawer.animationType : 'slide'}
200
+            style={params.drawer.style}
201
+            appStyle={params.appStyle}
188 202
           >
189 203
             {this.renderBody()}
190 204
           </DrawerControllerIOS>
@@ -200,11 +214,7 @@ async function startSingleScreenApp(params) {
200 214
           titleImage={screen.titleImage}
201 215
           component={screen.screen}
202 216
           components={components}
203
-          passProps={{
204
-            navigatorID: navigatorID,
205
-            screenInstanceID: screenInstanceID,
206
-            navigatorEventID: navigatorEventID
207
-          }}
217
+          passProps={passProps}
208 218
           style={navigatorStyle}
209 219
           leftButtons={navigatorButtons.leftButtons}
210 220
           rightButtons={navigatorButtons.rightButtons}
@@ -365,8 +375,8 @@ function navigatorResetTo(navigator, params) {
365 375
 }
366 376
 
367 377
 function navigatorSetDrawerEnabled(navigator, params) {
368
-    const controllerID = navigator.navigatorID.split('_')[0];
369
-    Controllers.NavigationControllerIOS(controllerID + '_drawer').setDrawerEnabled(params)
378
+  const controllerID = navigator.navigatorID.split('_')[0];
379
+  Controllers.NavigationControllerIOS(controllerID + '_drawer').setDrawerEnabled(params)
370 380
 }
371 381
 
372 382
 function navigatorSetTitle(navigator, params) {