|
@@ -3,9 +3,11 @@ package com.reactnativenavigation.views;
|
3
|
3
|
import android.animation.LayoutTransition;
|
4
|
4
|
import android.content.Context;
|
5
|
5
|
import android.util.AttributeSet;
|
|
6
|
+import android.view.ViewGroup;
|
6
|
7
|
import android.widget.FrameLayout;
|
7
|
8
|
|
8
|
9
|
import com.facebook.react.ReactInstanceManager;
|
|
10
|
+import com.facebook.react.ReactRootView;
|
9
|
11
|
import com.reactnativenavigation.activities.BaseReactActivity;
|
10
|
12
|
import com.reactnativenavigation.core.RctManager;
|
11
|
13
|
import com.reactnativenavigation.core.objects.Screen;
|
|
@@ -30,8 +32,7 @@ public class ScreenStack extends FrameLayout {
|
30
|
32
|
}
|
31
|
33
|
|
32
|
34
|
private final Stack<ScreenView> mStack = new Stack<>();
|
33
|
|
- private final ReactInstanceManager mReactInstanceManager =
|
34
|
|
- RctManager.getInstance().getReactInstanceManager();
|
|
35
|
+ private final ReactInstanceManager mReactInstanceManager = RctManager.getInstance().getReactInstanceManager();
|
35
|
36
|
private BaseReactActivity mReactActivity;
|
36
|
37
|
|
37
|
38
|
public ScreenStack(BaseReactActivity context) {
|
|
@@ -145,4 +146,24 @@ public class ScreenStack extends FrameLayout {
|
145
|
146
|
public Screen peek() {
|
146
|
147
|
return mStack.peek().screen;
|
147
|
148
|
}
|
|
149
|
+
|
|
150
|
+ /**
|
|
151
|
+ * Remove the ScreenStack from {@code parent} while preventing all child react views from getting unmounted
|
|
152
|
+ */
|
|
153
|
+ public void removeFromScreen(ViewGroup parent) {
|
|
154
|
+ ReactRootView view = mStack.peek().view.getReactRootView();
|
|
155
|
+ ReflectionUtils.setBooleanField(view, "mAttachScheduled", true);
|
|
156
|
+
|
|
157
|
+ parent.removeView(this);
|
|
158
|
+ }
|
|
159
|
+
|
|
160
|
+ /**
|
|
161
|
+ * Add ScreenStack to {@code parent}
|
|
162
|
+ */
|
|
163
|
+ public void addToScreen(ViewGroup parent) {
|
|
164
|
+ ReactRootView view = mStack.peek().view.getReactRootView();
|
|
165
|
+ ReflectionUtils.setBooleanField(view, "mAttachScheduled", false);
|
|
166
|
+
|
|
167
|
+ parent.addView(this, new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
|
|
168
|
+ }
|
148
|
169
|
}
|