Quellcode durchsuchen

deep stack passProps fix

yogevbd vor 7 Jahren
Ursprung
Commit
466387287f
2 geänderte Dateien mit 38 neuen und 26 gelöschten Zeilen
  1. 3
    1
      ios/RCCNavigationController.m
  2. 35
    25
      src/deprecated/platformSpecificDeprecated.ios.js

+ 3
- 1
ios/RCCNavigationController.m Datei anzeigen

71
   NSArray* components = props[@"components"];
71
   NSArray* components = props[@"components"];
72
   if (components.count) {
72
   if (components.count) {
73
     for (NSDictionary* component in components) {
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 Datei anzeigen

36
       Object.assign(tab, components[0]);
36
       Object.assign(tab, components[0]);
37
       components.shift();
37
       components.shift();
38
     }
38
     }
39
-    
39
+
40
     const {
40
     const {
41
       navigatorStyle,
41
       navigatorStyle,
42
       navigatorButtons,
42
       navigatorButtons,
90
         );
90
         );
91
       }
91
       }
92
     },
92
     },
93
-    renderBody: function() {
93
+    renderBody: function () {
94
       return (
94
       return (
95
         <TabBarControllerIOS
95
         <TabBarControllerIOS
96
           id={controllerID + '_tabs'}
96
           id={controllerID + '_tabs'}
98
           appStyle={params.appStyle}
98
           appStyle={params.appStyle}
99
           initialTabIndex={params.initialTabIndex}>
99
           initialTabIndex={params.initialTabIndex}>
100
           {
100
           {
101
-            params.tabs.map(function(tab, index) {
101
+            params.tabs.map(function (tab, index) {
102
               return (
102
               return (
103
                 <TabBarControllerIOS.Item {...tab} title={tab.label}>
103
                 <TabBarControllerIOS.Item {...tab} title={tab.label}>
104
                   <NavigationControllerIOS
104
                   <NavigationControllerIOS
109
                     component={tab.screen}
109
                     component={tab.screen}
110
                     components={tab.components}
110
                     components={tab.components}
111
                     passProps={{
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
                     style={tab.navigationParams.navigatorStyle}
116
                     style={tab.navigationParams.navigatorStyle}
117
                     leftButtons={tab.navigationParams.navigatorButtons.leftButtons}
117
                     leftButtons={tab.navigationParams.navigatorButtons.leftButtons}
118
                     rightButtons={tab.navigationParams.navigatorButtons.rightButtons}
118
                     rightButtons={tab.navigationParams.navigatorButtons.rightButtons}
141
   }
141
   }
142
 
142
 
143
   if (components) {
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
   const controllerID = _.uniqueId('controllerID');
155
   const controllerID = _.uniqueId('controllerID');
168
     navigatorID
175
     navigatorID
169
   };
176
   };
170
 
177
 
178
+  const passProps = {
179
+    navigatorID: navigatorID,
180
+    screenInstanceID: screenInstanceID,
181
+    navigatorEventID: navigatorEventID,
182
+    ...screen.passProps
183
+  };
184
+
171
   const Controller = Controllers.createClass({
185
   const Controller = Controllers.createClass({
172
     render: function() {
186
     render: function() {
173
       if (!params.drawer || (!params.drawer.left && !params.drawer.right)) {
187
       if (!params.drawer || (!params.drawer.left && !params.drawer.right)) {
176
         const navigatorID = controllerID + '_drawer';
190
         const navigatorID = controllerID + '_drawer';
177
         return (
191
         return (
178
           <DrawerControllerIOS id={navigatorID}
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
             {this.renderBody()}
203
             {this.renderBody()}
190
           </DrawerControllerIOS>
204
           </DrawerControllerIOS>
200
           titleImage={screen.titleImage}
214
           titleImage={screen.titleImage}
201
           component={screen.screen}
215
           component={screen.screen}
202
           components={components}
216
           components={components}
203
-          passProps={{
204
-            navigatorID: navigatorID,
205
-            screenInstanceID: screenInstanceID,
206
-            navigatorEventID: navigatorEventID
207
-          }}
217
+          passProps={passProps}
208
           style={navigatorStyle}
218
           style={navigatorStyle}
209
           leftButtons={navigatorButtons.leftButtons}
219
           leftButtons={navigatorButtons.leftButtons}
210
           rightButtons={navigatorButtons.rightButtons}
220
           rightButtons={navigatorButtons.rightButtons}
365
 }
375
 }
366
 
376
 
367
 function navigatorSetDrawerEnabled(navigator, params) {
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
 function navigatorSetTitle(navigator, params) {
382
 function navigatorSetTitle(navigator, params) {