|
@@ -5,77 +5,58 @@ import android.app.Dialog;
|
5
|
5
|
import android.content.Context;
|
6
|
6
|
import android.content.DialogInterface;
|
7
|
7
|
import android.support.annotation.Nullable;
|
8
|
|
-import android.view.LayoutInflater;
|
9
|
8
|
import android.view.View;
|
10
|
9
|
import android.view.Window;
|
11
|
10
|
import android.view.WindowManager;
|
12
|
|
-import android.view.animation.Animation;
|
13
|
|
-import android.view.animation.AnimationUtils;
|
14
|
11
|
|
15
|
12
|
import com.reactnativenavigation.R;
|
16
|
13
|
import com.reactnativenavigation.activities.BaseReactActivity;
|
17
|
14
|
import com.reactnativenavigation.controllers.ModalController;
|
18
|
15
|
import com.reactnativenavigation.core.objects.Screen;
|
|
16
|
+import com.reactnativenavigation.layouts.Layout;
|
|
17
|
+import com.reactnativenavigation.layouts.OnScreenPoppedListener;
|
19
|
18
|
import com.reactnativenavigation.utils.ContextProvider;
|
20
|
19
|
import com.reactnativenavigation.utils.SdkSupports;
|
21
|
20
|
import com.reactnativenavigation.utils.StyleHelper;
|
22
|
|
-import com.reactnativenavigation.views.RctView;
|
23
|
|
-import com.reactnativenavigation.views.RnnToolBar;
|
24
|
|
-import com.reactnativenavigation.views.ScreenStack;
|
25
|
21
|
|
26
|
|
-public class RnnModal extends Dialog implements DialogInterface.OnDismissListener {
|
|
22
|
+public class RnnModal extends Dialog implements DialogInterface.OnDismissListener, OnScreenPoppedListener {
|
27
|
23
|
|
28
|
|
- private ScreenStack mScreenStack;
|
29
|
|
- private View mContentView;
|
30
|
|
- private RnnToolBar mToolBar;
|
|
24
|
+ private Layout contentView;
|
31
|
25
|
|
32
|
|
- public RnnModal(BaseReactActivity context, Screen screen) {
|
|
26
|
+ public RnnModal(Context context, ModalController modalController, Screen screen) {
|
33
|
27
|
super(context, R.style.Modal);
|
34
|
|
- ModalController.getInstance().add(this);
|
|
28
|
+ modalController.add(this);
|
35
|
29
|
init(context, screen);
|
36
|
30
|
}
|
37
|
31
|
|
38
|
32
|
@SuppressLint("InflateParams")
|
39
|
33
|
private void init(final Context context, Screen screen) {
|
40
|
34
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
41
|
|
- mContentView = LayoutInflater.from(context).inflate(R.layout.modal_layout, null, false);
|
42
|
|
- mToolBar = (RnnToolBar) mContentView.findViewById(R.id.toolbar);
|
43
|
|
- mScreenStack = (ScreenStack) mContentView.findViewById(R.id.screenStack);
|
44
|
|
- setContentView(mContentView);
|
45
|
|
- mToolBar.update(screen);
|
46
|
|
- mScreenStack.push(screen, new RctView.OnDisplayedListener() {
|
47
|
|
- @Override
|
48
|
|
- public void onDisplayed() {
|
49
|
|
- Animation animation = AnimationUtils.loadAnimation(context, R.anim.slide_up);
|
50
|
|
- mContentView.setAnimation(animation);
|
51
|
|
- mContentView.animate();
|
52
|
|
- }
|
53
|
|
- });
|
|
35
|
+ contentView = null;
|
|
36
|
+ setContentView((View) contentView);
|
54
|
37
|
|
55
|
|
- // Set navigation colors
|
56
|
|
- if (SdkSupports.lollipop()) {
|
57
|
|
- Window window = getWindow();
|
58
|
|
- window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
59
|
|
- StyleHelper.setWindowStyle(window, context.getApplicationContext(), screen);
|
60
|
|
- }
|
|
38
|
+// // Set navigation colors
|
|
39
|
+// if (SdkSupports.lollipop()) {
|
|
40
|
+// Window window = getWindow();
|
|
41
|
+// window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
|
42
|
+// StyleHelper.setWindowStyle(window, context.getApplicationContext(), screen);
|
|
43
|
+// }
|
61
|
44
|
setOnDismissListener(this);
|
62
|
45
|
}
|
63
|
46
|
|
64
|
47
|
public void push(Screen screen) {
|
65
|
|
- mScreenStack.push(screen);
|
66
|
|
- mToolBar.update(screen);
|
|
48
|
+ contentView.push(screen);
|
67
|
49
|
}
|
68
|
50
|
|
69
|
51
|
public Screen pop() {
|
70
|
|
- Screen popped = mScreenStack.pop();
|
71
|
|
- if (mScreenStack.isEmpty()) {
|
|
52
|
+ return contentView.pop();
|
|
53
|
+ }
|
|
54
|
+
|
|
55
|
+ @Override
|
|
56
|
+ public void onScreenPopped(Screen popped) {
|
|
57
|
+ if (contentView.getScreenCount() == 0) {
|
72
|
58
|
dismiss();
|
73
|
59
|
}
|
74
|
|
- Screen currentScreen = getCurrentScreen();
|
75
|
|
- if (currentScreen != null) {
|
76
|
|
- mToolBar.update(currentScreen);
|
77
|
|
- }
|
78
|
|
- return popped;
|
79
|
60
|
}
|
80
|
61
|
|
81
|
62
|
@Nullable
|