Просмотр исходного кода

Missing fab in pushed screen (#613)

* Fix navigator buttons immutability issue

* Show fab in pushed screen
Guy Carmeli 8 лет назад
Родитель
Сommit
5640718604

+ 1
- 6
android/app/src/main/java/com/reactnativenavigation/events/ScreenChangedEvent.java Просмотреть файл

@@ -2,18 +2,13 @@ package com.reactnativenavigation.events;
2 2
 
3 3
 import com.reactnativenavigation.params.BaseScreenParams;
4 4
 import com.reactnativenavigation.params.FabParams;
5
-import com.reactnativenavigation.params.PageParams;
6 5
 
7 6
 public class ScreenChangedEvent implements Event {
8 7
     public static final String TYPE = "ScreenChangedEvent";
9 8
     public FabParams fabParams;
10 9
 
11 10
     public ScreenChangedEvent(BaseScreenParams screenParams) {
12
-        this.fabParams = screenParams.fabParams;
13
-    }
14
-
15
-    public ScreenChangedEvent(PageParams topTabParams) {
16
-        this.fabParams = topTabParams.fabParams;
11
+        this.fabParams = screenParams.getFab();
17 12
     }
18 13
 
19 14
     @Override

+ 4
- 0
android/app/src/main/java/com/reactnativenavigation/params/BaseScreenParams.java Просмотреть файл

@@ -38,4 +38,8 @@ public class BaseScreenParams {
38 38
     public boolean hasCollapsingTopBar() {
39 39
         return styleParams.collapsingTopBarParams != null;
40 40
     }
41
+
42
+    public FabParams getFab() {
43
+        return fabParams;
44
+    }
41 45
 }

+ 4
- 0
android/app/src/main/java/com/reactnativenavigation/params/ScreenParams.java Просмотреть файл

@@ -12,4 +12,8 @@ public class ScreenParams extends BaseScreenParams {
12 12
     public boolean hasTopTabs() {
13 13
         return topTabParams != null && !topTabParams.isEmpty();
14 14
     }
15
+
16
+    public FabParams getFab() {
17
+        return hasTopTabs() ? topTabParams.get(0).fabParams : null;
18
+    }
15 19
 }

+ 1
- 2
src/deprecated/platformSpecificDeprecated.android.js Просмотреть файл

@@ -36,6 +36,7 @@ function startSingleScreenApp(params) {
36 36
 }
37 37
 
38 38
 function adaptTopTabs(screen, navigatorID) {
39
+  screen.topTabs = _.cloneDeep(screen.topTabs);
39 40
   _.forEach(_.get(screen, 'topTabs'), (tab) => {
40 41
     addNavigatorParams(tab);
41 42
     if (navigatorID) {
@@ -279,8 +280,6 @@ function navigatorSetButtons(navigator, navigatorEventID, params) {
279 280
     }
280 281
   }
281 282
   const fab = getFab(params);
282
-  console.log('params: ', JSON.stringify(params));
283
-  console.log('fab: ', JSON.stringify(fab));
284 283
   newPlatformSpecific.setScreenButtons(navigator.screenInstanceID, navigatorEventID, params.rightButtons, leftButton, fab);
285 284
 }
286 285