|
@@ -1,6 +1,7 @@
|
1
|
1
|
package com.reactnativenavigation.layout;
|
2
|
2
|
|
3
|
3
|
import android.app.Activity;
|
|
4
|
+import android.support.annotation.NonNull;
|
4
|
5
|
import android.view.View;
|
5
|
6
|
|
6
|
7
|
import java.util.List;
|
|
@@ -21,17 +22,26 @@ public class LayoutFactory {
|
21
|
22
|
public View create(LayoutNode node) {
|
22
|
23
|
switch (node.type) {
|
23
|
24
|
case "Container":
|
24
|
|
- String name = (String) node.data.get("name");
|
25
|
|
- return new Container(activity, rootViewCreator, node.id, name);
|
26
|
|
-
|
|
25
|
+ return createContainerView(node);
|
27
|
26
|
case "ContainerStack":
|
28
|
|
- ContainerStack containerStack = new ContainerStack(activity);
|
29
|
|
- List<LayoutNode> children = node.children;
|
30
|
|
- addChildrenNodes(containerStack, children);
|
31
|
|
- return containerStack;
|
|
27
|
+ return createContainerStackView(node);
|
|
28
|
+ default:
|
|
29
|
+ throw new IllegalArgumentException("Invalid node type: "+node.type);
|
32
|
30
|
}
|
|
31
|
+ }
|
|
32
|
+
|
|
33
|
+ @NonNull
|
|
34
|
+ private View createContainerStackView(LayoutNode node) {
|
|
35
|
+ ContainerStack containerStack = new ContainerStack(activity);
|
|
36
|
+ List<LayoutNode> children = node.children;
|
|
37
|
+ addChildrenNodes(containerStack, children);
|
|
38
|
+ return containerStack;
|
|
39
|
+ }
|
33
|
40
|
|
34
|
|
- return null;
|
|
41
|
+ @NonNull
|
|
42
|
+ private View createContainerView(LayoutNode node) {
|
|
43
|
+ String name = (String) node.data.get("name");
|
|
44
|
+ return new Container(activity, rootViewCreator, node.id, name);
|
35
|
45
|
}
|
36
|
46
|
|
37
|
47
|
private void addChildrenNodes(ContainerStack containerStack, List<LayoutNode> children) {
|