Ver código fonte

creating layouts

Daniel Zlotin 8 anos atrás
pai
commit
d63dbb7b25

+ 5
- 5
android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactModule.java Ver arquivo

@@ -7,13 +7,13 @@ import com.facebook.react.bridge.ReadableMap;
7 7
 
8 8
 /**
9 9
  * The basic abstract components we will expose:
10
- * BottomTabs
11
- * TopBar
10
+ * BottomTabs (app) - boolean
11
+ * TopBar (per screen)
12 12
  * - TitleBar
13 13
  * - TopTabs (segmented control / view pager)
14
- * DeviceStatusBar
15
- * AndroidNavigationBar
16
- * SideMenu
14
+ * DeviceStatusBar (app) (colors are per screen)
15
+ * AndroidNavigationBar (app) (colors are per screen)
16
+ * SideMenu (app) - boolean
17 17
  */
18 18
 public class NavigationReactModule extends ReactContextBaseJavaModule {
19 19
     public static final String NAME = "NavigationReactModule";

+ 54
- 0
android/app/src/main/java/com/reactnativenavigation/layouts/LayoutFactory.java Ver arquivo

@@ -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
+}