|
@@ -4,6 +4,7 @@ import android.app.Activity;
|
4
|
4
|
|
5
|
5
|
import com.facebook.react.ReactInstanceManager;
|
6
|
6
|
import com.reactnativenavigation.layout.impl.ReactRootViewController;
|
|
7
|
+import com.reactnativenavigation.layout.impl.SideMenuController;
|
7
|
8
|
import com.reactnativenavigation.viewcontrollers.BottomTabsController;
|
8
|
9
|
import com.reactnativenavigation.viewcontrollers.StackController;
|
9
|
10
|
import com.reactnativenavigation.viewcontrollers.ViewController;
|
|
@@ -26,55 +27,54 @@ public class LayoutFactory {
|
26
|
27
|
case Container:
|
27
|
28
|
return createContainer(node);
|
28
|
29
|
case ContainerStack:
|
29
|
|
- default:
|
30
|
30
|
return createContainerStack(node);
|
31
|
31
|
case BottomTabs:
|
32
|
32
|
return createBottomTabs(node);
|
33
|
|
-// case SideMenuRoot:
|
34
|
|
-// return createSideMenuRoot(node);
|
35
|
|
-// case SideMenuCenter:
|
36
|
|
-// return createSideMenuContent(node);
|
37
|
|
-// case SideMenuLeft:
|
38
|
|
-// return createSideMenuLeft(node);
|
39
|
|
-// case SideMenuRight:
|
40
|
|
-// return createSideMenuRight(node);
|
41
|
|
-// default:
|
42
|
|
-// throw new IllegalArgumentException("Invalid node type: " + node.type);
|
|
33
|
+ case SideMenuRoot:
|
|
34
|
+ return createSideMenuRoot(node);
|
|
35
|
+ case SideMenuCenter:
|
|
36
|
+ return createSideMenuContent(node);
|
|
37
|
+ case SideMenuLeft:
|
|
38
|
+ return createSideMenuLeft(node);
|
|
39
|
+ case SideMenuRight:
|
|
40
|
+ return createSideMenuRight(node);
|
|
41
|
+ default:
|
|
42
|
+ throw new IllegalArgumentException("Invalid node type: " + node.type);
|
|
43
|
+ }
|
|
44
|
+ }
|
|
45
|
+
|
|
46
|
+ private ViewController createSideMenuRoot(LayoutNode node) {
|
|
47
|
+ SideMenuController sideMenuLayout = new SideMenuController(activity, node.id);
|
|
48
|
+ for (LayoutNode child : node.children) {
|
|
49
|
+ ViewController childLayout = create(child);
|
|
50
|
+ switch (child.type) {
|
|
51
|
+ case SideMenuCenter:
|
|
52
|
+ sideMenuLayout.setCenterController(childLayout);
|
|
53
|
+ break;
|
|
54
|
+ case SideMenuLeft:
|
|
55
|
+ sideMenuLayout.setLeftController(childLayout);
|
|
56
|
+ break;
|
|
57
|
+ case SideMenuRight:
|
|
58
|
+ sideMenuLayout.setRightController(childLayout);
|
|
59
|
+ break;
|
|
60
|
+ default:
|
|
61
|
+ throw new IllegalArgumentException("Invalid node type in sideMenu: " + node.type);
|
|
62
|
+ }
|
43
|
63
|
}
|
|
64
|
+ return sideMenuLayout;
|
44
|
65
|
}
|
45
|
66
|
|
46
|
|
-// private Layout createSideMenuRoot(LayoutNode node) {
|
47
|
|
-// SideMenuLayout sideMenuLayout = new SideMenuLayout(activity);
|
48
|
|
-// for (LayoutNode child : node.children) {
|
49
|
|
-// Layout childLayout = createAndSaveToStore(child);
|
50
|
|
-// switch (child.type) {
|
51
|
|
-// case SideMenuCenter:
|
52
|
|
-// sideMenuLayout.addCenterLayout(childLayout);
|
53
|
|
-// break;
|
54
|
|
-// case SideMenuLeft:
|
55
|
|
-// sideMenuLayout.addLeftLayout(childLayout);
|
56
|
|
-// break;
|
57
|
|
-// case SideMenuRight:
|
58
|
|
-// sideMenuLayout.addRightLayout(childLayout);
|
59
|
|
-// break;
|
60
|
|
-// default:
|
61
|
|
-// throw new IllegalArgumentException("Invalid node type in sideMenu: " + node.type);
|
62
|
|
-// }
|
63
|
|
-// }
|
64
|
|
-// return sideMenuLayout;
|
65
|
|
-// }
|
66
|
|
-//
|
67
|
|
-// private Layout createSideMenuContent(LayoutNode node) {
|
68
|
|
-// return createAndSaveToStore(node.children.get(0));
|
69
|
|
-// }
|
70
|
|
-//
|
71
|
|
-// private Layout createSideMenuLeft(LayoutNode node) {
|
72
|
|
-// return createAndSaveToStore(node.children.get(0));
|
73
|
|
-// }
|
74
|
|
-//
|
75
|
|
-// private Layout createSideMenuRight(LayoutNode node) {
|
76
|
|
-// return createAndSaveToStore(node.children.get(0));
|
77
|
|
-// }
|
|
67
|
+ private ViewController createSideMenuContent(LayoutNode node) {
|
|
68
|
+ return create(node.children.get(0));
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ private ViewController createSideMenuLeft(LayoutNode node) {
|
|
72
|
+ return create(node.children.get(0));
|
|
73
|
+ }
|
|
74
|
+
|
|
75
|
+ private ViewController createSideMenuRight(LayoutNode node) {
|
|
76
|
+ return create(node.children.get(0));
|
|
77
|
+ }
|
78
|
78
|
|
79
|
79
|
private ViewController createContainer(LayoutNode node) {
|
80
|
80
|
return new ReactRootViewController(activity, node.id, node.data.optString("name"), reactInstanceManager);
|