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