|
@@ -9,6 +9,7 @@ import android.widget.RelativeLayout;
|
9
|
9
|
import android.widget.RelativeLayout.LayoutParams;
|
10
|
10
|
|
11
|
11
|
import com.facebook.react.bridge.Callback;
|
|
12
|
+import com.facebook.react.bridge.Promise;
|
12
|
13
|
import com.reactnativenavigation.NavigationApplication;
|
13
|
14
|
import com.reactnativenavigation.params.ContextualMenuParams;
|
14
|
15
|
import com.reactnativenavigation.params.FabParams;
|
|
@@ -57,14 +58,14 @@ public class ScreenStack {
|
57
|
58
|
final Screen nextScreen = ScreenFactory.create(activity, params, leftButtonOnClickListener);
|
58
|
59
|
final Screen previousScreen = stack.peek();
|
59
|
60
|
if (isStackVisible) {
|
60
|
|
- pushScreenToVisibleStack(layoutParams, nextScreen, previousScreen, new Screen.OnDisplayListener() {
|
|
61
|
+ pushScreenToVisibleStack(layoutParams, nextScreen, previousScreen, null, new Screen.OnDisplayListener() {
|
61
|
62
|
@Override
|
62
|
63
|
public void onDisplay() {
|
63
|
64
|
removeElementsBelowTop();
|
64
|
65
|
}
|
65
|
66
|
});
|
66
|
67
|
} else {
|
67
|
|
- pushScreenToInvisibleStack(layoutParams, nextScreen, previousScreen);
|
|
68
|
+ pushScreenToInvisibleStack(layoutParams, nextScreen, previousScreen, null);
|
68
|
69
|
removeElementsBelowTop();
|
69
|
70
|
}
|
70
|
71
|
}
|
|
@@ -97,28 +98,29 @@ public class ScreenStack {
|
97
|
98
|
addScreen(initialScreen, params);
|
98
|
99
|
}
|
99
|
100
|
|
100
|
|
- public void push(final ScreenParams params, LayoutParams layoutParams) {
|
|
101
|
+ public void push(final ScreenParams params, LayoutParams layoutParams, Promise onPushComplete) {
|
101
|
102
|
Screen nextScreen = ScreenFactory.create(activity, params, leftButtonOnClickListener);
|
102
|
103
|
final Screen previousScreen = stack.peek();
|
103
|
104
|
if (isStackVisible) {
|
104
|
105
|
if (nextScreen.screenParams.sharedElementsTransitions.isEmpty()) {
|
105
|
|
- pushScreenToVisibleStack(layoutParams, nextScreen, previousScreen);
|
|
106
|
+ pushScreenToVisibleStack(layoutParams, nextScreen, previousScreen, onPushComplete);
|
106
|
107
|
} else {
|
107
|
|
- pushScreenToVisibleStackWithSharedElementTransition(layoutParams, nextScreen, previousScreen);
|
|
108
|
+ pushScreenToVisibleStackWithSharedElementTransition(layoutParams, nextScreen, previousScreen, onPushComplete);
|
108
|
109
|
}
|
109
|
110
|
} else {
|
110
|
|
- pushScreenToInvisibleStack(layoutParams, nextScreen, previousScreen);
|
|
111
|
+ pushScreenToInvisibleStack(layoutParams, nextScreen, previousScreen, onPushComplete);
|
111
|
112
|
}
|
112
|
113
|
}
|
113
|
114
|
|
114
|
115
|
private void pushScreenToVisibleStack(LayoutParams layoutParams, final Screen nextScreen,
|
115
|
|
- final Screen previousScreen) {
|
116
|
|
- pushScreenToVisibleStack(layoutParams, nextScreen, previousScreen, null);
|
|
116
|
+ final Screen previousScreen, Promise onPushComplete) {
|
|
117
|
+ pushScreenToVisibleStack(layoutParams, nextScreen, previousScreen, onPushComplete, null);
|
117
|
118
|
}
|
118
|
119
|
|
119
|
120
|
private void pushScreenToVisibleStack(LayoutParams layoutParams,
|
120
|
121
|
final Screen nextScreen,
|
121
|
122
|
final Screen previousScreen,
|
|
123
|
+ @Nullable final Promise onPushComplete,
|
122
|
124
|
@Nullable final Screen.OnDisplayListener onDisplay) {
|
123
|
125
|
nextScreen.setVisibility(View.INVISIBLE);
|
124
|
126
|
addScreen(nextScreen, layoutParams);
|
|
@@ -130,6 +132,7 @@ public class ScreenStack {
|
130
|
132
|
@Override
|
131
|
133
|
public void run() {
|
132
|
134
|
if (onDisplay != null) onDisplay.onDisplay();
|
|
135
|
+ if (onPushComplete != null) onPushComplete.resolve(null);
|
133
|
136
|
NavigationApplication.instance.getEventEmitter().sendDidDisappearEvent(previousScreen.getScreenParams(), NavigationType.Push);
|
134
|
137
|
parent.removeView(previousScreen);
|
135
|
138
|
}
|
|
@@ -138,7 +141,8 @@ public class ScreenStack {
|
138
|
141
|
});
|
139
|
142
|
}
|
140
|
143
|
|
141
|
|
- private void pushScreenToVisibleStackWithSharedElementTransition(LayoutParams layoutParams, final Screen nextScreen, final Screen previousScreen) {
|
|
144
|
+ private void pushScreenToVisibleStackWithSharedElementTransition(LayoutParams layoutParams, final Screen nextScreen,
|
|
145
|
+ final Screen previousScreen, @Nullable final Promise onPushComplete) {
|
142
|
146
|
nextScreen.setVisibility(View.INVISIBLE);
|
143
|
147
|
nextScreen.setOnDisplayListener(new Screen.OnDisplayListener() {
|
144
|
148
|
@Override
|
|
@@ -146,6 +150,7 @@ public class ScreenStack {
|
146
|
150
|
nextScreen.showWithSharedElementsTransitions(previousScreen.sharedElements.getToElements(), new Runnable() {
|
147
|
151
|
@Override
|
148
|
152
|
public void run() {
|
|
153
|
+ if (onPushComplete != null) onPushComplete.resolve(null);
|
149
|
154
|
parent.removeView(previousScreen);
|
150
|
155
|
}
|
151
|
156
|
});
|
|
@@ -154,8 +159,15 @@ public class ScreenStack {
|
154
|
159
|
addScreen(nextScreen, layoutParams);
|
155
|
160
|
}
|
156
|
161
|
|
157
|
|
- private void pushScreenToInvisibleStack(LayoutParams layoutParams, Screen nextScreen, Screen previousScreen) {
|
|
162
|
+ private void pushScreenToInvisibleStack(LayoutParams layoutParams, Screen nextScreen, Screen previousScreen,
|
|
163
|
+ @Nullable final Promise onPushComplete) {
|
158
|
164
|
nextScreen.setVisibility(View.INVISIBLE);
|
|
165
|
+ nextScreen.setOnDisplayListener(new Screen.OnDisplayListener() {
|
|
166
|
+ @Override
|
|
167
|
+ public void onDisplay() {
|
|
168
|
+ if (onPushComplete != null) onPushComplete.resolve(null);
|
|
169
|
+ }
|
|
170
|
+ });
|
159
|
171
|
addScreen(nextScreen, layoutParams);
|
160
|
172
|
parent.removeView(previousScreen);
|
161
|
173
|
}
|