|
@@ -0,0 +1,54 @@
|
|
1
|
+package com.reactnativenavigation.layouts;
|
|
2
|
+
|
|
3
|
+import android.app.Activity;
|
|
4
|
+import android.support.v4.widget.DrawerLayout;
|
|
5
|
+import android.view.Gravity;
|
|
6
|
+import android.widget.FrameLayout;
|
|
7
|
+import android.widget.LinearLayout;
|
|
8
|
+
|
|
9
|
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
|
10
|
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
|
11
|
+
|
|
12
|
+public class LayoutFactory {
|
|
13
|
+ public static class SideMenuParams {
|
|
14
|
+ private boolean enabled;
|
|
15
|
+ }
|
|
16
|
+
|
|
17
|
+ public static class BottomTabsParams {
|
|
18
|
+
|
|
19
|
+ }
|
|
20
|
+
|
|
21
|
+ public static class Params {
|
|
22
|
+ private SideMenuParams sideMenu;
|
|
23
|
+ private BottomTabsParams bottomTabs;
|
|
24
|
+ }
|
|
25
|
+
|
|
26
|
+ public static Layout create(Activity activity, Params params) {
|
|
27
|
+ LinearLayout root = createRoot(activity);
|
|
28
|
+ FrameLayout content = createContent(activity);
|
|
29
|
+ if (params.sideMenu.enabled) {
|
|
30
|
+ createSideMenu(activity, content);
|
|
31
|
+ }
|
|
32
|
+ return null;
|
|
33
|
+ }
|
|
34
|
+
|
|
35
|
+ private static LinearLayout createRoot(Activity activity) {
|
|
36
|
+ LinearLayout root = new LinearLayout(activity);
|
|
37
|
+ root.setOrientation(LinearLayout.VERTICAL);
|
|
38
|
+ return root;
|
|
39
|
+ }
|
|
40
|
+
|
|
41
|
+ private static void createSideMenu(Activity activity, FrameLayout content) {
|
|
42
|
+ DrawerLayout drawerLayout = new DrawerLayout(activity);
|
|
43
|
+ FrameLayout drawerContent = new FrameLayout(activity);
|
|
44
|
+ drawerLayout.addView(content, new DrawerLayout.LayoutParams(MATCH_PARENT, 0, 1));
|
|
45
|
+ DrawerLayout.LayoutParams drawerContentParams = new DrawerLayout.LayoutParams(WRAP_CONTENT, MATCH_PARENT);
|
|
46
|
+ drawerContentParams.gravity = Gravity.START;
|
|
47
|
+ drawerLayout.addView(drawerContent, drawerContentParams);
|
|
48
|
+ }
|
|
49
|
+
|
|
50
|
+ private static FrameLayout createContent(Activity activity) {
|
|
51
|
+ FrameLayout content = new FrameLayout(activity);
|
|
52
|
+ return content;
|
|
53
|
+ }
|
|
54
|
+}
|