|
@@ -1,44 +1,66 @@
|
1
|
1
|
package com.reactnativenavigation.layouts;
|
2
|
2
|
|
|
3
|
+import android.support.annotation.Nullable;
|
3
|
4
|
import android.support.v7.app.AppCompatActivity;
|
4
|
5
|
import android.view.View;
|
5
|
6
|
import android.widget.RelativeLayout;
|
6
|
7
|
|
7
|
8
|
import com.reactnativenavigation.params.ScreenParams;
|
|
9
|
+import com.reactnativenavigation.params.SideMenuParams;
|
8
|
10
|
import com.reactnativenavigation.params.TitleBarButtonParams;
|
9
|
11
|
import com.reactnativenavigation.params.TitleBarLeftButtonParams;
|
10
|
|
-import com.reactnativenavigation.screens.ScreenAnimator;
|
11
|
12
|
import com.reactnativenavigation.screens.ScreenStack;
|
|
13
|
+import com.reactnativenavigation.views.SideMenu;
|
12
|
14
|
import com.reactnativenavigation.views.TitleBarBackButtonListener;
|
13
|
15
|
|
14
|
16
|
import java.util.List;
|
15
|
17
|
|
|
18
|
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
|
19
|
+
|
16
|
20
|
public class SingleScreenLayout extends RelativeLayout implements Layout {
|
17
|
21
|
|
18
|
22
|
private final AppCompatActivity activity;
|
19
|
23
|
private final ScreenParams screenParams;
|
|
24
|
+ private final SideMenuParams sideMenuParams;
|
20
|
25
|
private ScreenStack stack;
|
21
|
|
- private ScreenAnimator screenAnimator;
|
22
|
26
|
private TitleBarBackButtonListener titleBarBackButtonListener;
|
|
27
|
+ private SideMenu sideMenu;
|
23
|
28
|
|
24
|
|
- public SingleScreenLayout(AppCompatActivity activity, ScreenParams screenParams, TitleBarBackButtonListener titleBarBackButtonListener) {
|
25
|
|
- this(activity, screenParams);
|
|
29
|
+ public SingleScreenLayout(AppCompatActivity activity, ScreenParams screenParams,
|
|
30
|
+ TitleBarBackButtonListener titleBarBackButtonListener) {
|
|
31
|
+ this(activity, null, screenParams);
|
26
|
32
|
this.titleBarBackButtonListener = titleBarBackButtonListener;
|
27
|
33
|
}
|
28
|
34
|
|
29
|
|
- public SingleScreenLayout(AppCompatActivity activity, ScreenParams screenParams) {
|
|
35
|
+ public SingleScreenLayout(AppCompatActivity activity, @Nullable SideMenuParams sideMenuParams, ScreenParams screenParams) {
|
30
|
36
|
super(activity);
|
31
|
37
|
this.activity = activity;
|
32
|
38
|
this.screenParams = screenParams;
|
33
|
|
- createStack();
|
|
39
|
+ this.sideMenuParams = sideMenuParams;
|
|
40
|
+ createLayout();
|
|
41
|
+ }
|
|
42
|
+
|
|
43
|
+ private void createLayout() {
|
|
44
|
+ if (sideMenuParams == null) {
|
|
45
|
+ createStack(this);
|
|
46
|
+ } else {
|
|
47
|
+ createSideMenu();
|
|
48
|
+ createStack(sideMenu.getContentContainer());
|
|
49
|
+ }
|
|
50
|
+ }
|
|
51
|
+
|
|
52
|
+ private void createSideMenu() {
|
|
53
|
+ sideMenu = new SideMenu(getContext(), sideMenuParams);
|
|
54
|
+ RelativeLayout.LayoutParams lp = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
|
|
55
|
+ addView(sideMenu, lp);
|
34
|
56
|
}
|
35
|
57
|
|
36
|
|
- private void createStack() {
|
|
58
|
+ private void createStack(RelativeLayout parent) {
|
37
|
59
|
if (stack != null) {
|
38
|
60
|
stack.destroy();
|
39
|
61
|
}
|
40
|
|
- stack = new ScreenStack(activity, this, this);
|
41
|
|
- LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
|
62
|
+ stack = new ScreenStack(activity, parent, this);
|
|
63
|
+ LayoutParams lp = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
|
42
|
64
|
stack.pushInitialScreen(screenParams, lp);
|
43
|
65
|
stack.showFirstScreen();
|
44
|
66
|
}
|
|
@@ -60,7 +82,7 @@ public class SingleScreenLayout extends RelativeLayout implements Layout {
|
60
|
82
|
|
61
|
83
|
@Override
|
62
|
84
|
public void push(ScreenParams params) {
|
63
|
|
- LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
|
85
|
+ LayoutParams lp = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
|
64
|
86
|
stack.push(params, lp);
|
65
|
87
|
}
|
66
|
88
|
|
|
@@ -76,7 +98,8 @@ public class SingleScreenLayout extends RelativeLayout implements Layout {
|
76
|
98
|
|
77
|
99
|
@Override
|
78
|
100
|
public void newStack(ScreenParams params) {
|
79
|
|
- createStack();
|
|
101
|
+ RelativeLayout parent = sideMenuParams == null ? this : sideMenu.getContentContainer();
|
|
102
|
+ createStack(parent);
|
80
|
103
|
}
|
81
|
104
|
|
82
|
105
|
@Override
|