Pārlūkot izejas kodu

Various fab fixes

* Don't show fab of a screen that's pushed to a none active tab
* Change fab when navigating back in the stack with back button
* Add screens before SnackbarAndFabContainer
Guy Carmeli 8 gadus atpakaļ
vecāks
revīzija
f7250b2753

+ 3
- 1
android/app/src/main/java/com/reactnativenavigation/layouts/BottomTabsLayout.java Parādīt failu

@@ -127,6 +127,7 @@ public class BottomTabsLayout extends RelativeLayout implements Layout, AHBottom
127 127
         if (getCurrentScreenStack().canPop()) {
128 128
             getCurrentScreenStack().pop(true);
129 129
             setBottomTabsStyleFromCurrentScreen();
130
+            EventBus.instance.post(new ScreenChangedEvent(getCurrentScreenStack().peek().getScreenParams()));
130 131
             return true;
131 132
         } else {
132 133
             return false;
@@ -206,8 +207,8 @@ public class BottomTabsLayout extends RelativeLayout implements Layout, AHBottom
206 207
         screenStack.push(params, createScreenLayoutParams(params));
207 208
         if (isCurrentStack(screenStack)) {
208 209
             bottomTabs.setStyleFromScreen(params.styleParams);
210
+            EventBus.instance.post(new ScreenChangedEvent(params));
209 211
         }
210
-        EventBus.instance.post(new ScreenChangedEvent(params));
211 212
     }
212 213
 
213 214
     @Override
@@ -324,6 +325,7 @@ public class BottomTabsLayout extends RelativeLayout implements Layout, AHBottom
324 325
                 @Override
325 326
                 public void onScreenPopAnimationEnd() {
326 327
                     setBottomTabsStyleFromCurrentScreen();
328
+                    EventBus.instance.post(new ScreenChangedEvent(getCurrentScreenStack().peek().getScreenParams()));
327 329
                 }
328 330
             });
329 331
             return true;

+ 14
- 11
android/app/src/main/java/com/reactnativenavigation/screens/ScreenStack.java Parādīt failu

@@ -5,6 +5,7 @@ import android.support.v7.app.AppCompatActivity;
5 5
 import android.util.Log;
6 6
 import android.view.View;
7 7
 import android.widget.RelativeLayout;
8
+import android.widget.RelativeLayout.LayoutParams;
8 9
 
9 10
 import com.reactnativenavigation.NavigationApplication;
10 11
 import com.reactnativenavigation.params.ScreenParams;
@@ -48,7 +49,7 @@ public class ScreenStack {
48 49
         keyboardVisibilityDetector = new KeyboardVisibilityDetector(parent);
49 50
     }
50 51
 
51
-    public void pushInitialScreenWithAnimation(final ScreenParams initialScreenParams, RelativeLayout.LayoutParams params) {
52
+    public void pushInitialScreenWithAnimation(final ScreenParams initialScreenParams, LayoutParams params) {
52 53
         isStackVisible = true;
53 54
         pushInitialScreen(initialScreenParams, params);
54 55
         final Screen screen = stack.peek();
@@ -61,30 +62,29 @@ public class ScreenStack {
61 62
         });
62 63
     }
63 64
 
64
-    public void pushInitialScreen(ScreenParams initialScreenParams, RelativeLayout.LayoutParams params) {
65
+    public void pushInitialScreen(ScreenParams initialScreenParams, LayoutParams params) {
65 66
         Screen initialScreen = ScreenFactory.create(activity, initialScreenParams, leftButtonOnClickListener);
66 67
         initialScreen.setVisibility(View.INVISIBLE);
67 68
         addScreen(initialScreen, params);
68 69
     }
69 70
 
70
-    public void push(final ScreenParams params, RelativeLayout.LayoutParams layoutParams) {
71
+    public void push(final ScreenParams params, LayoutParams layoutParams) {
71 72
         Screen nextScreen = ScreenFactory.create(activity, params, leftButtonOnClickListener);
72 73
         final Screen previousScreen = stack.peek();
73 74
         if (isStackVisible) {
74
-            pushScreenToVisibleStack(params, layoutParams, nextScreen, previousScreen);
75
+            pushScreenToVisibleStack(layoutParams, nextScreen, previousScreen);
75 76
         } else {
76 77
             pushScreenToInvisibleStack(layoutParams, nextScreen, previousScreen);
77 78
         }
78 79
     }
79 80
 
80
-    private void pushScreenToVisibleStack(final ScreenParams params, RelativeLayout.LayoutParams layoutParams,
81
-                                          final Screen nextScreen, final Screen previousScreen) {
81
+    private void pushScreenToVisibleStack(LayoutParams layoutParams, final Screen nextScreen, final Screen previousScreen) {
82 82
         nextScreen.setVisibility(View.INVISIBLE);
83 83
         addScreen(nextScreen, layoutParams);
84 84
         nextScreen.setOnDisplayListener(new Screen.OnDisplayListener() {
85 85
             @Override
86 86
             public void onDisplay() {
87
-                nextScreen.show(params.animateScreenTransitions, new Runnable() {
87
+                nextScreen.show(nextScreen.screenParams.animateScreenTransitions, new Runnable() {
88 88
                     @Override
89 89
                     public void run() {
90 90
                         removePreviousWithoutUnmount(previousScreen);
@@ -94,18 +94,21 @@ public class ScreenStack {
94 94
         });
95 95
     }
96 96
 
97
-    private void pushScreenToInvisibleStack(RelativeLayout.LayoutParams layoutParams, Screen nextScreen,
98
-                                            Screen previousScreen) {
97
+    private void pushScreenToInvisibleStack(LayoutParams layoutParams, Screen nextScreen, Screen previousScreen) {
99 98
         nextScreen.setVisibility(View.INVISIBLE);
100 99
         addScreen(nextScreen, layoutParams);
101 100
         removePreviousWithoutUnmount(previousScreen);
102 101
     }
103 102
 
104
-    private void addScreen(Screen screen, RelativeLayout.LayoutParams layoutParams) {
105
-        parent.addView(screen, layoutParams);
103
+    private void addScreen(Screen screen, LayoutParams layoutParams) {
104
+        addScreenBeforeSnackbarAndFabLayout(screen, layoutParams);
106 105
         stack.push(screen);
107 106
     }
108 107
 
108
+    private void addScreenBeforeSnackbarAndFabLayout(Screen screen, LayoutParams layoutParams) {
109
+        parent.addView(screen, parent.getChildCount() - 1, layoutParams);
110
+    }
111
+
109 112
     private void removePreviousWithoutUnmount(Screen previous) {
110 113
         previous.preventUnmountOnDetachedFromWindow();
111 114
         parent.removeView(previous);