Browse Source

Implement passProps in TopTabs screens

Guy Carmeli 8 years ago
parent
commit
fa153d4bb0

+ 4
- 1
android/app/src/main/java/com/reactnativenavigation/screens/FragmentScreen.java View File

38
     }
38
     }
39
 
39
 
40
     private void addContent() {
40
     private void addContent() {
41
-        ContentView contentView = new ContentView(getContext(), screenParams, screenParams.screenId);
41
+        ContentView contentView = new ContentView(getContext(),
42
+                screenParams,
43
+                screenParams.screenId,
44
+                screenParams.passProps);
42
         addView(contentView, 0, 0);
45
         addView(contentView, 0, 0);
43
         LayoutParams params = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
46
         LayoutParams params = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
44
         if (screenParams.styleParams.drawScreenBelowTopBar) {
47
         if (screenParams.styleParams.drawScreenBelowTopBar) {

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/screens/SingleScreen.java View File

19
 
19
 
20
     @Override
20
     @Override
21
     protected void createContent() {
21
     protected void createContent() {
22
-        contentView = new ContentView(getContext(), screenParams, screenParams.screenId);
22
+        contentView = new ContentView(getContext(), screenParams, screenParams.screenId, screenParams.passProps);
23
         LayoutParams params = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
23
         LayoutParams params = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
24
         if (screenParams.styleParams.drawScreenBelowTopBar) {
24
         if (screenParams.styleParams.drawScreenBelowTopBar) {
25
             params.addRule(BELOW, topBar.getId());
25
             params.addRule(BELOW, topBar.getId());

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/screens/ViewPagerScreen.java View File

44
 
44
 
45
     private void addPages() {
45
     private void addPages() {
46
         contentViews = new ArrayList<>();
46
         contentViews = new ArrayList<>();
47
-        for (TopTabParams topTabParam : screenParams.topTabParams) {
48
-            ContentView contentView = new ContentView(getContext(), screenParams, topTabParam.screenId);
47
+        for (TopTabParams tab : screenParams.topTabParams) {
48
+            ContentView contentView = new ContentView(getContext(), screenParams, tab.screenId, tab.passProps);
49
             addContent(contentView);
49
             addContent(contentView);
50
             contentViews.add(contentView);
50
             contentViews.add(contentView);
51
         }
51
         }

+ 5
- 7
android/app/src/main/java/com/reactnativenavigation/views/ContentView.java View File

14
     private final String screenId;
14
     private final String screenId;
15
     private final String navigatorEventId;
15
     private final String navigatorEventId;
16
     private final Bundle passProps;
16
     private final Bundle passProps;
17
-    private Bundle navigationParams;
18
 
17
 
19
-    public ContentView(Context context, ScreenParams screenParams, String screenId) {
18
+    public ContentView(Context context, ScreenParams screenParams, String screenId, Bundle passProps) {
20
         super(context);
19
         super(context);
21
         this.screenId = screenId;
20
         this.screenId = screenId;
22
         navigatorEventId = screenParams.navigatorEventId;
21
         navigatorEventId = screenParams.navigatorEventId;
23
-
24
-        passProps = screenParams.passProps;
25
-        navigationParams = screenParams.navigationParams;
22
+        this.passProps = mergePropsAndNavigationParams(screenParams, passProps);
26
         attachToJS();
23
         attachToJS();
27
     }
24
     }
28
 
25
 
44
 
41
 
45
     private void attachToJS() {
42
     private void attachToJS() {
46
         ReactInstanceManager react = NavigationApplication.instance.getNavigationReactInstance().getReactInstanceManager();
43
         ReactInstanceManager react = NavigationApplication.instance.getNavigationReactInstance().getReactInstanceManager();
47
-        startReactApplication(react, screenId, mergePropsAndNavigationParams());
44
+        startReactApplication(react, screenId, passProps);
48
     }
45
     }
49
 
46
 
50
-    private Bundle mergePropsAndNavigationParams() {
47
+    private Bundle mergePropsAndNavigationParams(ScreenParams screenParams, Bundle passProps) {
48
+        Bundle navigationParams = (Bundle) screenParams.navigationParams.clone();
51
         if (passProps != null) {
49
         if (passProps != null) {
52
             navigationParams.putAll(passProps);
50
             navigationParams.putAll(passProps);
53
         }
51
         }