|
@@ -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);
|