Parcourir la source

passProps android

Daniel Zlotin il y a 8 ans
Parent
révision
c6bf2f1226

+ 0
- 1
android/app/src/main/java/com/reactnativenavigation/params/ScreenParams.java Voir le fichier

@@ -18,7 +18,6 @@ public class ScreenParams {
18 18
     public String tabLabel;
19 19
     public Drawable tabIcon;
20 20
 
21
-    // TODO navigationParams should be a terminated. destroyed. annihilated. disintegrated. banished from existence. + abolished, eradicated, exterminated...
22 21
     public String screenInstanceId;
23 22
     public String navigatorEventId;
24 23
     public Bundle navigationParams;

+ 3
- 5
android/app/src/main/java/com/reactnativenavigation/screens/FragmentScreen.java Voir le fichier

@@ -8,16 +8,14 @@ import android.support.annotation.Nullable;
8 8
 import android.support.v7.app.AppCompatActivity;
9 9
 import android.widget.FrameLayout;
10 10
 
11
+import com.reactnativenavigation.R;
11 12
 import com.reactnativenavigation.params.ScreenParams;
12
-import com.reactnativenavigation.utils.ViewUtils;
13 13
 import com.reactnativenavigation.views.ContentView;
14 14
 import com.reactnativenavigation.views.TitleBarBackButtonListener;
15 15
 
16 16
 import java.lang.reflect.InvocationTargetException;
17 17
 import java.lang.reflect.Method;
18 18
 
19
-import com.reactnativenavigation.R;
20
-
21 19
 import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
22 20
 
23 21
 @SuppressWarnings("ResourceType")
@@ -91,7 +89,7 @@ public class FragmentScreen extends Screen {
91 89
             String className = screenParams.fragmentCreatorClassName;
92 90
             Class<?> fragmentCreatorClass = Class.forName(className);
93 91
             Method method = fragmentCreatorClass.getMethod(CONTRACT_GET_FRAGMENT, Bundle.class);
94
-            return (android.app.Fragment) method.invoke(null, "TODO");
92
+            return (android.app.Fragment) method.invoke(null, new Bundle());
95 93
         } catch (NoSuchMethodException noSuchMethod) {
96 94
             return null;
97 95
         }
@@ -103,7 +101,7 @@ public class FragmentScreen extends Screen {
103 101
             String className = screenParams.fragmentCreatorClassName;
104 102
             Class<?> fragmentCreatorClass = Class.forName(className);
105 103
             Method method = fragmentCreatorClass.getMethod(CONTRACT_GET_SUPPORT_FRAGMENT, Bundle.class);
106
-            return (android.support.v4.app.Fragment) method.invoke(null, "TODO");
104
+            return (android.support.v4.app.Fragment) method.invoke(null, new Bundle());
107 105
         } catch (NoSuchMethodException noSuchMethod) {
108 106
             return null;
109 107
         }

+ 2
- 2
src/Navigation.js Voir le fichier

@@ -29,7 +29,7 @@ function _registerComponentNoRedux(screenID, generator) {
29 29
 
30 30
       constructor(props) {
31 31
         super(props);
32
-        this.allProps = {...props, ...PropRegistry.load(this.navigator.screenInstanceID)};
32
+        this.allProps = {...props, ...PropRegistry.load(props.screenInstanceID)};
33 33
       }
34 34
 
35 35
       render() {
@@ -52,7 +52,7 @@ function _registerComponentRedux(screenID, generator, store, Provider) {
52 52
 
53 53
       constructor(props) {
54 54
         super(props);
55
-        this.allProps = {...props, ...PropRegistry.load(this.navigator.screenInstanceID)};
55
+        this.allProps = {...props, ...PropRegistry.load(props.screenInstanceID)};
56 56
       }
57 57
 
58 58
       render() {

+ 0
- 3
src/deprecated/platformSpecificDeprecated.android.js Voir le fichier

@@ -4,8 +4,6 @@ import _ from 'lodash';
4 4
 
5 5
 import Navigation from './../Navigation';
6 6
 
7
-import PropRegistry from '../PropRegistry';
8
-
9 7
 const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
10 8
 
11 9
 import * as newPlatformSpecific from './../platformSpecific';
@@ -20,7 +18,6 @@ function startSingleScreenApp(params) {
20 18
   addNavigatorButtons(screen);
21 19
   addNavigationStyleParams(screen);
22 20
   screen.passProps = params.passProps;
23
-  PropRegistry.save(screen.screenInstanceID, screen.passProps);
24 21
   //const drawer = setupDrawer(params.drawer);
25 22
 
26 23
   /*

+ 6
- 0
src/platformSpecific.android.js Voir le fichier

@@ -1,13 +1,17 @@
1 1
 import React, {Component} from 'react';
2 2
 import {AppRegistry, NativeModules} from 'react-native';
3 3
 
4
+import PropRegistry from './PropRegistry';
5
+
4 6
 const NativeReactModule = NativeModules.NavigationReactModule;
5 7
 
6 8
 function startApp(activityParams) {
9
+  PropRegistry.save(activityParams.screen.navigationParams.screenInstanceID, activityParams.screen.passProps);
7 10
   NativeReactModule.startApp(activityParams);
8 11
 }
9 12
 
10 13
 function push(screenParams) {
14
+  PropRegistry.save(screenParams.navigationParams.screenInstanceID, screenParams.passProps);
11 15
   NativeReactModule.push(screenParams);
12 16
 }
13 17
 
@@ -20,6 +24,7 @@ function popToRoot(screenParams) {
20 24
 }
21 25
 
22 26
 function newStack(screenParams) {
27
+  PropRegistry.save(screenParams.navigationParams.screenInstanceID, screenParams.passProps);
23 28
   NativeReactModule.newStack(screenParams);
24 29
 }
25 30
 
@@ -40,6 +45,7 @@ function setScreenTitleBarButtons(screenInstanceID, navigatorEventID, rightButto
40 45
 }
41 46
 
42 47
 function showModal(screenParams) {
48
+  PropRegistry.save(screenParams.navigationParams.screenInstanceID, screenParams.passProps);
43 49
   NativeReactModule.showModal(screenParams);
44 50
 }
45 51