Daniel Zlotin 7 years ago
parent
commit
80e52bec5d

+ 0
- 2
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/TopLevelApiTest.java View File

@@ -2,7 +2,6 @@ package com.reactnativenavigation.e2e.androide2e;
2 2
 
3 3
 import android.support.test.uiautomator.By;
4 4
 
5
-import org.junit.Ignore;
6 5
 import org.junit.Test;
7 6
 
8 7
 public class TopLevelApiTest extends BaseTest {
@@ -16,7 +15,6 @@ public class TopLevelApiTest extends BaseTest {
16 15
 		assertExists(By.text("Hello from a function!"));
17 16
 	}
18 17
 
19
-	@Ignore
20 18
 	@Test
21 19
 	public void switchToTabsWithSideMenu() throws Exception {
22 20
 		launchTheApp();

+ 43
- 43
lib/android/app/src/main/java/com/reactnativenavigation/layout/LayoutFactory.java View File

@@ -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);

+ 69
- 0
lib/android/app/src/main/java/com/reactnativenavigation/layout/impl/SideMenuController.java View File

@@ -0,0 +1,69 @@
1
+package com.reactnativenavigation.layout.impl;
2
+
3
+import android.app.Activity;
4
+import android.support.annotation.NonNull;
5
+import android.support.v4.widget.DrawerLayout;
6
+import android.view.Gravity;
7
+import android.view.View;
8
+import android.view.ViewGroup;
9
+
10
+import com.reactnativenavigation.viewcontrollers.ParentController;
11
+import com.reactnativenavigation.viewcontrollers.ViewController;
12
+
13
+import java.util.ArrayList;
14
+import java.util.Collection;
15
+
16
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
17
+import static android.widget.ListPopupWindow.WRAP_CONTENT;
18
+
19
+public class SideMenuController extends ParentController {
20
+
21
+	private ViewController centerController;
22
+	private ViewController leftController;
23
+	private ViewController rightController;
24
+
25
+	public SideMenuController(final Activity activity, final String id) {
26
+		super(activity, id);
27
+	}
28
+
29
+	@NonNull
30
+	@Override
31
+	protected ViewGroup createView() {
32
+		DrawerLayout root = new DrawerLayout(getActivity());
33
+		return root;
34
+	}
35
+
36
+	@NonNull
37
+	@Override
38
+	public Collection<ViewController> getChildControllers() {
39
+		ArrayList<ViewController> children = new ArrayList<>();
40
+		if (centerController != null) children.add(centerController);
41
+		if (leftController != null) children.add(leftController);
42
+		if (rightController != null) children.add(rightController);
43
+		return children;
44
+	}
45
+
46
+	public void setCenterController(ViewController centerController) {
47
+		this.centerController = centerController;
48
+		View childView = centerController.getView();
49
+		getView().addView(childView);
50
+	}
51
+
52
+	public void setLeftController(ViewController leftController) {
53
+		this.leftController = leftController;
54
+		View childView = leftController.getView();
55
+		DrawerLayout.LayoutParams lp = new DrawerLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT);
56
+		lp.gravity = Gravity.LEFT;
57
+		childView.setLayoutParams(lp);
58
+		getView().addView(childView);
59
+	}
60
+
61
+	public void setRightController(ViewController rightController) {
62
+		this.rightController = rightController;
63
+		View childView = rightController.getView();
64
+		DrawerLayout.LayoutParams lp = new DrawerLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT);
65
+		lp.gravity = Gravity.RIGHT;
66
+		childView.setLayoutParams(lp);
67
+		getView().addView(childView);
68
+	}
69
+}

+ 0
- 53
lib/android/app/src/main/java/com/reactnativenavigation/layout/impl/SideMenuLayout.java View File

@@ -1,53 +0,0 @@
1
-package com.reactnativenavigation.layout.impl;
2
-
3
-public class SideMenuLayout {
4
-
5
-//	private DrawerLayout view;
6
-//	private StackLayout stackLayout;
7
-//
8
-//	public SideMenuLayout(Context context) {
9
-//		view = new DrawerLayout(context);
10
-//		view.setId(CompatUtils.generateViewId());
11
-//	}
12
-//
13
-//	@Override
14
-//	public View getView() {
15
-//		return view;
16
-//	}
17
-//
18
-//	@Override
19
-//	public void destroy() {
20
-//		//
21
-//	}
22
-//
23
-//	public void addLeftLayout(final Layout childLayout) {
24
-//		View child = childLayout.getView();
25
-//		DrawerLayout.LayoutParams lp = new DrawerLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT);
26
-//		lp.gravity = Gravity.LEFT;
27
-//		child.setLayoutParams(lp);
28
-//		view.addView(child);
29
-//	}
30
-//
31
-//	public void addRightLayout(final Layout childLayout) {
32
-//		View child = childLayout.getView();
33
-//		DrawerLayout.LayoutParams lp = new DrawerLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT);
34
-//		lp.gravity = Gravity.RIGHT;
35
-//		child.setLayoutParams(lp);
36
-//		view.addView(child);
37
-//	}
38
-//
39
-//	public void addCenterLayout(final Layout childLayout) {
40
-//		View child = childLayout.getView();
41
-//		view.addView(child);
42
-//	}
43
-//
44
-//	@Override
45
-//	public void setParentStackLayout(final StackLayout stackLayout) {
46
-//		this.stackLayout = stackLayout;
47
-//	}
48
-//
49
-//	@Override
50
-//	public StackLayout getParentStackLayout() {
51
-//		return stackLayout;
52
-//	}
53
-}

+ 1
- 1
playground/src/containers/PushedScreen.js View File

@@ -19,7 +19,7 @@ class PushedScreen extends Component {
19 19
     this.onClickPush = this.onClickPush.bind(this);
20 20
     this.onClickPop = this.onClickPop.bind(this);
21 21
     this.onClickPopPrevious = this.onClickPopPrevious.bind(this);
22
-    this.onClickPopToFirstPosition = this.onClickPopToFirstPosition.bind(this);
22
+    thisw.onClickPopToFirstPosition = this.onClickPopToFirstPosition.bind(this);
23 23
     this.onClickPopToRoot = this.onClickPopToRoot.bind(this);
24 24
   }
25 25
   render() {